Panagiotis Triantafyllou

vouchers part4

......@@ -42,6 +42,12 @@
android:theme="@style/SDKAppTheme" />
<activity
android:name="ly.warp.sdk.activities.LoyaltyHistoryActivity"
android:exported="false"
android:screenOrientation="portrait"
android:theme="@style/SDKAppTheme" />
<activity
android:name="ly.warp.sdk.activities.CouponInfoActivity"
android:exported="false"
android:screenOrientation="portrait"
......
package ly.warp.sdk.activities;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.cardview.widget.CardView;
import androidx.core.content.ContextCompat;
import org.greenrobot.eventbus.EventBus;
import io.github.inflationx.viewpump.ViewPumpContextWrapper;
import ly.warp.sdk.R;
import ly.warp.sdk.io.models.LoyaltySDKFirebaseEventModel;
import ly.warp.sdk.utils.WarplyManagerHelper;
import ly.warp.sdk.utils.managers.WarplyAnalyticsManager;
import ly.warp.sdk.utils.managers.WarplyEventBusManager;
public class LoyaltyHistoryActivity extends Activity implements View.OnClickListener {
// ===========================================================
// Constants
// ===========================================================
// ===========================================================
// Fields
// ===========================================================
private ImageView mIvBack;
private int mTimer = 0;
private Handler mSecondsHandler;
private TextView mTvFavValue, mTvDealsValue;
private float mFavValue = 0.0f;
// ===========================================================
// Methods for/from SuperClass/Interfaces
// ===========================================================
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_loyalty_history);
mSecondsHandler = new Handler();
mIvBack = findViewById(R.id.iv_loyalty_history_close);
mTvFavValue = findViewById(R.id.tv_exp_value);
mTvDealsValue = findViewById(R.id.tv_deals_value);
initViews();
}
@Override
public void onResume() {
super.onResume();
WarplyAnalyticsManager.logTrackersEvent(this, "screen", "HistoryScreen");
mTimer = 0;
mSecondsHandler.post(new Runnable() {
@Override
public void run() {
mTimer++;
mSecondsHandler.postDelayed(this, 1000);
}
});
}
@Override
public void onPause() {
super.onPause();
if (mSecondsHandler != null) {
mSecondsHandler.removeCallbacksAndMessages(null);
LoyaltySDKFirebaseEventModel analyticsEvent = new LoyaltySDKFirebaseEventModel();
analyticsEvent.setEventName("time_spent_on_loyalty_sdk");
analyticsEvent.setParameter("name", "History");
analyticsEvent.setParameter("seconds", String.valueOf(mTimer));
EventBus.getDefault().post(new WarplyEventBusManager(analyticsEvent));
}
}
@Override
public void onClick(View view) {
if (view.getId() == R.id.iv_loyalty_analysis_close) {
onBackPressed();
return;
}
}
@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(ViewPumpContextWrapper.wrap(newBase));
}
// ===========================================================
// Methods
// ===========================================================
private void initViews() {
mIvBack.setOnClickListener(this);
/** First Banner */
String badgeValueFirst = String.format("%.02f", WarplyManagerHelper.getDealsCouponsSum());
mTvDealsValue.setText(String.format(getString(R.string.cos_value), badgeValueFirst));
if (String.valueOf(WarplyManagerHelper.getDealsCouponsSum()).length() >= 3) {
mTvDealsValue.setTextSize(12);
} else {
mTvDealsValue.setTextSize(14);
}
// SpannableStringBuilder sBuilder = new SpannableStringBuilder();
// sBuilder.append(String.format(getString(R.string.cos_deals_win_title_cos), badgeValueFirst));
// CalligraphyTypefaceSpan typefaceBoldSpanFirst = new CalligraphyTypefaceSpan(TypefaceUtils.load(getAssets(), "fonts/PeridotPE-Bold.ttf"));
// sBuilder.setSpan(typefaceBoldSpanFirst, 15, 16 + badgeValueFirst.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
// mTvDealsValueAll.setText(sBuilder, TextView.BufferType.SPANNABLE);
mFavValue += WarplyManagerHelper.getDealsCouponsSum();
/** First Banner */
/** Sum Banner */
String allValue = String.format("%.02f", mFavValue);
mTvFavValue.setText(String.format(getString(R.string.cos_value), allValue));
/** Sum Banner */
}
// ===========================================================
// Inner and Anonymous Classes
// ===========================================================
}
......@@ -157,7 +157,7 @@ public class LoyaltyMarketAnalysisActivity extends Activity implements View.OnCl
mSecondsHandler.removeCallbacksAndMessages(null);
LoyaltySDKFirebaseEventModel analyticsEvent = new LoyaltySDKFirebaseEventModel();
analyticsEvent.setEventName("time_spent_on_loyalty_sdk");
analyticsEvent.setParameter("name", "GiftsCalculator");
analyticsEvent.setParameter("name", "MarketCalculator");
analyticsEvent.setParameter("seconds", String.valueOf(mTimer));
EventBus.getDefault().post(new WarplyEventBusManager(analyticsEvent));
}
......
......@@ -379,7 +379,8 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener, Vie
analyticsEvent.setParameter("screen", "Loyalty Wallet");
EventBus.getDefault().post(new WarplyEventBusManager(analyticsEvent));
//TODO: add new history intent
Intent intent = new Intent(LoyaltyWallet.this, LoyaltyHistoryActivity.class);
startActivity(intent);
}
return;
}
......@@ -450,16 +451,19 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener, Vie
@Subscribe()
public void onMessageEvent(WarplyEventBusManager event) {
if (event.getVouchersFetched() != null) {
if (WarplyManagerHelper.getShowVouchersBanner().equals("true")) {
runOnUiThread(() -> {
mLlVouchersSpinner.setVisibility(View.GONE);
mLlVouchers.setVisibility(View.VISIBLE);
});
} else {
runOnUiThread(() -> {
mLlVouchersSpinner.setVisibility(View.GONE);
});
}
// if (WarplyManagerHelper.getShowVouchersBanner().equals("true")) {
// runOnUiThread(() -> {
// mLlVouchersSpinner.setVisibility(View.GONE);
// mLlVouchers.setVisibility(View.VISIBLE);
// });
// } else {
// runOnUiThread(() -> {
// mLlVouchersSpinner.setVisibility(View.GONE);
// });
// }
/** Empty View */
runOnUiThread(this::checkForEmpty);
/** Empty View */
return;
}
if (event.getUnifiedCouponsAdded() != null) {
......@@ -624,10 +628,6 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener, Vie
mTvGiftsCountBadge.setText("0");
});
}
/** Empty View */
runOnUiThread(this::checkForEmpty);
/** Empty View */
}
@Override
......@@ -640,15 +640,15 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener, Vie
// ===========================================================
private void initViews() {
if (TextUtils.isEmpty(WarplyManagerHelper.getShowVouchersBanner())) {
//TODO: show spinner
} else if (WarplyManagerHelper.getShowVouchersBanner().equals("true")) {
//TODO: hide spinner
mLlVouchers.setVisibility(View.VISIBLE);
} else {
//.equals("false)
//TODO: hide spinner
}
// if (TextUtils.isEmpty(WarplyManagerHelper.getShowVouchersBanner())) {
// //TODO: show spinner
// } else if (WarplyManagerHelper.getShowVouchersBanner().equals("true")) {
// //TODO: hide spinner
// mLlVouchers.setVisibility(View.VISIBLE);
// } else {
// //.equals("false)
// //TODO: hide spinner
// }
if (WarpUtils.getUserNonTelco(this)) {
nonTelcoDialog();
......
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<item>
<shape>
<!-- set the shadow color here -->
<stroke
android:width="1.5dp"
android:color="#24000000" />
<!-- setting the thickness of shadow (positive value will give shadow on that side) -->
<padding
android:bottom="2dp"
android:left="0dp"
android:right="-1dp"
android:top="-1dp" />
<corners
android:bottomRightRadius="16dp"
android:topLeftRadius="24dp"
android:topRightRadius="16dp" />
</shape>
</item>
<!-- Background -->
<item>
<shape>
<solid android:color="@color/cos_green_tr" />
<corners
android:bottomRightRadius="16dp"
android:topLeftRadius="24dp"
android:topRightRadius="16dp" />
</shape>
</item>
</layer-list>
\ No newline at end of file
<vector android:height="64dp" android:viewportHeight="32"
android:viewportWidth="32" android:width="64dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#00A5E3" android:fillType="evenOdd" android:pathData="M12.667,10.333C10.754,10.333 9.267,11.821 9.267,13.729C9.267,14.911 9.79,16.062 10.915,17.437C12.053,18.826 13.698,20.319 15.778,22.204L15.78,22.205C16.058,22.458 16.482,22.458 16.756,22.212C18.835,20.323 20.48,18.828 21.618,17.438C22.744,16.062 23.267,14.911 23.267,13.729C23.267,11.821 21.779,10.333 19.867,10.333C18.777,10.333 17.716,10.845 17.028,11.653L16.267,12.545L15.506,11.653C14.817,10.845 13.756,10.333 12.667,10.333ZM18.097,23.695C17.054,24.636 15.468,24.625 14.434,23.685L14.375,23.632C12.361,21.806 10.608,20.219 9.368,18.704C8.104,17.16 7.267,15.569 7.267,13.729C7.267,10.714 9.651,8.333 12.667,8.333C13.993,8.333 15.269,8.813 16.267,9.616C17.264,8.813 18.54,8.333 19.867,8.333C22.882,8.333 25.267,10.714 25.267,13.729C25.267,15.569 24.43,17.16 23.166,18.705C21.929,20.216 20.185,21.8 18.179,23.621L18.099,23.693L18.097,23.695Z"/>
<path android:fillColor="#00A5E3" android:pathData="M30,16C30,23.732 23.732,30 16,30V32C24.837,32 32,24.837 32,16H30Z"/>
<path android:fillColor="#00A5E3" android:pathData="M0,16H2C2,8.268 8.268,2 16,2V0C7.163,0 0,7.163 0,16Z"/>
</vector>
......@@ -198,7 +198,7 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp">
android:layout_marginTop="18dp">
<RelativeLayout
android:id="@+id/rv_deals_count"
......@@ -214,7 +214,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginHorizontal="2dp"
android:layout_marginVertical="2dp"
android:layout_marginVertical="4dp"
app:cardCornerRadius="16dp"
app:cardElevation="2dp">
......@@ -303,7 +303,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginHorizontal="2dp"
android:layout_marginVertical="2dp"
android:layout_marginVertical="4dp"
app:cardCornerRadius="16dp"
app:cardElevation="2dp">
......@@ -391,7 +391,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginHorizontal="2dp"
android:layout_marginVertical="2dp"
android:layout_marginVertical="4dp"
app:cardCornerRadius="16dp"
app:cardElevation="2dp">
......
......@@ -202,6 +202,9 @@
<string name="cos_dlg_positive_button3">Ναι</string>
<string name="cos_vouchers_title">Υπόλοιπο επιδότησης</string>
<string name="cos_vouchers_info_title">Ενημερώσου για το υπόλοιπο επιδότησης</string>
<string name="cos_loyalty_history">Ιστορικό</string>
<string name="cos_redeemed_coupons_loyalty_title">Εξαργυρωμένα κουπόνια</string>
<string name="cos_history_info_text">Δες αναλυτικά το συνολικό όφελός σου έως τώρα από κουπόνια</string>
<string-array name="coupons_array">
<item>Κουπόνια</item>
......