Showing
9 changed files
with
174 additions
and
7 deletions
... | @@ -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.4.6rc72' | 5 | + PUBLISH_VERSION = '4.5.4.6rc73' |
6 | PUBLISH_ARTIFACT_ID = 'warply-android-sdk' | 6 | PUBLISH_ARTIFACT_ID = 'warply-android-sdk' |
7 | } | 7 | } |
8 | 8 | ... | ... |
... | @@ -86,6 +86,10 @@ public class ActiveGiftsActivity extends Activity implements View.OnClickListene | ... | @@ -86,6 +86,10 @@ public class ActiveGiftsActivity extends Activity implements View.OnClickListene |
86 | mAdapterMergedActiveGifts.getPositionClicks() | 86 | mAdapterMergedActiveGifts.getPositionClicks() |
87 | .doOnNext(dataItem -> { | 87 | .doOnNext(dataItem -> { |
88 | if (dataItem.getDataType() == 1) { | 88 | if (dataItem.getDataType() == 1) { |
89 | + if (!WarplyManagerHelper.noInternetDialog(ActiveGiftsActivity.this, true)) { | ||
90 | + WarplyManagerHelper.noInternetDialog(ActiveGiftsActivity.this); | ||
91 | + return; | ||
92 | + } | ||
89 | startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(dataItem.getCampaign()))); | 93 | startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(dataItem.getCampaign()))); |
90 | } else if (dataItem.getDataType() == 2) { | 94 | } else if (dataItem.getDataType() == 2) { |
91 | Intent intent = new Intent(ActiveGiftsActivity.this, CouponInfoActivity.class); | 95 | Intent intent = new Intent(ActiveGiftsActivity.this, CouponInfoActivity.class); | ... | ... |
... | @@ -262,6 +262,10 @@ public class GiftsForYouActivity extends AppCompatActivity implements View.OnCli | ... | @@ -262,6 +262,10 @@ public class GiftsForYouActivity extends AppCompatActivity implements View.OnCli |
262 | } | 262 | } |
263 | } | 263 | } |
264 | } else { | 264 | } else { |
265 | + if (!WarplyManagerHelper.noInternetDialog(this, true)) { | ||
266 | + WarplyManagerHelper.noInternetDialog(this); | ||
267 | + return; | ||
268 | + } | ||
265 | WarplyAnalyticsManager.logTrackersEvent(this, "click", ("Loyalty").concat(":").concat(dataItem.getCampaign().getSessionUUID())); | 269 | WarplyAnalyticsManager.logTrackersEvent(this, "click", ("Loyalty").concat(":").concat(dataItem.getCampaign().getSessionUUID())); |
266 | startActivityForResult(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(dataItem.getCampaign())), 1004); | 270 | startActivityForResult(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(dataItem.getCampaign())), 1004); |
267 | } | 271 | } |
... | @@ -297,6 +301,10 @@ public class GiftsForYouActivity extends AppCompatActivity implements View.OnCli | ... | @@ -297,6 +301,10 @@ public class GiftsForYouActivity extends AppCompatActivity implements View.OnCli |
297 | } | 301 | } |
298 | } | 302 | } |
299 | } else { | 303 | } else { |
304 | + if (!WarplyManagerHelper.noInternetDialog(this, true)) { | ||
305 | + WarplyManagerHelper.noInternetDialog(this); | ||
306 | + return; | ||
307 | + } | ||
300 | WarplyAnalyticsManager.logTrackersEvent(this, "click", ("Loyalty").concat(":").concat(dataItem.getCampaign().getSessionUUID())); | 308 | WarplyAnalyticsManager.logTrackersEvent(this, "click", ("Loyalty").concat(":").concat(dataItem.getCampaign().getSessionUUID())); |
301 | startActivityForResult(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(dataItem.getCampaign())), 1004); | 309 | startActivityForResult(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(dataItem.getCampaign())), 1004); |
302 | } | 310 | } |
... | @@ -334,17 +342,29 @@ public class GiftsForYouActivity extends AppCompatActivity implements View.OnCli | ... | @@ -334,17 +342,29 @@ public class GiftsForYouActivity extends AppCompatActivity implements View.OnCli |
334 | if (extraFields.has("ccms_offer") && extraFields.optString("ccms_offer").equals("true")) { | 342 | if (extraFields.has("ccms_offer") && extraFields.optString("ccms_offer").equals("true")) { |
335 | for (LoyaltyContextualOfferModel ccms : WarplyManagerHelper.getCCMSLoyaltyCampaigns()) { | 343 | for (LoyaltyContextualOfferModel ccms : WarplyManagerHelper.getCCMSLoyaltyCampaigns()) { |
336 | if (ccms.getLoyaltyCampaignId().equals(dataItem.getCampaign().getSessionUUID())) { | 344 | if (ccms.getLoyaltyCampaignId().equals(dataItem.getCampaign().getSessionUUID())) { |
345 | + if (!WarplyManagerHelper.noInternetDialog(this, true)) { | ||
346 | + WarplyManagerHelper.noInternetDialog(this); | ||
347 | + return; | ||
348 | + } | ||
337 | WarplyAnalyticsManager.logTrackersEvent(this, "click", ("Contextual").concat(":").concat(ccms.getSessionId())); | 349 | WarplyAnalyticsManager.logTrackersEvent(this, "click", ("Contextual").concat(":").concat(ccms.getSessionId())); |
338 | startActivityForResult(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCcmsUrl(dataItem.getCampaign(), ccms)), 1004); | 350 | startActivityForResult(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCcmsUrl(dataItem.getCampaign(), ccms)), 1004); |
339 | break; | 351 | break; |
340 | } | 352 | } |
341 | } | 353 | } |
342 | } else { | 354 | } else { |
355 | + if (!WarplyManagerHelper.noInternetDialog(this, true)) { | ||
356 | + WarplyManagerHelper.noInternetDialog(this); | ||
357 | + return; | ||
358 | + } | ||
343 | WarplyAnalyticsManager.logTrackersEvent(this, "click", ("Loyalty").concat(":").concat(dataItem.getCampaign().getSessionUUID())); | 359 | WarplyAnalyticsManager.logTrackersEvent(this, "click", ("Loyalty").concat(":").concat(dataItem.getCampaign().getSessionUUID())); |
344 | startActivityForResult(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(dataItem.getCampaign())), 1004); | 360 | startActivityForResult(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(dataItem.getCampaign())), 1004); |
345 | } | 361 | } |
346 | } | 362 | } |
347 | } catch (Exception exception) { | 363 | } catch (Exception exception) { |
364 | + if (!WarplyManagerHelper.noInternetDialog(this, true)) { | ||
365 | + WarplyManagerHelper.noInternetDialog(this); | ||
366 | + return; | ||
367 | + } | ||
348 | WarplyAnalyticsManager.logTrackersEvent(this, "click", ("Loyalty").concat(":").concat(dataItem.getCampaign().getSessionUUID())); | 368 | WarplyAnalyticsManager.logTrackersEvent(this, "click", ("Loyalty").concat(":").concat(dataItem.getCampaign().getSessionUUID())); |
349 | startActivityForResult(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(dataItem.getCampaign())), 1004); | 369 | startActivityForResult(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(dataItem.getCampaign())), 1004); |
350 | } | 370 | } | ... | ... |
... | @@ -5,7 +5,6 @@ import android.content.Context; | ... | @@ -5,7 +5,6 @@ import android.content.Context; |
5 | import android.content.Intent; | 5 | import android.content.Intent; |
6 | import android.os.Bundle; | 6 | import android.os.Bundle; |
7 | import android.os.Handler; | 7 | import android.os.Handler; |
8 | -import android.os.Looper; | ||
9 | import android.text.SpannableStringBuilder; | 8 | import android.text.SpannableStringBuilder; |
10 | import android.text.Spanned; | 9 | import android.text.Spanned; |
11 | import android.text.TextUtils; | 10 | import android.text.TextUtils; |
... | @@ -41,9 +40,6 @@ import java.util.ArrayList; | ... | @@ -41,9 +40,6 @@ import java.util.ArrayList; |
41 | import java.util.Collections; | 40 | import java.util.Collections; |
42 | import java.util.Comparator; | 41 | import java.util.Comparator; |
43 | import java.util.Date; | 42 | import java.util.Date; |
44 | -import java.util.Locale; | ||
45 | -import java.util.concurrent.ExecutorService; | ||
46 | -import java.util.concurrent.Executors; | ||
47 | import java.util.concurrent.TimeUnit; | 43 | import java.util.concurrent.TimeUnit; |
48 | 44 | ||
49 | import io.github.inflationx.calligraphy3.CalligraphyTypefaceSpan; | 45 | import io.github.inflationx.calligraphy3.CalligraphyTypefaceSpan; |
... | @@ -237,6 +233,10 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener, Vie | ... | @@ -237,6 +233,10 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener, Vie |
237 | return; | 233 | return; |
238 | } | 234 | } |
239 | if (view.getId() == R.id.ll_user_questionnaire || view.getId() == R.id.ll_user_badge) { | 235 | if (view.getId() == R.id.ll_user_questionnaire || view.getId() == R.id.ll_user_badge) { |
236 | + if (!WarplyManagerHelper.noInternetDialog(this, true)) { | ||
237 | + WarplyManagerHelper.noInternetDialog(this); | ||
238 | + return; | ||
239 | + } | ||
240 | if (!mQuestionnairePressed) { | 240 | if (!mQuestionnairePressed) { |
241 | mQuestionnairePressed = true; | 241 | mQuestionnairePressed = true; |
242 | WarplyAnalyticsManager.logTrackersEvent(this, "click", ("LoyaltyWalletScreen") | 242 | WarplyAnalyticsManager.logTrackersEvent(this, "click", ("LoyaltyWalletScreen") |
... | @@ -577,6 +577,11 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener, Vie | ... | @@ -577,6 +577,11 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener, Vie |
577 | } else { | 577 | } else { |
578 | String badgeValue = String.format("%.02f", 0.0f); | 578 | String badgeValue = String.format("%.02f", 0.0f); |
579 | mTvMarketValue.setText(String.format(getString(R.string.cos_value), badgeValue)); | 579 | mTvMarketValue.setText(String.format(getString(R.string.cos_value), badgeValue)); |
580 | + SpannableStringBuilder sBuilderThird = new SpannableStringBuilder(); | ||
581 | + sBuilderThird.append(String.format(getString(R.string.cos_supermarket_win), badgeValue)); | ||
582 | + CalligraphyTypefaceSpan typefaceBoldSpanThird = new CalligraphyTypefaceSpan(TypefaceUtils.load(getAssets(), "fonts/PeridotPE-Bold.ttf")); | ||
583 | + sBuilderThird.setSpan(typefaceBoldSpanThird, 15, 16 + badgeValue.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); | ||
584 | + mTvMarketAll.setText(sBuilderThird, TextView.BufferType.SPANNABLE); | ||
580 | } | 585 | } |
581 | 586 | ||
582 | // Sum Expandable Banner | 587 | // Sum Expandable Banner | ... | ... |
... | @@ -236,6 +236,7 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener | ... | @@ -236,6 +236,7 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener |
236 | mIvPopupClose.setOnClickListener(this); | 236 | mIvPopupClose.setOnClickListener(this); |
237 | 237 | ||
238 | if (mUniqueSectionList != null) { | 238 | if (mUniqueSectionList != null) { |
239 | + if (mUniqueSectionList.size() == 1) { | ||
239 | try { | 240 | try { |
240 | String firstKey = (String) mUniqueSectionList.keySet().toArray()[0]; | 241 | String firstKey = (String) mUniqueSectionList.keySet().toArray()[0]; |
241 | if (mUniqueSectionList.get(firstKey) != null && mUniqueSectionList.get(firstKey).size() > 0) { | 242 | if (mUniqueSectionList.get(firstKey) != null && mUniqueSectionList.get(firstKey).size() > 0) { |
... | @@ -255,7 +256,9 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener | ... | @@ -255,7 +256,9 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener |
255 | } catch (IndexOutOfBoundsException ex) { | 256 | } catch (IndexOutOfBoundsException ex) { |
256 | ex.printStackTrace(); | 257 | ex.printStackTrace(); |
257 | } | 258 | } |
259 | + } | ||
258 | 260 | ||
261 | + if (mUniqueSectionList.size() == 2) { | ||
259 | try { | 262 | try { |
260 | String secondKey = (String) mUniqueSectionList.keySet().toArray()[1]; | 263 | String secondKey = (String) mUniqueSectionList.keySet().toArray()[1]; |
261 | if (mUniqueSectionList.get(secondKey) != null && mUniqueSectionList.get(secondKey).size() > 0) { | 264 | if (mUniqueSectionList.get(secondKey) != null && mUniqueSectionList.get(secondKey).size() > 0) { |
... | @@ -275,7 +278,9 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener | ... | @@ -275,7 +278,9 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener |
275 | } catch (IndexOutOfBoundsException ex) { | 278 | } catch (IndexOutOfBoundsException ex) { |
276 | ex.printStackTrace(); | 279 | ex.printStackTrace(); |
277 | } | 280 | } |
281 | + } | ||
278 | 282 | ||
283 | + if (mUniqueSectionList.size() == 3) { | ||
279 | try { | 284 | try { |
280 | String thirdKey = (String) mUniqueSectionList.keySet().toArray()[2]; | 285 | String thirdKey = (String) mUniqueSectionList.keySet().toArray()[2]; |
281 | if (mUniqueSectionList.get(thirdKey) != null && mUniqueSectionList.get(thirdKey).size() > 0) { | 286 | if (mUniqueSectionList.get(thirdKey) != null && mUniqueSectionList.get(thirdKey).size() > 0) { |
... | @@ -295,6 +300,7 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener | ... | @@ -295,6 +300,7 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener |
295 | } catch (IndexOutOfBoundsException ex) { | 300 | } catch (IndexOutOfBoundsException ex) { |
296 | ex.printStackTrace(); | 301 | ex.printStackTrace(); |
297 | } | 302 | } |
303 | + } | ||
298 | 304 | ||
299 | if (mContextualList != null && mContextualList.size() > 0) { | 305 | if (mContextualList != null && mContextualList.size() > 0) { |
300 | mTvContextualSection.setText(getString(R.string.cos_mfy_other)); | 306 | mTvContextualSection.setText(getString(R.string.cos_mfy_other)); |
... | @@ -318,6 +324,7 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener | ... | @@ -318,6 +324,7 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener |
318 | mIvPopupClose.setOnClickListener(this); | 324 | mIvPopupClose.setOnClickListener(this); |
319 | 325 | ||
320 | if (mUniqueSectionList != null) { | 326 | if (mUniqueSectionList != null) { |
327 | + if (mUniqueSectionList.size() == 1) { | ||
321 | try { | 328 | try { |
322 | String firstKey = (String) mUniqueSectionList.keySet().toArray()[0]; | 329 | String firstKey = (String) mUniqueSectionList.keySet().toArray()[0]; |
323 | if (mUniqueSectionList.get(firstKey) != null && mUniqueSectionList.get(firstKey).size() > 0) { | 330 | if (mUniqueSectionList.get(firstKey) != null && mUniqueSectionList.get(firstKey).size() > 0) { |
... | @@ -341,7 +348,9 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener | ... | @@ -341,7 +348,9 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener |
341 | } catch (IndexOutOfBoundsException ex) { | 348 | } catch (IndexOutOfBoundsException ex) { |
342 | ex.printStackTrace(); | 349 | ex.printStackTrace(); |
343 | } | 350 | } |
351 | + } | ||
344 | 352 | ||
353 | + if (mUniqueSectionList.size() == 2) { | ||
345 | try { | 354 | try { |
346 | String secondKey = (String) mUniqueSectionList.keySet().toArray()[1]; | 355 | String secondKey = (String) mUniqueSectionList.keySet().toArray()[1]; |
347 | if (mUniqueSectionList.get(secondKey) != null && mUniqueSectionList.get(secondKey).size() > 0) { | 356 | if (mUniqueSectionList.get(secondKey) != null && mUniqueSectionList.get(secondKey).size() > 0) { |
... | @@ -365,7 +374,9 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener | ... | @@ -365,7 +374,9 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener |
365 | } catch (IndexOutOfBoundsException ex) { | 374 | } catch (IndexOutOfBoundsException ex) { |
366 | ex.printStackTrace(); | 375 | ex.printStackTrace(); |
367 | } | 376 | } |
377 | + } | ||
368 | 378 | ||
379 | + if (mUniqueSectionList.size() == 3) { | ||
369 | try { | 380 | try { |
370 | String thirdKey = (String) mUniqueSectionList.keySet().toArray()[2]; | 381 | String thirdKey = (String) mUniqueSectionList.keySet().toArray()[2]; |
371 | if (mUniqueSectionList.get(thirdKey) != null && mUniqueSectionList.get(thirdKey).size() > 0) { | 382 | if (mUniqueSectionList.get(thirdKey) != null && mUniqueSectionList.get(thirdKey).size() > 0) { |
... | @@ -389,6 +400,7 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener | ... | @@ -389,6 +400,7 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener |
389 | } catch (IndexOutOfBoundsException ex) { | 400 | } catch (IndexOutOfBoundsException ex) { |
390 | ex.printStackTrace(); | 401 | ex.printStackTrace(); |
391 | } | 402 | } |
403 | + } | ||
392 | 404 | ||
393 | if (mContextualList != null && mContextualList.size() > 0) { | 405 | if (mContextualList != null && mContextualList.size() > 0) { |
394 | mTvContextualSection.setText(getString(R.string.cos_mfy_other)); | 406 | mTvContextualSection.setText(getString(R.string.cos_mfy_other)); |
... | @@ -439,6 +451,10 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener | ... | @@ -439,6 +451,10 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener |
439 | if (extraFields.has("ccms_offer") && extraFields.optString("ccms_offer").equals("true")) { | 451 | if (extraFields.has("ccms_offer") && extraFields.optString("ccms_offer").equals("true")) { |
440 | for (LoyaltyContextualOfferModel ccms : WarplyManagerHelper.getCCMSLoyaltyCampaigns()) { | 452 | for (LoyaltyContextualOfferModel ccms : WarplyManagerHelper.getCCMSLoyaltyCampaigns()) { |
441 | if (ccms.getLoyaltyCampaignId().equals(moreItem.getSessionUUID())) { | 453 | if (ccms.getLoyaltyCampaignId().equals(moreItem.getSessionUUID())) { |
454 | + if (!WarplyManagerHelper.noInternetDialog(this, true)) { | ||
455 | + WarplyManagerHelper.noInternetDialog(this); | ||
456 | + return; | ||
457 | + } | ||
442 | WarpUtils.log("CCMS_CLICK " + ccms.toString()); | 458 | WarpUtils.log("CCMS_CLICK " + ccms.toString()); |
443 | WarplyAnalyticsManager.logTrackersEvent(this, "click", ("Contextual").concat(":").concat(ccms.getSessionId())); | 459 | WarplyAnalyticsManager.logTrackersEvent(this, "click", ("Contextual").concat(":").concat(ccms.getSessionId())); |
444 | startActivityForResult(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCcmsUrl(moreItem, ccms)), 1003); | 460 | startActivityForResult(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCcmsUrl(moreItem, ccms)), 1003); |
... | @@ -446,11 +462,19 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener | ... | @@ -446,11 +462,19 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener |
446 | } | 462 | } |
447 | } | 463 | } |
448 | } else { | 464 | } else { |
465 | + if (!WarplyManagerHelper.noInternetDialog(this, true)) { | ||
466 | + WarplyManagerHelper.noInternetDialog(this); | ||
467 | + return; | ||
468 | + } | ||
449 | WarplyAnalyticsManager.logTrackersEvent(this, "click", ("Loyalty").concat(":").concat(moreItem.getSessionUUID())); | 469 | WarplyAnalyticsManager.logTrackersEvent(this, "click", ("Loyalty").concat(":").concat(moreItem.getSessionUUID())); |
450 | startActivityForResult(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(moreItem)), 1003); | 470 | startActivityForResult(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(moreItem)), 1003); |
451 | } | 471 | } |
452 | } | 472 | } |
453 | } catch (Exception exception) { | 473 | } catch (Exception exception) { |
474 | + if (!WarplyManagerHelper.noInternetDialog(this, true)) { | ||
475 | + WarplyManagerHelper.noInternetDialog(this); | ||
476 | + return; | ||
477 | + } | ||
454 | WarplyAnalyticsManager.logTrackersEvent(this, "click", ("Loyalty").concat(":").concat(moreItem.getSessionUUID())); | 478 | WarplyAnalyticsManager.logTrackersEvent(this, "click", ("Loyalty").concat(":").concat(moreItem.getSessionUUID())); |
455 | startActivityForResult(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(moreItem)), 1003); | 479 | startActivityForResult(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(moreItem)), 1003); |
456 | } | 480 | } | ... | ... |
... | @@ -6,6 +6,10 @@ import android.content.Context; | ... | @@ -6,6 +6,10 @@ import android.content.Context; |
6 | import android.content.pm.PackageInfo; | 6 | import android.content.pm.PackageInfo; |
7 | import android.content.pm.PackageManager; | 7 | import android.content.pm.PackageManager; |
8 | import android.graphics.Point; | 8 | import android.graphics.Point; |
9 | +import android.net.ConnectivityManager; | ||
10 | +import android.net.Network; | ||
11 | +import android.net.NetworkCapabilities; | ||
12 | +import android.net.NetworkInfo; | ||
9 | import android.os.Build; | 13 | import android.os.Build; |
10 | import android.provider.Settings; | 14 | import android.provider.Settings; |
11 | import android.telephony.TelephonyManager; | 15 | import android.telephony.TelephonyManager; |
... | @@ -23,11 +27,17 @@ import org.json.JSONObject; | ... | @@ -23,11 +27,17 @@ import org.json.JSONObject; |
23 | 27 | ||
24 | import java.io.IOException; | 28 | import java.io.IOException; |
25 | import java.io.UnsupportedEncodingException; | 29 | import java.io.UnsupportedEncodingException; |
30 | +import java.net.InetSocketAddress; | ||
31 | +import java.net.Socket; | ||
32 | +import java.net.SocketAddress; | ||
26 | import java.security.MessageDigest; | 33 | import java.security.MessageDigest; |
27 | import java.security.NoSuchAlgorithmException; | 34 | import java.security.NoSuchAlgorithmException; |
28 | import java.util.Arrays; | 35 | import java.util.Arrays; |
29 | import java.util.List; | 36 | import java.util.List; |
30 | 37 | ||
38 | +import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers; | ||
39 | +import io.reactivex.rxjava3.core.Single; | ||
40 | +import io.reactivex.rxjava3.schedulers.Schedulers; | ||
31 | import ly.warp.sdk.io.callbacks.SimpleCallbackReceiver; | 41 | import ly.warp.sdk.io.callbacks.SimpleCallbackReceiver; |
32 | import ly.warp.sdk.utils.constants.WarpConstants; | 42 | import ly.warp.sdk.utils.constants.WarpConstants; |
33 | 43 | ||
... | @@ -396,6 +406,57 @@ public class WarplyDeviceInfoCollector { | ... | @@ -396,6 +406,57 @@ public class WarplyDeviceInfoCollector { |
396 | } | 406 | } |
397 | } | 407 | } |
398 | 408 | ||
409 | + public static boolean isOnline() { | ||
410 | + try { | ||
411 | + int timeoutMs = 1500; | ||
412 | + Socket sock = new Socket(); | ||
413 | + SocketAddress sockaddr = new InetSocketAddress("8.8.8.8", 53); | ||
414 | + sock.connect(sockaddr, timeoutMs); | ||
415 | + sock.close(); | ||
416 | + | ||
417 | + return true; | ||
418 | + } catch (IOException e) { | ||
419 | + return false; | ||
420 | + } | ||
421 | + } | ||
422 | + | ||
423 | + public static Single<Boolean> hasInternetConnection() { | ||
424 | + return Single.fromCallable(() -> { | ||
425 | + try { | ||
426 | + // Connect to Google DNS to check for connection | ||
427 | + int timeoutMs = 1500; | ||
428 | + Socket socket = new Socket(); | ||
429 | + InetSocketAddress socketAddress = new InetSocketAddress("8.8.8.8", 53); | ||
430 | + | ||
431 | + socket.connect(socketAddress, timeoutMs); | ||
432 | + socket.close(); | ||
433 | + | ||
434 | + return true; | ||
435 | + } catch (IOException e) { | ||
436 | + return false; | ||
437 | + } | ||
438 | + }).subscribeOn(Schedulers.io()) | ||
439 | + .observeOn(AndroidSchedulers.mainThread()); | ||
440 | + } | ||
441 | + | ||
442 | + public static boolean isNetworkAvailable(Context context) { | ||
443 | + ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); | ||
444 | + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { | ||
445 | + Network nw = connectivityManager.getActiveNetwork(); | ||
446 | + if (nw == null) return false; | ||
447 | + NetworkCapabilities actNw = connectivityManager.getNetworkCapabilities(nw); | ||
448 | + return actNw != null && | ||
449 | + (actNw.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) || | ||
450 | + actNw.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) || | ||
451 | + actNw.hasTransport(NetworkCapabilities.TRANSPORT_WIFI_AWARE)) /*&& | ||
452 | + (actNw.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) && | ||
453 | + actNw.hasCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED))*/; | ||
454 | + } else { | ||
455 | + NetworkInfo nwInfo = connectivityManager.getActiveNetworkInfo(); | ||
456 | + return nwInfo != null && nwInfo.isConnected(); | ||
457 | + } | ||
458 | + } | ||
459 | + | ||
399 | // =========================================================== | 460 | // =========================================================== |
400 | // Inner and Anonymous Classes | 461 | // Inner and Anonymous Classes |
401 | // =========================================================== | 462 | // =========================================================== | ... | ... |
... | @@ -25,6 +25,7 @@ | ... | @@ -25,6 +25,7 @@ |
25 | 25 | ||
26 | package ly.warp.sdk.utils; | 26 | package ly.warp.sdk.utils; |
27 | 27 | ||
28 | +import android.app.Activity; | ||
28 | import android.app.ActivityManager; | 29 | import android.app.ActivityManager; |
29 | import android.content.Context; | 30 | import android.content.Context; |
30 | import android.content.Intent; | 31 | import android.content.Intent; |
... | @@ -122,8 +123,9 @@ public class WarplyManagerHelper { | ... | @@ -122,8 +123,9 @@ public class WarplyManagerHelper { |
122 | private static ArrayList<ActiveDFYCouponModel> mDfyCoupons = new ArrayList(); | 123 | private static ArrayList<ActiveDFYCouponModel> mDfyCoupons = new ArrayList(); |
123 | private static ArrayList<LoyaltyGiftsForYouPackage> mSeasonalList = new ArrayList<>(); | 124 | private static ArrayList<LoyaltyGiftsForYouPackage> mSeasonalList = new ArrayList<>(); |
124 | private static ArrayList<LoyaltyContextualOfferModel> mCCMSList = new ArrayList<>(); | 125 | private static ArrayList<LoyaltyContextualOfferModel> mCCMSList = new ArrayList<>(); |
125 | - private static AlertDialog mAlertDialogSharing, mAlertDialogAcceptSharing, mAlertDialogRejectSharing, | 126 | + private static AlertDialog mAlertDialogSharing, mAlertDialogAcceptSharing, |
126 | - mAlertDialogReturnSharing, mAlertDialogErrorSharing, mAlertDialogErrorUsedSharing, mAlertDialogErrorExpiredSharing; | 127 | + mAlertDialogRejectSharing, mAlertDialogReturnSharing, mAlertDialogErrorSharing, |
128 | + mAlertDialogErrorUsedSharing, mAlertDialogErrorExpiredSharing, mAlertDialogNoInternet; | ||
127 | private static LoyaltyBadgeModel mLoyaltyBadge = new LoyaltyBadgeModel(); | 129 | private static LoyaltyBadgeModel mLoyaltyBadge = new LoyaltyBadgeModel(); |
128 | private static float mDealsSum = 0.0f; | 130 | private static float mDealsSum = 0.0f; |
129 | private static MerchantList mMerchantList = new MerchantList(); | 131 | private static MerchantList mMerchantList = new MerchantList(); |
... | @@ -456,6 +458,37 @@ public class WarplyManagerHelper { | ... | @@ -456,6 +458,37 @@ public class WarplyManagerHelper { |
456 | } | 458 | } |
457 | 459 | ||
458 | /** | 460 | /** |
461 | + * No Internet Connection Dialog | ||
462 | + */ | ||
463 | + public static void noInternetDialog(Activity context) { | ||
464 | + if (!context.isFinishing()) { | ||
465 | + mAlertDialogNoInternet = new AlertDialog.Builder(context) | ||
466 | + .setTitle(R.string.cos_dlg_no_internet_title) | ||
467 | + .setMessage(R.string.cos_dlg_no_internet_subtitle) | ||
468 | + .setPositiveButton(R.string.cos_dlg_positive_button2, (dialogPositive, whichPositive) -> { | ||
469 | + dialogPositive.dismiss(); | ||
470 | + }) | ||
471 | + .show(); | ||
472 | + } | ||
473 | + } | ||
474 | + | ||
475 | + public static boolean noInternetDialog(Context context, boolean check) { | ||
476 | + final boolean[] hasInternetConnection = {true}; | ||
477 | + if (WarplyDeviceInfoCollector.isNetworkAvailable(context)) { | ||
478 | + WarplyDeviceInfoCollector.hasInternetConnection() | ||
479 | + .subscribe((hasInternet) -> { | ||
480 | + if (!hasInternet) { | ||
481 | + hasInternetConnection[0] = false; | ||
482 | + } | ||
483 | + }); | ||
484 | + } else { | ||
485 | + hasInternetConnection[0] = false; | ||
486 | + } | ||
487 | + | ||
488 | + return hasInternetConnection[0]; | ||
489 | + } | ||
490 | + | ||
491 | + /** | ||
459 | * Open CCMS campaign | 492 | * Open CCMS campaign |
460 | */ | 493 | */ |
461 | public static String constructCcmsUrl(Campaign item, LoyaltyContextualOfferModel ccmsItem) { | 494 | public static String constructCcmsUrl(Campaign item, LoyaltyContextualOfferModel ccmsItem) { |
... | @@ -755,6 +788,10 @@ public class WarplyManagerHelper { | ... | @@ -755,6 +788,10 @@ public class WarplyManagerHelper { |
755 | e.printStackTrace(); | 788 | e.printStackTrace(); |
756 | } | 789 | } |
757 | 790 | ||
791 | + if (!WarplyManagerHelper.noInternetDialog(context, true)) { | ||
792 | + WarplyManagerHelper.noInternetDialog((Activity) context); | ||
793 | + return; | ||
794 | + } | ||
758 | WarpUtils.setWebviewParams(Warply.getWarplyContext(), params); | 795 | WarpUtils.setWebviewParams(Warply.getWarplyContext(), params); |
759 | WarplyAnalyticsManager.logTrackersEvent(context, "click", ("Contextual").concat(":").concat(item.getSessionId())); | 796 | WarplyAnalyticsManager.logTrackersEvent(context, "click", ("Contextual").concat(":").concat(item.getSessionId())); |
760 | context.startActivity(WarpViewActivity.createIntentFromURL(context, url)); | 797 | context.startActivity(WarpViewActivity.createIntentFromURL(context, url)); |
... | @@ -823,6 +860,10 @@ public class WarplyManagerHelper { | ... | @@ -823,6 +860,10 @@ public class WarplyManagerHelper { |
823 | } | 860 | } |
824 | } | 861 | } |
825 | } else { | 862 | } else { |
863 | + if (!WarplyManagerHelper.noInternetDialog(context, true)) { | ||
864 | + WarplyManagerHelper.noInternetDialog((Activity) context); | ||
865 | + return; | ||
866 | + } | ||
826 | WarplyAnalyticsManager.logTrackersEvent(context, "click", ("Loyalty").concat(":").concat(item.getSessionUUID())); | 867 | WarplyAnalyticsManager.logTrackersEvent(context, "click", ("Loyalty").concat(":").concat(item.getSessionUUID())); |
827 | context.startActivity(WarpViewActivity.createIntentFromURL(context, WarplyManagerHelper.constructCampaignUrl(item))); | 868 | context.startActivity(WarpViewActivity.createIntentFromURL(context, WarplyManagerHelper.constructCampaignUrl(item))); |
828 | } | 869 | } |
... | @@ -858,6 +899,10 @@ public class WarplyManagerHelper { | ... | @@ -858,6 +899,10 @@ public class WarplyManagerHelper { |
858 | } | 899 | } |
859 | } | 900 | } |
860 | } else { | 901 | } else { |
902 | + if (!WarplyManagerHelper.noInternetDialog(context, true)) { | ||
903 | + WarplyManagerHelper.noInternetDialog((Activity) context); | ||
904 | + return; | ||
905 | + } | ||
861 | WarplyAnalyticsManager.logTrackersEvent(context, "click", ("Loyalty").concat(":").concat(item.getSessionUUID())); | 906 | WarplyAnalyticsManager.logTrackersEvent(context, "click", ("Loyalty").concat(":").concat(item.getSessionUUID())); |
862 | context.startActivity(WarpViewActivity.createIntentFromURL(context, WarplyManagerHelper.constructCampaignUrl(item))); | 907 | context.startActivity(WarpViewActivity.createIntentFromURL(context, WarplyManagerHelper.constructCampaignUrl(item))); |
863 | } | 908 | } |
... | @@ -869,6 +914,10 @@ public class WarplyManagerHelper { | ... | @@ -869,6 +914,10 @@ public class WarplyManagerHelper { |
869 | return; | 914 | return; |
870 | } | 915 | } |
871 | 916 | ||
917 | + if (!WarplyManagerHelper.noInternetDialog(context, true)) { | ||
918 | + WarplyManagerHelper.noInternetDialog((Activity) context); | ||
919 | + return; | ||
920 | + } | ||
872 | WarplyAnalyticsManager.logTrackersEvent(context, "click", ("Loyalty").concat(":").concat(item.getSessionUUID())); | 921 | WarplyAnalyticsManager.logTrackersEvent(context, "click", ("Loyalty").concat(":").concat(item.getSessionUUID())); |
873 | context.startActivity(WarpViewActivity.createIntentFromURL(context, WarplyManagerHelper.constructCampaignUrl(item))); | 922 | context.startActivity(WarpViewActivity.createIntentFromURL(context, WarplyManagerHelper.constructCampaignUrl(item))); |
874 | } | 923 | } | ... | ... |
... | @@ -3134,6 +3134,7 @@ public class WarplyManager { | ... | @@ -3134,6 +3134,7 @@ public class WarplyManager { |
3134 | 3134 | ||
3135 | @Override | 3135 | @Override |
3136 | public void onFailure(int errorCode) { | 3136 | public void onFailure(int errorCode) { |
3137 | + if (errorCode == 301 || errorCode == 302 || errorCode == 307 || errorCode == 308) { | ||
3137 | LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); | 3138 | LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); |
3138 | dynatraceEvent.setEventName("custom_success_read_campaign_loyalty"); | 3139 | dynatraceEvent.setEventName("custom_success_read_campaign_loyalty"); |
3139 | EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent)); | 3140 | EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent)); |
... | @@ -3151,6 +3152,7 @@ public class WarplyManager { | ... | @@ -3151,6 +3152,7 @@ public class WarplyManager { |
3151 | } | 3152 | } |
3152 | }); | 3153 | }); |
3153 | } | 3154 | } |
3155 | + } | ||
3154 | }, null); | 3156 | }, null); |
3155 | } | 3157 | } |
3156 | 3158 | ... | ... |
... | @@ -179,6 +179,8 @@ | ... | @@ -179,6 +179,8 @@ |
179 | <string name="cos_telematics">Telematics Demo</string> | 179 | <string name="cos_telematics">Telematics Demo</string> |
180 | <string name="cos_dlg_start_trip">Start Trip</string> | 180 | <string name="cos_dlg_start_trip">Start Trip</string> |
181 | <string name="cos_dlg_stop_trip">Stop Trip</string> | 181 | <string name="cos_dlg_stop_trip">Stop Trip</string> |
182 | + <string name="cos_dlg_no_internet_title">Δεν υπάρχει σύνδεση</string> | ||
183 | + <string name="cos_dlg_no_internet_subtitle">Αυτή τη στιγμή βρίσκεσαι εκτός σύνδεσης. Παρακαλούμε βεβαιώσου ότι είσαι συνδεδεμένος στο διαδίκτυο και προσπάθησε ξανά.</string> | ||
182 | 184 | ||
183 | <string-array name="coupons_array"> | 185 | <string-array name="coupons_array"> |
184 | <item>Κουπόνια</item> | 186 | <item>Κουπόνια</item> | ... | ... |
-
Please register or login to post a comment