Panagiotis Triantafyllou

new version

......@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
ext {
PUBLISH_GROUP_ID = 'ly.warp'
PUBLISH_VERSION = '4.5.4-cosbeta26'
PUBLISH_VERSION = '4.5.4-cosbeta27'
PUBLISH_ARTIFACT_ID = 'warply-android-sdk'
}
......@@ -34,42 +34,42 @@ android {
dependencies {
//------------------------------ Support -----------------------------//
api 'androidx.appcompat:appcompat:1.4.1'
api 'androidx.recyclerview:recyclerview:1.2.1'
api 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'androidx.cardview:cardview:1.0.0'
api "androidx.security:security-crypto:1.1.0-alpha03" // For minSDK 23 use 1.0.0, for minSDK 21 use 1.1.0 that is currently in alpha
api 'org.altbeacon:android-beacon-library:2.19.3'
api 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
api 'de.hdodenhof:circleimageview:3.1.0'
implementation 'de.hdodenhof:circleimageview:3.1.0'
api group: 'io.reactivex.rxjava2', name: 'rxjava', version: '2.2.21'
api 'com.google.android.material:material:1.5.0'
implementation 'com.google.android.material:material:1.5.0'
api group: 'com.google.zxing', name: 'core', version: '3.4.1'
api group: 'com.google.zxing', name: 'javase', version: '3.4.1'
api 'com.github.siyamed:android-shape-imageview:0.9.3'
api 'org.greenrobot:eventbus:3.3.1'
implementation 'org.greenrobot:eventbus:3.3.1'
//------------------------------ Firebase -----------------------------//
api platform('com.google.firebase:firebase-bom:29.0.3')
api 'com.google.firebase:firebase-messaging'
implementation 'com.google.firebase:firebase-messaging'
//------------------------------ GMS -----------------------------//
api 'com.google.android.gms:play-services-base:18.0.1'
api 'com.google.android.gms:play-services-location:19.0.1'
api 'com.google.android.gms:play-services-maps:18.0.2'
implementation 'com.google.android.gms:play-services-location:19.0.1'
implementation 'com.google.android.gms:play-services-maps:18.0.2'
api 'com.google.maps.android:android-maps-utils:0.5'
//------------------------------ Work Manager -----------------------------//
api 'androidx.work:work-runtime:2.7.1'
//------------------------------ Glide -----------------------------//
api 'com.github.bumptech.glide:glide:4.12.0'
implementation 'com.github.bumptech.glide:glide:4.12.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
//------------------------------ Huawei -----------------------------//
api 'com.huawei.agconnect:agconnect-core:1.6.5.300'
api 'com.huawei.hms:base:6.4.0.302'
api 'com.huawei.hms:push:6.3.0.304'
api 'com.huawei.hms:ads-identifier:3.4.39.302'
implementation 'com.huawei.agconnect:agconnect-core:1.6.5.300'
implementation 'com.huawei.hms:base:6.4.0.302'
implementation 'com.huawei.hms:push:6.3.0.304'
implementation 'com.huawei.hms:ads-identifier:3.4.39.302'
//------------------------------ SQLCipher -----------------------------//
api "net.zetetic:android-database-sqlcipher:4.5.0"
......
......@@ -471,7 +471,7 @@ public enum Warply {
INSTANCE.getInboxInternal(new CallbackReceiver<CampaignList>() {
@Override
public void onSuccess(CampaignList result) {
WarplyManagerHelper.setUniqueCampaignList(result);
WarplyManagerHelper.setCampaignList(result);
if (result.size() >= 0) {
objectSerializer.serialize(result, File.separator + requestSignature);
warplyPreferences.saveInboxLastCachedTimeStamp(requestSignature, System.currentTimeMillis());
......
......@@ -193,8 +193,7 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation
// Thread.currentThread().interrupt();
WarplyManager.getCouponsets(new WarplyGetCouponsetsRequest()
.setLanguage(WarplyProperty.getLanguage(BaseFragmentActivity.this)), mCouponsetsReceiver);
WarplyManager.getUserCouponsWithCouponsets(new WarplyUserCouponsRequest(), mUserCouponsReceiver);
}
......@@ -204,18 +203,6 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation
}
};
private CallbackReceiver<CouponsetsList> mCouponsetsReceiver = new CallbackReceiver<CouponsetsList>() {
@Override
public void onSuccess(CouponsetsList result) {
WarplyManager.getUserCoupons(new WarplyUserCouponsRequest(), mUserCouponsReceiver);
}
@Override
public void onFailure(int errorCode) {
Thread.currentThread().interrupt();
}
};
private final CallbackReceiver<CouponList> mUserCouponsReceiver = new CallbackReceiver<CouponList>() {
@Override
......
......@@ -13,6 +13,7 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import org.greenrobot.eventbus.EventBus;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.HashMap;
......@@ -49,9 +50,8 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene
private ArrayList<MergedGifts> mData = new ArrayList();
private RecyclerView mRecyclerMergedGifts;
private MergedGiftsAdapter mAdapterMergedGifts;
private ArrayList<Campaign> mValuesList = new ArrayList<>();
private HashSet<Campaign> mHashSetList = new HashSet<>();
// private HashSet<Campaign> mHashSetList = new HashSet<>();
private ArrayList<LoyaltyGiftsForYouPackage> mSeasonalList = new ArrayList<>();
private HashSet<LoyaltyGiftsForYouPackage> mHashSetSeasonalList = new HashSet<>();
......@@ -64,11 +64,13 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_gifts_for_you);
if (WarplyManagerHelper.getUniqueCampaignList().get("gifts_for_you") != null && WarplyManagerHelper.getUniqueCampaignList().get("gifts_for_you").size() > 0) {
mHashSetList.addAll(WarplyManagerHelper.getUniqueCampaignList().get("gifts_for_you"));
mValuesList.clear();
mValuesList.addAll(mHashSetList);
}
// if (WarplyManagerHelper.getUniqueCampaignList().get("gifts_for_you") != null && WarplyManagerHelper.getUniqueCampaignList().get("gifts_for_you").size() > 0) {
// mHashSetList.addAll(WarplyManagerHelper.getUniqueCampaignList().get("gifts_for_you"));
// mValuesList.clear();
// mValuesList.addAll(mHashSetList);
// }
filterItems();
if (WarplyManagerHelper.getSeasonalList() != null && WarplyManagerHelper.getSeasonalList().size() > 0) {
mHashSetSeasonalList.addAll(WarplyManagerHelper.getSeasonalList());
......@@ -114,7 +116,6 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene
private void initViews() {
mIvBack.setOnClickListener(this);
mTvTitle.setText(getIntent().getStringExtra("title"));
mIvPopupClose.setOnClickListener(this);
// if (WarpUtils.getGiftsPopup(this))
......@@ -130,21 +131,19 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene
EventBus.getDefault().post(new WarplyEventBusManager(new LoyaltyGiftsForYouOfferClickEvent()));
try {
String key = WarpJSONParser.getJSONFromString(dataItem.getCampaign().getExtraFields()).keys().next();
if (!TextUtils.isEmpty(key) && key.equals("ccms_offer")) {
String value = WarpJSONParser.getJSONFromString(dataItem.getCampaign().getExtraFields()).optString(key);
if (!TextUtils.isEmpty(value) && value.equals("true")) {
JSONObject extraFields = WarpJSONParser.getJSONFromString(dataItem.getCampaign().getExtraFields());
if (extraFields != null) {
if (extraFields.has("ccms_offer") && extraFields.optString("ccms_offer").equals("true")) {
for (LoyaltyContextualOfferModel ccms : WarplyManagerHelper.getCCMSLoyaltyCampaigns()) {
if (ccms.getLoyaltyCampaignId().equals(dataItem.getCampaign().getSessionUUID())) {
startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCcmsUrl(dataItem.getCampaign(), ccms)));
return;
break;
}
}
} else {
startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(dataItem.getCampaign())));
}
}
startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(dataItem.getCampaign())));
} catch (Exception exception) {
startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(dataItem.getCampaign())));
}
......@@ -175,7 +174,7 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene
}
if (seasonalList != null && seasonalList.size() > 0) {
Log.v("GIFTS_FOR_YOU", String.valueOf(seasonalList.size()));
Log.v("SEASONAL", String.valueOf(seasonalList.size()));
for (LoyaltyGiftsForYouPackage seasonal : seasonalList) {
MergedGifts data = new MergedGifts();
data.setCampaign(null);
......@@ -186,6 +185,58 @@ 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.getCCMSLoyaltyCampaigns() == null || WarplyManagerHelper.getCCMSLoyaltyCampaigns().size() == 0) {
Log.v("Got C:{0}", " CCMS campaigns");
for (Campaign camp : WarplyManagerHelper.getCampaignList()) {
if (camp.getOfferCategory().equals("gifts_for_you")) {
try {
JSONObject extraFields = WarpJSONParser.getJSONFromString(camp.getExtraFields());
if (extraFields != null) {
if (extraFields.length() == 0 || !extraFields.has("ccms_offer") || !(extraFields.has("ccms_offer") && extraFields.optString("ccms_offer").equals("true"))) {
gfyList.add(camp);
}
}
} catch (Exception exception) {
gfyList.add(camp);
}
}
}
} else {
int ccmsCount = 0;
Log.v("Got C:{" + String.valueOf(WarplyManagerHelper.getCCMSLoyaltyCampaigns().size()) + "}", " CCMS campaigns");
for (Campaign camp : WarplyManagerHelper.getCampaignList()) {
if (camp.getOfferCategory().equals("gifts_for_you")) {
try {
JSONObject extraFields = WarpJSONParser.getJSONFromString(camp.getExtraFields());
if (extraFields != null) {
if (extraFields.has("ccms_offer") && extraFields.optString("ccms_offer").equals("true")) {
for (LoyaltyContextualOfferModel ccms : WarplyManagerHelper.getCCMSLoyaltyCampaigns()) {
if (ccms.getLoyaltyCampaignId().equals(camp.getSessionUUID())) {
gfyList.add(camp);
ccmsCount++;
break;
}
}
} else {
gfyList.add(camp);
}
}
} catch (Exception exception) {
gfyList.add(camp);
}
}
}
Log.v("Got M:{" + String.valueOf(ccmsCount) + "}", " Matched campaigns");
}
mValuesList.addAll(gfyList);
}
}
// ===========================================================
// Inner and Anonymous Classes
// ===========================================================
......
......@@ -12,13 +12,17 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import org.greenrobot.eventbus.EventBus;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.HashSet;
import ly.warp.sdk.R;
import ly.warp.sdk.io.models.Campaign;
import ly.warp.sdk.io.models.CampaignList;
import ly.warp.sdk.io.models.LoyaltyContextualOfferModel;
import ly.warp.sdk.io.models.LoyaltySDKFirebaseEventModel;
import ly.warp.sdk.utils.WarpJSONParser;
import ly.warp.sdk.utils.WarpUtils;
import ly.warp.sdk.utils.WarplyManagerHelper;
import ly.warp.sdk.utils.managers.WarplyEventBusManager;
......@@ -41,7 +45,7 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener
private MoreCampaignAdapter mAdapterMore;
private LinearLayout mLlMorePopup;
private ArrayList<Campaign> mValuesList = new ArrayList<>();
private HashSet<Campaign> mHashSetList = new HashSet<>();
// private HashSet<Campaign> mHashSetList = new HashSet<>();
// ===========================================================
// Methods for/from SuperClass/Interfaces
......@@ -59,12 +63,13 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener
mRecyclerMore = findViewById(R.id.rv_more_items);
// if (WarplyManagerHelper.getUniqueCampaignList().get("more_for_you") != null && WarplyManagerHelper.getUniqueCampaignList().get("more_for_you").size() > 0) {
// mHashSetList.addAll(WarplyManagerHelper.getUniqueCampaignList().get("more_for_you"));
// mValuesList.clear();
// mValuesList.addAll(mHashSetList);
// }
if (WarplyManagerHelper.getUniqueCampaignList().get("more_for_you") != null && WarplyManagerHelper.getUniqueCampaignList().get("more_for_you").size() > 0) {
mHashSetList.addAll(WarplyManagerHelper.getUniqueCampaignList().get("more_for_you"));
mValuesList.clear();
mValuesList.addAll(mHashSetList);
}
filterItems();
initViews();
}
......@@ -92,7 +97,6 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener
private void initViews() {
mIvBack.setOnClickListener(this);
mTvTitle.setText(getIntent().getStringExtra("title"));
mIvPopupClose.setOnClickListener(this);
// if (WarpUtils.getMorePopup(this))
......@@ -106,7 +110,24 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener
mAdapterMore.getPositionClicks()
.doOnNext(gift -> {
EventBus.getDefault().post(new WarplyEventBusManager(new LoyaltySDKFirebaseEventModel()));
try {
JSONObject extraFields = WarpJSONParser.getJSONFromString(gift.getExtraFields());
if (extraFields != null) {
if (extraFields.has("ccms_offer") && extraFields.optString("ccms_offer").equals("true")) {
for (LoyaltyContextualOfferModel ccms : WarplyManagerHelper.getCCMSLoyaltyCampaigns()) {
if (ccms.getLoyaltyCampaignId().equals(gift.getSessionUUID())) {
startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCcmsUrl(gift, ccms)));
break;
}
}
} else {
startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(gift)));
}
}
} catch (Exception exception) {
startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(gift)));
}
})
.doOnError(error -> {
})
......@@ -116,6 +137,58 @@ 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.getCCMSLoyaltyCampaigns() == null || WarplyManagerHelper.getCCMSLoyaltyCampaigns().size() == 0) {
Log.v("Got C:{0}", " CCMS campaigns");
for (Campaign camp : WarplyManagerHelper.getCampaignList()) {
if (camp.getOfferCategory().equals("more_for_you")) {
try {
JSONObject extraFields = WarpJSONParser.getJSONFromString(camp.getExtraFields());
if (extraFields != null) {
if (extraFields.length() == 0 || !extraFields.has("ccms_offer") || !(extraFields.has("ccms_offer") && extraFields.optString("ccms_offer").equals("true"))) {
gfyList.add(camp);
}
}
} catch (Exception exception) {
gfyList.add(camp);
}
}
}
} else {
int ccmsCount = 0;
Log.v("Got C:{" + String.valueOf(WarplyManagerHelper.getCCMSLoyaltyCampaigns().size()) + "}", " CCMS campaigns");
for (Campaign camp : WarplyManagerHelper.getCampaignList()) {
if (camp.getOfferCategory().equals("more_for_you")) {
try {
JSONObject extraFields = WarpJSONParser.getJSONFromString(camp.getExtraFields());
if (extraFields != null) {
if (extraFields.has("ccms_offer") && extraFields.optString("ccms_offer").equals("true")) {
for (LoyaltyContextualOfferModel ccms : WarplyManagerHelper.getCCMSLoyaltyCampaigns()) {
if (ccms.getLoyaltyCampaignId().equals(camp.getSessionUUID())) {
gfyList.add(camp);
ccmsCount++;
break;
}
}
} else {
gfyList.add(camp);
}
}
} catch (Exception exception) {
gfyList.add(camp);
}
}
}
Log.v("Got M:{" + String.valueOf(ccmsCount) + "}", " Matched campaigns");
}
mValuesList.addAll(gfyList);
}
}
// ===========================================================
// Inner and Anonymous Classes
// ===========================================================
......
......@@ -122,17 +122,16 @@ public class WarpViewActivity extends WarpBaseActivity {
@Subscribe()
public void onMessageEvent(WarplyEventBusManager event) {
EventBus.getDefault().unregister(this);
// EventBus.getDefault().unregister(this);
if (event.getQuestionnaire() != null) {
EventBus.getDefault().post(new WarplyEventBusManager(event.getQuestionnaire()));
setResult(RESULT_OK,new Intent());
setResult(RESULT_OK, new Intent());
finish();
}
if (event.getCoupon() != null)
EventBus.getDefault().post(new WarplyEventBusManager(event.getCoupon()));
finish();
if (event.getPacingCard() != null)
EventBus.getDefault().post(new WarplyEventBusManager(event.getPacingCard()));
finish();
if (event.getPacingService() != null)
EventBus.getDefault().post(new WarplyEventBusManager(event.getPacingService()));
finish();
}
......
......@@ -14,11 +14,16 @@ import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import org.json.JSONObject;
import ly.warp.sdk.R;
import ly.warp.sdk.activities.GiftsForYouActivity;
import ly.warp.sdk.activities.LoyaltyWallet;
import ly.warp.sdk.activities.MoreForYouActivity;
import ly.warp.sdk.activities.WarpViewActivity;
import ly.warp.sdk.io.models.Campaign;
import ly.warp.sdk.io.models.CampaignList;
import ly.warp.sdk.utils.WarpJSONParser;
import ly.warp.sdk.utils.WarplyManagerHelper;
import ly.warp.sdk.views.adapters.ProfileCampaignAdapter;
......@@ -66,28 +71,35 @@ public class LoyaltyFragment extends Fragment implements View.OnClickListener {
mIvMore = view.findViewById(R.id.iv_more3);
mIvMore.setOnClickListener(this);
mClDealsOuter = view.findViewById(R.id.cl_recycler_inner);
mRecyclerDeals = view.findViewById(R.id.rv_deals);
if (WarplyManagerHelper.getUniqueCampaignList().get("deals_for_you") != null && WarplyManagerHelper.getUniqueCampaignList().get("deals_for_you").size() > 0) {
mRecyclerDeals.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false));
mAdapterDeals = new ProfileCampaignAdapter(getContext(), WarplyManagerHelper.getUniqueCampaignList().get("deals_for_you"));
mRecyclerDeals.setAdapter(mAdapterDeals);
mAdapterDeals.getPositionClicks()
.doOnNext(deal -> {
startActivity(WarpViewActivity.createIntentFromURL(getContext(), WarplyManagerHelper.constructCampaignUrl(deal)));
})
.doOnError(error -> {
})
.subscribe();
} else {
mClDealsOuter.setVisibility(View.GONE);
}
// mClDealsOuter = view.findViewById(R.id.cl_recycler_inner);
// mRecyclerDeals = view.findViewById(R.id.rv_deals);
// if (WarplyManagerHelper.getUniqueCampaignList().get("deals_for_you") != null && WarplyManagerHelper.getUniqueCampaignList().get("deals_for_you").size() > 0) {
// mRecyclerDeals.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false));
// mAdapterDeals = new ProfileCampaignAdapter(getContext(), WarplyManagerHelper.getUniqueCampaignList().get("deals_for_you"));
// mRecyclerDeals.setAdapter(mAdapterDeals);
// mAdapterDeals.getPositionClicks()
// .doOnNext(deal -> {
// startActivity(WarpViewActivity.createIntentFromURL(getContext(), WarplyManagerHelper.constructCampaignUrl(deal)));
// })
// .doOnError(error -> {
// })
// .subscribe();
// } else {
// mClDealsOuter.setVisibility(View.GONE);
// }
mClGiftsOuter = view.findViewById(R.id.cl_recycler_inner2);
mRecyclerGifts = view.findViewById(R.id.rv_gifts);
if (WarplyManagerHelper.getUniqueCampaignList().get("gifts_for_you") != null && WarplyManagerHelper.getUniqueCampaignList().get("gifts_for_you").size() > 0) {
if (WarplyManagerHelper.getCampaignList() != null && WarplyManagerHelper.getCampaignList().size() > 0) {
CampaignList gfyList = new CampaignList();
for (Campaign camp : WarplyManagerHelper.getCampaignList()) {
if (camp.getOfferCategory().equals("gifts_for_you")) {
gfyList.add(camp);
}
}
mRecyclerGifts.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false));
mAdapterGifts = new ProfileCampaignAdapter(getContext(), WarplyManagerHelper.getUniqueCampaignList().get("gifts_for_you"));
mAdapterGifts = new ProfileCampaignAdapter(getContext(), gfyList);
mRecyclerGifts.setAdapter(mAdapterGifts);
mAdapterGifts.getPositionClicks()
.doOnNext(gift -> {
......@@ -102,9 +114,16 @@ public class LoyaltyFragment extends Fragment implements View.OnClickListener {
mClMoreOuter = view.findViewById(R.id.cl_recycler_inner3);
mRecyclerMore = view.findViewById(R.id.rv_more);
if (WarplyManagerHelper.getUniqueCampaignList().get("more_for_you") != null && WarplyManagerHelper.getUniqueCampaignList().get("more_for_you").size() > 0) {
if (WarplyManagerHelper.getCampaignList() != null && WarplyManagerHelper.getCampaignList().size() > 0) {
CampaignList mfyList = new CampaignList();
for (Campaign camp : WarplyManagerHelper.getCampaignList()) {
if (camp.getOfferCategory().equals("more_for_you")) {
mfyList.add(camp);
}
}
mRecyclerMore.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false));
mAdapterMore = new ProfileCampaignAdapter(getContext(), WarplyManagerHelper.getUniqueCampaignList().get("more_for_you"));
mAdapterMore = new ProfileCampaignAdapter(getContext(), mfyList);
mRecyclerMore.setAdapter(mAdapterMore);
mAdapterMore.getPositionClicks()
.doOnNext(more -> {
......@@ -127,15 +146,12 @@ public class LoyaltyFragment extends Fragment implements View.OnClickListener {
}
if (view.getId() == R.id.iv_more2) {
Intent intent = new Intent(getContext(), GiftsForYouActivity.class);
intent.putExtra("title", getString(R.string.cos_gifts_title));
startActivity(intent);
return;
}
if (view.getId() == R.id.iv_more3) {
Intent intent = new Intent(getContext(), MoreForYouActivity.class);
intent.putExtra("title", getString(R.string.cos_more_title));
startActivity(intent);
return;
}
}
......
......@@ -128,6 +128,44 @@ public class Consumer implements Parcelable, Serializable {
this(new JSONObject(json));
}
public Consumer() {
this.ackOptin = false;
this.billingInfo = new JSONObject();
this.birthday = "";
this.burntPoints = 0.0d;
this.companyName = "";
this.consumerMetadata = new JSONObject();
this.displayName = "";
this.email = "";
this.firstName = "";
this.gender = "";
this.imageUrl = "";
this.language = "";
this.lastName ="";
this.loyaltyId = "";
this.msisdn = "";
this.nameday = "";
this.nickname = "";
this.optin = new JSONObject();
if (this.optin != null) {
this.newsletter = false;
this.sms = false;
this.segmentation = false;
this.sms_segmentation = false;
}
this.passwordSet = false;
this.profileMetadata = "";
this.redeemedPoints = 0.0d;
this.retrievedPoints = 0.0d;
this.salutation = "";
this.subscribe = false;
this.tags = new JSONObject();
this.taxId = "";
this.userPoints = 0.0d;
this.uuid = "";
this.verified = false;
}
/**
* Constructor used to create an Object from a given JSON Object
*
......
......@@ -301,6 +301,14 @@ public class PacingDetails {
// ================================================================================
public boolean isEnabled() {
return enabled;
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
public PacingInner getSteps() {
return steps;
}
......
......@@ -38,6 +38,10 @@ public class WarplyIntegrationRequest {
private HashMap<String, String> mFilters;
private long mCacheUpdateInterval = 0;
private boolean isNonTelco = false;
private boolean hasAcceptedConsent = false;
private String guid = "";
private ArrayList<String> phoneList = new ArrayList<>();
// ===========================================================
// Constructor
......@@ -83,6 +87,26 @@ public class WarplyIntegrationRequest {
// Getter & Setter
// ===========================================================
public WarplyIntegrationRequest setIsNoTelco(boolean isNonTelco) {
isNonTelco = isNonTelco;
return this;
}
public WarplyIntegrationRequest setHasAcceptedConsent(boolean hasAcceptedConsent) {
hasAcceptedConsent = hasAcceptedConsent;
return this;
}
public WarplyIntegrationRequest setMsisdnList(ArrayList<String> phoneList) {
phoneList = phoneList;
return this;
}
public WarplyIntegrationRequest setGuid(String guid) {
guid = guid;
return this;
}
/**
* Call this to get how often the cached data will be updated.
*
......@@ -147,10 +171,10 @@ public class WarplyIntegrationRequest {
extraJson.putOpt(KEY_ACTION, KEY_ACTION_VALUE);
extraJson.putOpt(KEY_METHOD, KEY_METHOD_VALUE);
JSONObject data = new JSONObject();
data.putOpt("nonTelco", WarplyManagerHelper.loadCustomerState().isNonTelco());
data.putOpt("acceptedConsent", WarplyManagerHelper.loadCustomerState().isAcceptedConsent());
data.putOpt("msisdnList", new JSONArray(WarplyManagerHelper.loadCustomerState().getMsisdnList()));
data.putOpt("guid", WarplyManagerHelper.loadCustomerState().getGuid());
data.putOpt("nonTelco", isNonTelco);
data.putOpt("acceptedConsent", hasAcceptedConsent);
data.putOpt("msisdnList", new JSONArray(phoneList));
data.putOpt("guid", guid);
extraJson.putOpt(KEY_DATA, data);
bodyJsonObject.putOpt(KEY_MAPP, extraJson);
......
......@@ -53,6 +53,7 @@ import ly.warp.sdk.io.models.LoyaltyContextualOfferModel;
import ly.warp.sdk.io.models.LoyaltyGiftsForYouPackage;
import ly.warp.sdk.io.request.CosmoteRetrieveSharingRequest;
import ly.warp.sdk.io.request.CosmoteSharingRequest;
import ly.warp.sdk.io.request.WarplyIntegrationRequest;
import ly.warp.sdk.utils.managers.WarplyManager;
/**
......@@ -69,12 +70,12 @@ public class WarplyManagerHelper {
// Fields
// ===========================================================
private static Consumer mConsumer;
private static Consumer mConsumer = new Consumer();
private static HashMap<String, CampaignList> mUniqueCampaignList = new HashMap<String, CampaignList>();
private static CouponList mCouponList = new CouponList();
private static CouponsetsList mCouponsetsList = new CouponsetsList();
private static CustomerStateModel mCustomerStateModel;
private static CampaignList mCampaignList;
private static CustomerStateModel mCustomerStateModel = new CustomerStateModel();
private static CampaignList mCampaignList = new CampaignList();
private static ArrayList<ActiveDFYCouponModel> mDfyCoupons = new ArrayList();
private static ArrayList<LoyaltyGiftsForYouPackage> mSeasonalList = new ArrayList<>();
private static ArrayList<LoyaltyContextualOfferModel> mCCMSList = new ArrayList<>();
......@@ -403,73 +404,73 @@ public class WarplyManagerHelper {
*/
public static void setCCMSLoyaltyCampaigns(ArrayList<LoyaltyContextualOfferModel> list) {
mCCMSList.clear();
mCCMSList = list;
if (list == null || list.size() == 0) {
CampaignList tempGifts = new CampaignList();
if (mUniqueCampaignList != null && mUniqueCampaignList.get("gifts_for_you") != null && mUniqueCampaignList.get("gifts_for_you").size() > 0) {
for (Campaign camp : mUniqueCampaignList.get("gifts_for_you")) {
try {
String key = WarpJSONParser.getJSONFromString(camp.getExtraFields()).keys().next();
if (!TextUtils.isEmpty(key)) {
String value = WarpJSONParser.getJSONFromString(camp.getExtraFields()).optString(key);
if (!(key.equals("ccms_offer") && value.equals("true"))) {
tempGifts.add(camp);
}
}
} catch (Exception exception) {
tempGifts.add(camp);
}
}
Log.v("Got L:{" + String.valueOf(mCampaignList.size()) + "}", " LOYALTY campaigns");
Log.v("Got C:{0}", " CCMS campaigns");
Log.v("Matched M:{0}", " CCMS campaigns");
Log.v("=====================================", "");
Log.v("TOTAL: Campaigns Sum=" + String.valueOf(mCampaignList.size()), " campaigns to display");
mUniqueCampaignList.get("gifts_for_you").removeAll(tempGifts);
}
return;
}
CampaignList tempGifts = new CampaignList();
if (mUniqueCampaignList != null && mUniqueCampaignList.get("gifts_for_you") != null && mUniqueCampaignList.get("gifts_for_you").size() > 0) {
int ccmsCount = 0;
int loyaltyCount = 0;
for (Campaign camp : mUniqueCampaignList.get("gifts_for_you")) {
try {
String key = WarpJSONParser.getJSONFromString(camp.getExtraFields()).keys().next();
if (!TextUtils.isEmpty(key) && key.equals("ccms_offer")) {
String value = WarpJSONParser.getJSONFromString(camp.getExtraFields()).optString(key);
if (!TextUtils.isEmpty(value) && value.equals("true")) {
for (LoyaltyContextualOfferModel ccms : list) {
if (ccms.getLoyaltyCampaignId().equals(camp.getSessionUUID())) {
tempGifts.add(camp);
ccmsCount++;
break;
}
}
} else {
tempGifts.add(camp);
loyaltyCount++;
}
} else {
tempGifts.add(camp);
loyaltyCount++;
}
} catch (Exception exception) {
tempGifts.add(camp);
loyaltyCount++;
}
}
Log.v("Got L:{" + String.valueOf(mCampaignList.size()) + "}", " LOYALTY campaigns");
Log.v("Got C:{" + String.valueOf(list.size()) + "}", " CCMS campaigns");
Log.v("Matched M:{" + String.valueOf(ccmsCount) + "}", " CCMS campaigns");
Log.v("=====================================", "");
Log.v("TOTAL: Campaigns Sum=" + String.valueOf(mCampaignList.size() - loyaltyCount + ccmsCount), " campaigns to display");
mUniqueCampaignList.get("gifts_for_you").retainAll(tempGifts);
}
mCCMSList.addAll(list);
// if (list == null || list.size() == 0) {
// CampaignList tempGifts = new CampaignList();
// if (mUniqueCampaignList != null && mUniqueCampaignList.get("gifts_for_you") != null && mUniqueCampaignList.get("gifts_for_you").size() > 0) {
// for (Campaign camp : mUniqueCampaignList.get("gifts_for_you")) {
// try {
// String key = WarpJSONParser.getJSONFromString(camp.getExtraFields()).keys().next();
// if (!TextUtils.isEmpty(key)) {
// String value = WarpJSONParser.getJSONFromString(camp.getExtraFields()).optString(key);
// if (!(key.equals("ccms_offer") && value.equals("true"))) {
// tempGifts.add(camp);
// }
// }
// } catch (Exception exception) {
// tempGifts.add(camp);
// }
// }
//
// Log.v("Got L:{" + String.valueOf(mCampaignList.size()) + "}", " LOYALTY campaigns");
// Log.v("Got C:{0}", " CCMS campaigns");
// Log.v("Matched M:{0}", " CCMS campaigns");
// Log.v("=====================================", "");
// Log.v("TOTAL: Campaigns Sum=" + String.valueOf(mCampaignList.size()), " campaigns to display");
// mUniqueCampaignList.get("gifts_for_you").removeAll(tempGifts);
// }
// return;
// }
//
// CampaignList tempGifts = new CampaignList();
// if (mUniqueCampaignList != null && mUniqueCampaignList.get("gifts_for_you") != null && mUniqueCampaignList.get("gifts_for_you").size() > 0) {
// int ccmsCount = 0;
// int loyaltyCount = 0;
// for (Campaign camp : mUniqueCampaignList.get("gifts_for_you")) {
// try {
// String key = WarpJSONParser.getJSONFromString(camp.getExtraFields()).keys().next();
// if (!TextUtils.isEmpty(key) && key.equals("ccms_offer")) {
// String value = WarpJSONParser.getJSONFromString(camp.getExtraFields()).optString(key);
// if (!TextUtils.isEmpty(value) && value.equals("true")) {
// for (LoyaltyContextualOfferModel ccms : list) {
// if (ccms.getLoyaltyCampaignId().equals(camp.getSessionUUID())) {
// tempGifts.add(camp);
// ccmsCount++;
// break;
// }
// }
// } else {
// tempGifts.add(camp);
// loyaltyCount++;
// }
// } else {
// tempGifts.add(camp);
// loyaltyCount++;
// }
// } catch (Exception exception) {
// tempGifts.add(camp);
// loyaltyCount++;
// }
// }
//
// Log.v("Got L:{" + String.valueOf(mCampaignList.size()) + "}", " LOYALTY campaigns");
// Log.v("Got C:{" + String.valueOf(list.size()) + "}", " CCMS campaigns");
// Log.v("Matched M:{" + String.valueOf(ccmsCount) + "}", " CCMS campaigns");
// Log.v("=====================================", "");
// Log.v("TOTAL: Campaigns Sum=" + String.valueOf(mCampaignList.size() - loyaltyCount + ccmsCount), " campaigns to display");
// mUniqueCampaignList.get("gifts_for_you").retainAll(tempGifts);
// }
}
/**
......@@ -497,8 +498,12 @@ public class WarplyManagerHelper {
* Open Questionnaire
*/
public static String openQuestionnaire() {
if (mUniqueCampaignList != null && mUniqueCampaignList.get("questionnaire") != null && mUniqueCampaignList.get("questionnaire").size() > 0) {
return constructCampaignUrl(mUniqueCampaignList.get("questionnaire").get(0));
if (mCampaignList != null && mCampaignList.size() > 0) {
for (Campaign camp : mCampaignList) {
if (camp.getOfferCategory().equals("questionnaire")) {
return constructCampaignUrl(camp);
}
}
}
return "";
......@@ -508,8 +513,12 @@ public class WarplyManagerHelper {
* Open Pacing
*/
public static String openPacing() {
if (mUniqueCampaignList != null && mUniqueCampaignList.get("pacing") != null && mUniqueCampaignList.get("pacing").size() > 0) {
return constructCampaignUrl(mUniqueCampaignList.get("pacing").get(0));
if (mCampaignList != null && mCampaignList.size() > 0) {
for (Campaign camp : mCampaignList) {
if (camp.getOfferCategory().equals("pacing")) {
return constructCampaignUrl(camp);
}
}
}
return "";
......@@ -521,6 +530,23 @@ public class WarplyManagerHelper {
*/
public static void saveCustomerState(CustomerStateModel customerState) {
mCustomerStateModel = customerState;
WarplyIntegrationRequest request = new WarplyIntegrationRequest();
request.setIsNoTelco(customerState.isNonTelco());
request.setHasAcceptedConsent(customerState.isAcceptedConsent());
request.setGuid(customerState.getGuid());
request.setMsisdnList(customerState.getMsisdnList());
WarplyManager.consumerIntegration(request, new CallbackReceiver<JSONObject>() {
@Override
public void onSuccess(JSONObject result) {
WarpUtils.log("CUSTOMER STATE SUCCESS");
}
@Override
public void onFailure(int errorCode) {
WarpUtils.log("CUSTOMER STATE ERROR");
}
});
}
/**
......@@ -569,24 +595,28 @@ public class WarplyManagerHelper {
}
public static void setUniqueCampaignList(CampaignList campaignList) {
mCampaignList = campaignList;
if (campaignList != null) {
for (Campaign campaign : campaignList) {
if (mUniqueCampaignList.containsKey(campaign.getOfferCategory().trim())) {
CampaignList tempCampaignList = (CampaignList) mUniqueCampaignList.get(campaign.getOfferCategory().trim());
tempCampaignList.add(campaign);
mUniqueCampaignList.put(campaign.getOfferCategory().trim(), tempCampaignList);
} else {
CampaignList tempCampaignList = new CampaignList();
tempCampaignList.add(campaign);
mUniqueCampaignList.put(campaign.getOfferCategory().trim(), tempCampaignList);
}
}
}
mCampaignList.clear();
mCampaignList.addAll(campaignList);
// if (campaignList != null) {
// for (Campaign campaign : campaignList) {
// if (mUniqueCampaignList.containsKey(campaign.getOfferCategory().trim())) {
// CampaignList tempCampaignList = (CampaignList) mUniqueCampaignList.get(campaign.getOfferCategory().trim());
// tempCampaignList.add(campaign);
// mUniqueCampaignList.put(campaign.getOfferCategory().trim(), tempCampaignList);
// } else {
// CampaignList tempCampaignList = new CampaignList();
// tempCampaignList.add(campaign);
// mUniqueCampaignList.put(campaign.getOfferCategory().trim(), tempCampaignList);
// }
// }
// }
}
public static void setCampaignList(CampaignList campaignList) {
mCampaignList = campaignList;
mCampaignList.clear();
mCampaignList.addAll(campaignList);
}
public static CampaignList getCampaignList() {
......
......@@ -29,6 +29,7 @@ import org.json.JSONException;
import org.json.JSONObject;
import ly.warp.sdk.Warply;
import ly.warp.sdk.activities.BaseFragmentActivity;
import ly.warp.sdk.db.WarplyDBHelper;
import ly.warp.sdk.io.callbacks.AddressHook;
import ly.warp.sdk.io.callbacks.CallbackReceiver;
......@@ -107,6 +108,7 @@ import ly.warp.sdk.io.request.WarplyVerifyOTPRequest;
import ly.warp.sdk.io.request.WarplyVerifyTicketRequest;
import ly.warp.sdk.utils.WarpUtils;
import ly.warp.sdk.utils.WarplyManagerHelper;
import ly.warp.sdk.utils.WarplyProperty;
import ly.warp.sdk.utils.constants.WarpConstants;
/**
......@@ -1524,4 +1526,63 @@ public class WarplyManager {
}
});
}
public static void getUserCouponsWithCouponsets(WarplyUserCouponsRequest request, final CallbackReceiver<CouponList> receiver) {
WarpUtils.log("************* WARPLY User Coupons Request ********************");
WarpUtils.log("[WARP Trace] WARPLY User Coupons Request is active");
WarpUtils.log("**************************************************");
WarplyManager.getCouponsets(new WarplyGetCouponsetsRequest()
.setLanguage(WarplyProperty.getLanguage(Warply.getWarplyContext())), new CallbackReceiver<CouponsetsList>() {
@Override
public void onSuccess(CouponsetsList result) {
Warply.postReceiveMicroappData(WarpConstants.MICROAPP_COUPONS, true, "context", request.toJson(), new CouponsHook(new CallbackReceiver<CouponList>() {
@Override
public void onSuccess(CouponList response) {
CouponList mCouponList = new CouponList();
for (Coupon coupon : response) {
for (Couponset couponset : result) {
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);
}
@Override
public void onFailure(int errorCode) {
if (errorCode == 401) {
refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() {
@Override
public void onSuccess(JSONObject result) {
int status = result.optInt("status", 2);
if (status == 1)
getUserCoupons(request, receiver);
else
receiver.onFailure(status);
}
@Override
public void onFailure(int errorCode) {
receiver.onFailure(errorCode);
}
});
} else
receiver.onFailure(errorCode);
}
},
request.getSignature()));
}
@Override
public void onFailure(int errorCode) {
receiver.onFailure(errorCode);
}
});
}
}
......
......@@ -383,10 +383,17 @@ public class WarpView extends WebView {
EventBus.getDefault().post(new WarplyEventBusManager(questionnaireEvent));
} else if (parts[1].equals("addUserTag")) {
QuestionnaireEventModel questionnaireEvent = new QuestionnaireEventModel();
try {
questionnaireEvent.setName(parts[1]);
questionnaireEvent.setParameter(parts[2]);
WarpUtils.setUserTag(Warply.getWarplyContext(), parts[2]);
EventBus.getDefault().post(new WarplyEventBusManager(questionnaireEvent));
} catch (IndexOutOfBoundsException e) {
questionnaireEvent.setName(parts[1]);
questionnaireEvent.setParameter("");
WarpUtils.setUserTag(Warply.getWarplyContext(), "");
EventBus.getDefault().post(new WarplyEventBusManager(questionnaireEvent));
}
} else if (parts[1].equals("couponRetrieved")) {
// EventBus.getDefault().post(new WarplyEventBusManager(new CouponEventModel()));
} else if (parts[2].equals("serviceDisabled")) {
......
......@@ -32,6 +32,7 @@
android:textColor="@color/grey"
android:textSize="17sp"
android:textStyle="bold"
android:text="@string/cos_gifts_title"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.356"
......
......@@ -31,6 +31,7 @@
android:textColor="@color/grey"
android:textSize="17sp"
android:textStyle="bold"
android:text="@string/cos_more_title"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.356"
......