Panagiotis Triantafyllou

supermarket fixes

1 -<?xml version="1.0" encoding="UTF-8"?>
2 <project version="4"> 1 <project version="4">
3 <component name="DesignSurface"> 2 <component name="DesignSurface">
4 <option name="filePathToZoomLevelMap"> 3 <option name="filePathToZoomLevelMap">
......
...@@ -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.6rc58' 5 + PUBLISH_VERSION = '4.5.4.6rc59'
6 PUBLISH_ARTIFACT_ID = 'warply-android-sdk' 6 PUBLISH_ARTIFACT_ID = 'warply-android-sdk'
7 } 7 }
8 8
...@@ -107,6 +107,9 @@ dependencies { ...@@ -107,6 +107,9 @@ dependencies {
107 107
108 //------------------------------ Expandable Layout -----------------------------// 108 //------------------------------ Expandable Layout -----------------------------//
109 api 'net.cachapa.expandablelayout:expandablelayout:2.9.2' 109 api 'net.cachapa.expandablelayout:expandablelayout:2.9.2'
110 +
111 + //------------------------------ Lifecycle -----------------------------//
112 + implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
110 } 113 }
111 114
112 // In every export please update the version number 115 // In every export please update the version number
......
...@@ -54,7 +54,7 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener ...@@ -54,7 +54,7 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener
54 54
55 private ImageView mIvBack, mIvCouponPhoto, mIvBarcode; 55 private ImageView mIvBack, mIvCouponPhoto, mIvBarcode;
56 private TextView mTvTerms, mTvCouponCode, mTvCouponTitle, mTvCouponSubtitle, mTvCouponDate, 56 private TextView mTvTerms, mTvCouponCode, mTvCouponTitle, mTvCouponSubtitle, mTvCouponDate,
57 - mTvTermsValue, mTvFullBarcode, mTvDescription; 57 + mTvTermsValue, mTvFullBarcode, mTvDescription, mTvCouponCodeTitle;
58 private LinearLayout mLlGiftIt, mLlShops, mLlBarcodeShown, mLlBarcodeContainer, mLlTerms, mLlWebsite; 58 private LinearLayout mLlGiftIt, mLlShops, mLlBarcodeShown, mLlBarcodeContainer, mLlTerms, mLlWebsite;
59 private Coupon mCoupon; 59 private Coupon mCoupon;
60 private Couponset mCouponset; 60 private Couponset mCouponset;
...@@ -90,6 +90,7 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener ...@@ -90,6 +90,7 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener
90 mTvTermsValue = findViewById(R.id.tv_terms_value); 90 mTvTermsValue = findViewById(R.id.tv_terms_value);
91 mTvFullBarcode = findViewById(R.id.tv_full_barcode); 91 mTvFullBarcode = findViewById(R.id.tv_full_barcode);
92 mTvDescription = findViewById(R.id.tv_clickable_link); 92 mTvDescription = findViewById(R.id.tv_clickable_link);
93 + mTvCouponCodeTitle = findViewById(R.id.textView15);
93 94
94 initViews(); 95 initViews();
95 } 96 }
...@@ -199,6 +200,10 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener ...@@ -199,6 +200,10 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener
199 // =========================================================== 200 // ===========================================================
200 201
201 private void initViews() { 202 private void initViews() {
203 + if (mIsFromWallet) {
204 + mTvCouponCodeTitle.setVisibility(View.GONE);
205 + mTvCouponCode.setVisibility(View.GONE);
206 + }
202 mLlBarcodeShown.setVisibility(View.GONE); 207 mLlBarcodeShown.setVisibility(View.GONE);
203 mLlBarcodeContainer.setVisibility(View.GONE); 208 mLlBarcodeContainer.setVisibility(View.GONE);
204 mIvBarcode.setVisibility(View.GONE); 209 mIvBarcode.setVisibility(View.GONE);
...@@ -245,6 +250,37 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener ...@@ -245,6 +250,37 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener
245 mTvCouponSubtitle.setText(mCouponset.getShortDescription()); 250 mTvCouponSubtitle.setText(mCouponset.getShortDescription());
246 mTvTermsValue.setText(HtmlCompat.fromHtml(mCouponset.getTerms(), HtmlCompat.FROM_HTML_MODE_COMPACT)); 251 mTvTermsValue.setText(HtmlCompat.fromHtml(mCouponset.getTerms(), HtmlCompat.FROM_HTML_MODE_COMPACT));
247 mTvTermsValue.setMovementMethod(LinkMovementMethod.getInstance()); 252 mTvTermsValue.setMovementMethod(LinkMovementMethod.getInstance());
253 + } else {
254 + if (mIsFromWallet) {
255 + if (WarplyManagerHelper.getMerchantList() != null && WarplyManagerHelper.getMerchantList().size() > 0) {
256 + for (Merchant merchant : WarplyManagerHelper.getMerchantList()) {
257 + if (merchant.getUuid().equals(mCoupon.getMerchantUuid())) {
258 + mMerchant = merchant;
259 + break;
260 + }
261 + }
262 +
263 + if (mMerchant != null && !TextUtils.isEmpty(mMerchant.getBody()) && !mMerchant.getBody().equals("null")) {
264 + mTvDescription.setText(HtmlCompat.fromHtml(mMerchant.getBody(), HtmlCompat.FROM_HTML_MODE_COMPACT));
265 + mTvDescription.setMovementMethod(LinkMovementMethod.getInstance());
266 + } else {
267 + mTvDescription.setVisibility(View.GONE);
268 + }
269 +
270 +// if (mMerchant != null) {
271 +// if (mMerchant.getExtraFields() != null && mMerchant.getExtraFields().has("show_map") && (mMerchant.getExtraFields().optBoolean("show_map") || mMerchant.getExtraFields().optString("show_map").equals("true"))) {
272 + mLlShops.setVisibility(View.VISIBLE);
273 +// }
274 +// if (mMerchant.getExtraFields() != null && mMerchant.getExtraFields().has("eshop") && (mMerchant.getExtraFields().optBoolean("eshop") || mMerchant.getExtraFields().optString("eshop").equals("true"))) {
275 +// mLlWebsite.setVisibility(View.VISIBLE);
276 +// }
277 +// }
278 + }
279 +
280 + mTvCouponSubtitle.setText(mCoupon.getShort_description());
281 + mTvTermsValue.setText(HtmlCompat.fromHtml(mCoupon.getTerms(), HtmlCompat.FROM_HTML_MODE_COMPACT));
282 + mTvTermsValue.setMovementMethod(LinkMovementMethod.getInstance());
283 + }
248 } 284 }
249 285
250 SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm"); 286 SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm");
......
...@@ -21,6 +21,7 @@ import com.google.zxing.BarcodeFormat; ...@@ -21,6 +21,7 @@ import com.google.zxing.BarcodeFormat;
21 import com.google.zxing.common.BitMatrix; 21 import com.google.zxing.common.BitMatrix;
22 import com.google.zxing.oned.EAN13Writer; 22 import com.google.zxing.oned.EAN13Writer;
23 23
24 +import java.io.Serializable;
24 import java.text.ParseException; 25 import java.text.ParseException;
25 import java.text.SimpleDateFormat; 26 import java.text.SimpleDateFormat;
26 import java.util.Collections; 27 import java.util.Collections;
...@@ -202,11 +203,11 @@ public class UnifiedCouponInfoActivity extends Activity implements View.OnClickL ...@@ -202,11 +203,11 @@ public class UnifiedCouponInfoActivity extends Activity implements View.OnClickL
202 mRecyclerCoupons.setAdapter(mAdapterCoupons); 203 mRecyclerCoupons.setAdapter(mAdapterCoupons);
203 mAdapterCoupons.getPositionClicks() 204 mAdapterCoupons.getPositionClicks()
204 .doOnNext(coupon -> { 205 .doOnNext(coupon -> {
205 -// WarplyAnalyticsManager.logTrackersEvent(this, "click", ("MarketCoupon").concat(":").concat(coupon.getName())); 206 + WarplyAnalyticsManager.logTrackersEvent(this, "click", ("MarketCoupon").concat(":").concat(coupon.getName()));
206 -// Intent intent = new Intent(UnifiedCouponInfoActivity.this, CouponInfoActivity.class); 207 + Intent intent = new Intent(UnifiedCouponInfoActivity.this, CouponInfoActivity.class);
207 -// intent.putExtra("coupon", (Serializable) coupon); 208 + intent.putExtra("coupon", (Serializable) coupon);
208 -// intent.putExtra("isFromWallet", true); 209 + intent.putExtra("isFromWallet", true);
209 -// startActivityForResult(intent, 1002); 210 + startActivity(intent);
210 }) 211 })
211 .doOnError(error -> { 212 .doOnError(error -> {
212 }) 213 })
......
...@@ -30,6 +30,7 @@ import static ly.warp.sdk.utils.constants.WarpConstants.RANDOM_MIN; ...@@ -30,6 +30,7 @@ import static ly.warp.sdk.utils.constants.WarpConstants.RANDOM_MIN;
30 30
31 import android.content.Context; 31 import android.content.Context;
32 import android.content.Intent; 32 import android.content.Intent;
33 +import android.content.pm.PackageManager;
33 import android.graphics.Color; 34 import android.graphics.Color;
34 import android.os.Build; 35 import android.os.Build;
35 import android.os.Bundle; 36 import android.os.Bundle;
...@@ -43,6 +44,7 @@ import android.widget.ProgressBar; ...@@ -43,6 +44,7 @@ import android.widget.ProgressBar;
43 import android.widget.RelativeLayout; 44 import android.widget.RelativeLayout;
44 45
45 import androidx.annotation.NonNull; 46 import androidx.annotation.NonNull;
47 +import androidx.lifecycle.ProcessLifecycleOwner;
46 import androidx.work.Constraints; 48 import androidx.work.Constraints;
47 import androidx.work.NetworkType; 49 import androidx.work.NetworkType;
48 import androidx.work.OneTimeWorkRequest; 50 import androidx.work.OneTimeWorkRequest;
...@@ -64,12 +66,12 @@ import ly.warp.sdk.Warply; ...@@ -64,12 +66,12 @@ import ly.warp.sdk.Warply;
64 import ly.warp.sdk.db.WarplyDBHelper; 66 import ly.warp.sdk.db.WarplyDBHelper;
65 import ly.warp.sdk.io.callbacks.CallbackReceiver; 67 import ly.warp.sdk.io.callbacks.CallbackReceiver;
66 import ly.warp.sdk.io.models.CouponList; 68 import ly.warp.sdk.io.models.CouponList;
69 +import ly.warp.sdk.io.models.WarplyWebviewActivityCallbackEventModel;
70 +import ly.warp.sdk.io.models.WarplyWebviewCallbackEventModel;
67 import ly.warp.sdk.io.request.PacingCalculateRequest; 71 import ly.warp.sdk.io.request.PacingCalculateRequest;
68 -import ly.warp.sdk.io.request.WarplyUserCouponsRequest;
69 import ly.warp.sdk.services.EventCampaignCouponService; 72 import ly.warp.sdk.services.EventCampaignCouponService;
70 import ly.warp.sdk.services.EventQuestionnaireService; 73 import ly.warp.sdk.services.EventQuestionnaireService;
71 import ly.warp.sdk.services.PushEventsClickedWorkerService; 74 import ly.warp.sdk.services.PushEventsClickedWorkerService;
72 -import ly.warp.sdk.services.WarplyHealthService;
73 import ly.warp.sdk.utils.WarpJSONParser; 75 import ly.warp.sdk.utils.WarpJSONParser;
74 import ly.warp.sdk.utils.WarpUtils; 76 import ly.warp.sdk.utils.WarpUtils;
75 import ly.warp.sdk.utils.WarplyManagerHelper; 77 import ly.warp.sdk.utils.WarplyManagerHelper;
...@@ -128,8 +130,7 @@ public class WarpViewActivity extends WarpBaseActivity { ...@@ -128,8 +130,7 @@ public class WarpViewActivity extends WarpBaseActivity {
128 @Override 130 @Override
129 protected void onDestroy() { 131 protected void onDestroy() {
130 super.onDestroy(); 132 super.onDestroy();
131 - if (metersHandler != null) 133 + if (metersHandler != null) metersHandler.removeCallbacksAndMessages(null);
132 - metersHandler.removeCallbacksAndMessages(null);
133 sendSteps(); 134 sendSteps();
134 WarpUtils.setWebviewParams(this, new JSONObject()); 135 WarpUtils.setWebviewParams(this, new JSONObject());
135 } 136 }
...@@ -146,6 +147,28 @@ public class WarpViewActivity extends WarpBaseActivity { ...@@ -146,6 +147,28 @@ public class WarpViewActivity extends WarpBaseActivity {
146 return super.onKeyDown(keyCode, event); 147 return super.onKeyDown(keyCode, event);
147 } 148 }
148 149
150 + @Override
151 + public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
152 + super.onRequestPermissionsResult(requestCode, permissions, grantResults);
153 + if (requestCode == 3001) {
154 + WarplyWebviewCallbackEventModel webviewCallbackEventModel = new WarplyWebviewCallbackEventModel();
155 + webviewCallbackEventModel.setRequestId(requestCode);
156 + webviewCallbackEventModel.setResponseCode(grantResults[0] == PackageManager.PERMISSION_GRANTED ? "allow" : "deny");
157 + EventBus.getDefault().post(new WarplyEventBusManager(webviewCallbackEventModel));
158 + }
159 + }
160 +
161 + @Override
162 + protected void onActivityResult(int requestCode, int resultCode, Intent data) {
163 + super.onActivityResult(requestCode, resultCode, data);
164 + if (requestCode == 3002 || requestCode == 3003) {
165 + WarplyWebviewActivityCallbackEventModel webviewCallbackEventModel = new WarplyWebviewActivityCallbackEventModel();
166 + webviewCallbackEventModel.setRequestId(requestCode);
167 + webviewCallbackEventModel.setResponseCode(resultCode == RESULT_OK ? "enabled" : "disabled");
168 + EventBus.getDefault().post(new WarplyEventBusManager(webviewCallbackEventModel));
169 + }
170 + }
171 +
149 @Subscribe() 172 @Subscribe()
150 public void onMessageEvent(WarplyEventBusManager event) { 173 public void onMessageEvent(WarplyEventBusManager event) {
151 // EventBus.getDefault().unregister(this); 174 // EventBus.getDefault().unregister(this);
...@@ -163,8 +186,7 @@ public class WarpViewActivity extends WarpBaseActivity { ...@@ -163,8 +186,7 @@ public class WarpViewActivity extends WarpBaseActivity {
163 // finish(); 186 // finish();
164 // if (event.getPacingService() != null) 187 // if (event.getPacingService() != null)
165 // finish(); 188 // finish();
166 - if (event.getPacing() != null && !event.getPacing().isVisible()) 189 + if (event.getPacing() != null && !event.getPacing().isVisible()) finish();
167 - finish();
168 } 190 }
169 191
170 // =========================================================== 192 // ===========================================================
...@@ -177,19 +199,15 @@ public class WarpViewActivity extends WarpBaseActivity { ...@@ -177,19 +199,15 @@ public class WarpViewActivity extends WarpBaseActivity {
177 root.setBackgroundColor(Color.WHITE); 199 root.setBackgroundColor(Color.WHITE);
178 200
179 final ImageView ivLogo = new ImageView(this); 201 final ImageView ivLogo = new ImageView(this);
180 - RelativeLayout.LayoutParams ivLogoParams = new RelativeLayout.LayoutParams( 202 + RelativeLayout.LayoutParams ivLogoParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
181 - RelativeLayout.LayoutParams.WRAP_CONTENT,
182 - RelativeLayout.LayoutParams.WRAP_CONTENT);
183 ivLogoParams.addRule(RelativeLayout.CENTER_IN_PARENT); 203 ivLogoParams.addRule(RelativeLayout.CENTER_IN_PARENT);
184 root.addView(ivLogo, ivLogoParams); 204 root.addView(ivLogo, ivLogoParams);
185 205
186 ivLogo.setImageDrawable(WarplyProperty.getProgressDrawable(this)); 206 ivLogo.setImageDrawable(WarplyProperty.getProgressDrawable(this));
187 ivLogo.startAnimation(WarpUtils.getPulseAnimation()); 207 ivLogo.startAnimation(WarpUtils.getPulseAnimation());
188 208
189 - mWarpView = new WarpView(this); 209 + mWarpView = new WarpView(this, WarpViewActivity.this, true);
190 - RelativeLayout.LayoutParams warpViewParams = new RelativeLayout.LayoutParams( 210 + RelativeLayout.LayoutParams warpViewParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
191 - RelativeLayout.LayoutParams.MATCH_PARENT,
192 - RelativeLayout.LayoutParams.MATCH_PARENT);
193 root.setFitsSystemWindows(true); 211 root.setFitsSystemWindows(true);
194 root.addView(mWarpView, warpViewParams); 212 root.addView(mWarpView, warpViewParams);
195 213
...@@ -197,9 +215,7 @@ public class WarpViewActivity extends WarpBaseActivity { ...@@ -197,9 +215,7 @@ public class WarpViewActivity extends WarpBaseActivity {
197 int progressHeightDp = 7; 215 int progressHeightDp = 7;
198 final ProgressBar progressBar = new ProgressBar(this, null, android.R.attr.progressBarStyleHorizontal); 216 final ProgressBar progressBar = new ProgressBar(this, null, android.R.attr.progressBarStyleHorizontal);
199 progressBar.setProgressDrawable(WarpUtils.getHorizontalProgressDrawable(WarplyProperty.getProgressColor(this))); 217 progressBar.setProgressDrawable(WarpUtils.getHorizontalProgressDrawable(WarplyProperty.getProgressColor(this)));
200 - RelativeLayout.LayoutParams progressBarParams = new RelativeLayout.LayoutParams( 218 + RelativeLayout.LayoutParams progressBarParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, (int) (progressHeightDp * getResources().getDisplayMetrics().density + 0.5f));
201 - RelativeLayout.LayoutParams.MATCH_PARENT, (int)
202 - (progressHeightDp * getResources().getDisplayMetrics().density + 0.5f));
203 mWarpView.setProgressChangeListener(new WarpView.ProgressChangeListener() { 219 mWarpView.setProgressChangeListener(new WarpView.ProgressChangeListener() {
204 @Override 220 @Override
205 public void onProgressChanged(WebView view, int newProgress) { 221 public void onProgressChanged(WebView view, int newProgress) {
...@@ -224,8 +240,7 @@ public class WarpViewActivity extends WarpBaseActivity { ...@@ -224,8 +240,7 @@ public class WarpViewActivity extends WarpBaseActivity {
224 String sessionUUID = intent.getStringExtra("sessionUUID"); 240 String sessionUUID = intent.getStringExtra("sessionUUID");
225 241
226 // user viewed campaign through notification 242 // user viewed campaign through notification
227 - if (intent.hasExtra("source") && intent.getStringExtra("source"). 243 + if (intent.hasExtra("source") && intent.getStringExtra("source").equalsIgnoreCase("from_notification_status")) {
228 - equalsIgnoreCase("from_notification_status")) {
229 JSONObject params = new JSONObject(); 244 JSONObject params = new JSONObject();
230 try { 245 try {
231 params.putOpt("web_id", WarpUtils.getWebId(Warply.getWarplyContext())); 246 params.putOpt("web_id", WarpUtils.getWebId(Warply.getWarplyContext()));
...@@ -246,8 +261,7 @@ public class WarpViewActivity extends WarpBaseActivity { ...@@ -246,8 +261,7 @@ public class WarpViewActivity extends WarpBaseActivity {
246 } 261 }
247 262
248 // ensure update campaigns and count if was used cache 263 // ensure update campaigns and count if was used cache
249 - if (Warply.INSTANCE.getLastReceivedCampaigns() != null && 264 + if (Warply.INSTANCE.getLastReceivedCampaigns() != null && Warply.INSTANCE.getLastReceivedCampaigns().containsUuid(sessionUUID)) {
250 - Warply.INSTANCE.getLastReceivedCampaigns().containsUuid(sessionUUID)) {
251 new WarplyPreferences(this).clearInboxLastCachedTimeStamps(); 265 new WarplyPreferences(this).clearInboxLastCachedTimeStamps();
252 } 266 }
253 267
...@@ -263,10 +277,7 @@ public class WarpViewActivity extends WarpBaseActivity { ...@@ -263,10 +277,7 @@ public class WarpViewActivity extends WarpBaseActivity {
263 277
264 // if (WorkManager.getInstance(this).getWorkInfosByTag(PushEventsWorkerService.TAG).isDone() || WorkManager.getInstance(this).getWorkInfosByTag(PushEventsWorkerService.TAG).isCancelled()) { 278 // if (WorkManager.getInstance(this).getWorkInfosByTag(PushEventsWorkerService.TAG).isDone() || WorkManager.getInstance(this).getWorkInfosByTag(PushEventsWorkerService.TAG).isCancelled()) {
265 Constraints constraints = new Constraints.Builder().setRequiredNetworkType(NetworkType.CONNECTED).build(); 279 Constraints constraints = new Constraints.Builder().setRequiredNetworkType(NetworkType.CONNECTED).build();
266 - OneTimeWorkRequest sendEvent = new OneTimeWorkRequest.Builder(PushEventsClickedWorkerService.class) 280 + OneTimeWorkRequest sendEvent = new OneTimeWorkRequest.Builder(PushEventsClickedWorkerService.class).setConstraints(constraints).setInitialDelay(defineRandomStart(), TimeUnit.MINUTES).build();
267 - .setConstraints(constraints)
268 - .setInitialDelay(defineRandomStart(), TimeUnit.MINUTES)
269 - .build();
270 281
271 WorkManager.getInstance(this).enqueue(sendEvent); 282 WorkManager.getInstance(this).enqueue(sendEvent);
272 // } 283 // }
...@@ -319,10 +330,7 @@ public class WarpViewActivity extends WarpBaseActivity { ...@@ -319,10 +330,7 @@ public class WarpViewActivity extends WarpBaseActivity {
319 String date = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss", Locale.getDefault()).format(new Date()); 330 String date = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss", Locale.getDefault()).format(new Date());
320 WarpUtils.log("SEND_STEPS: " + String.valueOf(WarpUtils.getStepsCounter(this))); 331 WarpUtils.log("SEND_STEPS: " + String.valueOf(WarpUtils.getStepsCounter(this)));
321 if (WarpUtils.getStepsCounter(this) > 0) { 332 if (WarpUtils.getStepsCounter(this) > 0) {
322 - WarplyManager.setPacingDetails(new PacingCalculateRequest() 333 + WarplyManager.setPacingDetails(new PacingCalculateRequest().setCounter(WarpUtils.getStepsCounter(this)).setDate(date), new CallbackReceiver<JSONObject>() {
323 - .setCounter(WarpUtils.getStepsCounter(this))
324 - .setDate(date),
325 - new CallbackReceiver<JSONObject>() {
326 @Override 334 @Override
327 public void onSuccess(JSONObject result) { 335 public void onSuccess(JSONObject result) {
328 int status = result.optInt("status", 2); 336 int status = result.optInt("status", 2);
......
...@@ -65,6 +65,8 @@ public class Coupon implements Parcelable, Serializable { ...@@ -65,6 +65,8 @@ public class Coupon implements Parcelable, Serializable {
65 private static final String INNER_TEXT = "inner_text"; 65 private static final String INNER_TEXT = "inner_text";
66 private static final String FINAL_PRICE = "final_price"; 66 private static final String FINAL_PRICE = "final_price";
67 private static final String DISCOUNT_TYPE = "discount_type"; 67 private static final String DISCOUNT_TYPE = "discount_type";
68 + private static final String SHORT_DESCRIPTION = "short_description";
69 + private static final String TERMS = "terms";
68 70
69 /* Member variables of the Campaign object */ 71 /* Member variables of the Campaign object */
70 72
...@@ -87,6 +89,8 @@ public class Coupon implements Parcelable, Serializable { ...@@ -87,6 +89,8 @@ public class Coupon implements Parcelable, Serializable {
87 private Date expirationDate = new Date(); 89 private Date expirationDate = new Date();
88 private String discount_type = ""; 90 private String discount_type = "";
89 private double final_price = 0.0d; 91 private double final_price = 0.0d;
92 + private String short_description = "";
93 + private String terms = "";
90 94
91 public Coupon() { 95 public Coupon() {
92 this.barcode = ""; 96 this.barcode = "";
...@@ -108,6 +112,8 @@ public class Coupon implements Parcelable, Serializable { ...@@ -108,6 +112,8 @@ public class Coupon implements Parcelable, Serializable {
108 this.expirationDate = new Date(); 112 this.expirationDate = new Date();
109 this.discount_type = ""; 113 this.discount_type = "";
110 this.final_price = 0.0d; 114 this.final_price = 0.0d;
115 + this.short_description = "";
116 + this.terms = "";
111 } 117 }
112 118
113 /** 119 /**
...@@ -146,6 +152,8 @@ public class Coupon implements Parcelable, Serializable { ...@@ -146,6 +152,8 @@ public class Coupon implements Parcelable, Serializable {
146 this.innerText = json.optString(INNER_TEXT); 152 this.innerText = json.optString(INNER_TEXT);
147 this.discount_type = json.isNull(DISCOUNT_TYPE) ? "" : json.optString(DISCOUNT_TYPE); 153 this.discount_type = json.isNull(DISCOUNT_TYPE) ? "" : json.optString(DISCOUNT_TYPE);
148 this.final_price = json.optDouble(FINAL_PRICE); 154 this.final_price = json.optDouble(FINAL_PRICE);
155 + this.short_description = json.optString(SHORT_DESCRIPTION);
156 + this.terms = json.optString(TERMS);
149 } 157 }
150 } 158 }
151 159
...@@ -167,6 +175,8 @@ public class Coupon implements Parcelable, Serializable { ...@@ -167,6 +175,8 @@ public class Coupon implements Parcelable, Serializable {
167 this.innerText = source.readString(); 175 this.innerText = source.readString();
168 this.discount_type = source.readString(); 176 this.discount_type = source.readString();
169 this.final_price = source.readDouble(); 177 this.final_price = source.readDouble();
178 + this.short_description = source.readString();
179 + this.terms = source.readString();
170 } 180 }
171 181
172 @Override 182 @Override
...@@ -188,6 +198,8 @@ public class Coupon implements Parcelable, Serializable { ...@@ -188,6 +198,8 @@ public class Coupon implements Parcelable, Serializable {
188 dest.writeString(this.innerText); 198 dest.writeString(this.innerText);
189 dest.writeString(this.discount_type); 199 dest.writeString(this.discount_type);
190 dest.writeDouble(this.final_price); 200 dest.writeDouble(this.final_price);
201 + dest.writeString(this.short_description);
202 + dest.writeString(this.terms);
191 } 203 }
192 204
193 /** 205 /**
...@@ -216,6 +228,8 @@ public class Coupon implements Parcelable, Serializable { ...@@ -216,6 +228,8 @@ public class Coupon implements Parcelable, Serializable {
216 jObj.putOpt(INNER_TEXT, this.innerText); 228 jObj.putOpt(INNER_TEXT, this.innerText);
217 jObj.putOpt(DISCOUNT_TYPE, this.discount_type); 229 jObj.putOpt(DISCOUNT_TYPE, this.discount_type);
218 jObj.putOpt(FINAL_PRICE, this.final_price); 230 jObj.putOpt(FINAL_PRICE, this.final_price);
231 + jObj.putOpt(SHORT_DESCRIPTION, this.short_description);
232 + jObj.putOpt(TERMS, this.terms);
219 } catch (JSONException e) { 233 } catch (JSONException e) {
220 if (WarpConstants.DEBUG) { 234 if (WarpConstants.DEBUG) {
221 e.printStackTrace(); 235 e.printStackTrace();
...@@ -407,6 +421,22 @@ public class Coupon implements Parcelable, Serializable { ...@@ -407,6 +421,22 @@ public class Coupon implements Parcelable, Serializable {
407 this.final_price = final_price; 421 this.final_price = final_price;
408 } 422 }
409 423
424 + public String getShort_description() {
425 + return short_description;
426 + }
427 +
428 + public void setShort_description(String short_description) {
429 + this.short_description = short_description;
430 + }
431 +
432 + public String getTerms() {
433 + return terms;
434 + }
435 +
436 + public void setTerms(String terms) {
437 + this.terms = terms;
438 + }
439 +
410 @Override 440 @Override
411 public int describeContents() { 441 public int describeContents() {
412 return 0; 442 return 0;
......
1 +/*
2 + * Copyright 2010-2013 Warply Ltd. All rights reserved.
3 + *
4 + * Redistribution and use in source and binary forms, without modification, are
5 + * permitted provided that the following conditions are met:
6 + *
7 + * 1. Redistributions of source code must retain the above copyright notice,
8 + * this list of conditions and the following disclaimer.
9 + *
10 + * 2. Redistributions in binary form must reproduce the above copyright notice,
11 + * this list of conditions and the following disclaimer in the documentation
12 + * and/or other materials provided with the distribution.
13 + *
14 + * THIS SOFTWARE IS PROVIDED BY THE WARPLY LTD ``AS IS'' AND ANY EXPRESS OR
15 + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16 + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
17 + * EVENT SHALL WARPLY LTD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
18 + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
19 + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
20 + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21 + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22 + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
23 + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 + */
25 +
26 +package ly.warp.sdk.io.models;
27 +
28 +
29 +/**
30 + * Created by Panagiotis Triantafyllou on 14-June-23.
31 + */
32 +
33 +public class WarplyWebviewActivityCallbackEventModel {
34 + private String responseCode;
35 + private int requestId;
36 +
37 + public WarplyWebviewActivityCallbackEventModel() {
38 + this.requestId = -1;
39 + this.responseCode = "";
40 + }
41 +
42 + public int getRequestId() {
43 + return requestId;
44 + }
45 +
46 + public String getResponseCode() {
47 + return responseCode;
48 + }
49 +
50 + public void setRequestId(int requestId) {
51 + this.requestId = requestId;
52 + }
53 +
54 + public void setResponseCode(String responseCode) {
55 + this.responseCode = responseCode;
56 + }
57 +}
1 +/*
2 + * Copyright 2010-2013 Warply Ltd. All rights reserved.
3 + *
4 + * Redistribution and use in source and binary forms, without modification, are
5 + * permitted provided that the following conditions are met:
6 + *
7 + * 1. Redistributions of source code must retain the above copyright notice,
8 + * this list of conditions and the following disclaimer.
9 + *
10 + * 2. Redistributions in binary form must reproduce the above copyright notice,
11 + * this list of conditions and the following disclaimer in the documentation
12 + * and/or other materials provided with the distribution.
13 + *
14 + * THIS SOFTWARE IS PROVIDED BY THE WARPLY LTD ``AS IS'' AND ANY EXPRESS OR
15 + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16 + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
17 + * EVENT SHALL WARPLY LTD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
18 + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
19 + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
20 + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21 + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22 + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
23 + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 + */
25 +
26 +package ly.warp.sdk.io.models;
27 +
28 +
29 +/**
30 + * Created by Panagiotis Triantafyllou on 13-June-23.
31 + */
32 +
33 +public class WarplyWebviewCallbackEventModel {
34 + private String responseCode;
35 + private int requestId;
36 +
37 + public WarplyWebviewCallbackEventModel() {
38 + this.requestId = -1;
39 + this.responseCode = "";
40 + }
41 +
42 + public int getRequestId() {
43 + return requestId;
44 + }
45 +
46 + public String getResponseCode() {
47 + return responseCode;
48 + }
49 +
50 + public void setRequestId(int requestId) {
51 + this.requestId = requestId;
52 + }
53 +
54 + public void setResponseCode(String responseCode) {
55 + this.responseCode = responseCode;
56 + }
57 +}
...@@ -20,6 +20,8 @@ import ly.warp.sdk.io.models.WarplyDealsAnalysisEventModel; ...@@ -20,6 +20,8 @@ import ly.warp.sdk.io.models.WarplyDealsAnalysisEventModel;
20 import ly.warp.sdk.io.models.WarplyPacingCardEventModel; 20 import ly.warp.sdk.io.models.WarplyPacingCardEventModel;
21 import ly.warp.sdk.io.models.WarplyPacingCardServiceEnabledModel; 21 import ly.warp.sdk.io.models.WarplyPacingCardServiceEnabledModel;
22 import ly.warp.sdk.io.models.WarplyPacingEventModel; 22 import ly.warp.sdk.io.models.WarplyPacingEventModel;
23 +import ly.warp.sdk.io.models.WarplyWebviewActivityCallbackEventModel;
24 +import ly.warp.sdk.io.models.WarplyWebviewCallbackEventModel;
23 25
24 /** 26 /**
25 * Created by Panagiotis Triantafyllou on 26/Απρ/2022. 27 * Created by Panagiotis Triantafyllou on 26/Απρ/2022.
...@@ -46,6 +48,9 @@ public class WarplyEventBusManager { ...@@ -46,6 +48,9 @@ public class WarplyEventBusManager {
46 private WarplyPacingCardEventModel widgetChanged; 48 private WarplyPacingCardEventModel widgetChanged;
47 private LoyaltySDKSessionExpiredEventModel sessionExpired; 49 private LoyaltySDKSessionExpiredEventModel sessionExpired;
48 50
51 + private WarplyWebviewCallbackEventModel webviewCallback;
52 + private WarplyWebviewActivityCallbackEventModel webviewActivityCallback;
53 +
49 public WarplyEventBusManager() { 54 public WarplyEventBusManager() {
50 55
51 } 56 }
...@@ -58,11 +63,19 @@ public class WarplyEventBusManager { ...@@ -58,11 +63,19 @@ public class WarplyEventBusManager {
58 this.questionnaire = questionnaire; 63 this.questionnaire = questionnaire;
59 } 64 }
60 65
66 + public WarplyEventBusManager(WarplyWebviewCallbackEventModel webviewCallback) {
67 + this.webviewCallback = webviewCallback;
68 + }
69 +
70 + public WarplyEventBusManager(WarplyWebviewActivityCallbackEventModel webviewActivityCallback) {
71 + this.webviewActivityCallback = webviewActivityCallback;
72 + }
73 +
61 public WarplyEventBusManager(ContexualEventModel ccmsAdded) { 74 public WarplyEventBusManager(ContexualEventModel ccmsAdded) {
62 this.ccmsAdded = ccmsAdded; 75 this.ccmsAdded = ccmsAdded;
63 } 76 }
64 77
65 - public WarplyEventBusManager (LoyaltySDKSessionExpiredEventModel sessionExpired) { 78 + public WarplyEventBusManager(LoyaltySDKSessionExpiredEventModel sessionExpired) {
66 this.sessionExpired = sessionExpired; 79 this.sessionExpired = sessionExpired;
67 } 80 }
68 81
...@@ -227,4 +240,12 @@ public class WarplyEventBusManager { ...@@ -227,4 +240,12 @@ public class WarplyEventBusManager {
227 public LoyaltySDKSessionExpiredEventModel isLoyaltySessionExpired() { 240 public LoyaltySDKSessionExpiredEventModel isLoyaltySessionExpired() {
228 return sessionExpired; 241 return sessionExpired;
229 } 242 }
243 +
244 + public WarplyWebviewCallbackEventModel getWarplyWebviewCallbackEventModel() {
245 + return webviewCallback;
246 + }
247 +
248 + public WarplyWebviewActivityCallbackEventModel getWarplyWebviewActivityCallbackEventModel() {
249 + return webviewActivityCallback;
250 + }
230 } 251 }
......
...@@ -25,18 +25,22 @@ ...@@ -25,18 +25,22 @@
25 25
26 package ly.warp.sdk.views; 26 package ly.warp.sdk.views;
27 27
28 +import android.Manifest;
28 import android.annotation.SuppressLint; 29 import android.annotation.SuppressLint;
30 +import android.app.Activity;
29 import android.app.ActivityManager; 31 import android.app.ActivityManager;
30 import android.app.AlertDialog; 32 import android.app.AlertDialog;
31 import android.content.ActivityNotFoundException; 33 import android.content.ActivityNotFoundException;
32 import android.content.Context; 34 import android.content.Context;
33 import android.content.DialogInterface; 35 import android.content.DialogInterface;
34 import android.content.Intent; 36 import android.content.Intent;
37 +import android.content.IntentSender;
35 import android.content.pm.ApplicationInfo; 38 import android.content.pm.ApplicationInfo;
39 +import android.content.pm.PackageManager;
40 +import android.location.LocationManager;
36 import android.net.Uri; 41 import android.net.Uri;
37 import android.net.http.SslError; 42 import android.net.http.SslError;
38 import android.os.Build; 43 import android.os.Build;
39 -import android.os.Handler;
40 import android.text.TextUtils; 44 import android.text.TextUtils;
41 import android.util.AttributeSet; 45 import android.util.AttributeSet;
42 import android.webkit.GeolocationPermissions.Callback; 46 import android.webkit.GeolocationPermissions.Callback;
...@@ -48,11 +52,24 @@ import android.webkit.WebView; ...@@ -48,11 +52,24 @@ import android.webkit.WebView;
48 import android.webkit.WebViewClient; 52 import android.webkit.WebViewClient;
49 import android.widget.Toast; 53 import android.widget.Toast;
50 54
55 +import androidx.annotation.NonNull;
56 +import androidx.core.app.ActivityCompat;
51 import androidx.core.content.ContextCompat; 57 import androidx.core.content.ContextCompat;
52 -import androidx.work.PeriodicWorkRequest; 58 +import androidx.lifecycle.DefaultLifecycleObserver;
53 -import androidx.work.WorkManager; 59 +import androidx.lifecycle.LifecycleOwner;
60 +import androidx.lifecycle.ProcessLifecycleOwner;
61 +
62 +import com.google.android.gms.common.api.GoogleApiClient;
63 +import com.google.android.gms.common.api.PendingResult;
64 +import com.google.android.gms.common.api.Status;
65 +import com.google.android.gms.location.LocationRequest;
66 +import com.google.android.gms.location.LocationServices;
67 +import com.google.android.gms.location.LocationSettingsRequest;
68 +import com.google.android.gms.location.LocationSettingsResult;
69 +import com.google.android.gms.location.LocationSettingsStatusCodes;
54 70
55 import org.greenrobot.eventbus.EventBus; 71 import org.greenrobot.eventbus.EventBus;
72 +import org.greenrobot.eventbus.Subscribe;
56 import org.json.JSONArray; 73 import org.json.JSONArray;
57 import org.json.JSONException; 74 import org.json.JSONException;
58 import org.json.JSONObject; 75 import org.json.JSONObject;
...@@ -62,8 +79,8 @@ import java.net.URLDecoder; ...@@ -62,8 +79,8 @@ import java.net.URLDecoder;
62 import java.util.HashMap; 79 import java.util.HashMap;
63 import java.util.LinkedHashMap; 80 import java.util.LinkedHashMap;
64 import java.util.Map; 81 import java.util.Map;
65 -import java.util.concurrent.TimeUnit;
66 82
83 +import ly.warp.sdk.R;
67 import ly.warp.sdk.Warply; 84 import ly.warp.sdk.Warply;
68 import ly.warp.sdk.activities.WarpViewActivity; 85 import ly.warp.sdk.activities.WarpViewActivity;
69 import ly.warp.sdk.db.WarplyDBHelper; 86 import ly.warp.sdk.db.WarplyDBHelper;
...@@ -82,7 +99,7 @@ import ly.warp.sdk.utils.constants.WarpConstants; ...@@ -82,7 +99,7 @@ import ly.warp.sdk.utils.constants.WarpConstants;
82 import ly.warp.sdk.utils.managers.WarplyAnalyticsManager; 99 import ly.warp.sdk.utils.managers.WarplyAnalyticsManager;
83 import ly.warp.sdk.utils.managers.WarplyEventBusManager; 100 import ly.warp.sdk.utils.managers.WarplyEventBusManager;
84 101
85 -public class WarpView extends WebView { 102 +public class WarpView extends WebView implements DefaultLifecycleObserver {
86 103
87 private static final String URL_ACTION_TEL = "tel"; 104 private static final String URL_ACTION_TEL = "tel";
88 private static final String URL_ACTION_SMS = "sms"; 105 private static final String URL_ACTION_SMS = "sms";
...@@ -100,6 +117,9 @@ public class WarpView extends WebView { ...@@ -100,6 +117,9 @@ public class WarpView extends WebView {
100 private WarplyUrlHandler mExternalUrlHandler; 117 private WarplyUrlHandler mExternalUrlHandler;
101 private WarplyUrlHandler mInternalUrlHandler; 118 private WarplyUrlHandler mInternalUrlHandler;
102 private String sessionUUID; 119 private String sessionUUID;
120 + private Activity WarpActivity;
121 + private String geolocationOrigin = "";
122 + private Callback geolocationCallback;
103 123
104 // =========================================================== 124 // ===========================================================
105 // Constructors 125 // Constructors
...@@ -114,8 +134,14 @@ public class WarpView extends WebView { ...@@ -114,8 +134,14 @@ public class WarpView extends WebView {
114 init(); 134 init();
115 } 135 }
116 136
117 - public WarpView(Context context, AttributeSet attrs, 137 + public WarpView(Context context, Activity activity, boolean isActivity) {
118 - int defStyleAttr) { 138 + super(context, null);
139 + ProcessLifecycleOwner.get().getLifecycle().addObserver(this);
140 + WarpActivity = activity;
141 + init();
142 + }
143 +
144 + public WarpView(Context context, AttributeSet attrs, int defStyleAttr) {
119 super(context, attrs, defStyleAttr); 145 super(context, attrs, defStyleAttr);
120 init(); 146 init();
121 } 147 }
...@@ -142,6 +168,14 @@ public class WarpView extends WebView { ...@@ -142,6 +168,14 @@ public class WarpView extends WebView {
142 settings.setGeolocationDatabasePath(getContext().getCacheDir().getAbsolutePath()); 168 settings.setGeolocationDatabasePath(getContext().getCacheDir().getAbsolutePath());
143 settings.setGeolocationEnabled(true); 169 settings.setGeolocationEnabled(true);
144 settings.setBuiltInZoomControls(false); 170 settings.setBuiltInZoomControls(false);
171 + settings.setAllowContentAccess(true);
172 + settings.setLoadWithOverviewMode(true);
173 + settings.setAllowFileAccess(true);
174 + settings.setJavaScriptCanOpenWindowsAutomatically(true);
175 + settings.setAllowFileAccessFromFileURLs(true);
176 + settings.setAllowUniversalAccessFromFileURLs(true);
177 + settings.setSupportMultipleWindows(true);
178 +// settings.setGeolocationDatabasePath(getContext().getFilesDir().getPath());
145 WarpView.this.addJavascriptInterface(new JSInterface(), "Cosmote"); 179 WarpView.this.addJavascriptInterface(new JSInterface(), "Cosmote");
146 setBackgroundColor(ContextCompat.getColor(getContext(), android.R.color.transparent)); 180 setBackgroundColor(ContextCompat.getColor(getContext(), android.R.color.transparent));
147 setWebViewClient(new WarplyWebViewClient()); 181 setWebViewClient(new WarplyWebViewClient());
...@@ -167,8 +201,7 @@ public class WarpView extends WebView { ...@@ -167,8 +201,7 @@ public class WarpView extends WebView {
167 private void initCustomActionHandler() { 201 private void initCustomActionHandler() {
168 202
169 String actionHandlerName = WarplyProperty.getWebActionListenerClassName(getContext()); 203 String actionHandlerName = WarplyProperty.getWebActionListenerClassName(getContext());
170 - if (TextUtils.isEmpty(actionHandlerName)) 204 + if (TextUtils.isEmpty(actionHandlerName)) return;
171 - return;
172 if (actionHandlerName.startsWith(".")) 205 if (actionHandlerName.startsWith("."))
173 actionHandlerName = getContext().getPackageName().concat(actionHandlerName); 206 actionHandlerName = getContext().getPackageName().concat(actionHandlerName);
174 try { 207 try {
...@@ -177,13 +210,9 @@ public class WarpView extends WebView { ...@@ -177,13 +210,9 @@ public class WarpView extends WebView {
177 } catch (ClassNotFoundException e) { 210 } catch (ClassNotFoundException e) {
178 WarpUtils.warn("Warply action handler class was not found", e); 211 WarpUtils.warn("Warply action handler class was not found", e);
179 } catch (ClassCastException e) { 212 } catch (ClassCastException e) {
180 - WarpUtils 213 + WarpUtils.warn("Warply action handler does not implement the correct interface", e);
181 - .warn("Warply action handler does not implement the correct interface",
182 - e);
183 } catch (InstantiationException e) { 214 } catch (InstantiationException e) {
184 - WarpUtils 215 + WarpUtils.warn("Warply action handler could not be instantiated, maybe missing default constructor", e);
185 - .warn("Warply action handler could not be instantiated, maybe missing default constructor",
186 - e);
187 } catch (IllegalAccessException e) { 216 } catch (IllegalAccessException e) {
188 WarpUtils.warn("Warply action handler could not be accessed", e); 217 WarpUtils.warn("Warply action handler could not be accessed", e);
189 } 218 }
...@@ -198,8 +227,7 @@ public class WarpView extends WebView { ...@@ -198,8 +227,7 @@ public class WarpView extends WebView {
198 metadata.putOpt("session_uuid", sessionUUID); 227 metadata.putOpt("session_uuid", sessionUUID);
199 JSONArray results = new JSONArray("[\"call_clicked\"]"); 228 JSONArray results = new JSONArray("[\"call_clicked\"]");
200 metadata.putOpt("result", results); 229 metadata.putOpt("result", results);
201 - WarplyAnalyticsManager.logUrgentEvent("TEL", "NB_CUSTOM_ACTION", 230 + WarplyAnalyticsManager.logUrgentEvent("TEL", "NB_CUSTOM_ACTION", metadata);
202 - metadata);
203 } catch (JSONException e) { 231 } catch (JSONException e) {
204 if (WarpConstants.DEBUG) { 232 if (WarpConstants.DEBUG) {
205 e.printStackTrace(); 233 e.printStackTrace();
...@@ -226,8 +254,7 @@ public class WarpView extends WebView { ...@@ -226,8 +254,7 @@ public class WarpView extends WebView {
226 } 254 }
227 255
228 String body = splitQuery(uri).get("body"); 256 String body = splitQuery(uri).get("body");
229 - if (body == null) 257 + if (body == null) body = "";
230 - body = "";
231 258
232 try { 259 try {
233 Intent i = new Intent(Intent.ACTION_VIEW); 260 Intent i = new Intent(Intent.ACTION_VIEW);
...@@ -241,8 +268,7 @@ public class WarpView extends WebView { ...@@ -241,8 +268,7 @@ public class WarpView extends WebView {
241 JSONArray results = new JSONArray("[\"sms_prompt_clicked\"]"); 268 JSONArray results = new JSONArray("[\"sms_prompt_clicked\"]");
242 metadata.putOpt("result", results); 269 metadata.putOpt("result", results);
243 WarpUtils.log(metadata.toString()); 270 WarpUtils.log(metadata.toString());
244 - WarplyAnalyticsManager.logUrgentEvent("SMS", "NB_CUSTOM_ACTION", 271 + WarplyAnalyticsManager.logUrgentEvent("SMS", "NB_CUSTOM_ACTION", metadata);
245 - metadata);
246 } catch (JSONException e) { 272 } catch (JSONException e) {
247 WarpUtils.log(e.toString()); 273 WarpUtils.log(e.toString());
248 } 274 }
...@@ -281,8 +307,7 @@ public class WarpView extends WebView { ...@@ -281,8 +307,7 @@ public class WarpView extends WebView {
281 JSONArray results = new JSONArray("[\"mailto_prompt_clicked\"]"); 307 JSONArray results = new JSONArray("[\"mailto_prompt_clicked\"]");
282 metadata.putOpt("result", results); 308 metadata.putOpt("result", results);
283 WarpUtils.log(metadata.toString()); 309 WarpUtils.log(metadata.toString());
284 - WarplyAnalyticsManager.logUrgentEvent("MAIL_TO", 310 + WarplyAnalyticsManager.logUrgentEvent("MAIL_TO", "NB_CUSTOM_ACTION", metadata);
285 - "NB_CUSTOM_ACTION", metadata);
286 } catch (JSONException e) { 311 } catch (JSONException e) {
287 WarpUtils.log(e.toString()); 312 WarpUtils.log(e.toString());
288 } 313 }
...@@ -307,8 +332,7 @@ public class WarpView extends WebView { ...@@ -307,8 +332,7 @@ public class WarpView extends WebView {
307 metadata.putOpt("result", results); 332 metadata.putOpt("result", results);
308 metadata.putOpt("session_uuid", sessionUUID); 333 metadata.putOpt("session_uuid", sessionUUID);
309 metadata.putOpt("url", uri.toString()); 334 metadata.putOpt("url", uri.toString());
310 - WarplyAnalyticsManager.logUrgentEvent("APP_DOWNLOAD", 335 + WarplyAnalyticsManager.logUrgentEvent("APP_DOWNLOAD", "NB_CUSTOM_ACTION", metadata);
311 - "NB_CUSTOM_ACTION", metadata);
312 } catch (JSONException e) { 336 } catch (JSONException e) {
313 if (WarpConstants.DEBUG) { 337 if (WarpConstants.DEBUG) {
314 e.printStackTrace(); 338 e.printStackTrace();
...@@ -328,14 +352,12 @@ public class WarpView extends WebView { ...@@ -328,14 +352,12 @@ public class WarpView extends WebView {
328 String[] pairs = query.split("&"); 352 String[] pairs = query.split("&");
329 for (String pair : pairs) { 353 for (String pair : pairs) {
330 354
331 - if (TextUtils.isEmpty(pair)) 355 + if (TextUtils.isEmpty(pair)) continue;
332 - continue;
333 356
334 int idx = pair.indexOf("="); 357 int idx = pair.indexOf("=");
335 if (idx != -1) { 358 if (idx != -1) {
336 try { 359 try {
337 - queryPairs.put(URLDecoder.decode(pair.substring(0, idx), "UTF-8"), 360 + queryPairs.put(URLDecoder.decode(pair.substring(0, idx), "UTF-8"), URLDecoder.decode(pair.substring(idx + 1), "UTF-8"));
338 - URLDecoder.decode(pair.substring(idx + 1), "UTF-8"));
339 } catch (UnsupportedEncodingException e) { 361 } catch (UnsupportedEncodingException e) {
340 if (WarpConstants.DEBUG) { 362 if (WarpConstants.DEBUG) {
341 e.printStackTrace(); 363 e.printStackTrace();
...@@ -381,6 +403,38 @@ public class WarpView extends WebView { ...@@ -381,6 +403,38 @@ public class WarpView extends WebView {
381 return sessionUUID; 403 return sessionUUID;
382 } 404 }
383 405
406 + @Override
407 + public void onStart(@NonNull LifecycleOwner owner) {
408 + DefaultLifecycleObserver.super.onStart(owner);
409 + if (!EventBus.getDefault().isRegistered(this))
410 + EventBus.getDefault().register(this);
411 + }
412 +
413 + @Override
414 + public void onStop(@NonNull LifecycleOwner owner) {
415 + DefaultLifecycleObserver.super.onStop(owner);
416 + }
417 +
418 + @Subscribe()
419 + public void onMessageEvent(WarplyEventBusManager event) {
420 + if (event.getWarplyWebviewCallbackEventModel() != null) {
421 + if (event.getWarplyWebviewCallbackEventModel().getRequestId() == 3001 && event.getWarplyWebviewCallbackEventModel().getResponseCode().equals("allow")) {
422 +// geolocationCallback.invoke(geolocationOrigin, true, false);
423 + enableLocationSettings();
424 + } else {
425 + geolocationCallback.invoke(geolocationOrigin, false, false);
426 + }
427 + return;
428 + }
429 + if (event.getWarplyWebviewActivityCallbackEventModel() != null) {
430 + if (event.getWarplyWebviewActivityCallbackEventModel().getRequestId() == 3002 && event.getWarplyWebviewActivityCallbackEventModel().getResponseCode().equals("enabled")) {
431 + geolocationCallback.invoke(geolocationOrigin, true, false);
432 + } else {
433 + geolocationCallback.invoke(geolocationOrigin, false, false);
434 + }
435 + }
436 + }
437 +
384 // =========================================================== 438 // ===========================================================
385 // Inner and Anonymous Classes 439 // Inner and Anonymous Classes
386 // =========================================================== 440 // ===========================================================
...@@ -511,10 +565,7 @@ public class WarpView extends WebView { ...@@ -511,10 +565,7 @@ public class WarpView extends WebView {
511 } else if (parts[1].equals("refreshToken")) { 565 } else if (parts[1].equals("refreshToken")) {
512 try { 566 try {
513 if (Warply.getWarplyContext() != null) { 567 if (Warply.getWarplyContext() != null) {
514 - WarplyDBHelper.getInstance(Warply.getWarplyContext()).saveAuthAccess( 568 + WarplyDBHelper.getInstance(Warply.getWarplyContext()).saveAuthAccess(parts[2], parts[3]);
515 - parts[2],
516 - parts[3]
517 - );
518 } 569 }
519 } catch (Exception e) { 570 } catch (Exception e) {
520 e.printStackTrace(); 571 e.printStackTrace();
...@@ -531,7 +582,14 @@ public class WarpView extends WebView { ...@@ -531,7 +582,14 @@ public class WarpView extends WebView {
531 private class WarplyWebChromeClient extends WebChromeClient { 582 private class WarplyWebChromeClient extends WebChromeClient {
532 @Override 583 @Override
533 public void onGeolocationPermissionsShowPrompt(String origin, Callback callback) { 584 public void onGeolocationPermissionsShowPrompt(String origin, Callback callback) {
534 - callback.invoke(origin, true, true); 585 + AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
586 + builder.setTitle(getContext().getString(R.string.lbl_cosmote_webview_permission_title));
587 + builder.setMessage(getContext().getString(R.string.lbl_cosmote_webview_permission_message))
588 + .setCancelable(false)
589 + .setPositiveButton(getContext().getString(R.string.lbl_take_photo_accept), (dialog, id) -> checkForPermissions(origin, callback))
590 + .setNegativeButton(getContext().getString(R.string.lbl_take_photo_decline), (dialog, id) -> callback.invoke(origin, false, false));
591 + AlertDialog alert = builder.create();
592 + alert.show();
535 } 593 }
536 594
537 @Override 595 @Override
...@@ -543,17 +601,82 @@ public class WarpView extends WebView { ...@@ -543,17 +601,82 @@ public class WarpView extends WebView {
543 } 601 }
544 } 602 }
545 603
604 + private void checkForPermissions(String origin, Callback callback) {
605 + String perm = Manifest.permission.ACCESS_FINE_LOCATION;
606 + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M || getContext().checkSelfPermission(perm) == PackageManager.PERMISSION_GRANTED) {
607 + if (isGPSEnabled()) {
608 + callback.invoke(origin, true, false);
609 + } else {
610 + enableLocationSettings();
611 + }
612 + } else {
613 + if (WarpActivity != null && !WarpActivity.isFinishing()) {
614 + if (!ActivityCompat.shouldShowRequestPermissionRationale(WarpActivity, perm)) {
615 + ActivityCompat.requestPermissions(WarpActivity, new String[]{perm}, 3001);
616 + geolocationOrigin = origin;
617 + geolocationCallback = callback;
618 + } else {
619 + //TODO: show infromative popup and go to settings
620 + }
621 + }
622 + }
623 + }
624 +
625 + private void enableLocationSettings() {
626 + GoogleApiClient googleApiClient = new GoogleApiClient.Builder(WarpActivity)
627 + .addApi(LocationServices.API)
628 + .build();
629 + googleApiClient.connect();
630 +
631 + LocationRequest locationRequest = LocationRequest.create();
632 + locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
633 + locationRequest.setInterval(30 * 1000);
634 + locationRequest.setFastestInterval(5 * 1000);
635 + LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder()
636 + .addLocationRequest(locationRequest);
637 + builder.setAlwaysShow(true); //this is the key ingredient
638 +
639 + PendingResult<LocationSettingsResult> result = LocationServices.SettingsApi.checkLocationSettings(googleApiClient, builder.build());
640 + result.setResultCallback(result1 -> {
641 + final Status status = result1.getStatus();
642 + switch (status.getStatusCode()) {
643 + case LocationSettingsStatusCodes.SUCCESS:
644 + geolocationCallback.invoke(geolocationOrigin, true, false);
645 + break;
646 + case LocationSettingsStatusCodes.RESOLUTION_REQUIRED:
647 + try {
648 + status.startResolutionForResult(WarpActivity, 3002);
649 + } catch (IntentSender.SendIntentException ignored) {
650 + geolocationCallback.invoke(geolocationOrigin, true, false);
651 + }
652 + break;
653 + case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE:
654 + geolocationCallback.invoke(geolocationOrigin, true, false);
655 + break;
656 + }
657 + });
658 + }
659 +
660 + private boolean isGPSEnabled() {
661 + LocationManager lm = (LocationManager) getContext().getSystemService(Context.LOCATION_SERVICE);
662 + try {
663 + boolean gpsEnabled = lm.isProviderEnabled(LocationManager.GPS_PROVIDER);
664 + return gpsEnabled;
665 + } catch (Exception ex) {
666 + ex.printStackTrace();
667 + return false;
668 + }
669 + }
670 +
546 private class WarplyWebViewClient extends WebViewClient { 671 private class WarplyWebViewClient extends WebViewClient {
547 672
548 @SuppressWarnings("deprecation") 673 @SuppressWarnings("deprecation")
549 - public void onReceivedError(WebView view, int errorCode, 674 + public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
550 - String description, String failingUrl) {
551 675
552 WarpUtils.log("Error " + errorCode + " loading url " + failingUrl); 676 WarpUtils.log("Error " + errorCode + " loading url " + failingUrl);
553 WarpUtils.log("Error description " + description); 677 WarpUtils.log("Error description " + description);
554 678
555 - if (android.os.Build.VERSION.SDK_INT >= 679 + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) {
556 - android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) {
557 WarpView.this.loadUrl("about:blank"); 680 WarpView.this.loadUrl("about:blank");
558 } else { 681 } else {
559 WarpView.this.clearView(); 682 WarpView.this.clearView();
...@@ -626,8 +749,7 @@ public class WarpView extends WebView { ...@@ -626,8 +749,7 @@ public class WarpView extends WebView {
626 String scheme = uri.getScheme(); 749 String scheme = uri.getScheme();
627 String authority = uri.getAuthority(); 750 String authority = uri.getAuthority();
628 751
629 - if (scheme == null) 752 + if (scheme == null) return false;
630 - return false;
631 if (scheme.equalsIgnoreCase(URL_ACTION_TEL)) { 753 if (scheme.equalsIgnoreCase(URL_ACTION_TEL)) {
632 actionTel(uri); 754 actionTel(uri);
633 return true; 755 return true;
...@@ -643,8 +765,7 @@ public class WarpView extends WebView { ...@@ -643,8 +765,7 @@ public class WarpView extends WebView {
643 } else if (scheme.equals(URL_ACTION_MARKET)) { 765 } else if (scheme.equals(URL_ACTION_MARKET)) {
644 actionMarket(uri); 766 actionMarket(uri);
645 return true; 767 return true;
646 - } else if (authority != null 768 + } else if (authority != null && authority.equalsIgnoreCase(URL_ACTION_MARKET_AUTHORITY)) {
647 - && authority.equalsIgnoreCase(URL_ACTION_MARKET_AUTHORITY)) {
648 actionMarket(uri); 769 actionMarket(uri);
649 return true; 770 return true;
650 } else if (scheme.equals(WarplyProperty.getDlUrlScheme(Warply.getWarplyContext()))) { 771 } else if (scheme.equals(WarplyProperty.getDlUrlScheme(Warply.getWarplyContext()))) {
......
...@@ -170,6 +170,11 @@ ...@@ -170,6 +170,11 @@
170 <string name="cos_for_you_all">Μέχρι τώρα έχεις κερδίσει&#160;%1$s€&#160;στο For You!</string> 170 <string name="cos_for_you_all">Μέχρι τώρα έχεις κερδίσει&#160;%1$s€&#160;στο For You!</string>
171 <string name="cos_supermarket_win">Έχεις κερδίσει&#160;%1$s€&#160;με τα\nSuperMarket Deals!</string> 171 <string name="cos_supermarket_win">Έχεις κερδίσει&#160;%1$s€&#160;με τα\nSuperMarket Deals!</string>
172 <string name="cos_supermarket_history">Μέχρι τώρα έχεις κερδίσει %1$s€ σε προσφορές από %2$s κουπόνια!</string> 172 <string name="cos_supermarket_history">Μέχρι τώρα έχεις κερδίσει %1$s€ σε προσφορές από %2$s κουπόνια!</string>
173 + <string name="lbl_cosmote_webview_permission_title">COSMOTE</string>
174 + <string name="lbl_cosmote_webview_permission_message">Το COSMOTE ζητάει πρόσβαση στην τοποθεσία σας.</string>
175 + <string name="lbl_take_photo_accept">Οκ</string>
176 + <string name="lbl_take_photo_decline">Άκυρο</string>
177 + <string name="lbl_gps_enabled">Θέλετε να ενεργοποιήσετε το GPS;</string>
173 178
174 <string-array name="coupons_array"> 179 <string-array name="coupons_array">
175 <item>Κουπόνια</item> 180 <item>Κουπόνια</item>
......