Panagiotis Triantafyllou

minor changes

...@@ -2,7 +2,7 @@ apply plugin: 'com.android.library' ...@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
2 2
3 ext { 3 ext {
4 PUBLISH_GROUP_ID = 'ly.warp' 4 PUBLISH_GROUP_ID = 'ly.warp'
5 - PUBLISH_VERSION = '4.5.5.4r14' 5 + PUBLISH_VERSION = '4.5.5.4r15'
6 PUBLISH_ARTIFACT_ID = 'warply-android-sdk' 6 PUBLISH_ARTIFACT_ID = 'warply-android-sdk'
7 } 7 }
8 8
......
...@@ -2,6 +2,7 @@ package ly.warp.sdk.activities; ...@@ -2,6 +2,7 @@ package ly.warp.sdk.activities;
2 2
3 import android.app.Activity; 3 import android.app.Activity;
4 import android.content.Context; 4 import android.content.Context;
5 +import android.content.Intent;
5 import android.os.Bundle; 6 import android.os.Bundle;
6 import android.text.TextUtils; 7 import android.text.TextUtils;
7 import android.text.method.LinkMovementMethod; 8 import android.text.method.LinkMovementMethod;
...@@ -274,9 +275,11 @@ public class CouponsetInfoActivity extends Activity implements View.OnClickListe ...@@ -274,9 +275,11 @@ public class CouponsetInfoActivity extends Activity implements View.OnClickListe
274 if (success) { 275 if (success) {
275 // setResult(RESULT_OK, new Intent()); 276 // setResult(RESULT_OK, new Intent());
276 onBackPressed(); 277 onBackPressed();
277 - OpenMyRewardsEventModel openMyRewards = new OpenMyRewardsEventModel(); 278 +// OpenMyRewardsEventModel openMyRewards = new OpenMyRewardsEventModel();
278 - openMyRewards.setOpen(true); 279 +// openMyRewards.setOpen(true);
279 - EventBus.getDefault().post(new WarplyEventBusManager(openMyRewards)); 280 +// EventBus.getDefault().post(new WarplyEventBusManager(openMyRewards));
281 + Intent intent = new Intent(CouponsetInfoActivity.this, ActiveCouponsActivity.class);
282 + startActivity(intent);
280 } 283 }
281 }) 284 })
282 .setNegativeButton(R.string.cos_dlg_negative_button5, (dialogNegative, whichNegative) -> { 285 .setNegativeButton(R.string.cos_dlg_negative_button5, (dialogNegative, whichNegative) -> {
......
...@@ -108,6 +108,7 @@ public class Campaign implements Parcelable, Serializable { ...@@ -108,6 +108,7 @@ public class Campaign implements Parcelable, Serializable {
108 private String categoryId; 108 private String categoryId;
109 private Integer couponAvailability; 109 private Integer couponAvailability;
110 private String endDate, startDate; 110 private String endDate, startDate;
111 + private boolean showExpiration;
111 112
112 /** 113 /**
113 * Basic constructor used to create an object from a String, representing a 114 * Basic constructor used to create an object from a String, representing a
...@@ -151,6 +152,7 @@ public class Campaign implements Parcelable, Serializable { ...@@ -151,6 +152,7 @@ public class Campaign implements Parcelable, Serializable {
151 this.categoryId = ""; 152 this.categoryId = "";
152 this.endDate = ""; 153 this.endDate = "";
153 this.startDate = ""; 154 this.startDate = "";
155 + this.showExpiration = false;
154 } 156 }
155 157
156 /** 158 /**
...@@ -678,6 +680,14 @@ public class Campaign implements Parcelable, Serializable { ...@@ -678,6 +680,14 @@ public class Campaign implements Parcelable, Serializable {
678 this.startDate = startDate; 680 this.startDate = startDate;
679 } 681 }
680 682
683 + public boolean isShowExpiration() {
684 + return showExpiration;
685 + }
686 +
687 + public void setShowExpiration(boolean showExpiration) {
688 + this.showExpiration = showExpiration;
689 + }
690 +
681 @Override 691 @Override
682 public int describeContents() { 692 public int describeContents() {
683 return 0; 693 return 0;
......
...@@ -93,6 +93,7 @@ public class NewCampaign implements Parcelable, Serializable { ...@@ -93,6 +93,7 @@ public class NewCampaign implements Parcelable, Serializable {
93 private boolean isNew = false; 93 private boolean isNew = false;
94 private String bannerImage = ""; 94 private String bannerImage = "";
95 private String bannerTitle = ""; 95 private String bannerTitle = "";
96 + private boolean showExpiration = false;
96 97
97 /** 98 /**
98 * Basic constructor used to create an object from a String, representing a 99 * Basic constructor used to create an object from a String, representing a
...@@ -139,6 +140,11 @@ public class NewCampaign implements Parcelable, Serializable { ...@@ -139,6 +140,11 @@ public class NewCampaign implements Parcelable, Serializable {
139 if (this.extraFields.has(BANNER_TITLE)) { 140 if (this.extraFields.has(BANNER_TITLE)) {
140 this.bannerTitle = this.extraFields.optString(BANNER_TITLE); 141 this.bannerTitle = this.extraFields.optString(BANNER_TITLE);
141 } 142 }
143 + if (this.extraFields.has("show_expiration")) {
144 + this.showExpiration = this.extraFields.optBoolean("show_expiration");
145 + } else {
146 + this.showExpiration = false;
147 + }
142 } 148 }
143 } 149 }
144 150
...@@ -378,6 +384,14 @@ public class NewCampaign implements Parcelable, Serializable { ...@@ -378,6 +384,14 @@ public class NewCampaign implements Parcelable, Serializable {
378 return bannerTitle; 384 return bannerTitle;
379 } 385 }
380 386
387 + public boolean isShowExpiration() {
388 + return showExpiration;
389 + }
390 +
391 + public void setShowExpiration(boolean showExpiration) {
392 + this.showExpiration = showExpiration;
393 + }
394 +
381 @Override 395 @Override
382 public int describeContents() { 396 public int describeContents() {
383 return 0; 397 return 0;
......
...@@ -1768,6 +1768,7 @@ public class WarplyManager { ...@@ -1768,6 +1768,7 @@ public class WarplyManager {
1768 camp.setType(newCamp.getCampaignType()); 1768 camp.setType(newCamp.getCampaignType());
1769 camp.setEndDate(newCamp.getEndDate()); 1769 camp.setEndDate(newCamp.getEndDate());
1770 camp.setStartDate(newCamp.getStartDate()); 1770 camp.setStartDate(newCamp.getStartDate());
1771 + camp.setShowExpiration(newCamp.isShowExpiration());
1771 try { 1772 try {
1772 camp.setExtraFields(newCamp.getExtraFields().toString()); 1773 camp.setExtraFields(newCamp.getExtraFields().toString());
1773 if (!TextUtils.isEmpty(newCamp.getExtraFields().toString())) { 1774 if (!TextUtils.isEmpty(newCamp.getExtraFields().toString())) {
...@@ -1786,11 +1787,13 @@ public class WarplyManager { ...@@ -1786,11 +1787,13 @@ public class WarplyManager {
1786 } else { 1787 } else {
1787 camp.setBannerImage(""); 1788 camp.setBannerImage("");
1788 camp.setBannerTitle(""); 1789 camp.setBannerTitle("");
1790 + camp.setCategoryId("");
1789 } 1791 }
1790 } catch (NullPointerException e) { 1792 } catch (NullPointerException e) {
1791 camp.setExtraFields(""); 1793 camp.setExtraFields("");
1792 camp.setBannerImage(""); 1794 camp.setBannerImage("");
1793 camp.setBannerTitle(""); 1795 camp.setBannerTitle("");
1796 + camp.setCategoryId("");
1794 e.printStackTrace(); 1797 e.printStackTrace();
1795 } 1798 }
1796 1799
...@@ -1912,6 +1915,7 @@ public class WarplyManager { ...@@ -1912,6 +1915,7 @@ public class WarplyManager {
1912 camp.setType(newCamp.getCampaignType()); 1915 camp.setType(newCamp.getCampaignType());
1913 camp.setEndDate(newCamp.getEndDate()); 1916 camp.setEndDate(newCamp.getEndDate());
1914 camp.setStartDate(newCamp.getStartDate()); 1917 camp.setStartDate(newCamp.getStartDate());
1918 + camp.setShowExpiration(newCamp.isShowExpiration());
1915 try { 1919 try {
1916 camp.setExtraFields(newCamp.getExtraFields().toString()); 1920 camp.setExtraFields(newCamp.getExtraFields().toString());
1917 if (!TextUtils.isEmpty(newCamp.getExtraFields().toString())) { 1921 if (!TextUtils.isEmpty(newCamp.getExtraFields().toString())) {
...@@ -1930,11 +1934,13 @@ public class WarplyManager { ...@@ -1930,11 +1934,13 @@ public class WarplyManager {
1930 } else { 1934 } else {
1931 camp.setBannerImage(""); 1935 camp.setBannerImage("");
1932 camp.setBannerTitle(""); 1936 camp.setBannerTitle("");
1937 + camp.setCategoryId("");
1933 } 1938 }
1934 } catch (NullPointerException e) { 1939 } catch (NullPointerException e) {
1935 camp.setExtraFields(""); 1940 camp.setExtraFields("");
1936 camp.setBannerImage(""); 1941 camp.setBannerImage("");
1937 camp.setBannerTitle(""); 1942 camp.setBannerTitle("");
1943 + camp.setCategoryId("");
1938 e.printStackTrace(); 1944 e.printStackTrace();
1939 } 1945 }
1940 1946
......
...@@ -41,6 +41,7 @@ import android.location.LocationManager; ...@@ -41,6 +41,7 @@ import android.location.LocationManager;
41 import android.net.Uri; 41 import android.net.Uri;
42 import android.net.http.SslError; 42 import android.net.http.SslError;
43 import android.os.Build; 43 import android.os.Build;
44 +import android.os.Handler;
44 import android.text.TextUtils; 45 import android.text.TextUtils;
45 import android.util.AttributeSet; 46 import android.util.AttributeSet;
46 import android.webkit.GeolocationPermissions.Callback; 47 import android.webkit.GeolocationPermissions.Callback;
...@@ -58,6 +59,8 @@ import androidx.core.content.ContextCompat; ...@@ -58,6 +59,8 @@ import androidx.core.content.ContextCompat;
58 import androidx.lifecycle.DefaultLifecycleObserver; 59 import androidx.lifecycle.DefaultLifecycleObserver;
59 import androidx.lifecycle.LifecycleOwner; 60 import androidx.lifecycle.LifecycleOwner;
60 import androidx.lifecycle.ProcessLifecycleOwner; 61 import androidx.lifecycle.ProcessLifecycleOwner;
62 +import androidx.work.OneTimeWorkRequest;
63 +import androidx.work.WorkManager;
61 64
62 import com.google.android.gms.common.api.GoogleApiClient; 65 import com.google.android.gms.common.api.GoogleApiClient;
63 import com.google.android.gms.common.api.PendingResult; 66 import com.google.android.gms.common.api.PendingResult;
...@@ -77,15 +80,21 @@ import org.json.JSONObject; ...@@ -77,15 +80,21 @@ import org.json.JSONObject;
77 import java.io.UnsupportedEncodingException; 80 import java.io.UnsupportedEncodingException;
78 import java.net.URISyntaxException; 81 import java.net.URISyntaxException;
79 import java.net.URLDecoder; 82 import java.net.URLDecoder;
83 +import java.util.ArrayList;
80 import java.util.HashMap; 84 import java.util.HashMap;
81 import java.util.LinkedHashMap; 85 import java.util.LinkedHashMap;
82 import java.util.Map; 86 import java.util.Map;
83 87
84 import ly.warp.sdk.R; 88 import ly.warp.sdk.R;
85 import ly.warp.sdk.Warply; 89 import ly.warp.sdk.Warply;
90 +import ly.warp.sdk.activities.ActiveCouponsActivity;
91 +import ly.warp.sdk.activities.CouponsetInfoActivity;
86 import ly.warp.sdk.activities.WarpViewActivity; 92 import ly.warp.sdk.activities.WarpViewActivity;
87 import ly.warp.sdk.db.WarplyDBHelper; 93 import ly.warp.sdk.db.WarplyDBHelper;
94 +import ly.warp.sdk.io.callbacks.CallbackReceiver;
95 +import ly.warp.sdk.io.models.Campaign;
88 import ly.warp.sdk.io.models.CouponEventModel; 96 import ly.warp.sdk.io.models.CouponEventModel;
97 +import ly.warp.sdk.io.models.CouponList;
89 import ly.warp.sdk.io.models.LoyaltySDKDynatraceEventModel; 98 import ly.warp.sdk.io.models.LoyaltySDKDynatraceEventModel;
90 import ly.warp.sdk.io.models.LoyaltySDKFirebaseEventModel; 99 import ly.warp.sdk.io.models.LoyaltySDKFirebaseEventModel;
91 import ly.warp.sdk.io.models.OpenMyRewardsEventModel; 100 import ly.warp.sdk.io.models.OpenMyRewardsEventModel;
...@@ -93,9 +102,11 @@ import ly.warp.sdk.io.models.QuestionnaireEventModel; ...@@ -93,9 +102,11 @@ import ly.warp.sdk.io.models.QuestionnaireEventModel;
93 import ly.warp.sdk.io.models.RefreshUnifiedCouponsEventModel; 102 import ly.warp.sdk.io.models.RefreshUnifiedCouponsEventModel;
94 import ly.warp.sdk.io.models.RefreshVouchersEventModel; 103 import ly.warp.sdk.io.models.RefreshVouchersEventModel;
95 import ly.warp.sdk.io.models.WarplyCCMSEnabledModel; 104 import ly.warp.sdk.io.models.WarplyCCMSEnabledModel;
105 +import ly.warp.sdk.io.models.WarplyCouponsChangedEventModel;
96 import ly.warp.sdk.io.models.WarplyPacingCardEventModel; 106 import ly.warp.sdk.io.models.WarplyPacingCardEventModel;
97 import ly.warp.sdk.io.models.WarplyPacingEventModel; 107 import ly.warp.sdk.io.models.WarplyPacingEventModel;
98 import ly.warp.sdk.io.models.WarplyUnifiedActivatedEventModel; 108 import ly.warp.sdk.io.models.WarplyUnifiedActivatedEventModel;
109 +import ly.warp.sdk.services.EventCampaignService;
99 import ly.warp.sdk.services.WarplyHealthService; 110 import ly.warp.sdk.services.WarplyHealthService;
100 import ly.warp.sdk.utils.WarpUtils; 111 import ly.warp.sdk.utils.WarpUtils;
101 import ly.warp.sdk.utils.WarplyManagerHelper; 112 import ly.warp.sdk.utils.WarplyManagerHelper;
...@@ -104,6 +115,7 @@ import ly.warp.sdk.utils.WarplyUrlHandler; ...@@ -104,6 +115,7 @@ import ly.warp.sdk.utils.WarplyUrlHandler;
104 import ly.warp.sdk.utils.constants.WarpConstants; 115 import ly.warp.sdk.utils.constants.WarpConstants;
105 import ly.warp.sdk.utils.managers.WarplyAnalyticsManager; 116 import ly.warp.sdk.utils.managers.WarplyAnalyticsManager;
106 import ly.warp.sdk.utils.managers.WarplyEventBusManager; 117 import ly.warp.sdk.utils.managers.WarplyEventBusManager;
118 +import ly.warp.sdk.utils.managers.WarplyManager;
107 119
108 public class WarpView extends WebView implements DefaultLifecycleObserver { 120 public class WarpView extends WebView implements DefaultLifecycleObserver {
109 121
...@@ -503,6 +515,23 @@ public class WarpView extends WebView implements DefaultLifecycleObserver { ...@@ -503,6 +515,23 @@ public class WarpView extends WebView implements DefaultLifecycleObserver {
503 RefreshVouchersEventModel vouchersRefreshed = new RefreshVouchersEventModel(); 515 RefreshVouchersEventModel vouchersRefreshed = new RefreshVouchersEventModel();
504 vouchersRefreshed.setRefreshed(true); 516 vouchersRefreshed.setRefreshed(true);
505 EventBus.getDefault().post(new WarplyEventBusManager(vouchersRefreshed)); 517 EventBus.getDefault().post(new WarplyEventBusManager(vouchersRefreshed));
518 + } else if (parts[1].equals("activeCoupons")) {
519 + new Thread(() -> {
520 + if (!Thread.currentThread().isInterrupted()) {
521 + WarplyManager.getUserCouponsWithCouponsets(mUserCouponsReceiver);
522 + WarplyManager.getCampaigns(mCampaignsCallback);
523 + }
524 + }).start();
525 +
526 + Handler handlerIntent = new Handler();
527 + Runnable runnableIntent = new Runnable() {
528 + @Override
529 + public void run() {
530 + Intent intent = new Intent((WarpActivity != null && !WarpActivity.isFinishing()) ? WarpActivity : getContext(), ActiveCouponsActivity.class);
531 + getContext().startActivity(intent);
532 + }
533 + };
534 + handlerIntent.postDelayed(runnableIntent, 1500);
506 } else if (parts[1].equals("ccmsRetrieved")) { 535 } else if (parts[1].equals("ccmsRetrieved")) {
507 WarplyCCMSEnabledModel ccmsEnabled = new WarplyCCMSEnabledModel(); 536 WarplyCCMSEnabledModel ccmsEnabled = new WarplyCCMSEnabledModel();
508 ccmsEnabled.setActivated(true); 537 ccmsEnabled.setActivated(true);
...@@ -869,4 +898,33 @@ public class WarpView extends WebView implements DefaultLifecycleObserver { ...@@ -869,4 +898,33 @@ public class WarpView extends WebView implements DefaultLifecycleObserver {
869 return false; 898 return false;
870 } 899 }
871 } 900 }
901 +
902 + private final CallbackReceiver<CouponList> mUserCouponsReceiver = new CallbackReceiver<CouponList>() {
903 + @Override
904 + public void onSuccess(CouponList result) {
905 +// Thread.currentThread().interrupt();
906 + WarplyCouponsChangedEventModel couponsChanged = new WarplyCouponsChangedEventModel();
907 + couponsChanged.setChanged(true);
908 + EventBus.getDefault().post(new WarplyEventBusManager(couponsChanged));
909 + }
910 +
911 + @Override
912 + public void onFailure(int errorCode) {
913 + Thread.currentThread().interrupt();
914 + }
915 + };
916 +
917 + private CallbackReceiver<ArrayList<Campaign>> mCampaignsCallback = new CallbackReceiver<ArrayList<Campaign>>() {
918 + @Override
919 + public void onSuccess(ArrayList<Campaign> result) {
920 + OneTimeWorkRequest mywork = new OneTimeWorkRequest.Builder(EventCampaignService.class).build();
921 + WorkManager.getInstance((WarpActivity != null && !WarpActivity.isFinishing()) ? WarpActivity : getContext()).enqueue(mywork);
922 +// Thread.currentThread().interrupt();
923 + }
924 +
925 + @Override
926 + public void onFailure(int errorCode) {
927 + Thread.currentThread().interrupt();
928 + }
929 + };
872 } 930 }
...\ No newline at end of file ...\ No newline at end of file
......