Panagiotis Triantafyllou

feedback fixes

...@@ -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,64 +236,70 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener ...@@ -236,64 +236,70 @@ 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 - try { 239 + if (mUniqueSectionList.size() == 1) {
240 - String firstKey = (String) mUniqueSectionList.keySet().toArray()[0]; 240 + try {
241 - if (mUniqueSectionList.get(firstKey) != null && mUniqueSectionList.get(firstKey).size() > 0) { 241 + String firstKey = (String) mUniqueSectionList.keySet().toArray()[0];
242 - mTvResearchSection.setText(firstKey.substring(1)); 242 + if (mUniqueSectionList.get(firstKey) != null && mUniqueSectionList.get(firstKey).size() > 0) {
243 - mResearchItems.setNestedScrollingEnabled(false); 243 + mTvResearchSection.setText(firstKey.substring(1));
244 - mResearchItems.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false)); 244 + mResearchItems.setNestedScrollingEnabled(false);
245 - mAdapterResearch = new MoreCampaignAdapter(this, mUniqueSectionList.get(firstKey)); 245 + mResearchItems.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
246 - mResearchItems.setAdapter(mAdapterResearch); 246 + mAdapterResearch = new MoreCampaignAdapter(this, mUniqueSectionList.get(firstKey));
247 - mAdapterResearch.getPositionClicks() 247 + mResearchItems.setAdapter(mAdapterResearch);
248 - .doOnNext(this::handleMoreItemClick) 248 + mAdapterResearch.getPositionClicks()
249 - .doOnError(error -> { 249 + .doOnNext(this::handleMoreItemClick)
250 - }) 250 + .doOnError(error -> {
251 - .subscribe(); 251 + })
252 - 252 + .subscribe();
253 - mLlResearchItems.setVisibility(View.VISIBLE); 253 +
254 + mLlResearchItems.setVisibility(View.VISIBLE);
255 + }
256 + } catch (IndexOutOfBoundsException ex) {
257 + ex.printStackTrace();
254 } 258 }
255 - } catch (IndexOutOfBoundsException ex) {
256 - ex.printStackTrace();
257 } 259 }
258 260
259 - try { 261 + if (mUniqueSectionList.size() == 2) {
260 - String secondKey = (String) mUniqueSectionList.keySet().toArray()[1]; 262 + try {
261 - if (mUniqueSectionList.get(secondKey) != null && mUniqueSectionList.get(secondKey).size() > 0) { 263 + String secondKey = (String) mUniqueSectionList.keySet().toArray()[1];
262 - mTvExclusiveSection.setText(secondKey.substring(1)); 264 + if (mUniqueSectionList.get(secondKey) != null && mUniqueSectionList.get(secondKey).size() > 0) {
263 - mExclusiveItems.setNestedScrollingEnabled(false); 265 + mTvExclusiveSection.setText(secondKey.substring(1));
264 - mExclusiveItems.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false)); 266 + mExclusiveItems.setNestedScrollingEnabled(false);
265 - mAdapterExclusive = new MoreCampaignAdapter(this, mUniqueSectionList.get(secondKey)); 267 + mExclusiveItems.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
266 - mExclusiveItems.setAdapter(mAdapterExclusive); 268 + mAdapterExclusive = new MoreCampaignAdapter(this, mUniqueSectionList.get(secondKey));
267 - mAdapterExclusive.getPositionClicks() 269 + mExclusiveItems.setAdapter(mAdapterExclusive);
268 - .doOnNext(this::handleMoreItemClick) 270 + mAdapterExclusive.getPositionClicks()
269 - .doOnError(error -> { 271 + .doOnNext(this::handleMoreItemClick)
270 - }) 272 + .doOnError(error -> {
271 - .subscribe(); 273 + })
272 - 274 + .subscribe();
273 - mLlExclusiveItems.setVisibility(View.VISIBLE); 275 +
276 + mLlExclusiveItems.setVisibility(View.VISIBLE);
277 + }
278 + } catch (IndexOutOfBoundsException ex) {
279 + ex.printStackTrace();
274 } 280 }
275 - } catch (IndexOutOfBoundsException ex) {
276 - ex.printStackTrace();
277 } 281 }
278 282
279 - try { 283 + if (mUniqueSectionList.size() == 3) {
280 - String thirdKey = (String) mUniqueSectionList.keySet().toArray()[2]; 284 + try {
281 - if (mUniqueSectionList.get(thirdKey) != null && mUniqueSectionList.get(thirdKey).size() > 0) { 285 + String thirdKey = (String) mUniqueSectionList.keySet().toArray()[2];
282 - mTvContestSection.setText(thirdKey.substring(1)); 286 + if (mUniqueSectionList.get(thirdKey) != null && mUniqueSectionList.get(thirdKey).size() > 0) {
283 - mContestItems.setNestedScrollingEnabled(false); 287 + mTvContestSection.setText(thirdKey.substring(1));
284 - mContestItems.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false)); 288 + mContestItems.setNestedScrollingEnabled(false);
285 - mAdapterContest = new MoreCampaignAdapter(this, mUniqueSectionList.get(thirdKey)); 289 + mContestItems.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
286 - mContestItems.setAdapter(mAdapterContest); 290 + mAdapterContest = new MoreCampaignAdapter(this, mUniqueSectionList.get(thirdKey));
287 - mAdapterContest.getPositionClicks() 291 + mContestItems.setAdapter(mAdapterContest);
288 - .doOnNext(this::handleMoreItemClick) 292 + mAdapterContest.getPositionClicks()
289 - .doOnError(error -> { 293 + .doOnNext(this::handleMoreItemClick)
290 - }) 294 + .doOnError(error -> {
291 - .subscribe(); 295 + })
292 - 296 + .subscribe();
293 - mLlContestItems.setVisibility(View.VISIBLE); 297 +
298 + mLlContestItems.setVisibility(View.VISIBLE);
299 + }
300 + } catch (IndexOutOfBoundsException ex) {
301 + ex.printStackTrace();
294 } 302 }
295 - } catch (IndexOutOfBoundsException ex) {
296 - ex.printStackTrace();
297 } 303 }
298 304
299 if (mContextualList != null && mContextualList.size() > 0) { 305 if (mContextualList != null && mContextualList.size() > 0) {
...@@ -318,10 +324,11 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener ...@@ -318,10 +324,11 @@ 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) {
321 - try { 327 + if (mUniqueSectionList.size() == 1) {
322 - String firstKey = (String) mUniqueSectionList.keySet().toArray()[0]; 328 + try {
323 - if (mUniqueSectionList.get(firstKey) != null && mUniqueSectionList.get(firstKey).size() > 0) { 329 + String firstKey = (String) mUniqueSectionList.keySet().toArray()[0];
324 - mTvResearchSection.setText(firstKey.substring(1)); 330 + if (mUniqueSectionList.get(firstKey) != null && mUniqueSectionList.get(firstKey).size() > 0) {
331 + mTvResearchSection.setText(firstKey.substring(1));
325 // mResearchItems.setNestedScrollingEnabled(false); 332 // mResearchItems.setNestedScrollingEnabled(false);
326 // mAdapterResearch = new MoreCampaignAdapter(this, mUniqueSectionList.get(firstKey)); 333 // mAdapterResearch = new MoreCampaignAdapter(this, mUniqueSectionList.get(firstKey));
327 // mResearchItems.setItemAnimator(null); 334 // mResearchItems.setItemAnimator(null);
...@@ -334,18 +341,20 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener ...@@ -334,18 +341,20 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener
334 // .subscribe(); 341 // .subscribe();
335 // mAdapterResearch.notifyDataSetChanged(); 342 // mAdapterResearch.notifyDataSetChanged();
336 343
337 - mAdapterResearch.updateData(mUniqueSectionList.get(firstKey)); 344 + mAdapterResearch.updateData(mUniqueSectionList.get(firstKey));
338 345
339 - mLlResearchItems.setVisibility(View.VISIBLE); 346 + mLlResearchItems.setVisibility(View.VISIBLE);
347 + }
348 + } catch (IndexOutOfBoundsException ex) {
349 + ex.printStackTrace();
340 } 350 }
341 - } catch (IndexOutOfBoundsException ex) {
342 - ex.printStackTrace();
343 } 351 }
344 352
345 - try { 353 + if (mUniqueSectionList.size() == 2) {
346 - String secondKey = (String) mUniqueSectionList.keySet().toArray()[1]; 354 + try {
347 - if (mUniqueSectionList.get(secondKey) != null && mUniqueSectionList.get(secondKey).size() > 0) { 355 + String secondKey = (String) mUniqueSectionList.keySet().toArray()[1];
348 - mTvExclusiveSection.setText(secondKey.substring(1)); 356 + if (mUniqueSectionList.get(secondKey) != null && mUniqueSectionList.get(secondKey).size() > 0) {
357 + mTvExclusiveSection.setText(secondKey.substring(1));
349 // mExclusiveItems.setNestedScrollingEnabled(false); 358 // mExclusiveItems.setNestedScrollingEnabled(false);
350 // mAdapterExclusive = new MoreCampaignAdapter(this, mUniqueSectionList.get(secondKey)); 359 // mAdapterExclusive = new MoreCampaignAdapter(this, mUniqueSectionList.get(secondKey));
351 // mExclusiveItems.setItemAnimator(null); 360 // mExclusiveItems.setItemAnimator(null);
...@@ -358,18 +367,20 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener ...@@ -358,18 +367,20 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener
358 // .subscribe(); 367 // .subscribe();
359 // mAdapterExclusive.notifyDataSetChanged(); 368 // mAdapterExclusive.notifyDataSetChanged();
360 369
361 - mAdapterExclusive.updateData(mUniqueSectionList.get(secondKey)); 370 + mAdapterExclusive.updateData(mUniqueSectionList.get(secondKey));
362 371
363 - mLlExclusiveItems.setVisibility(View.VISIBLE); 372 + mLlExclusiveItems.setVisibility(View.VISIBLE);
373 + }
374 + } catch (IndexOutOfBoundsException ex) {
375 + ex.printStackTrace();
364 } 376 }
365 - } catch (IndexOutOfBoundsException ex) {
366 - ex.printStackTrace();
367 } 377 }
368 378
369 - try { 379 + if (mUniqueSectionList.size() == 3) {
370 - String thirdKey = (String) mUniqueSectionList.keySet().toArray()[2]; 380 + try {
371 - if (mUniqueSectionList.get(thirdKey) != null && mUniqueSectionList.get(thirdKey).size() > 0) { 381 + String thirdKey = (String) mUniqueSectionList.keySet().toArray()[2];
372 - mTvContestSection.setText(thirdKey.substring(1)); 382 + if (mUniqueSectionList.get(thirdKey) != null && mUniqueSectionList.get(thirdKey).size() > 0) {
383 + mTvContestSection.setText(thirdKey.substring(1));
373 // mContestItems.setNestedScrollingEnabled(false); 384 // mContestItems.setNestedScrollingEnabled(false);
374 // mAdapterContest = new MoreCampaignAdapter(this, mUniqueSectionList.get(thirdKey)); 385 // mAdapterContest = new MoreCampaignAdapter(this, mUniqueSectionList.get(thirdKey));
375 // mContestItems.setItemAnimator(null); 386 // mContestItems.setItemAnimator(null);
...@@ -382,12 +393,13 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener ...@@ -382,12 +393,13 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener
382 // .subscribe(); 393 // .subscribe();
383 // mAdapterContest.notifyDataSetChanged(); 394 // mAdapterContest.notifyDataSetChanged();
384 395
385 - mAdapterContest.updateData(mUniqueSectionList.get(thirdKey)); 396 + mAdapterContest.updateData(mUniqueSectionList.get(thirdKey));
386 397
387 - mLlContestItems.setVisibility(View.VISIBLE); 398 + mLlContestItems.setVisibility(View.VISIBLE);
399 + }
400 + } catch (IndexOutOfBoundsException ex) {
401 + ex.printStackTrace();
388 } 402 }
389 - } catch (IndexOutOfBoundsException ex) {
390 - ex.printStackTrace();
391 } 403 }
392 404
393 if (mContextualList != null && mContextualList.size() > 0) { 405 if (mContextualList != null && mContextualList.size() > 0) {
...@@ -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,22 +3134,24 @@ public class WarplyManager { ...@@ -3134,22 +3134,24 @@ public class WarplyManager {
3134 3134
3135 @Override 3135 @Override
3136 public void onFailure(int errorCode) { 3136 public void onFailure(int errorCode) {
3137 - LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); 3137 + if (errorCode == 301 || errorCode == 302 || errorCode == 307 || errorCode == 308) {
3138 - dynatraceEvent.setEventName("custom_success_read_campaign_loyalty"); 3138 + LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel();
3139 - EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent)); 3139 + dynatraceEvent.setEventName("custom_success_read_campaign_loyalty");
3140 + EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent));
3140 3141
3141 - getCampaigns(new WarplyGetCampaignsRequest().setLanguage("en"), new CallbackReceiver<ArrayList<Campaign>>() { 3142 + getCampaigns(new WarplyGetCampaignsRequest().setLanguage("en"), new CallbackReceiver<ArrayList<Campaign>>() {
3142 - @Override 3143 + @Override
3143 - public void onSuccess(ArrayList<Campaign> result) { 3144 + public void onSuccess(ArrayList<Campaign> result) {
3144 - OneTimeWorkRequest mywork = new OneTimeWorkRequest.Builder(EventCampaignService.class).build(); 3145 + OneTimeWorkRequest mywork = new OneTimeWorkRequest.Builder(EventCampaignService.class).build();
3145 - WorkManager.getInstance(Warply.getWarplyContext()).enqueue(mywork); 3146 + WorkManager.getInstance(Warply.getWarplyContext()).enqueue(mywork);
3146 - } 3147 + }
3147 3148
3148 - @Override 3149 + @Override
3149 - public void onFailure(int errorCode) { 3150 + public void onFailure(int errorCode) {
3150 3151
3151 - } 3152 + }
3152 - }); 3153 + });
3154 + }
3153 } 3155 }
3154 }, null); 3156 }, null);
3155 } 3157 }
......
...@@ -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>
......