Panagiotis Triantafyllou

added eurobank home activity, new colors, new files

...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
12 <!-- android:xlargeScreens="false" />--> 12 <!-- android:xlargeScreens="false" />-->
13 13
14 <application 14 <application
15 - android:name="warp.ly.android_sdk.WarplyAndroidSDKApplication" 15 + android:name=".WarplyAndroidSDKApplication"
16 android:allowBackup="false" 16 android:allowBackup="false"
17 android:exported="true" 17 android:exported="true"
18 android:extractNativeLibs="true" 18 android:extractNativeLibs="true"
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
25 android:theme="@style/AppTheme"> 25 android:theme="@style/AppTheme">
26 26
27 <activity 27 <activity
28 - android:name="warp.ly.android_sdk.activities.SplashActivity" 28 + android:name=".activities.SplashActivity"
29 android:exported="true" 29 android:exported="true"
30 android:label="@string/app_name" 30 android:label="@string/app_name"
31 android:screenOrientation="portrait"> 31 android:screenOrientation="portrait">
...@@ -41,8 +41,6 @@ ...@@ -41,8 +41,6 @@
41 android:exported="false" 41 android:exported="false"
42 android:label="@string/title_activity_main" 42 android:label="@string/title_activity_main"
43 android:screenOrientation="portrait" /> 43 android:screenOrientation="portrait" />
44 -
45 -
46 </application> 44 </application>
47 45
48 <!-- For Huawei Push, only if we targetSdkVersion 30, comment if we are in Google build --> 46 <!-- For Huawei Push, only if we targetSdkVersion 30, comment if we are in Google build -->
......
1 # {@link ly.warp.sdk.utils.WarplyProperty} 1 # {@link ly.warp.sdk.utils.WarplyProperty}
2 2
3 # The app uuid the warply sdk need to connect to the engage server 3 # The app uuid the warply sdk need to connect to the engage server
4 -Uuid=b13ade8ef743468b89a7aaa8efbfc468 4 +# Epistrofi dev app uuid 4e067691826111e2998e8d972467e239
5 +Uuid=4e067691826111e2998e8d972467e239
5 6
6 # If we need to see logs in Logcat 7 # If we need to see logs in Logcat
7 Debug=false 8 Debug=false
...@@ -37,7 +38,7 @@ SendPackages=false ...@@ -37,7 +38,7 @@ SendPackages=false
37 #Language=el 38 #Language=el
38 39
39 # The merchant id for some requests 40 # The merchant id for some requests
40 -MerchantId=20113 41 +MerchantId=59949
41 42
42 # The login type must be one of the below: 43 # The login type must be one of the below:
43 # email, msisdn, username 44 # email, msisdn, username
......
...@@ -2,14 +2,21 @@ package warp.ly.android_sdk.activities; ...@@ -2,14 +2,21 @@ package warp.ly.android_sdk.activities;
2 2
3 import android.content.Intent; 3 import android.content.Intent;
4 import android.os.Bundle; 4 import android.os.Bundle;
5 +import android.widget.Toast;
5 6
7 +import java.util.ArrayList;
6 import java.util.Timer; 8 import java.util.Timer;
7 import java.util.TimerTask; 9 import java.util.TimerTask;
8 10
9 import ly.warp.sdk.Warply; 11 import ly.warp.sdk.Warply;
12 +import ly.warp.sdk.activities.EurobankHomeActivity;
13 +import ly.warp.sdk.io.callbacks.CallbackReceiver;
10 import ly.warp.sdk.io.callbacks.SimpleCallbackReceiver; 14 import ly.warp.sdk.io.callbacks.SimpleCallbackReceiver;
11 import ly.warp.sdk.io.callbacks.WarplyReadyCallback; 15 import ly.warp.sdk.io.callbacks.WarplyReadyCallback;
16 +import ly.warp.sdk.io.models.Campaign;
17 +import ly.warp.sdk.io.request.WarplyGetCampaignsRequest;
12 import ly.warp.sdk.utils.WarplyInitializer; 18 import ly.warp.sdk.utils.WarplyInitializer;
19 +import ly.warp.sdk.utils.managers.WarplyManager;
13 import warp.ly.android_sdk.R; 20 import warp.ly.android_sdk.R;
14 21
15 import static warp.ly.android_sdk.utils.Constants.SENDER_ID; 22 import static warp.ly.android_sdk.utils.Constants.SENDER_ID;
...@@ -26,19 +33,20 @@ public class SplashActivity extends BaseActivity { ...@@ -26,19 +33,20 @@ public class SplashActivity extends BaseActivity {
26 mWarplyInitializer = Warply.getInitializer(this, new WarplyReadyCallback() { 33 mWarplyInitializer = Warply.getInitializer(this, new WarplyReadyCallback() {
27 @Override 34 @Override
28 public void onWarplyReady() { 35 public void onWarplyReady() {
29 - checkForAppUpdate(); 36 + showToast("Warply initialization success!");
37 + WarplyManager.getCampaigns(new WarplyGetCampaignsRequest(), mCampaignsCallback);
30 } 38 }
31 39
32 @Override 40 @Override
33 public void onWarplyInitTimeOut() { 41 public void onWarplyInitTimeOut() {
34 showToast("Warply initialization timeout!"); 42 showToast("Warply initialization timeout!");
35 - checkForAppUpdate(); 43 + startNextActivity();
36 } 44 }
37 45
38 @Override 46 @Override
39 public void onWarplyPermissionsDenied() { 47 public void onWarplyPermissionsDenied() {
40 showToast("Warply permissions denied!"); 48 showToast("Warply permissions denied!");
41 - checkForAppUpdate(); 49 + startNextActivity();
42 } 50 }
43 }); 51 });
44 } 52 }
...@@ -55,20 +63,7 @@ public class SplashActivity extends BaseActivity { ...@@ -55,20 +63,7 @@ public class SplashActivity extends BaseActivity {
55 // super.onRequestPermissionsResult(requestCode, permissions, grantResults); 63 // super.onRequestPermissionsResult(requestCode, permissions, grantResults);
56 // } 64 // }
57 65
58 - private void checkForAppUpdate() {
59 -
60 - Warply.checkForAppUpdate(SplashActivity.this, new SimpleCallbackReceiver<Boolean>() {
61 - @Override
62 - public void onResult(Boolean updateAccepted, int errorCode) {
63 - if (!updateAccepted) {
64 - startNextActivity();
65 - }
66 - }
67 - });
68 - }
69 -
70 private void startNextActivity() { 66 private void startNextActivity() {
71 -
72 if (!isFinishing()) { 67 if (!isFinishing()) {
73 long MIN_SPLASH_TIME = 2000; 68 long MIN_SPLASH_TIME = 2000;
74 new Timer().schedule(new TimerTask() { 69 new Timer().schedule(new TimerTask() {
...@@ -80,7 +75,7 @@ public class SplashActivity extends BaseActivity { ...@@ -80,7 +75,7 @@ public class SplashActivity extends BaseActivity {
80 public void run() { 75 public void run() {
81 if (!isFinishing()) { 76 if (!isFinishing()) {
82 startActivity(new Intent(SplashActivity.this, 77 startActivity(new Intent(SplashActivity.this,
83 - MainActivity.class)); 78 + EurobankHomeActivity.class));
84 finish(); 79 finish();
85 } 80 }
86 } 81 }
...@@ -89,4 +84,16 @@ public class SplashActivity extends BaseActivity { ...@@ -89,4 +84,16 @@ public class SplashActivity extends BaseActivity {
89 }, MIN_SPLASH_TIME); 84 }, MIN_SPLASH_TIME);
90 } 85 }
91 } 86 }
87 +
88 + private final CallbackReceiver<ArrayList<Campaign>> mCampaignsCallback = new CallbackReceiver<ArrayList<Campaign>>() {
89 + @Override
90 + public void onSuccess(ArrayList<Campaign> result) {
91 + startNextActivity();
92 + }
93 +
94 + @Override
95 + public void onFailure(int errorCode) {
96 + Toast.makeText(SplashActivity.this, "Campaigns Error", Toast.LENGTH_SHORT).show();
97 + }
98 + };
92 } 99 }
......
...@@ -4,14 +4,16 @@ ...@@ -4,14 +4,16 @@
4 4
5 <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 5 <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
6 <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> 6 <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
7 - <uses-permission android:name="android.permission.READ_PHONE_STATE" /> 7 + <uses-permission
8 + android:name="android.permission.READ_PHONE_STATE"
9 + tools:node="remove" />
8 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 10 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
9 <uses-permission android:name="android.permission.BLUETOOTH" /> 11 <uses-permission android:name="android.permission.BLUETOOTH" />
10 <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> 12 <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
11 <uses-permission 13 <uses-permission
12 android:name="android.permission.REQUEST_INSTALL_PACKAGES" 14 android:name="android.permission.REQUEST_INSTALL_PACKAGES"
13 tools:node="remove" /> 15 tools:node="remove" />
14 - <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/> 16 + <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
15 17
16 <application> 18 <application>
17 <!-- For Huawei Push --> 19 <!-- For Huawei Push -->
...@@ -24,6 +26,11 @@ ...@@ -24,6 +26,11 @@
24 android:value="false" /> 26 android:value="false" />
25 27
26 <activity 28 <activity
29 + android:name="ly.warp.sdk.activities.EurobankHomeActivity"
30 + android:exported="false"
31 + android:screenOrientation="portrait" />
32 +
33 + <activity
27 android:name="ly.warp.sdk.activities.WarpViewActivity" 34 android:name="ly.warp.sdk.activities.WarpViewActivity"
28 android:exported="false" 35 android:exported="false"
29 android:screenOrientation="portrait" /> 36 android:screenOrientation="portrait" />
......
1 +package ly.warp.sdk.activities;
2 +
3 +import android.os.Bundle;
4 +
5 +import ly.warp.sdk.R;
6 +
7 +public class EurobankHomeActivity extends WarpBaseActivity {
8 +
9 + // ===========================================================
10 + // Constants
11 + // ===========================================================
12 +
13 + // ===========================================================
14 + // Fields
15 + // ===========================================================
16 +
17 + // ===========================================================
18 + // Methods for/from SuperClass/Interfaces
19 + // ===========================================================
20 +
21 + @Override
22 + public void onCreate(Bundle savedInstanceState) {
23 + super.onCreate(savedInstanceState);
24 + setContentView(R.layout.activity_eurobank_home);
25 + initViews();
26 + }
27 +
28 + @Override
29 + protected void onResume() {
30 + super.onResume();
31 + }
32 +
33 + private void initViews() {
34 +
35 +
36 + }
37 +
38 + // ===========================================================
39 + // Methods
40 + // ===========================================================
41 +
42 + // ===========================================================
43 + // Inner and Anonymous Classes
44 + // ===========================================================
45 +
46 +}
1 +/*
2 + * Copyright 2010-2013 Warply Ltd. All rights reserved.
3 + *
4 + * Redistribution and use in source and binary forms, without modification, are
5 + * permitted provided that the following conditions are met:
6 + *
7 + * 1. Redistributions of source code must retain the above copyright notice,
8 + * this list of conditions and the following disclaimer.
9 + *
10 + * 2. Redistributions in binary form must reproduce the above copyright notice,
11 + * this list of conditions and the following disclaimer in the documentation
12 + * and/or other materials provided with the distribution.
13 + *
14 + * THIS SOFTWARE IS PROVIDED BY THE WARPLY LTD ``AS IS'' AND ANY EXPRESS OR
15 + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16 + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
17 + * EVENT SHALL WARPLY LTD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
18 + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
19 + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
20 + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21 + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22 + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
23 + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 + */
25 +package ly.warp.sdk.io.callbacks;
26 +import android.text.TextUtils;
27 +import org.json.JSONObject;
28 +import java.util.ArrayList;
29 +import ly.warp.sdk.io.models.Campaign;
30 +import ly.warp.sdk.io.models.NewCampaign;
31 +import ly.warp.sdk.io.models.NewCampaignList;
32 +import ly.warp.sdk.utils.WarpJSONParser;
33 +/**
34 + * Created by Panagiotis Triantafyllou on 12-May-22.
35 + */
36 +public class NewCampaignsHookDefault implements CallbackReceiver<JSONObject> {
37 + private final CallbackReceiver<ArrayList<Campaign>> mListener;
38 + private final String mRequestSignature;
39 + public NewCampaignsHookDefault(CallbackReceiver<ArrayList<Campaign>> listener, String requestSignature) {
40 + this.mListener = listener;
41 + this.mRequestSignature = requestSignature;
42 + }
43 + @Override
44 + public void onSuccess(JSONObject result) {
45 + if (mListener != null) {
46 + int status = result.optInt("status", 2);
47 + if (status == 1) {
48 + NewCampaignList cmpList = new NewCampaignList(result, mRequestSignature);
49 + ArrayList<Campaign> tempCampaigns = new ArrayList<>();
50 + for (NewCampaign newCamp : cmpList) {
51 + Campaign camp = new Campaign();
52 + camp.setIndexUrl(newCamp.getIndexUrl());
53 + camp.setLogoUrl(newCamp.getLogoUrl());
54 + camp.setMessage(newCamp.getMessage());
55 + camp.setOfferCategory(newCamp.getCommunicationCategory());
56 + camp.setSessionUUID(newCamp.getCommunicationUUID());
57 + camp.setTitle(newCamp.getTitle());
58 + camp.setSubtitle(newCamp.getSubtitle());
59 + camp.setSorting(newCamp.getSorting());
60 + camp.setNew(newCamp.getIsNew());
61 + camp.setType(newCamp.getCampaignType());
62 + try {
63 + camp.setExtraFields(newCamp.getExtraFields().toString());
64 + if (!TextUtils.isEmpty(newCamp.getExtraFields().toString())) {
65 + JSONObject extraFieldsResp = WarpJSONParser.getJSONFromString(newCamp.getExtraFields().toString());
66 + if (extraFieldsResp != null) {
67 + if (extraFieldsResp.has("Banner_title")) {
68 + camp.setBannerTitle(extraFieldsResp.optString("Banner_title", ""));
69 + }
70 + if (extraFieldsResp.has("Banner_img")) {
71 + camp.setBannerImage(extraFieldsResp.optString("Banner_img", ""));
72 + }
73 + }
74 + } else {
75 + camp.setBannerImage("");
76 + camp.setBannerTitle("");
77 + }
78 + } catch (NullPointerException e) {
79 + camp.setExtraFields("");
80 + camp.setBannerImage("");
81 + camp.setBannerTitle("");
82 + e.printStackTrace();
83 + }
84 + try {
85 + camp.setCampaignTypeSettings(newCamp.getSettings().toString());
86 + } catch (NullPointerException e) {
87 + camp.setCampaignTypeSettings("");
88 + e.printStackTrace();
89 + }
90 + tempCampaigns.add(camp);
91 + }
92 + mListener.onSuccess(tempCampaigns);
93 + } else
94 + mListener.onFailure(status);
95 + }
96 + }
97 + @Override
98 + public void onFailure(int errorCode) {
99 + if (mListener != null)
100 + mListener.onFailure(errorCode);
101 + }
102 +}
...\ No newline at end of file ...\ No newline at end of file
...@@ -22,11 +22,11 @@ ...@@ -22,11 +22,11 @@
22 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 22 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
23 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 -
26 package ly.warp.sdk.io.models; 25 package ly.warp.sdk.io.models;
27 26
28 import android.os.Parcel; 27 import android.os.Parcel;
29 import android.os.Parcelable; 28 import android.os.Parcelable;
29 +import android.text.TextUtils;
30 30
31 import org.json.JSONArray; 31 import org.json.JSONArray;
32 import org.json.JSONException; 32 import org.json.JSONException;
...@@ -36,16 +36,15 @@ import java.io.Serializable; ...@@ -36,16 +36,15 @@ import java.io.Serializable;
36 import java.util.ArrayList; 36 import java.util.ArrayList;
37 37
38 import ly.warp.sdk.Warply; 38 import ly.warp.sdk.Warply;
39 +import ly.warp.sdk.utils.WarpJSONParser;
39 import ly.warp.sdk.utils.WarpUtils; 40 import ly.warp.sdk.utils.WarpUtils;
40 import ly.warp.sdk.utils.WarplyProperty; 41 import ly.warp.sdk.utils.WarplyProperty;
41 import ly.warp.sdk.utils.constants.WarpConstants; 42 import ly.warp.sdk.utils.constants.WarpConstants;
42 43
43 public class Campaign implements Parcelable, Serializable { 44 public class Campaign implements Parcelable, Serializable {
44 -
45 private static final long serialVersionUID = -4754964462459705285L; 45 private static final long serialVersionUID = -4754964462459705285L;
46 -
47 /* Constants used to export the campaign in JSON formal and vice versa */ 46 /* Constants used to export the campaign in JSON formal and vice versa */
48 - 47 + private static final String INDEX_URL = "index_url";
49 private static final String LOGO_URL = "logo_url"; 48 private static final String LOGO_URL = "logo_url";
50 private static final String ACTION = "action"; 49 private static final String ACTION = "action";
51 private static final String DELIVERED = "delivered"; 50 private static final String DELIVERED = "delivered";
...@@ -67,30 +66,37 @@ public class Campaign implements Parcelable, Serializable { ...@@ -67,30 +66,37 @@ public class Campaign implements Parcelable, Serializable {
67 private static final String DELIVERY_METHOD = "delivery_method"; 66 private static final String DELIVERY_METHOD = "delivery_method";
68 private static final String DISPLAY_TYPE = "display_type"; 67 private static final String DISPLAY_TYPE = "display_type";
69 private static final String ACTIONS = "actions"; 68 private static final String ACTIONS = "actions";
70 - 69 + private static final String BUS_ID = "busId";
70 + private static final String CAMPAIGN_TYPE_SETTINGS = "campaign_type_settings";
71 + private static final String BANNER_IMAGE = "Banner_img";
72 + private static final String BANNER_TITLE = "Banner_title";
71 /* Member variables of the Campaign object */ 73 /* Member variables of the Campaign object */
72 - 74 + private int action;
73 - private final int action; 75 + private double delivered;
74 - private final double delivered;
75 private double expires; 76 private double expires;
76 - private final String message; 77 + private String message;
77 private String offerCategory; 78 private String offerCategory;
78 - private final String offerMessage; 79 + private String offerMessage;
79 - private final String sessionUUID; 80 + private String sessionUUID;
80 - private final double starts; 81 + private double starts;
81 - private final String subtitle; 82 + private String subtitle;
82 - private final String title; 83 + private String title;
83 - private final int sorting; 84 + private int sorting;
84 - private final int opened; 85 + private int opened;
85 - private final boolean isNew; 86 + private boolean isNew;
86 - private final String logoUrl; 87 + private String logoUrl;
87 - private final String extraFields; 88 + private String extraFields;
88 - private final String type; 89 + private String type;
89 - private final boolean expired; 90 + private boolean expired;
90 private boolean show; 91 private boolean show;
91 private String deliveryMethod; 92 private String deliveryMethod;
92 private String displayType; 93 private String displayType;
94 + private String indexUrl;
95 + private String busId;
93 private ArrayList<CampaignAction> actions = new ArrayList<>(); 96 private ArrayList<CampaignAction> actions = new ArrayList<>();
97 + private String campaignTypeSettings;
98 + private String bannerImage;
99 + private String bannerTitle;
94 100
95 /** 101 /**
96 * Basic constructor used to create an object from a String, representing a 102 * Basic constructor used to create an object from a String, representing a
...@@ -103,12 +109,42 @@ public class Campaign implements Parcelable, Serializable { ...@@ -103,12 +109,42 @@ public class Campaign implements Parcelable, Serializable {
103 this(new JSONObject(json)); 109 this(new JSONObject(json));
104 } 110 }
105 111
112 + public Campaign() {
113 + this.action = 0;
114 + this.delivered = 0.0d;
115 + this.expires = 0.0d;
116 + this.message = "";
117 + this.offerCategory = "";
118 + this.offerMessage = "";
119 + this.sessionUUID = "";
120 + this.starts = 0.0d;
121 + this.subtitle = "";
122 + this.title = "";
123 + this.sorting = 0;
124 + this.opened = 0;
125 + this.isNew = true;
126 + this.logoUrl = "";
127 + this.extraFields = "";
128 + this.type = "";
129 + this.expired = false;
130 + this.show = true;
131 + this.deliveryMethod = "";
132 + this.displayType = "";
133 + this.indexUrl = "";
134 + this.busId = "";
135 + this.actions = new ArrayList<>();
136 + this.campaignTypeSettings = "";
137 + this.bannerImage = "";
138 + this.bannerTitle = "";
139 + }
140 +
106 /** 141 /**
107 * Constructor used to create an Object from a given JSON Object 142 * Constructor used to create an Object from a given JSON Object
108 * 143 *
109 * @param json JSON Object used to create the Campaign 144 * @param json JSON Object used to create the Campaign
110 */ 145 */
111 public Campaign(JSONObject json) { 146 public Campaign(JSONObject json) {
147 + this.indexUrl = json.optString(INDEX_URL);
112 this.logoUrl = json.optString(LOGO_URL); 148 this.logoUrl = json.optString(LOGO_URL);
113 this.delivered = json.optDouble(DELIVERED); 149 this.delivered = json.optDouble(DELIVERED);
114 this.sessionUUID = json.optString(SESSION_UUID); 150 this.sessionUUID = json.optString(SESSION_UUID);
...@@ -118,24 +154,37 @@ public class Campaign implements Parcelable, Serializable { ...@@ -118,24 +154,37 @@ public class Campaign implements Parcelable, Serializable {
118 this.opened = json.optInt(OPENED); 154 this.opened = json.optInt(OPENED);
119 this.expires = json.optDouble(EXPIRES); 155 this.expires = json.optDouble(EXPIRES);
120 this.offerCategory = json.optString(OFFER_CATEGORY); 156 this.offerCategory = json.optString(OFFER_CATEGORY);
121 -
122 if (belongsInCategory(WarpConstants.MICROAPP_CAMPAIGNS_STANDARD_OFFER_NO_DATE)) { 157 if (belongsInCategory(WarpConstants.MICROAPP_CAMPAIGNS_STANDARD_OFFER_NO_DATE)) {
123 this.expires = 0; 158 this.expires = 0;
124 this.offerCategory = WarpConstants.MICROAPP_CAMPAIGNS_STANDARD_OFFER; 159 this.offerCategory = WarpConstants.MICROAPP_CAMPAIGNS_STANDARD_OFFER;
125 } 160 }
126 -
127 this.title = json.optString(TITLE); 161 this.title = json.optString(TITLE);
128 this.action = json.optInt(ACTION); 162 this.action = json.optInt(ACTION);
129 this.offerMessage = json.optString(OFFER_MESSAGE); 163 this.offerMessage = json.optString(OFFER_MESSAGE);
130 this.isNew = json.optBoolean(IS_NEW); 164 this.isNew = json.optBoolean(IS_NEW);
131 this.sorting = json.optInt(SORTING); 165 this.sorting = json.optInt(SORTING);
132 this.extraFields = json.optString(EXTRA_FIELDS); 166 this.extraFields = json.optString(EXTRA_FIELDS);
167 + if (!TextUtils.isEmpty(this.extraFields)) {
168 + JSONObject extraFieldsResp = WarpJSONParser.getJSONFromString(this.extraFields);
169 + if (extraFieldsResp != null) {
170 + if (extraFieldsResp.has("Banner_title")) {
171 + this.bannerTitle = extraFieldsResp.optString(BANNER_TITLE, "");
172 + }
173 + if (extraFieldsResp.has("Banner_img")) {
174 + this.bannerImage = extraFieldsResp.optString(BANNER_IMAGE, "");
175 + }
176 + }
177 + } else {
178 + this.bannerImage = "";
179 + this.bannerTitle = "";
180 + }
133 this.type = json.optString(TYPE); 181 this.type = json.optString(TYPE);
134 this.expired = json.optBoolean(EXPIRED); 182 this.expired = json.optBoolean(EXPIRED);
135 this.show = json.optBoolean(SHOW); 183 this.show = json.optBoolean(SHOW);
136 this.deliveryMethod = json.optString(DELIVERY_METHOD); 184 this.deliveryMethod = json.optString(DELIVERY_METHOD);
137 this.displayType = json.optString(DISPLAY_TYPE); 185 this.displayType = json.optString(DISPLAY_TYPE);
138 - 186 + this.busId = json.optString(BUS_ID);
187 + this.campaignTypeSettings = json.optString(CAMPAIGN_TYPE_SETTINGS);
139 JSONArray actions = json.optJSONArray(ACTIONS); 188 JSONArray actions = json.optJSONArray(ACTIONS);
140 if (actions != null) { 189 if (actions != null) {
141 for (int i = 0; i < actions.length(); i++) { 190 for (int i = 0; i < actions.length(); i++) {
...@@ -147,7 +196,7 @@ public class Campaign implements Parcelable, Serializable { ...@@ -147,7 +196,7 @@ public class Campaign implements Parcelable, Serializable {
147 } 196 }
148 197
149 public Campaign(Parcel source) { 198 public Campaign(Parcel source) {
150 - 199 + this.indexUrl = source.readString();
151 this.action = source.readInt(); 200 this.action = source.readInt();
152 this.delivered = source.readDouble(); 201 this.delivered = source.readDouble();
153 this.expires = source.readDouble(); 202 this.expires = source.readDouble();
...@@ -169,11 +218,13 @@ public class Campaign implements Parcelable, Serializable { ...@@ -169,11 +218,13 @@ public class Campaign implements Parcelable, Serializable {
169 this.deliveryMethod = source.readString(); 218 this.deliveryMethod = source.readString();
170 this.displayType = source.readString(); 219 this.displayType = source.readString();
171 this.actions = source.readArrayList(CampaignAction.class.getClassLoader()); 220 this.actions = source.readArrayList(CampaignAction.class.getClassLoader());
221 + this.busId = source.readString();
222 + this.campaignTypeSettings = source.readString();
172 } 223 }
173 224
174 @Override 225 @Override
175 public void writeToParcel(Parcel dest, int flags) { 226 public void writeToParcel(Parcel dest, int flags) {
176 - 227 + dest.writeString(this.indexUrl);
177 dest.writeInt(this.action); 228 dest.writeInt(this.action);
178 dest.writeDouble(this.delivered); 229 dest.writeDouble(this.delivered);
179 dest.writeDouble(this.expires); 230 dest.writeDouble(this.expires);
...@@ -188,13 +239,15 @@ public class Campaign implements Parcelable, Serializable { ...@@ -188,13 +239,15 @@ public class Campaign implements Parcelable, Serializable {
188 dest.writeInt(this.opened); 239 dest.writeInt(this.opened);
189 dest.writeInt(this.isNew ? 1 : 0); 240 dest.writeInt(this.isNew ? 1 : 0);
190 dest.writeString(this.logoUrl); 241 dest.writeString(this.logoUrl);
191 - dest.writeString(extraFields); 242 + dest.writeString(this.extraFields);
192 - dest.writeString(type); 243 + dest.writeString(this.type);
193 dest.writeInt(this.expired ? 1 : 0); 244 dest.writeInt(this.expired ? 1 : 0);
194 dest.writeInt(this.show ? 1 : 0); 245 dest.writeInt(this.show ? 1 : 0);
195 - dest.writeString(deliveryMethod); 246 + dest.writeString(this.deliveryMethod);
196 - dest.writeString(displayType); 247 + dest.writeString(this.displayType);
197 - dest.writeList(actions); 248 + dest.writeList(this.actions);
249 + dest.writeString(this.busId);
250 + dest.writeString(this.campaignTypeSettings);
198 } 251 }
199 252
200 /** 253 /**
...@@ -205,6 +258,7 @@ public class Campaign implements Parcelable, Serializable { ...@@ -205,6 +258,7 @@ public class Campaign implements Parcelable, Serializable {
205 public JSONObject toJSONObject() { 258 public JSONObject toJSONObject() {
206 JSONObject jObj = new JSONObject(); 259 JSONObject jObj = new JSONObject();
207 try { 260 try {
261 + jObj.putOpt(INDEX_URL, this.indexUrl);
208 jObj.putOpt(LOGO_URL, this.logoUrl); 262 jObj.putOpt(LOGO_URL, this.logoUrl);
209 jObj.putOpt(ACTION, this.action); 263 jObj.putOpt(ACTION, this.action);
210 jObj.putOpt(DELIVERED, this.delivered); 264 jObj.putOpt(DELIVERED, this.delivered);
...@@ -226,6 +280,8 @@ public class Campaign implements Parcelable, Serializable { ...@@ -226,6 +280,8 @@ public class Campaign implements Parcelable, Serializable {
226 jObj.putOpt(SHOW, this.show); 280 jObj.putOpt(SHOW, this.show);
227 jObj.putOpt(DELIVERY_METHOD, this.deliveryMethod); 281 jObj.putOpt(DELIVERY_METHOD, this.deliveryMethod);
228 jObj.putOpt(DISPLAY_TYPE, this.displayType); 282 jObj.putOpt(DISPLAY_TYPE, this.displayType);
283 + jObj.put(BUS_ID, this.busId);
284 + jObj.put(CAMPAIGN_TYPE_SETTINGS, this.campaignTypeSettings);
229 } catch (JSONException e) { 285 } catch (JSONException e) {
230 if (WarpConstants.DEBUG) { 286 if (WarpConstants.DEBUG) {
231 e.printStackTrace(); 287 e.printStackTrace();
...@@ -294,7 +350,6 @@ public class Campaign implements Parcelable, Serializable { ...@@ -294,7 +350,6 @@ public class Campaign implements Parcelable, Serializable {
294 } 350 }
295 return humanReadableString; 351 return humanReadableString;
296 } 352 }
297 -
298 // ================================================================================ 353 // ================================================================================
299 // Getters 354 // Getters
300 // ================================================================================ 355 // ================================================================================
...@@ -411,6 +466,10 @@ public class Campaign implements Parcelable, Serializable { ...@@ -411,6 +466,10 @@ public class Campaign implements Parcelable, Serializable {
411 return logoUrl; 466 return logoUrl;
412 } 467 }
413 468
469 + public String getIndexUrl() {
470 + return indexUrl;
471 + }
472 +
414 public String getExtraFields() { 473 public String getExtraFields() {
415 return extraFields; 474 return extraFields;
416 } 475 }
...@@ -439,6 +498,126 @@ public class Campaign implements Parcelable, Serializable { ...@@ -439,6 +498,126 @@ public class Campaign implements Parcelable, Serializable {
439 return actions; 498 return actions;
440 } 499 }
441 500
501 + public String getBusId() {
502 + return busId;
503 + }
504 +
505 + public void setBusId(String busId) {
506 + this.busId = busId;
507 + }
508 +
509 + public void setNew(boolean aNew) {
510 + isNew = aNew;
511 + }
512 +
513 + public String getCampaignTypeSettings() {
514 + return campaignTypeSettings;
515 + }
516 +
517 + public void setExpires(double expires) {
518 + this.expires = expires;
519 + }
520 +
521 + public void setOfferCategory(String offerCategory) {
522 + this.offerCategory = offerCategory;
523 + }
524 +
525 + public void setShow(boolean show) {
526 + this.show = show;
527 + }
528 +
529 + public void setDeliveryMethod(String deliveryMethod) {
530 + this.deliveryMethod = deliveryMethod;
531 + }
532 +
533 + public void setDisplayType(String displayType) {
534 + this.displayType = displayType;
535 + }
536 +
537 + public void setIndexUrl(String indexUrl) {
538 + this.indexUrl = indexUrl;
539 + }
540 +
541 + public void setActions(ArrayList<CampaignAction> actions) {
542 + this.actions = actions;
543 + }
544 +
545 + public void setAction(int action) {
546 + this.action = action;
547 + }
548 +
549 + public void setDelivered(double delivered) {
550 + this.delivered = delivered;
551 + }
552 +
553 + public void setMessage(String message) {
554 + this.message = message;
555 + }
556 +
557 + public void setOfferMessage(String offerMessage) {
558 + this.offerMessage = offerMessage;
559 + }
560 +
561 + public void setSessionUUID(String sessionUUID) {
562 + this.sessionUUID = sessionUUID;
563 + }
564 +
565 + public void setStarts(double starts) {
566 + this.starts = starts;
567 + }
568 +
569 + public void setSubtitle(String subtitle) {
570 + this.subtitle = subtitle;
571 + }
572 +
573 + public void setTitle(String title) {
574 + this.title = title;
575 + }
576 +
577 + public void setSorting(int sorting) {
578 + this.sorting = sorting;
579 + }
580 +
581 + public void setOpened(int opened) {
582 + this.opened = opened;
583 + }
584 +
585 + public void setLogoUrl(String logoUrl) {
586 + this.logoUrl = logoUrl;
587 + }
588 +
589 + public void setExtraFields(String extraFields) {
590 + this.extraFields = extraFields;
591 + }
592 +
593 + public void setType(String type) {
594 + this.type = type;
595 + }
596 +
597 + public void setExpired(boolean expired) {
598 + this.expired = expired;
599 + }
600 +
601 + public void setCampaignTypeSettings(String campaignTypeSettings) {
602 + this.campaignTypeSettings = campaignTypeSettings;
603 + }
604 +
605 + public String getBannerImage() {
606 + return this.bannerImage;
607 + }
608 +
609 + public String getBannerTitle() {
610 + return this.bannerTitle;
611 + }
612 +
613 + public void setBannerImage(String bannerImage) {
614 + this.bannerImage = bannerImage;
615 + }
616 +
617 + public void setBannerTitle(String bannerTitle) {
618 + this.bannerTitle = bannerTitle;
619 + }
620 +
442 @Override 621 @Override
443 public int describeContents() { 622 public int describeContents() {
444 return 0; 623 return 0;
...@@ -453,4 +632,4 @@ public class Campaign implements Parcelable, Serializable { ...@@ -453,4 +632,4 @@ public class Campaign implements Parcelable, Serializable {
453 return new Campaign[size]; 632 return new Campaign[size];
454 } 633 }
455 }; 634 };
456 -} 635 +}
...\ No newline at end of file ...\ No newline at end of file
......
1 +/*
2 + * Copyright 2010-2022 Warply Ltd. All rights reserved.
3 + *
4 + * Redistribution and use in source and binary forms, without modification, are
5 + * permitted provided that the following conditions are met:
6 + *
7 + * 1. Redistributions of source code must retain the above copyright notice,
8 + * this list of conditions and the following disclaimer.
9 + *
10 + * 2. Redistributions in binary form must reproduce the above copyright notice,
11 + * this list of conditions and the following disclaimer in the documentation
12 + * and/or other materials provided with the distribution.
13 + *
14 + * THIS SOFTWARE IS PROVIDED BY THE WARPLY LTD ``AS IS'' AND ANY EXPRESS OR
15 + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16 + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
17 + * EVENT SHALL WARPLY LTD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
18 + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
19 + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
20 + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21 + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22 + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
23 + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 + */
25 +
26 +package ly.warp.sdk.utils;
27 +
28 +import java.util.ArrayList;
29 +
30 +import ly.warp.sdk.io.models.Campaign;
31 +
32 +public class WarplyManagerHelper {
33 + private static ArrayList<Campaign> mCampaignList = new ArrayList<Campaign>();
34 +
35 + public static ArrayList<Campaign> getCampaignList() {
36 + return mCampaignList;
37 + }
38 +
39 + public static void setCampaignList(ArrayList<Campaign> campaignList) {
40 + mCampaignList.clear();
41 + mCampaignList = campaignList;
42 + }
43 +}
...@@ -28,6 +28,8 @@ package ly.warp.sdk.utils.managers; ...@@ -28,6 +28,8 @@ package ly.warp.sdk.utils.managers;
28 import org.json.JSONException; 28 import org.json.JSONException;
29 import org.json.JSONObject; 29 import org.json.JSONObject;
30 30
31 +import java.util.ArrayList;
32 +
31 import ly.warp.sdk.Warply; 33 import ly.warp.sdk.Warply;
32 import ly.warp.sdk.db.WarplyDBHelper; 34 import ly.warp.sdk.db.WarplyDBHelper;
33 import ly.warp.sdk.io.callbacks.AddressHook; 35 import ly.warp.sdk.io.callbacks.AddressHook;
...@@ -40,12 +42,14 @@ import ly.warp.sdk.io.callbacks.CouponsetsHook; ...@@ -40,12 +42,14 @@ import ly.warp.sdk.io.callbacks.CouponsetsHook;
40 import ly.warp.sdk.io.callbacks.MerchantCategoriesHook; 42 import ly.warp.sdk.io.callbacks.MerchantCategoriesHook;
41 import ly.warp.sdk.io.callbacks.MerchantsHook; 43 import ly.warp.sdk.io.callbacks.MerchantsHook;
42 import ly.warp.sdk.io.callbacks.NewCampaignsHook; 44 import ly.warp.sdk.io.callbacks.NewCampaignsHook;
45 +import ly.warp.sdk.io.callbacks.NewCampaignsHookDefault;
43 import ly.warp.sdk.io.callbacks.PointsHook; 46 import ly.warp.sdk.io.callbacks.PointsHook;
44 import ly.warp.sdk.io.callbacks.ProductsHook; 47 import ly.warp.sdk.io.callbacks.ProductsHook;
45 import ly.warp.sdk.io.callbacks.TagsCategoriesHook; 48 import ly.warp.sdk.io.callbacks.TagsCategoriesHook;
46 import ly.warp.sdk.io.callbacks.TagsHook; 49 import ly.warp.sdk.io.callbacks.TagsHook;
47 import ly.warp.sdk.io.callbacks.TransactionsHook; 50 import ly.warp.sdk.io.callbacks.TransactionsHook;
48 import ly.warp.sdk.io.models.AddressList; 51 import ly.warp.sdk.io.models.AddressList;
52 +import ly.warp.sdk.io.models.Campaign;
49 import ly.warp.sdk.io.models.Card; 53 import ly.warp.sdk.io.models.Card;
50 import ly.warp.sdk.io.models.CardList; 54 import ly.warp.sdk.io.models.CardList;
51 import ly.warp.sdk.io.models.Consumer; 55 import ly.warp.sdk.io.models.Consumer;
...@@ -97,6 +101,7 @@ import ly.warp.sdk.io.request.WarplyValidateCouponRequest; ...@@ -97,6 +101,7 @@ import ly.warp.sdk.io.request.WarplyValidateCouponRequest;
97 import ly.warp.sdk.io.request.WarplyVerifyOTPRequest; 101 import ly.warp.sdk.io.request.WarplyVerifyOTPRequest;
98 import ly.warp.sdk.io.request.WarplyVerifyTicketRequest; 102 import ly.warp.sdk.io.request.WarplyVerifyTicketRequest;
99 import ly.warp.sdk.utils.WarpUtils; 103 import ly.warp.sdk.utils.WarpUtils;
104 +import ly.warp.sdk.utils.WarplyManagerHelper;
100 import ly.warp.sdk.utils.WarplyProperty; 105 import ly.warp.sdk.utils.WarplyProperty;
101 import ly.warp.sdk.utils.constants.WarpConstants; 106 import ly.warp.sdk.utils.constants.WarpConstants;
102 107
...@@ -1272,6 +1277,25 @@ public class WarplyManager { ...@@ -1272,6 +1277,25 @@ public class WarplyManager {
1272 }); 1277 });
1273 } 1278 }
1274 1279
1280 + public static void getCampaigns(WarplyGetCampaignsRequest request, final CallbackReceiver<ArrayList<Campaign>> receiver) {
1281 + WarpUtils.log("************* WARPLY Get Campaigns Request ********************");
1282 + WarpUtils.log("[WARP Trace] WARPLY Get Campaigns Request is active");
1283 + WarpUtils.log("**************************************************");
1284 + Warply.postReceiveMicroappData(WarpConstants.MICROAPP_NEW_CAMPAIGNS, false, "campaigns", request.toJson(), new NewCampaignsHookDefault(new CallbackReceiver<ArrayList<Campaign>>() {
1285 + @Override
1286 + public void onSuccess(ArrayList<Campaign> result) {
1287 + WarplyManagerHelper.setCampaignList(result);
1288 + receiver.onSuccess(result);
1289 + }
1290 +
1291 + @Override
1292 + public void onFailure(int errorCode) {
1293 + receiver.onFailure(errorCode);
1294 + }
1295 + },
1296 + request.getSignature()));
1297 + }
1298 +
1275 public static void getCampaigns(WarplyGetCampaignsRequest request, boolean auth, final CallbackReceiver<NewCampaignList> receiver) { 1299 public static void getCampaigns(WarplyGetCampaignsRequest request, boolean auth, final CallbackReceiver<NewCampaignList> receiver) {
1276 WarpUtils.log("************* WARPLY Get Campaigns Request ********************"); 1300 WarpUtils.log("************* WARPLY Get Campaigns Request ********************");
1277 WarpUtils.log("[WARP Trace] WARPLY Get Campaigns Request is active"); 1301 WarpUtils.log("[WARP Trace] WARPLY Get Campaigns Request is active");
......
1 +<?xml version="1.0" encoding="utf-8"?>
2 +<shape xmlns:android="http://schemas.android.com/apk/res/android">
3 + <gradient
4 + android:angle="0"
5 + android:endColor="@color/blue"
6 + android:startColor="@color/blue_dark"
7 + android:type="linear" />
8 +</shape>
...\ No newline at end of file ...\ No newline at end of file
1 +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
2 + xmlns:app="http://schemas.android.com/apk/res-auto"
3 + android:layout_width="match_parent"
4 + android:layout_height="match_parent"
5 + android:background="@color/grey">
6 +
7 + <androidx.constraintlayout.widget.ConstraintLayout
8 + android:layout_width="match_parent"
9 + android:layout_height="120dp"
10 + android:background="@drawable/background_gradient"
11 + android:scaleType="centerCrop">
12 +
13 + <ImageView
14 + android:layout_width="180dp"
15 + android:layout_height="60dp"
16 + android:src="@drawable/logo"
17 + app:layout_constraintBottom_toBottomOf="parent"
18 + app:layout_constraintStart_toStartOf="parent"
19 + app:layout_constraintTop_toTopOf="parent" />
20 +
21 + </androidx.constraintlayout.widget.ConstraintLayout>
22 +</RelativeLayout>
...@@ -3,4 +3,7 @@ ...@@ -3,4 +3,7 @@
3 <color name="colorPrimary">#0a1a50</color> 3 <color name="colorPrimary">#0a1a50</color>
4 <color name="colorAccent">#044C86</color> 4 <color name="colorAccent">#044C86</color>
5 <color name="colorPrimaryDark">#0a1a50</color> 5 <color name="colorPrimaryDark">#0a1a50</color>
6 + <color name="grey">#E7EAEB</color>
7 + <color name="blue_dark">#081748</color>
8 + <color name="blue">#204EAC</color>
6 </resources> 9 </resources>
...\ No newline at end of file ...\ No newline at end of file
......