Panagiotis Triantafyllou

fixes

......@@ -42,7 +42,7 @@ public class SplashActivity extends BaseActivity {
// );
WarplyManager.getCosmoteUser(new WarplyCosmoteUserRequest()
.setGuid("6012049321"),
.setGuid("6012049322"),
mLoginReceiver);
// WarplyManager.verifyTicket(new WarplyVerifyTicketRequest()
......
......@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
ext {
PUBLISH_GROUP_ID = 'ly.warp'
PUBLISH_VERSION = '4.5.4-cosbeta29'
PUBLISH_VERSION = '4.5.4-cosbeta30i'
PUBLISH_ARTIFACT_ID = 'warply-android-sdk'
}
......
......@@ -67,7 +67,8 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation
new Thread(() -> {
if (!Thread.currentThread().isInterrupted()) {
WarplyManager.getConsumer(new WarplyConsumerRequest(), mConsumerReceiver);
// WarplyManager.getConsumer(new WarplyConsumerRequest(), mConsumerReceiver);
Warply.getInbox(new WarplyInboxRequest().setUseCache(false), mInboxReceiver);
}
}).start();
}
......@@ -161,20 +162,20 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation
// Inner and Anonymous Classes
// ===========================================================
private final CallbackReceiver<Consumer> mConsumerReceiver = new CallbackReceiver<Consumer>() {
@Override
public void onSuccess(Consumer result) {
mConsumer = result;
WarplyManagerHelper.setConsumer(result);
// private final CallbackReceiver<Consumer> mConsumerReceiver = new CallbackReceiver<Consumer>() {
// @Override
// public void onSuccess(Consumer result) {
// mConsumer = result;
//// WarplyManagerHelper.setConsumer(result);
//// Thread.currentThread().interrupt();
// Warply.getInbox(new WarplyInboxRequest().setUseCache(false), mInboxReceiver);
// }
//
// @Override
// public void onFailure(int errorCode) {
// Thread.currentThread().interrupt();
Warply.getInbox(new WarplyInboxRequest().setUseCache(false), mInboxReceiver);
}
@Override
public void onFailure(int errorCode) {
Thread.currentThread().interrupt();
}
};
// }
// };
private final CallbackReceiver<CampaignList> mInboxReceiver = new CallbackReceiver<CampaignList>() {
@Override
......
......@@ -215,11 +215,11 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene
private void filterItems() {
ArrayList<Campaign> gfyList = new ArrayList<>();
if (WarplyManagerHelper.getCampaignList() != null && WarplyManagerHelper.getCampaignList().size() > 0) {
Log.v("Got L:{" + String.valueOf(WarplyManagerHelper.getCampaignList().size()) + "}", " LOYALTY campaigns");
if (WarplyManagerHelper.getCampaignListAll() != null && WarplyManagerHelper.getCampaignListAll().size() > 0) {
Log.v("Got L:{" + String.valueOf(WarplyManagerHelper.getCampaignListAll().size()) + "}", " LOYALTY campaigns");
if (WarplyManagerHelper.getCCMSLoyaltyCampaigns() == null || WarplyManagerHelper.getCCMSLoyaltyCampaigns().size() == 0) {
Log.v("Got C:{0}", " CCMS campaigns");
for (Campaign camp : WarplyManagerHelper.getCampaignList()) {
for (Campaign camp : WarplyManagerHelper.getCampaignListAll()) {
if (camp.getOfferCategory().equals("gifts_for_you")) {
try {
JSONObject extraFields = WarpJSONParser.getJSONFromString(camp.getExtraFields());
......@@ -236,7 +236,7 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene
} else {
int ccmsCount = 0;
Log.v("Got C:{" + String.valueOf(WarplyManagerHelper.getCCMSLoyaltyCampaigns().size()) + "}", " CCMS campaigns");
for (Campaign camp : WarplyManagerHelper.getCampaignList()) {
for (Campaign camp : WarplyManagerHelper.getCampaignListAll()) {
if (camp.getOfferCategory().equals("gifts_for_you")) {
try {
JSONObject extraFields = WarpJSONParser.getJSONFromString(camp.getExtraFields());
......
......@@ -19,21 +19,14 @@ import com.bumptech.glide.load.engine.DiskCacheStrategy;
import org.greenrobot.eventbus.EventBus;
import java.io.Serializable;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.concurrent.TimeUnit;
import ly.warp.sdk.R;
import ly.warp.sdk.io.models.ActiveDFYCouponEventModel;
import ly.warp.sdk.io.models.ActiveDFYCouponModel;
import ly.warp.sdk.io.models.Coupon;
import ly.warp.sdk.io.models.CouponList;
import ly.warp.sdk.io.models.Couponset;
import ly.warp.sdk.io.models.CouponsetsList;
import ly.warp.sdk.io.models.WarplyDealsAnalysisEventModel;
import ly.warp.sdk.utils.WarpUtils;
import ly.warp.sdk.utils.WarplyManagerHelper;
import ly.warp.sdk.utils.managers.WarplyEventBusManager;
import ly.warp.sdk.views.adapters.ActiveCouponAdapter;
......@@ -164,23 +157,7 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener {
// ===========================================================
private void initViews() {
CouponList mCouponList = new CouponList();
CouponList mCouponListInitial = new CouponList();
mCouponListInitial.addAll(WarplyManagerHelper.getCouponList());
CouponsetsList mCouponsetListInitial = new CouponsetsList();
mCouponsetListInitial.addAll(WarplyManagerHelper.getCouponsets());
for (Coupon coupon : mCouponListInitial) {
for (Couponset couponset : mCouponsetListInitial) {
if (coupon.getCouponsetUuid().equals(couponset.getUuid())) {
coupon.setDescription(couponset.getShortDescription());
coupon.setImage(couponset.getImgPreview());
coupon.setName(couponset.getName());
mCouponList.add(coupon);
}
}
}
if (mCouponList != null) {
if (WarplyManagerHelper.getCouponList() != null) {
mAdapterCoupons = new ActiveCouponAdapter(this, WarplyManagerHelper.getCouponList());
mRecyclerCoupons.setAdapter(mAdapterCoupons);
mAdapterCoupons.getPositionClicks()
......@@ -194,6 +171,11 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener {
.subscribe();
}
if (WarplyManagerHelper.getLoyaltyBadge() != null) {
WarpUtils.log("LOYALTY_BADGE_COUNT: " + String.valueOf(WarplyManagerHelper.getLoyaltyBadge().getCouponCount()));
WarpUtils.log("LOYALTY_BADGE_SUM: " + String.valueOf(WarplyManagerHelper.getLoyaltyBadge().getValue()));
}
mTvGiftsValue.setText(String.format(getString(R.string.cos_value), String.valueOf(WarplyManagerHelper.getLoyaltyBadge().getValue())));
mTvGiftsValueAll.setText(String.format(getString(R.string.cos_deals_win_title), String.valueOf(WarplyManagerHelper.getLoyaltyBadge().getValue()), String.valueOf(WarplyManagerHelper.getLoyaltyBadge().getCouponCount())));
mTvDealsValue.setText(String.format(getString(R.string.cos_value), String.valueOf(/*couponDfyValue*/ WarplyManagerHelper.getDealsCouponsSum())));
......
......@@ -139,11 +139,11 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener
private void filterItems() {
ArrayList<Campaign> gfyList = new ArrayList<>();
if (WarplyManagerHelper.getCampaignList() != null && WarplyManagerHelper.getCampaignList().size() > 0) {
Log.v("Got L:{" + String.valueOf(WarplyManagerHelper.getCampaignList().size()) + "}", " LOYALTY campaigns");
if (WarplyManagerHelper.getCampaignListAll() != null && WarplyManagerHelper.getCampaignListAll().size() > 0) {
Log.v("Got L:{" + String.valueOf(WarplyManagerHelper.getCampaignListAll().size()) + "}", " LOYALTY campaigns");
if (WarplyManagerHelper.getCCMSLoyaltyCampaigns() == null || WarplyManagerHelper.getCCMSLoyaltyCampaigns().size() == 0) {
Log.v("Got C:{0}", " CCMS campaigns");
for (Campaign camp : WarplyManagerHelper.getCampaignList()) {
for (Campaign camp : WarplyManagerHelper.getCampaignListAll()) {
if (camp.getOfferCategory().equals("more_for_you")) {
try {
JSONObject extraFields = WarpJSONParser.getJSONFromString(camp.getExtraFields());
......@@ -160,7 +160,7 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener
} else {
int ccmsCount = 0;
Log.v("Got C:{" + String.valueOf(WarplyManagerHelper.getCCMSLoyaltyCampaigns().size()) + "}", " CCMS campaigns");
for (Campaign camp : WarplyManagerHelper.getCampaignList()) {
for (Campaign camp : WarplyManagerHelper.getCampaignListAll()) {
if (camp.getOfferCategory().equals("more_for_you")) {
try {
JSONObject extraFields = WarpJSONParser.getJSONFromString(camp.getExtraFields());
......
......@@ -127,8 +127,8 @@ public class WarpViewActivity extends WarpBaseActivity {
setResult(RESULT_OK, new Intent());
finish();
}
if (event.getCoupon() != null)
finish();
// if (event.getCoupon() != null)
// finish();
// if (event.getPacingCard() != null)
// finish();
// if (event.getPacingService() != null)
......
......@@ -32,12 +32,12 @@ package ly.warp.sdk.io.models;
public class WarplyPacingEventModel {
private boolean isVisible = false;
private boolean isEnabled = false;
// private boolean isEnabled = false;
public WarplyPacingEventModel() {
this.isVisible = false;
this.isEnabled = false;
// this.isEnabled = false;
}
public boolean isVisible() {
......@@ -48,11 +48,11 @@ public class WarplyPacingEventModel {
isVisible = visible;
}
public boolean isEnabled() {
return isEnabled;
}
public void setEnabled(boolean enabled) {
isEnabled = enabled;
}
// public boolean isEnabled() {
// return isEnabled;
// }
//
// public void setEnabled(boolean enabled) {
// isEnabled = enabled;
// }
}
......
......@@ -77,6 +77,7 @@ public class WarplyManagerHelper {
private static CouponsetsList mCouponsetsList = new CouponsetsList();
private static CustomerStateModel mCustomerStateModel = new CustomerStateModel();
private static CampaignList mCampaignList = new CampaignList();
private static CampaignList mCampaignListAll = new CampaignList();
private static ArrayList<ActiveDFYCouponModel> mDfyCoupons = new ArrayList();
private static ArrayList<LoyaltyGiftsForYouPackage> mSeasonalList = new ArrayList<>();
private static ArrayList<LoyaltyContextualOfferModel> mCCMSList = new ArrayList<>();
......@@ -120,6 +121,7 @@ public class WarplyManagerHelper {
* Handle sharing flow
*/
public static void handleSharing(Context context, String sharingId) {
WarpUtils.log("SHARING_ID: " + sharingId);
WarplyManager.cosmoteSharing(new CosmoteSharingRequest().setSharingId(sharingId), new CallbackReceiver<JSONObject>() {
@Override
public void onSuccess(JSONObject result) {
......@@ -274,7 +276,7 @@ public class WarplyManagerHelper {
public static String constructCcmsUrl(Campaign item, LoyaltyContextualOfferModel ccmsItem) {
Log.v("CCMS_PRESSED", ccmsItem.getId() + " " + ccmsItem.getOfferName());
item.setNew(false);
String tempAudienceLevel = ccmsItem.getEligibleAssets() != null && ccmsItem.getEligibleAssets().size() > 0 ? "MSISDN" : "GUID";
// String tempAudienceLevel = ccmsItem.getEligibleAssets() != null && ccmsItem.getEligibleAssets().size() > 0 ? "MSISDN" : "GUID";
String assets = "";
if (ccmsItem.getEligibleAssets() != null && ccmsItem.getEligibleAssets().size() > 0) {
for (String singleAsset : ccmsItem.getEligibleAssets()) {
......@@ -313,7 +315,7 @@ public class WarplyManagerHelper {
+ "&WAVE=" + ccmsItem.getWave()
+ "&VALIDITY=" + ccmsItem.getValidity()
+ "&TREATMENT_CODE=" + ccmsItem.getTreatmentCode()
+ "&OfferAudienceLevel=" + tempAudienceLevel
+ "&OfferAudienceLevel=" + ccmsItem.getOfferAudienceLevel()
+ "&ASSETS=" + assets
+ "&ZONE=" + ccmsItem.getZone();
......@@ -339,7 +341,7 @@ public class WarplyManagerHelper {
if (extraFields != null) {
if (extraFields.has("ccms_offer") && extraFields.optString("ccms_offer").equals("true")) {
if (item.getLoyaltyCampaignId().equals(camp.getSessionUUID())) {
String tempAudienceLevel = item.getEligibleAssets() != null && item.getEligibleAssets().size() > 0 ? "MSISDN" : "GUID";
// String tempAudienceLevel = item.getEligibleAssets() != null && item.getEligibleAssets().size() > 0 ? "MSISDN" : "GUID";
String assets = "";
if (item.getEligibleAssets() != null && item.getEligibleAssets().size() > 0) {
for (String singleAsset : item.getEligibleAssets()) {
......@@ -379,7 +381,7 @@ public class WarplyManagerHelper {
+ "&WAVE=" + item.getWave()
+ "&VALIDITY=" + item.getValidity()
+ "&TREATMENT_CODE=" + item.getTreatmentCode()
+ "&OfferAudienceLevel=" + tempAudienceLevel
+ "&OfferAudienceLevel=" + item.getOfferAudienceLevel()
+ "&ASSETS=" + assets
+ "&ZONE=" + item.getZone();
break;
......@@ -518,7 +520,9 @@ public class WarplyManagerHelper {
if (mCampaignList != null && mCampaignList.size() > 0) {
for (Campaign camp : mCampaignList) {
if (camp.getOfferCategory().equals("pacing")) {
return constructCampaignUrl(camp);
String pacingUrl = constructCampaignUrl(camp);
WarpUtils.log("PACING_LOG: " + pacingUrl);
return pacingUrl;
}
}
}
......@@ -589,6 +593,11 @@ public class WarplyManagerHelper {
}
public static CouponList getCouponList() {
if (mCouponList != null && mCouponList.size() > 0) {
WarpUtils.log("GET_COUPON_LIST size: " + String.valueOf(mCouponList.size()));
} else {
WarpUtils.log("GET_COUPON_LIST size: 0");
}
return mCouponList;
}
......@@ -617,14 +626,35 @@ public class WarplyManagerHelper {
}
public static void setCampaignList(CampaignList campaignList) {
// mCampaignList.clear();
// mCampaignList.addAll(campaignList);
mCampaignListAll.clear();
mCampaignListAll.addAll(campaignList);
mCampaignList.clear();
mCampaignList.addAll(campaignList);
for (Campaign camp : campaignList) {
try {
JSONObject extraFields = WarpJSONParser.getJSONFromString(camp.getExtraFields());
if (extraFields != null) {
if (extraFields.length() == 0 || !extraFields.has("ccms_offer")) {
mCampaignList.add(camp);
}
}
} catch (Exception exception) {
mCampaignList.add(camp);
}
}
}
public static CampaignList getCampaignList() {
return mCampaignList;
}
public static CampaignList getCampaignListAll() {
return mCampaignListAll;
}
public static void setCouponList(CouponList couponList) {
LoyaltyBadgeModel badge = new LoyaltyBadgeModel();
CouponList cpnlist = new CouponList();
......@@ -632,19 +662,13 @@ public class WarplyManagerHelper {
int couponCount = 0;
for (Coupon coupon : couponList) {
if (coupon.getStatus() == 1) {
try {
float tempCouponValue = Float.parseFloat(coupon.getDiscount());
cpnlist.add(coupon);
} catch (NumberFormatException e) {
cpnlist.remove(coupon);
}
cpnlist.add(coupon);
} else if (coupon.getStatus() == 0) {
try {
couponCount += 1;
couponValue += Float.parseFloat(coupon.getDiscount());
} catch (NumberFormatException e) {
couponCount -= 1;
cpnlist.remove(coupon);
}
}
}
......
......@@ -107,6 +107,7 @@ import ly.warp.sdk.io.request.WarplyUserCouponsRequest;
import ly.warp.sdk.io.request.WarplyValidateCouponRequest;
import ly.warp.sdk.io.request.WarplyVerifyOTPRequest;
import ly.warp.sdk.io.request.WarplyVerifyTicketRequest;
import ly.warp.sdk.utils.WarpJSONParser;
import ly.warp.sdk.utils.WarpUtils;
import ly.warp.sdk.utils.WarplyManagerHelper;
import ly.warp.sdk.utils.WarplyProperty;
......@@ -778,6 +779,26 @@ public class WarplyManager {
e.printStackTrace();
receiver.onFailure(2);
}
getConsumer(new WarplyConsumerRequest(), new CallbackReceiver<Consumer>() {
@Override
public void onSuccess(Consumer result) {
WarplyManagerHelper.setConsumer(result);
if (result != null) {
JSONObject profMetadata = WarpJSONParser.getJSONFromString(result.getProfileMetadata());
if (profMetadata != null) {
if (profMetadata.has("badge")) {
WarpUtils.setUserTag(Warply.getWarplyContext(), profMetadata.optString("badge"));
}
}
}
}
@Override
public void onFailure(int errorCode) {
}
});
} else
receiver.onFailure(2);
} else
......@@ -799,19 +820,19 @@ public class WarplyManager {
Warply.postReceiveMicroappData(WarpConstants.MICROAPP_COUPONS, true, "context", request.toJson(), new CouponsHook(new CallbackReceiver<CouponList>() {
@Override
public void onSuccess(CouponList result) {
CouponList mCouponList = new CouponList();
for (Coupon coupon : result) {
for (Couponset couponset : WarplyManagerHelper.getCouponsets()) {
if (coupon.getCouponsetUuid().equals(couponset.getUuid())) {
coupon.setDescription(couponset.getShortDescription());
coupon.setImage(couponset.getImgPreview());
coupon.setName(couponset.getName());
mCouponList.add(coupon);
}
}
}
WarplyManagerHelper.setCouponList(mCouponList);
receiver.onSuccess(mCouponList);
// CouponList mCouponList = new CouponList();
// for (Coupon coupon : result) {
// for (Couponset couponset : WarplyManagerHelper.getCouponsets()) {
// if (coupon.getCouponsetUuid().equals(couponset.getUuid())) {
// coupon.setDescription(couponset.getShortDescription());
// coupon.setImage(couponset.getImgPreview());
// coupon.setName(couponset.getName());
// mCouponList.add(coupon);
// }
// }
// }
// WarplyManagerHelper.setCouponList(mCouponList);
receiver.onSuccess(/*mCouponList*/ result);
}
@Override
......@@ -1618,6 +1639,26 @@ public class WarplyManager {
e.printStackTrace();
receiver.onFailure(2);
}
getConsumer(new WarplyConsumerRequest(), new CallbackReceiver<Consumer>() {
@Override
public void onSuccess(Consumer result) {
WarplyManagerHelper.setConsumer(result);
if (result != null) {
JSONObject profMetadata = WarpJSONParser.getJSONFromString(result.getProfileMetadata());
if (profMetadata != null) {
if (profMetadata.has("badge")) {
WarpUtils.setUserTag(Warply.getWarplyContext(), profMetadata.optString("badge"));
}
}
}
}
@Override
public void onFailure(int errorCode) {
}
});
} else
receiver.onFailure(2);
} else
......
......@@ -396,8 +396,10 @@ public class WarpView extends WebView {
EventBus.getDefault().post(new WarplyEventBusManager(questionnaireEvent));
}
} else if (parts[1].equals("couponRetrieved")) {
EventBus.getDefault().post(new WarplyEventBusManager(new CouponEventModel()));
} else if (parts[1].equals("couponShared")) {
// EventBus.getDefault().post(new WarplyEventBusManager(new CouponEventModel()));
} else if (parts[2].equals("serviceDisabled")) {
} /*else if (parts[2].equals("serviceDisabled")) {
// WorkManager.getInstance(Warply.getWarplyContext()).cancelAllWorkByTag(UpdateUserLocationService.TAG);
WarplyPacingEventModel pacingService = new WarplyPacingEventModel();
pacingService.setEnabled(false);
......@@ -407,11 +409,11 @@ public class WarpView extends WebView {
WarplyPacingEventModel pacingService = new WarplyPacingEventModel();
pacingService.setEnabled(true);
EventBus.getDefault().post(new WarplyEventBusManager(pacingService));
} else if (parts[2].equals("shortcutEnabled")) {
}*/ else if (parts[1].equals("steps") && parts[2].equals("shortcutEnabled")) {
WarplyPacingEventModel pacingVisible = new WarplyPacingEventModel();
pacingVisible.setVisible(true);
EventBus.getDefault().post(new WarplyEventBusManager(pacingVisible));
} else if (parts[2].equals("shortcutDisabled")) {
} else if (parts[1].equals("steps") && parts[2].equals("shortcutDisabled")) {
WarplyPacingEventModel pacingVisible = new WarplyPacingEventModel();
pacingVisible.setVisible(false);
EventBus.getDefault().post(new WarplyEventBusManager(pacingVisible));
......
......@@ -129,7 +129,7 @@ public class ActiveCouponAdapter extends RecyclerView.Adapter<ActiveCouponAdapte
else
holder.tvCouponDate.setText(String.format(mContext.getString(R.string.cos_coupon_date), simpleDateFormat.format(newDate != null ? newDate : "")));
holder.tvCouponValue.setText(couponItem.getDiscount() + mContext.getResources().getString(R.string.euro));
holder.tvCouponValue.setText(couponItem.getDiscount());
holder.itemView.setOnClickListener(v -> onClickSubject.onNext(couponItem));
}
}
......