Panagiotis Triantafyllou

push fix

...@@ -7,12 +7,12 @@ ...@@ -7,12 +7,12 @@
7 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 7 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
8 <uses-permission android:name="android.permission.BLUETOOTH" /> 8 <uses-permission android:name="android.permission.BLUETOOTH" />
9 <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> 9 <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
10 - <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/> 10 + <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
11 11
12 <application> 12 <application>
13 -<!-- <meta-data--> 13 + <!-- <meta-data-->
14 -<!-- android:name="com.google.android.geo.API_KEY"--> 14 + <!-- android:name="com.google.android.geo.API_KEY"-->
15 -<!-- android:value="@string/google_maps_key" />--> 15 + <!-- android:value="@string/google_maps_key" />-->
16 16
17 <!-- For Huawei Push --> 17 <!-- For Huawei Push -->
18 <meta-data 18 <meta-data
...@@ -26,80 +26,80 @@ ...@@ -26,80 +26,80 @@
26 <activity 26 <activity
27 android:name="ly.warp.sdk.activities.WarpViewActivity" 27 android:name="ly.warp.sdk.activities.WarpViewActivity"
28 android:exported="false" 28 android:exported="false"
29 - android:theme="@style/SDKAppTheme" 29 + android:screenOrientation="portrait"
30 - android:screenOrientation="portrait" /> 30 + android:theme="@style/SDKAppTheme" />
31 31
32 <activity 32 <activity
33 android:name="ly.warp.sdk.activities.LoyaltyAnalysisActivity" 33 android:name="ly.warp.sdk.activities.LoyaltyAnalysisActivity"
34 android:exported="false" 34 android:exported="false"
35 - android:theme="@style/SDKAppTheme" 35 + android:screenOrientation="portrait"
36 - android:screenOrientation="portrait" /> 36 + android:theme="@style/SDKAppTheme" />
37 37
38 <activity 38 <activity
39 android:name="ly.warp.sdk.activities.CouponInfoActivity" 39 android:name="ly.warp.sdk.activities.CouponInfoActivity"
40 android:exported="false" 40 android:exported="false"
41 - android:theme="@style/SDKAppTheme" 41 + android:screenOrientation="portrait"
42 - android:screenOrientation="portrait" /> 42 + android:theme="@style/SDKAppTheme" />
43 43
44 <activity 44 <activity
45 android:name="ly.warp.sdk.activities.ActiveCouponsActivity" 45 android:name="ly.warp.sdk.activities.ActiveCouponsActivity"
46 android:exported="false" 46 android:exported="false"
47 - android:theme="@style/SDKAppTheme" 47 + android:screenOrientation="portrait"
48 - android:screenOrientation="portrait" /> 48 + android:theme="@style/SDKAppTheme" />
49 49
50 <activity 50 <activity
51 android:name="ly.warp.sdk.activities.GiftsForYouActivity" 51 android:name="ly.warp.sdk.activities.GiftsForYouActivity"
52 android:exported="false" 52 android:exported="false"
53 - android:theme="@style/SDKAppTheme" 53 + android:screenOrientation="portrait"
54 - android:screenOrientation="portrait" /> 54 + android:theme="@style/SDKAppTheme" />
55 55
56 <activity 56 <activity
57 android:name="ly.warp.sdk.activities.MoreForYouActivity" 57 android:name="ly.warp.sdk.activities.MoreForYouActivity"
58 android:exported="false" 58 android:exported="false"
59 - android:theme="@style/SDKAppTheme" 59 + android:screenOrientation="portrait"
60 - android:screenOrientation="portrait" /> 60 + android:theme="@style/SDKAppTheme" />
61 61
62 <activity 62 <activity
63 android:name="ly.warp.sdk.activities.CouponsetInfoActivity" 63 android:name="ly.warp.sdk.activities.CouponsetInfoActivity"
64 android:exported="false" 64 android:exported="false"
65 - android:theme="@style/SDKAppTheme" 65 + android:screenOrientation="portrait"
66 - android:screenOrientation="portrait" /> 66 + android:theme="@style/SDKAppTheme" />
67 67
68 <activity 68 <activity
69 android:name="ly.warp.sdk.activities.LoyaltyWallet" 69 android:name="ly.warp.sdk.activities.LoyaltyWallet"
70 android:exported="false" 70 android:exported="false"
71 - android:theme="@style/SDKAppTheme" 71 + android:screenOrientation="portrait"
72 - android:screenOrientation="portrait" /> 72 + android:theme="@style/SDKAppTheme" />
73 73
74 <activity 74 <activity
75 android:name="ly.warp.sdk.activities.ActiveGiftsActivity" 75 android:name="ly.warp.sdk.activities.ActiveGiftsActivity"
76 android:exported="false" 76 android:exported="false"
77 - android:theme="@style/SDKAppTheme" 77 + android:screenOrientation="portrait"
78 - android:screenOrientation="portrait" /> 78 + android:theme="@style/SDKAppTheme" />
79 79
80 <activity 80 <activity
81 android:name="ly.warp.sdk.activities.ShopsActivity" 81 android:name="ly.warp.sdk.activities.ShopsActivity"
82 android:exported="false" 82 android:exported="false"
83 - android:theme="@style/SDKAppTheme" 83 + android:screenOrientation="portrait"
84 - android:screenOrientation="portrait" /> 84 + android:theme="@style/SDKAppTheme" />
85 85
86 <activity 86 <activity
87 android:name="ly.warp.sdk.activities.CouponShareActivity" 87 android:name="ly.warp.sdk.activities.CouponShareActivity"
88 android:exported="false" 88 android:exported="false"
89 - android:theme="@style/SDKAppTheme" 89 + android:screenOrientation="portrait"
90 - android:screenOrientation="portrait" /> 90 + android:theme="@style/SDKAppTheme" />
91 91
92 <activity 92 <activity
93 android:name="ly.warp.sdk.activities.TelcoActivity" 93 android:name="ly.warp.sdk.activities.TelcoActivity"
94 android:exported="false" 94 android:exported="false"
95 - android:theme="@style/SDKAppTheme" 95 + android:screenOrientation="portrait"
96 - android:screenOrientation="portrait" /> 96 + android:theme="@style/SDKAppTheme" />
97 97
98 <activity 98 <activity
99 android:name="ly.warp.sdk.activities.ContextualActivity" 99 android:name="ly.warp.sdk.activities.ContextualActivity"
100 android:exported="false" 100 android:exported="false"
101 - android:theme="@style/SDKAppTheme" 101 + android:screenOrientation="portrait"
102 - android:screenOrientation="portrait" /> 102 + android:theme="@style/SDKAppTheme" />
103 103
104 <activity 104 <activity
105 android:name="ly.warp.sdk.dexter.PermissionsActivity" 105 android:name="ly.warp.sdk.dexter.PermissionsActivity"
...@@ -156,6 +156,11 @@ ...@@ -156,6 +156,11 @@
156 android:permission="android.permission.BIND_JOB_SERVICE" /> 156 android:permission="android.permission.BIND_JOB_SERVICE" />
157 157
158 <service 158 <service
159 + android:name="ly.warp.sdk.services.EventRefreshDeviceTokenService"
160 + android:exported="false"
161 + android:permission="android.permission.BIND_JOB_SERVICE" />
162 +
163 + <service
159 android:name="ly.warp.sdk.services.EventQuestionnaireService" 164 android:name="ly.warp.sdk.services.EventQuestionnaireService"
160 android:exported="false" 165 android:exported="false"
161 android:permission="android.permission.BIND_JOB_SERVICE" /> 166 android:permission="android.permission.BIND_JOB_SERVICE" />
...@@ -175,22 +180,22 @@ ...@@ -175,22 +180,22 @@
175 android:exported="false" /> 180 android:exported="false" />
176 181
177 <!-- FCM Service for push notifications --> 182 <!-- FCM Service for push notifications -->
178 -<!-- <service--> 183 + <!-- <service-->
179 -<!-- android:name="ly.warp.sdk.services.FCMBaseMessagingService"--> 184 + <!-- android:name="ly.warp.sdk.services.FCMBaseMessagingService"-->
180 -<!-- android:exported="false">--> 185 + <!-- android:exported="false">-->
181 -<!-- <intent-filter>--> 186 + <!-- <intent-filter>-->
182 -<!-- <action android:name="com.google.firebase.MESSAGING_EVENT" />--> 187 + <!-- <action android:name="com.google.firebase.MESSAGING_EVENT" />-->
183 -<!-- </intent-filter>--> 188 + <!-- </intent-filter>-->
184 -<!-- </service>--> 189 + <!-- </service>-->
185 190
186 <!-- Service used for handling Huawei Push Notifications, comment if we are in Google build --> 191 <!-- Service used for handling Huawei Push Notifications, comment if we are in Google build -->
187 -<!-- <service--> 192 + <!-- <service-->
188 -<!-- android:name="ly.warp.sdk.services.HMSBaseMessagingService"--> 193 + <!-- android:name="ly.warp.sdk.services.HMSBaseMessagingService"-->
189 -<!-- android:exported="false">--> 194 + <!-- android:exported="false">-->
190 -<!-- <intent-filter>--> 195 + <!-- <intent-filter>-->
191 -<!-- <action android:name="com.huawei.push.action.MESSAGING_EVENT" />--> 196 + <!-- <action android:name="com.huawei.push.action.MESSAGING_EVENT" />-->
192 -<!-- </intent-filter>--> 197 + <!-- </intent-filter>-->
193 -<!-- </service>--> 198 + <!-- </service>-->
194 199
195 <receiver 200 <receiver
196 android:name="ly.warp.sdk.receivers.LocationChangedReceiver" 201 android:name="ly.warp.sdk.receivers.LocationChangedReceiver"
......
...@@ -101,7 +101,7 @@ public enum Warply { ...@@ -101,7 +101,7 @@ public enum Warply {
101 101
102 public WeakReference<Context> mContext; 102 public WeakReference<Context> mContext;
103 private CallbackReceiver<ServiceRegistrationCallback> mRegistrationListener; 103 private CallbackReceiver<ServiceRegistrationCallback> mRegistrationListener;
104 - private static RequestQueue mRequestQueue; 104 + private RequestQueue mRequestQueue;
105 105
106 /* Locks */ 106 /* Locks */
107 private final AtomicBoolean registerLock = new AtomicBoolean(false); 107 private final AtomicBoolean registerLock = new AtomicBoolean(false);
...@@ -1309,7 +1309,7 @@ public enum Warply { ...@@ -1309,7 +1309,7 @@ public enum Warply {
1309 isInitializedOrThrow(); 1309 isInitializedOrThrow();
1310 1310
1311 WarpUtils.log("************* WARPLY Microapp ********************"); 1311 WarpUtils.log("************* WARPLY Microapp ********************");
1312 - if (!WarplyServerPreferencesManager.isMicroAppActive(WarpConstants.MicroApp.DEVICE_INFO)) { 1312 + if (!WarplyServerPreferencesManager.isMicroAppActive(WarpConstants.MicroApp.APPLICATION_DATA)) {
1313 WarpUtils.log("[WARP Trace] Application Info Microapp is not active"); 1313 WarpUtils.log("[WARP Trace] Application Info Microapp is not active");
1314 return; 1314 return;
1315 } else { 1315 } else {
...@@ -1325,23 +1325,18 @@ public enum Warply { ...@@ -1325,23 +1325,18 @@ public enum Warply {
1325 super.onResult(json, errorCode); 1325 super.onResult(json, errorCode);
1326 1326
1327 if (json != null) { 1327 if (json != null) {
1328 - // OLD LOGIC // 1328 + if (!WarpUtils.getIsDeviceInfoSaved(mContext.get())) {
1329 -// if (!WarpUtils.getIsDeviceInfoSaved(mContext.get())) { 1329 + WarpUtils.setIsDeviceInfoSaved(mContext.get(), true);
1330 -// WarpUtils.setIsDeviceInfoSaved(mContext.get(), true); 1330 + WarpUtils.setDeviceInfoObject(mContext.get(), json);
1331 -// WarpUtils.setDeviceInfoObject(mContext.get(), json); 1331 + postMicroappData(WarpConstants.MICROAPP_DEVICE_INFO, json, true);
1332 -// postMicroappData(WarpConstants.MICROAPP_DEVICE_INFO, json, true); 1332 + } else {
1333 -// } else { 1333 + if (hasDeviceInfoDifference(WarpUtils.getDeviceInfoObject(mContext.get()), json)) {
1334 -// if (hasDeviceInfoDifference(WarpUtils.getDeviceInfoObject(mContext.get()), json)) { 1334 + WarpUtils.setDeviceInfoObject(mContext.get(), json);
1335 -// WarpUtils.setDeviceInfoObject(mContext.get(), json);
1336 -// postMicroappData(WarpConstants.MICROAPP_DEVICE_INFO, json, true);
1337 -// }
1338 -// }
1339 - // OLD LOGIC //
1340 -
1341 - // NEW LOGIC - REVERT IF NEEDED //
1342 postMicroappData(WarpConstants.MICROAPP_DEVICE_INFO, json, true); 1335 postMicroappData(WarpConstants.MICROAPP_DEVICE_INFO, json, true);
1343 } 1336 }
1344 } 1337 }
1338 + }
1339 + }
1345 }); 1340 });
1346 } 1341 }
1347 1342
...@@ -1813,7 +1808,7 @@ public enum Warply { ...@@ -1813,7 +1808,7 @@ public enum Warply {
1813 mRequestQueue.add(request); 1808 mRequestQueue.add(request);
1814 } 1809 }
1815 1810
1816 - private static void requestToServerInternalNew(int method, String url, JSONObject data, 1811 + public void requestToServerInternalNew(int method, String url, JSONObject data,
1817 CallbackReceiver<JSONObject> listener, Object tag) { 1812 CallbackReceiver<JSONObject> listener, Object tag) {
1818 1813
1819 VolleyTransformer vt = new VolleyTransformer(listener); 1814 VolleyTransformer vt = new VolleyTransformer(listener);
...@@ -2003,6 +1998,35 @@ public enum Warply { ...@@ -2003,6 +1998,35 @@ public enum Warply {
2003 private void postToServerInternal(String warplyPath, JSONArray data, 1998 private void postToServerInternal(String warplyPath, JSONArray data,
2004 CallbackReceiver<JSONObject> listener, Object tag) { 1999 CallbackReceiver<JSONObject> listener, Object tag) {
2005 String url = buildWarplyRequestUrl(warplyPath); 2000 String url = buildWarplyRequestUrl(warplyPath);
2001 +
2002 + JSONArray tempAnalytics = new JSONArray();
2003 + JSONArray tempDeviceInfo = new JSONArray();
2004 + JSONArray tempOther = new JSONArray();
2005 + if (data.length() > 0) {
2006 + for (int i = 0; i < data.length(); i++) {
2007 + JSONObject microappItem = data.optJSONObject(i);
2008 + if (microappItem != null) {
2009 + if (microappItem.has("inapp_analytics")) {
2010 + tempAnalytics.put(microappItem);
2011 + } else if (microappItem.has("device_info") || microappItem.has("application_data")) {
2012 + tempDeviceInfo.put(microappItem);
2013 + } else {
2014 + tempOther.put(microappItem);
2015 + }
2016 + }
2017 + }
2018 + }
2019 +
2020 + if (tempAnalytics != null && tempAnalytics.length() > 0) {
2021 + url = WarplyProperty.getBaseUrl(mContext.get()) + WarpConstants.WARPLY_ASYNC + WarpConstants.WARPLY_ANALYTICS + WarplyProperty.getAppUuid(mContext.get()) + "/";
2022 + }
2023 + if (tempDeviceInfo != null && tempDeviceInfo.length() > 0) {
2024 + url = WarplyProperty.getBaseUrl(mContext.get()) + WarpConstants.WARPLY_ASYNC + WarpConstants.WARPLY_DEVICE_INFO + WarplyProperty.getAppUuid(mContext.get()) + "/";
2025 + }
2026 + if (tempOther != null && tempOther.length() > 0) {
2027 + url = buildWarplyRequestUrl(warplyPath);
2028 + }
2029 +
2006 requestToServerInternal(Method.POST, url, data, listener, tag); 2030 requestToServerInternal(Method.POST, url, data, listener, tag);
2007 } 2031 }
2008 2032
...@@ -2015,7 +2039,7 @@ public enum Warply { ...@@ -2015,7 +2039,7 @@ public enum Warply {
2015 } 2039 }
2016 } 2040 }
2017 2041
2018 - public static void getSingleCampaign(JSONObject data, String url, 2042 + public void getSingleCampaign(JSONObject data, String url,
2019 CallbackReceiver<JSONObject> listener, Object tag) { 2043 CallbackReceiver<JSONObject> listener, Object tag) {
2020 requestToServerInternalNew(Method.GET, url, data, listener, tag); 2044 requestToServerInternalNew(Method.GET, url, data, listener, tag);
2021 } 2045 }
...@@ -2146,7 +2170,7 @@ public enum Warply { ...@@ -2146,7 +2170,7 @@ public enum Warply {
2146 WarpUtils.log("******************************************************"); 2170 WarpUtils.log("******************************************************");
2147 if (mRegistrationListener != null) 2171 if (mRegistrationListener != null)
2148 mRegistrationListener.onSuccess(ServiceRegistrationCallback.REGISTERED_WARPLY); 2172 mRegistrationListener.onSuccess(ServiceRegistrationCallback.REGISTERED_WARPLY);
2149 - postDeviceInfoData(); 2173 +// postDeviceInfoData();
2150 postApplicationData(true); 2174 postApplicationData(true);
2151 } 2175 }
2152 releaseRegisterLock(); 2176 releaseRegisterLock();
......
1 +package ly.warp.sdk.services;
2 +
3 +import android.content.Context;
4 +
5 +import androidx.annotation.NonNull;
6 +import androidx.work.Worker;
7 +import androidx.work.WorkerParameters;
8 +
9 +import ly.warp.sdk.Warply;
10 +
11 +/**
12 + * Created by Panagiotis Triantafyllou on 27/09/2022.
13 + */
14 +public class EventRefreshDeviceTokenService extends Worker {
15 +
16 + public EventRefreshDeviceTokenService(@NonNull Context context, @NonNull WorkerParameters workerParams) {
17 + super(context, workerParams);
18 + }
19 +
20 + @NonNull
21 + @Override
22 + public Result doWork() {
23 + Warply.INSTANCE.postDeviceInfoData();
24 +
25 + return Result.success();
26 + }
27 +}
...@@ -51,6 +51,8 @@ import android.view.animation.ScaleAnimation; ...@@ -51,6 +51,8 @@ import android.view.animation.ScaleAnimation;
51 51
52 import androidx.security.crypto.EncryptedSharedPreferences; 52 import androidx.security.crypto.EncryptedSharedPreferences;
53 import androidx.security.crypto.MasterKey; 53 import androidx.security.crypto.MasterKey;
54 +import androidx.work.OneTimeWorkRequest;
55 +import androidx.work.WorkManager;
54 56
55 import org.apache.http.client.HttpClient; 57 import org.apache.http.client.HttpClient;
56 import org.apache.http.client.methods.HttpRequestBase; 58 import org.apache.http.client.methods.HttpRequestBase;
...@@ -65,8 +67,10 @@ import java.nio.charset.Charset; ...@@ -65,8 +67,10 @@ import java.nio.charset.Charset;
65 import java.security.GeneralSecurityException; 67 import java.security.GeneralSecurityException;
66 import java.security.MessageDigest; 68 import java.security.MessageDigest;
67 import java.security.NoSuchAlgorithmException; 69 import java.security.NoSuchAlgorithmException;
70 +import java.util.concurrent.TimeUnit;
68 import java.util.zip.GZIPInputStream; 71 import java.util.zip.GZIPInputStream;
69 72
73 +import ly.warp.sdk.services.EventRefreshDeviceTokenService;
70 import ly.warp.sdk.utils.constants.WarpConstants; 74 import ly.warp.sdk.utils.constants.WarpConstants;
71 75
72 public class WarpUtils { 76 public class WarpUtils {
...@@ -454,6 +458,9 @@ public class WarpUtils { ...@@ -454,6 +458,9 @@ public class WarpUtils {
454 SharedPreferences.Editor editor = getPreferences(context).edit(); 458 SharedPreferences.Editor editor = getPreferences(context).edit();
455 editor.putString(PREFERENCES_KEY_DEVICE_TOKEN, token); 459 editor.putString(PREFERENCES_KEY_DEVICE_TOKEN, token);
456 editor.apply(); 460 editor.apply();
461 +
462 + OneTimeWorkRequest mywork = new OneTimeWorkRequest.Builder(EventRefreshDeviceTokenService.class).setInitialDelay(1, TimeUnit.MINUTES).build();
463 + WorkManager.getInstance(context).enqueue(mywork);
457 } 464 }
458 465
459 public static boolean getHasApplicationInfo(Context context) { 466 public static boolean getHasApplicationInfo(Context context) {
......
...@@ -2582,7 +2582,7 @@ public class WarplyManager { ...@@ -2582,7 +2582,7 @@ public class WarplyManager {
2582 2582
2583 String url = WarplyProperty.getBaseUrl(Warply.getWarplyContext()) + WarpConstants.BASE_REMOTE_PAGE_URL + sessionUuid; 2583 String url = WarplyProperty.getBaseUrl(Warply.getWarplyContext()) + WarpConstants.BASE_REMOTE_PAGE_URL + sessionUuid;
2584 2584
2585 - Warply.getSingleCampaign(null, url, 2585 + Warply.INSTANCE.getSingleCampaign(null, url,
2586 new CallbackReceiver<JSONObject>() { 2586 new CallbackReceiver<JSONObject>() {
2587 @Override 2587 @Override
2588 public void onSuccess(JSONObject result) { 2588 public void onSuccess(JSONObject result) {
......
...@@ -103,8 +103,8 @@ ...@@ -103,8 +103,8 @@
103 <string name="cos_dlg_positive_coupon_subtitle">Είσαι σίγουρος /-ή ότι θέλεις να κάνεις δώρο το κουπόνι σου;</string> 103 <string name="cos_dlg_positive_coupon_subtitle">Είσαι σίγουρος /-ή ότι θέλεις να κάνεις δώρο το κουπόνι σου;</string>
104 <string name="cos_dlg_negative_button3">Αποστολή</string> 104 <string name="cos_dlg_negative_button3">Αποστολή</string>
105 <string name="cos_dlg_error_subtitle2">Τα πεδία δεν είναι σωστά</string> 105 <string name="cos_dlg_error_subtitle2">Τα πεδία δεν είναι σωστά</string>
106 - <string name="cos_dlg_success_couponset_title">Το κουπόνι σου ενεργοποιήθηκε</string> 106 + <string name="cos_dlg_success_couponset_title">Επιτυχής ενεργοποίηση</string>
107 - <string name="cos_dlg_success_couponset_subtitle">Μπορείς να το βρεις στην αρχική οθόνη της εφαρμογής και στην ενότητα ενεργά δώρα!</string> 107 + <string name="cos_dlg_success_couponset_subtitle">Το κουπόνι σου έχει ενεργοποιηθεί στην ενότητα My Rewards.</string>
108 <string name="cos_dlg_activate_telco_title">Ενεργοποίηση υπηρεσίας</string> 108 <string name="cos_dlg_activate_telco_title">Ενεργοποίηση υπηρεσίας</string>
109 <string name="cos_dlg_activate_telco_subtitle">Θέλετε να γίνει ενεργοποίηση στο Κινητό μου;</string> 109 <string name="cos_dlg_activate_telco_subtitle">Θέλετε να γίνει ενεργοποίηση στο Κινητό μου;</string>
110 <string name="cos_dlg_activate_success_title">Το αίτημά σου ολοκληρώθηκε επιτυχώς!</string> 110 <string name="cos_dlg_activate_success_title">Το αίτημά σου ολοκληρώθηκε επιτυχώς!</string>
......