Showing
4 changed files
with
81 additions
and
9 deletions
| ... | @@ -5,7 +5,7 @@ android.buildFeatures.buildConfig = true | ... | @@ -5,7 +5,7 @@ android.buildFeatures.buildConfig = true |
| 5 | 5 | ||
| 6 | ext { | 6 | ext { |
| 7 | PUBLISH_GROUP_ID = 'ly.warp' | 7 | PUBLISH_GROUP_ID = 'ly.warp' |
| 8 | - PUBLISH_VERSION = '4.5.5.4m1' | 8 | + PUBLISH_VERSION = '4.5.5.4m2' |
| 9 | PUBLISH_ARTIFACT_ID = 'warply-android-sdk' | 9 | PUBLISH_ARTIFACT_ID = 'warply-android-sdk' |
| 10 | } | 10 | } |
| 11 | 11 | ... | ... |
| ... | @@ -43,6 +43,7 @@ import android.graphics.drawable.LayerDrawable; | ... | @@ -43,6 +43,7 @@ import android.graphics.drawable.LayerDrawable; |
| 43 | import android.graphics.drawable.ShapeDrawable; | 43 | import android.graphics.drawable.ShapeDrawable; |
| 44 | import android.os.Build; | 44 | import android.os.Build; |
| 45 | import android.os.Bundle; | 45 | import android.os.Bundle; |
| 46 | +import android.text.TextUtils; | ||
| 46 | import android.util.Base64; | 47 | import android.util.Base64; |
| 47 | import android.util.Log; | 48 | import android.util.Log; |
| 48 | import android.view.Gravity; | 49 | import android.view.Gravity; |
| ... | @@ -161,11 +162,39 @@ public class WarpUtils { | ... | @@ -161,11 +162,39 @@ public class WarpUtils { |
| 161 | + "steps_manually_stopped"; | 162 | + "steps_manually_stopped"; |
| 162 | private static final String PREFERENCES_KEY_JWT_ENABLED = PREFERENCES_PREFIX | 163 | private static final String PREFERENCES_KEY_JWT_ENABLED = PREFERENCES_PREFIX |
| 163 | + "jwt_enabled"; | 164 | + "jwt_enabled"; |
| 165 | + private static final String PREFERENCES_KEY_APP_LOCALE = PREFERENCES_PREFIX | ||
| 166 | + + "app_locale"; | ||
| 167 | + private static final String PREFERENCES_KEY_DARK_MODE_ENABLED = PREFERENCES_PREFIX | ||
| 168 | + + "dark_mode_enabled"; | ||
| 164 | 169 | ||
| 165 | private static SharedPreferences _prefs; | 170 | private static SharedPreferences _prefs; |
| 166 | 171 | ||
| 167 | /* Public methods */ | 172 | /* Public methods */ |
| 168 | 173 | ||
| 174 | + public static String getApplicationLocale(Context context) { | ||
| 175 | + return getPreferences(context).getString(PREFERENCES_KEY_APP_LOCALE, "el"); | ||
| 176 | + } | ||
| 177 | + | ||
| 178 | + public static void setApplicationLocale(Context context, String localeParam) { | ||
| 179 | + String tempLocale = localeParam.toLowerCase(); | ||
| 180 | + if ("gr".equals(tempLocale)) { | ||
| 181 | + tempLocale = "el"; | ||
| 182 | + } | ||
| 183 | + SharedPreferences.Editor editor = getPreferences(context).edit(); | ||
| 184 | + editor.putString(PREFERENCES_KEY_APP_LOCALE, TextUtils.isEmpty(tempLocale) ? "el" : tempLocale); | ||
| 185 | + editor.apply(); | ||
| 186 | + } | ||
| 187 | + | ||
| 188 | + public static boolean getIsDarkModeEnabled(Context context) { | ||
| 189 | + return getPreferences(context).getBoolean(PREFERENCES_KEY_DARK_MODE_ENABLED, false); | ||
| 190 | + } | ||
| 191 | + | ||
| 192 | + public static void setIsDarkModeEnabled(Context context, boolean isDarkModeEnabled) { | ||
| 193 | + SharedPreferences.Editor editor = getPreferences(context).edit(); | ||
| 194 | + editor.putBoolean(PREFERENCES_KEY_DARK_MODE_ENABLED, isDarkModeEnabled); | ||
| 195 | + editor.apply(); | ||
| 196 | + } | ||
| 197 | + | ||
| 169 | public static boolean getIsSteps(Context context) { | 198 | public static boolean getIsSteps(Context context) { |
| 170 | return getPreferences(context).getBoolean(PREFERENCES_KEY_STEPS, false); | 199 | return getPreferences(context).getBoolean(PREFERENCES_KEY_STEPS, false); |
| 171 | } | 200 | } | ... | ... |
| ... | @@ -107,6 +107,8 @@ public class WarplyManagerHelper { | ... | @@ -107,6 +107,8 @@ public class WarplyManagerHelper { |
| 107 | params.putOpt("refresh_token", WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("refresh_token")); | 107 | params.putOpt("refresh_token", WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("refresh_token")); |
| 108 | params.putOpt("client_id", WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_id")); | 108 | params.putOpt("client_id", WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_id")); |
| 109 | params.putOpt("client_secret", WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_secret")); | 109 | params.putOpt("client_secret", WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_secret")); |
| 110 | + params.putOpt("lan", WarpUtils.getApplicationLocale(Warply.getWarplyContext())); | ||
| 111 | + params.putOpt("dark", String.valueOf(WarpUtils.getIsDarkModeEnabled(Warply.getWarplyContext()))); | ||
| 110 | } catch (JSONException e) { | 112 | } catch (JSONException e) { |
| 111 | e.printStackTrace(); | 113 | e.printStackTrace(); |
| 112 | } | 114 | } |
| ... | @@ -131,6 +133,8 @@ public class WarplyManagerHelper { | ... | @@ -131,6 +133,8 @@ public class WarplyManagerHelper { |
| 131 | params.putOpt("refresh_token", WarplyDBHelper.getInstance(context).getAuthValue("refresh_token")); | 133 | params.putOpt("refresh_token", WarplyDBHelper.getInstance(context).getAuthValue("refresh_token")); |
| 132 | params.putOpt("client_id", WarplyDBHelper.getInstance(context).getClientValue("client_id")); | 134 | params.putOpt("client_id", WarplyDBHelper.getInstance(context).getClientValue("client_id")); |
| 133 | params.putOpt("client_secret", WarplyDBHelper.getInstance(context).getClientValue("client_secret")); | 135 | params.putOpt("client_secret", WarplyDBHelper.getInstance(context).getClientValue("client_secret")); |
| 136 | + params.putOpt("lan", WarpUtils.getApplicationLocale(context)); | ||
| 137 | + params.putOpt("dark", String.valueOf(WarpUtils.getIsDarkModeEnabled(context))); | ||
| 134 | } catch (JSONException e) { | 138 | } catch (JSONException e) { |
| 135 | e.printStackTrace(); | 139 | e.printStackTrace(); |
| 136 | } | 140 | } |
| ... | @@ -152,6 +156,8 @@ public class WarplyManagerHelper { | ... | @@ -152,6 +156,8 @@ public class WarplyManagerHelper { |
| 152 | params.putOpt("client_id", WarplyDBHelper.getInstance(context).getClientValue("client_id")); | 156 | params.putOpt("client_id", WarplyDBHelper.getInstance(context).getClientValue("client_id")); |
| 153 | params.putOpt("client_secret", WarplyDBHelper.getInstance(context).getClientValue("client_secret")); | 157 | params.putOpt("client_secret", WarplyDBHelper.getInstance(context).getClientValue("client_secret")); |
| 154 | params.putOpt("map", "true"); | 158 | params.putOpt("map", "true"); |
| 159 | + params.putOpt("lan", WarpUtils.getApplicationLocale(context)); | ||
| 160 | + params.putOpt("dark", String.valueOf(WarpUtils.getIsDarkModeEnabled(context))); | ||
| 155 | } catch (JSONException e) { | 161 | } catch (JSONException e) { |
| 156 | e.printStackTrace(); | 162 | e.printStackTrace(); |
| 157 | } | 163 | } | ... | ... |
| ... | @@ -163,7 +163,26 @@ public class WarplyManager { | ... | @@ -163,7 +163,26 @@ public class WarplyManager { |
| 163 | 163 | ||
| 164 | RequestBody loginRequest = RequestBody.create(MediaType.get("application/json; charset=utf-8"), (new JSONObject(jsonParams)).toString()); | 164 | RequestBody loginRequest = RequestBody.create(MediaType.get("application/json; charset=utf-8"), (new JSONObject(jsonParams)).toString()); |
| 165 | 165 | ||
| 166 | - Call<ResponseBody> logoutCall = WarpUtils.isJWTEnabled(Warply.getWarplyContext()) ? service.logoutUserJwt(WarplyProperty.getAppUuid(Warply.getWarplyContext()), loginRequest, timeStamp, "android:" + Warply.getWarplyContext().getPackageName(), new WarplyDeviceInfoCollector(Warply.getWarplyContext()).getUniqueDeviceId(), "mobile", webId, WarpUtils.produceSignature(apiKey + timeStamp)) : service.logoutUser(WarplyProperty.getAppUuid(Warply.getWarplyContext()), loginRequest, timeStamp, "android:" + Warply.getWarplyContext().getPackageName(), new WarplyDeviceInfoCollector(Warply.getWarplyContext()).getUniqueDeviceId(), "mobile", webId, WarpUtils.produceSignature(apiKey + timeStamp)); | 166 | + Call<ResponseBody> logoutCall = WarpUtils.isJWTEnabled(Warply.getWarplyContext()) |
| 167 | + ? service.logoutUserJwt( | ||
| 168 | + WarplyProperty.getAppUuid(Warply.getWarplyContext()), | ||
| 169 | + loginRequest, | ||
| 170 | + timeStamp, | ||
| 171 | + "android:" + Warply.getWarplyContext().getPackageName(), | ||
| 172 | + new WarplyDeviceInfoCollector(Warply.getWarplyContext()).getUniqueDeviceId(), | ||
| 173 | + "mobile", | ||
| 174 | + webId, | ||
| 175 | + WarpUtils.produceSignature(apiKey + timeStamp) | ||
| 176 | + ) | ||
| 177 | + : service.logoutUser(WarplyProperty.getAppUuid(Warply.getWarplyContext()), | ||
| 178 | + loginRequest, | ||
| 179 | + timeStamp, | ||
| 180 | + "android:" + Warply.getWarplyContext().getPackageName(), | ||
| 181 | + new WarplyDeviceInfoCollector(Warply.getWarplyContext()).getUniqueDeviceId(), | ||
| 182 | + "mobile", | ||
| 183 | + webId, | ||
| 184 | + WarpUtils.produceSignature(apiKey + timeStamp) | ||
| 185 | + ); | ||
| 167 | 186 | ||
| 168 | logoutCall.enqueue(new Callback<ResponseBody>() { | 187 | logoutCall.enqueue(new Callback<ResponseBody>() { |
| 169 | @Override | 188 | @Override |
| ... | @@ -237,7 +256,17 @@ public class WarplyManager { | ... | @@ -237,7 +256,17 @@ public class WarplyManager { |
| 237 | 256 | ||
| 238 | RequestBody loginRequest = RequestBody.create(MediaType.get("application/json; charset=utf-8"), (new JSONObject(jsonParams)).toString()); | 257 | RequestBody loginRequest = RequestBody.create(MediaType.get("application/json; charset=utf-8"), (new JSONObject(jsonParams)).toString()); |
| 239 | 258 | ||
| 240 | - Call<ResponseBody> loginCall = service.cosmoteUser(WarplyProperty.getAppUuid(Warply.getWarplyContext()), loginRequest, timeStamp, "android:" + Warply.getWarplyContext().getPackageName(), new WarplyDeviceInfoCollector(Warply.getWarplyContext()).getUniqueDeviceId(), "mobile", webId, WarpUtils.produceSignature(apiKey + timeStamp), "Basic MVBQNFhCQzhFYTJBaUdCNkJWZGFGUERlTTNLQ3kzMjU6YzViMzAyZDY5N2FiNGY3NzhiNThhMTg0YzBkZWRmNGU="); | 259 | + Call<ResponseBody> loginCall = service.cosmoteUser( |
| 260 | + WarplyProperty.getAppUuid(Warply.getWarplyContext()), | ||
| 261 | + loginRequest, | ||
| 262 | + timeStamp, | ||
| 263 | + "android:" + Warply.getWarplyContext().getPackageName(), | ||
| 264 | + new WarplyDeviceInfoCollector(Warply.getWarplyContext()).getUniqueDeviceId(), | ||
| 265 | + "mobile", | ||
| 266 | + webId, | ||
| 267 | + WarpUtils.produceSignature(apiKey + timeStamp), | ||
| 268 | + "Basic MVBQNFhCQzhFYTJBaUdCNkJWZGFGUERlTTNLQ3kzMjU6YzViMzAyZDY5N2FiNGY3NzhiNThhMTg0YzBkZWRmNGU=" | ||
| 269 | + ); | ||
| 241 | 270 | ||
| 242 | loginCall.enqueue(new Callback<ResponseBody>() { | 271 | loginCall.enqueue(new Callback<ResponseBody>() { |
| 243 | @Override | 272 | @Override |
| ... | @@ -323,7 +352,15 @@ public class WarplyManager { | ... | @@ -323,7 +352,15 @@ public class WarplyManager { |
| 323 | 352 | ||
| 324 | RequestBody loginRequest = RequestBody.create(MediaType.get("application/json; charset=utf-8"), (new JSONObject(jsonParams)).toString()); | 353 | RequestBody loginRequest = RequestBody.create(MediaType.get("application/json; charset=utf-8"), (new JSONObject(jsonParams)).toString()); |
| 325 | 354 | ||
| 326 | - Call<ResponseBody> loginCall = service.verifyUser(loginRequest, timeStamp, "android:" + Warply.getWarplyContext().getPackageName(), new WarplyDeviceInfoCollector(Warply.getWarplyContext()).getUniqueDeviceId(), "mobile", webId, WarpUtils.produceSignature(apiKey + timeStamp)); | 355 | + Call<ResponseBody> loginCall = service.verifyUser( |
| 356 | + loginRequest, | ||
| 357 | + timeStamp, | ||
| 358 | + "android:" + Warply.getWarplyContext().getPackageName(), | ||
| 359 | + new WarplyDeviceInfoCollector(Warply.getWarplyContext()).getUniqueDeviceId(), | ||
| 360 | + "mobile", | ||
| 361 | + webId, | ||
| 362 | + WarpUtils.produceSignature(apiKey + timeStamp) | ||
| 363 | + ); | ||
| 327 | 364 | ||
| 328 | loginCall.enqueue(new Callback<ResponseBody>() { | 365 | loginCall.enqueue(new Callback<ResponseBody>() { |
| 329 | @Override | 366 | @Override |
| ... | @@ -516,7 +553,7 @@ public class WarplyManager { | ... | @@ -516,7 +553,7 @@ public class WarplyManager { |
| 516 | Map<String, Object> jsonParams = new ArrayMap<>(); | 553 | Map<String, Object> jsonParams = new ArrayMap<>(); |
| 517 | jsonParams.put("action", "retrieve"); | 554 | jsonParams.put("action", "retrieve"); |
| 518 | jsonParams.put("filters", new JSONObject()); | 555 | jsonParams.put("filters", new JSONObject()); |
| 519 | - jsonParams.put("language", WarplyProperty.getLanguage(Warply.getWarplyContext())); | 556 | + jsonParams.put("language", WarpUtils.getApplicationLocale(Warply.getWarplyContext())); |
| 520 | 557 | ||
| 521 | jsonParamsCampaigns.put("campaigns", jsonParams); | 558 | jsonParamsCampaigns.put("campaigns", jsonParams); |
| 522 | RequestBody campaignsRequest = RequestBody.create(MediaType.get("application/json; charset=utf-8"), (new JSONObject(jsonParamsCampaigns)).toString()); | 559 | RequestBody campaignsRequest = RequestBody.create(MediaType.get("application/json; charset=utf-8"), (new JSONObject(jsonParamsCampaigns)).toString()); |
| ... | @@ -655,7 +692,7 @@ public class WarplyManager { | ... | @@ -655,7 +692,7 @@ public class WarplyManager { |
| 655 | Map<String, Object> jsonParams = new ArrayMap<>(); | 692 | Map<String, Object> jsonParams = new ArrayMap<>(); |
| 656 | jsonParams.put("action", "retrieve"); | 693 | jsonParams.put("action", "retrieve"); |
| 657 | jsonParams.put("filters", new JSONObject()); | 694 | jsonParams.put("filters", new JSONObject()); |
| 658 | - jsonParams.put("language", WarplyProperty.getLanguage(Warply.getWarplyContext())); | 695 | + jsonParams.put("language", WarpUtils.getApplicationLocale(Warply.getWarplyContext())); |
| 659 | 696 | ||
| 660 | jsonParamsCampaigns.put("campaigns", jsonParams); | 697 | jsonParamsCampaigns.put("campaigns", jsonParams); |
| 661 | RequestBody campaignsPersonalizedRequest = RequestBody.create(MediaType.get("application/json; charset=utf-8"), (new JSONObject(jsonParamsCampaigns)).toString()); | 698 | RequestBody campaignsPersonalizedRequest = RequestBody.create(MediaType.get("application/json; charset=utf-8"), (new JSONObject(jsonParamsCampaigns)).toString()); |
| ... | @@ -987,7 +1024,7 @@ public class WarplyManager { | ... | @@ -987,7 +1024,7 @@ public class WarplyManager { |
| 987 | jArr.put("merchant"); | 1024 | jArr.put("merchant"); |
| 988 | jArr.put("redemption"); | 1025 | jArr.put("redemption"); |
| 989 | jsonParams.put("details", jArr); | 1026 | jsonParams.put("details", jArr); |
| 990 | - jsonParams.put("language", WarplyProperty.getLanguage(Warply.getWarplyContext())); | 1027 | + jsonParams.put("language", WarpUtils.getApplicationLocale(Warply.getWarplyContext())); |
| 991 | jsonParams.put("couponset_types", new JSONArray().put("supermarket")); | 1028 | jsonParams.put("couponset_types", new JSONArray().put("supermarket")); |
| 992 | 1029 | ||
| 993 | jsonParamsCoupons.put("coupon", jsonParams); | 1030 | jsonParamsCoupons.put("coupon", jsonParams); |
| ... | @@ -1113,7 +1150,7 @@ public class WarplyManager { | ... | @@ -1113,7 +1150,7 @@ public class WarplyManager { |
| 1113 | jArr.put("merchant"); | 1150 | jArr.put("merchant"); |
| 1114 | jArr.put("redemption"); | 1151 | jArr.put("redemption"); |
| 1115 | jsonParams.put("details", jArr); | 1152 | jsonParams.put("details", jArr); |
| 1116 | - jsonParams.put("language", WarplyProperty.getLanguage(Warply.getWarplyContext())); | 1153 | + jsonParams.put("language", WarpUtils.getApplicationLocale(Warply.getWarplyContext())); |
| 1117 | // JSONObject jPagination= new JSONObject(); | 1154 | // JSONObject jPagination= new JSONObject(); |
| 1118 | // try { | 1155 | // try { |
| 1119 | // jPagination.putOpt("page",1); | 1156 | // jPagination.putOpt("page",1); |
| ... | @@ -1316,7 +1353,7 @@ public class WarplyManager { | ... | @@ -1316,7 +1353,7 @@ public class WarplyManager { |
| 1316 | } | 1353 | } |
| 1317 | jsonParams.put("action", "retrieve"); | 1354 | jsonParams.put("action", "retrieve"); |
| 1318 | jsonParams.put("filters", jFilters); | 1355 | jsonParams.put("filters", jFilters); |
| 1319 | - jsonParams.put("language", WarplyProperty.getLanguage(Warply.getWarplyContext())); | 1356 | + jsonParams.put("language", WarpUtils.getApplicationLocale(Warply.getWarplyContext())); |
| 1320 | 1357 | ||
| 1321 | jsonParamsCampaigns.put("campaigns", jsonParams); | 1358 | jsonParamsCampaigns.put("campaigns", jsonParams); |
| 1322 | RequestBody campaignsRequest = RequestBody.create(MediaType.get("application/json; charset=utf-8"), (new JSONObject(jsonParamsCampaigns)).toString()); | 1359 | RequestBody campaignsRequest = RequestBody.create(MediaType.get("application/json; charset=utf-8"), (new JSONObject(jsonParamsCampaigns)).toString()); | ... | ... |
-
Please register or login to post a comment