Panagiotis Triantafyllou

push fix

......@@ -7,12 +7,12 @@
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<application>
<!-- <meta-data-->
<!-- android:name="com.google.android.geo.API_KEY"-->
<!-- android:value="@string/google_maps_key" />-->
<!-- <meta-data-->
<!-- android:name="com.google.android.geo.API_KEY"-->
<!-- android:value="@string/google_maps_key" />-->
<!-- For Huawei Push -->
<meta-data
......@@ -26,80 +26,80 @@
<activity
android:name="ly.warp.sdk.activities.WarpViewActivity"
android:exported="false"
android:theme="@style/SDKAppTheme"
android:screenOrientation="portrait" />
android:screenOrientation="portrait"
android:theme="@style/SDKAppTheme" />
<activity
android:name="ly.warp.sdk.activities.LoyaltyAnalysisActivity"
android:exported="false"
android:theme="@style/SDKAppTheme"
android:screenOrientation="portrait" />
android:screenOrientation="portrait"
android:theme="@style/SDKAppTheme" />
<activity
android:name="ly.warp.sdk.activities.CouponInfoActivity"
android:exported="false"
android:theme="@style/SDKAppTheme"
android:screenOrientation="portrait" />
android:screenOrientation="portrait"
android:theme="@style/SDKAppTheme" />
<activity
android:name="ly.warp.sdk.activities.ActiveCouponsActivity"
android:exported="false"
android:theme="@style/SDKAppTheme"
android:screenOrientation="portrait" />
android:screenOrientation="portrait"
android:theme="@style/SDKAppTheme" />
<activity
android:name="ly.warp.sdk.activities.GiftsForYouActivity"
android:exported="false"
android:theme="@style/SDKAppTheme"
android:screenOrientation="portrait" />
android:screenOrientation="portrait"
android:theme="@style/SDKAppTheme" />
<activity
android:name="ly.warp.sdk.activities.MoreForYouActivity"
android:exported="false"
android:theme="@style/SDKAppTheme"
android:screenOrientation="portrait" />
android:screenOrientation="portrait"
android:theme="@style/SDKAppTheme" />
<activity
android:name="ly.warp.sdk.activities.CouponsetInfoActivity"
android:exported="false"
android:theme="@style/SDKAppTheme"
android:screenOrientation="portrait" />
android:screenOrientation="portrait"
android:theme="@style/SDKAppTheme" />
<activity
android:name="ly.warp.sdk.activities.LoyaltyWallet"
android:exported="false"
android:theme="@style/SDKAppTheme"
android:screenOrientation="portrait" />
android:screenOrientation="portrait"
android:theme="@style/SDKAppTheme" />
<activity
android:name="ly.warp.sdk.activities.ActiveGiftsActivity"
android:exported="false"
android:theme="@style/SDKAppTheme"
android:screenOrientation="portrait" />
android:screenOrientation="portrait"
android:theme="@style/SDKAppTheme" />
<activity
android:name="ly.warp.sdk.activities.ShopsActivity"
android:exported="false"
android:theme="@style/SDKAppTheme"
android:screenOrientation="portrait" />
android:screenOrientation="portrait"
android:theme="@style/SDKAppTheme" />
<activity
android:name="ly.warp.sdk.activities.CouponShareActivity"
android:exported="false"
android:theme="@style/SDKAppTheme"
android:screenOrientation="portrait" />
android:screenOrientation="portrait"
android:theme="@style/SDKAppTheme" />
<activity
android:name="ly.warp.sdk.activities.TelcoActivity"
android:exported="false"
android:theme="@style/SDKAppTheme"
android:screenOrientation="portrait" />
android:screenOrientation="portrait"
android:theme="@style/SDKAppTheme" />
<activity
android:name="ly.warp.sdk.activities.ContextualActivity"
android:exported="false"
android:theme="@style/SDKAppTheme"
android:screenOrientation="portrait" />
android:screenOrientation="portrait"
android:theme="@style/SDKAppTheme" />
<activity
android:name="ly.warp.sdk.dexter.PermissionsActivity"
......@@ -156,6 +156,11 @@
android:permission="android.permission.BIND_JOB_SERVICE" />
<service
android:name="ly.warp.sdk.services.EventRefreshDeviceTokenService"
android:exported="false"
android:permission="android.permission.BIND_JOB_SERVICE" />
<service
android:name="ly.warp.sdk.services.EventQuestionnaireService"
android:exported="false"
android:permission="android.permission.BIND_JOB_SERVICE" />
......@@ -175,22 +180,22 @@
android:exported="false" />
<!-- FCM Service for push notifications -->
<!-- <service-->
<!-- android:name="ly.warp.sdk.services.FCMBaseMessagingService"-->
<!-- android:exported="false">-->
<!-- <intent-filter>-->
<!-- <action android:name="com.google.firebase.MESSAGING_EVENT" />-->
<!-- </intent-filter>-->
<!-- </service>-->
<!-- <service-->
<!-- android:name="ly.warp.sdk.services.FCMBaseMessagingService"-->
<!-- android:exported="false">-->
<!-- <intent-filter>-->
<!-- <action android:name="com.google.firebase.MESSAGING_EVENT" />-->
<!-- </intent-filter>-->
<!-- </service>-->
<!-- Service used for handling Huawei Push Notifications, comment if we are in Google build -->
<!-- <service-->
<!-- android:name="ly.warp.sdk.services.HMSBaseMessagingService"-->
<!-- android:exported="false">-->
<!-- <intent-filter>-->
<!-- <action android:name="com.huawei.push.action.MESSAGING_EVENT" />-->
<!-- </intent-filter>-->
<!-- </service>-->
<!-- <service-->
<!-- android:name="ly.warp.sdk.services.HMSBaseMessagingService"-->
<!-- android:exported="false">-->
<!-- <intent-filter>-->
<!-- <action android:name="com.huawei.push.action.MESSAGING_EVENT" />-->
<!-- </intent-filter>-->
<!-- </service>-->
<receiver
android:name="ly.warp.sdk.receivers.LocationChangedReceiver"
......
......@@ -101,7 +101,7 @@ public enum Warply {
public WeakReference<Context> mContext;
private CallbackReceiver<ServiceRegistrationCallback> mRegistrationListener;
private static RequestQueue mRequestQueue;
private RequestQueue mRequestQueue;
/* Locks */
private final AtomicBoolean registerLock = new AtomicBoolean(false);
......@@ -1309,7 +1309,7 @@ public enum Warply {
isInitializedOrThrow();
WarpUtils.log("************* WARPLY Microapp ********************");
if (!WarplyServerPreferencesManager.isMicroAppActive(WarpConstants.MicroApp.DEVICE_INFO)) {
if (!WarplyServerPreferencesManager.isMicroAppActive(WarpConstants.MicroApp.APPLICATION_DATA)) {
WarpUtils.log("[WARP Trace] Application Info Microapp is not active");
return;
} else {
......@@ -1325,23 +1325,18 @@ public enum Warply {
super.onResult(json, errorCode);
if (json != null) {
// OLD LOGIC //
// if (!WarpUtils.getIsDeviceInfoSaved(mContext.get())) {
// WarpUtils.setIsDeviceInfoSaved(mContext.get(), true);
// WarpUtils.setDeviceInfoObject(mContext.get(), json);
// postMicroappData(WarpConstants.MICROAPP_DEVICE_INFO, json, true);
// } else {
// if (hasDeviceInfoDifference(WarpUtils.getDeviceInfoObject(mContext.get()), json)) {
// WarpUtils.setDeviceInfoObject(mContext.get(), json);
// postMicroappData(WarpConstants.MICROAPP_DEVICE_INFO, json, true);
// }
// }
// OLD LOGIC //
// NEW LOGIC - REVERT IF NEEDED //
if (!WarpUtils.getIsDeviceInfoSaved(mContext.get())) {
WarpUtils.setIsDeviceInfoSaved(mContext.get(), true);
WarpUtils.setDeviceInfoObject(mContext.get(), json);
postMicroappData(WarpConstants.MICROAPP_DEVICE_INFO, json, true);
} else {
if (hasDeviceInfoDifference(WarpUtils.getDeviceInfoObject(mContext.get()), json)) {
WarpUtils.setDeviceInfoObject(mContext.get(), json);
postMicroappData(WarpConstants.MICROAPP_DEVICE_INFO, json, true);
}
}
}
}
});
}
......@@ -1813,7 +1808,7 @@ public enum Warply {
mRequestQueue.add(request);
}
private static void requestToServerInternalNew(int method, String url, JSONObject data,
public void requestToServerInternalNew(int method, String url, JSONObject data,
CallbackReceiver<JSONObject> listener, Object tag) {
VolleyTransformer vt = new VolleyTransformer(listener);
......@@ -2003,6 +1998,35 @@ public enum Warply {
private void postToServerInternal(String warplyPath, JSONArray data,
CallbackReceiver<JSONObject> listener, Object tag) {
String url = buildWarplyRequestUrl(warplyPath);
JSONArray tempAnalytics = new JSONArray();
JSONArray tempDeviceInfo = new JSONArray();
JSONArray tempOther = new JSONArray();
if (data.length() > 0) {
for (int i = 0; i < data.length(); i++) {
JSONObject microappItem = data.optJSONObject(i);
if (microappItem != null) {
if (microappItem.has("inapp_analytics")) {
tempAnalytics.put(microappItem);
} else if (microappItem.has("device_info") || microappItem.has("application_data")) {
tempDeviceInfo.put(microappItem);
} else {
tempOther.put(microappItem);
}
}
}
}
if (tempAnalytics != null && tempAnalytics.length() > 0) {
url = WarplyProperty.getBaseUrl(mContext.get()) + WarpConstants.WARPLY_ASYNC + WarpConstants.WARPLY_ANALYTICS + WarplyProperty.getAppUuid(mContext.get()) + "/";
}
if (tempDeviceInfo != null && tempDeviceInfo.length() > 0) {
url = WarplyProperty.getBaseUrl(mContext.get()) + WarpConstants.WARPLY_ASYNC + WarpConstants.WARPLY_DEVICE_INFO + WarplyProperty.getAppUuid(mContext.get()) + "/";
}
if (tempOther != null && tempOther.length() > 0) {
url = buildWarplyRequestUrl(warplyPath);
}
requestToServerInternal(Method.POST, url, data, listener, tag);
}
......@@ -2015,7 +2039,7 @@ public enum Warply {
}
}
public static void getSingleCampaign(JSONObject data, String url,
public void getSingleCampaign(JSONObject data, String url,
CallbackReceiver<JSONObject> listener, Object tag) {
requestToServerInternalNew(Method.GET, url, data, listener, tag);
}
......@@ -2146,7 +2170,7 @@ public enum Warply {
WarpUtils.log("******************************************************");
if (mRegistrationListener != null)
mRegistrationListener.onSuccess(ServiceRegistrationCallback.REGISTERED_WARPLY);
postDeviceInfoData();
// postDeviceInfoData();
postApplicationData(true);
}
releaseRegisterLock();
......
package ly.warp.sdk.services;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.work.Worker;
import androidx.work.WorkerParameters;
import ly.warp.sdk.Warply;
/**
* Created by Panagiotis Triantafyllou on 27/09/2022.
*/
public class EventRefreshDeviceTokenService extends Worker {
public EventRefreshDeviceTokenService(@NonNull Context context, @NonNull WorkerParameters workerParams) {
super(context, workerParams);
}
@NonNull
@Override
public Result doWork() {
Warply.INSTANCE.postDeviceInfoData();
return Result.success();
}
}
......@@ -51,6 +51,8 @@ import android.view.animation.ScaleAnimation;
import androidx.security.crypto.EncryptedSharedPreferences;
import androidx.security.crypto.MasterKey;
import androidx.work.OneTimeWorkRequest;
import androidx.work.WorkManager;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpRequestBase;
......@@ -65,8 +67,10 @@ import java.nio.charset.Charset;
import java.security.GeneralSecurityException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.concurrent.TimeUnit;
import java.util.zip.GZIPInputStream;
import ly.warp.sdk.services.EventRefreshDeviceTokenService;
import ly.warp.sdk.utils.constants.WarpConstants;
public class WarpUtils {
......@@ -454,6 +458,9 @@ public class WarpUtils {
SharedPreferences.Editor editor = getPreferences(context).edit();
editor.putString(PREFERENCES_KEY_DEVICE_TOKEN, token);
editor.apply();
OneTimeWorkRequest mywork = new OneTimeWorkRequest.Builder(EventRefreshDeviceTokenService.class).setInitialDelay(1, TimeUnit.MINUTES).build();
WorkManager.getInstance(context).enqueue(mywork);
}
public static boolean getHasApplicationInfo(Context context) {
......
......@@ -2582,7 +2582,7 @@ public class WarplyManager {
String url = WarplyProperty.getBaseUrl(Warply.getWarplyContext()) + WarpConstants.BASE_REMOTE_PAGE_URL + sessionUuid;
Warply.getSingleCampaign(null, url,
Warply.INSTANCE.getSingleCampaign(null, url,
new CallbackReceiver<JSONObject>() {
@Override
public void onSuccess(JSONObject result) {
......
......@@ -103,8 +103,8 @@
<string name="cos_dlg_positive_coupon_subtitle">Είσαι σίγουρος /-ή ότι θέλεις να κάνεις δώρο το κουπόνι σου;</string>
<string name="cos_dlg_negative_button3">Αποστολή</string>
<string name="cos_dlg_error_subtitle2">Τα πεδία δεν είναι σωστά</string>
<string name="cos_dlg_success_couponset_title">Το κουπόνι σου ενεργοποιήθηκε</string>
<string name="cos_dlg_success_couponset_subtitle">Μπορείς να το βρεις στην αρχική οθόνη της εφαρμογής και στην ενότητα ενεργά δώρα!</string>
<string name="cos_dlg_success_couponset_title">Επιτυχής ενεργοποίηση</string>
<string name="cos_dlg_success_couponset_subtitle">Το κουπόνι σου έχει ενεργοποιηθεί στην ενότητα My Rewards.</string>
<string name="cos_dlg_activate_telco_title">Ενεργοποίηση υπηρεσίας</string>
<string name="cos_dlg_activate_telco_subtitle">Θέλετε να γίνει ενεργοποίηση στο Κινητό μου;</string>
<string name="cos_dlg_activate_success_title">Το αίτημά σου ολοκληρώθηκε επιτυχώς!</string>
......