Showing
15 changed files
with
1064 additions
and
177 deletions
... | @@ -42,7 +42,7 @@ public class SplashActivity extends BaseActivity { | ... | @@ -42,7 +42,7 @@ public class SplashActivity extends BaseActivity { |
42 | // ); | 42 | // ); |
43 | 43 | ||
44 | WarplyManager.getCosmoteUser(new WarplyCosmoteUserRequest() | 44 | WarplyManager.getCosmoteUser(new WarplyCosmoteUserRequest() |
45 | - .setGuid("6012049323"), //6012049321, 6012049322, 6012049323 | 45 | + .setGuid("6012049321"), //6012049321, 6012049322, 6012049323 |
46 | mLoginReceiver); | 46 | mLoginReceiver); |
47 | 47 | ||
48 | // WarplyManager.verifyTicket(new WarplyVerifyTicketRequest() | 48 | // WarplyManager.verifyTicket(new WarplyVerifyTicketRequest() | ... | ... |
... | @@ -157,6 +157,11 @@ | ... | @@ -157,6 +157,11 @@ |
157 | android:permission="android.permission.BIND_JOB_SERVICE" /> | 157 | android:permission="android.permission.BIND_JOB_SERVICE" /> |
158 | 158 | ||
159 | <service | 159 | <service |
160 | + android:name="ly.warp.sdk.services.WarplyHealthService" | ||
161 | + android:exported="false" | ||
162 | + android:permission="android.permission.BIND_JOB_SERVICE" /> | ||
163 | + | ||
164 | + <service | ||
160 | android:name="ly.warp.sdk.services.WarplyBeaconsRangingService" | 165 | android:name="ly.warp.sdk.services.WarplyBeaconsRangingService" |
161 | android:exported="false" /> | 166 | android:exported="false" /> |
162 | 167 | ... | ... |
... | @@ -45,7 +45,7 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener { | ... | @@ -45,7 +45,7 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener { |
45 | private ImageView mIvBack, mIvDealsLogo, mIvProfilePhoto; | 45 | private ImageView mIvBack, mIvDealsLogo, mIvProfilePhoto; |
46 | private TextView mTvUsername, mTvDealsValue, mTvDealsValueAll, | 46 | private TextView mTvUsername, mTvDealsValue, mTvDealsValueAll, |
47 | mTvUserBadge, mTvGiftsValue, mTvGiftsValueAll, mTvActiveCode, mTvActiveDate, | 47 | mTvUserBadge, mTvGiftsValue, mTvGiftsValueAll, mTvActiveCode, mTvActiveDate, |
48 | - mTvActiveTitle; | 48 | + mTvActiveTitle, mTvActiveCouponsHeader; |
49 | private ConstraintLayout mClDealsBanner, mClDealsView, | 49 | private ConstraintLayout mClDealsBanner, mClDealsView, |
50 | mClGiftsBanner; | 50 | mClGiftsBanner; |
51 | private LinearLayout mLlQuestionnaire, mLlUserBadge; | 51 | private LinearLayout mLlQuestionnaire, mLlUserBadge; |
... | @@ -79,6 +79,7 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener { | ... | @@ -79,6 +79,7 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener { |
79 | mClDealsView = findViewById(R.id.cl_mygifts); | 79 | mClDealsView = findViewById(R.id.cl_mygifts); |
80 | mIvProfilePhoto = findViewById(R.id.iv_profile_photo); | 80 | mIvProfilePhoto = findViewById(R.id.iv_profile_photo); |
81 | mTvActiveTitle = findViewById(R.id.tv_active_gifts); | 81 | mTvActiveTitle = findViewById(R.id.tv_active_gifts); |
82 | + mTvActiveCouponsHeader = findViewById(R.id.tv_active_coupons_header); | ||
82 | 83 | ||
83 | if (WarplyManagerHelper.getActiveDFYCoupons() != null) { | 84 | if (WarplyManagerHelper.getActiveDFYCoupons() != null) { |
84 | Collections.sort(WarplyManagerHelper.getActiveDFYCoupons(), new Comparator<ActiveDFYCouponModel>() { | 85 | Collections.sort(WarplyManagerHelper.getActiveDFYCoupons(), new Comparator<ActiveDFYCouponModel>() { |
... | @@ -116,6 +117,7 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener { | ... | @@ -116,6 +117,7 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener { |
116 | } | 117 | } |
117 | if (view.getId() == R.id.ll_user_questionnaire || view.getId() == R.id.ll_user_badge) { | 118 | if (view.getId() == R.id.ll_user_questionnaire || view.getId() == R.id.ll_user_badge) { |
118 | startActivityForResult(WarpViewActivity.createIntentFromURL(LoyaltyWallet.this, WarplyManagerHelper.openQuestionnaire()), 1000); | 119 | startActivityForResult(WarpViewActivity.createIntentFromURL(LoyaltyWallet.this, WarplyManagerHelper.openQuestionnaire()), 1000); |
120 | +// startActivity(WarpViewActivity.createIntentFromURL(LoyaltyWallet.this, WarplyManagerHelper.openPacing())); | ||
119 | return; | 121 | return; |
120 | } | 122 | } |
121 | if (view.getId() == R.id.cl_deals_cos) { | 123 | if (view.getId() == R.id.cl_deals_cos) { |
... | @@ -171,15 +173,24 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener { | ... | @@ -171,15 +173,24 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener { |
171 | .subscribe(); | 173 | .subscribe(); |
172 | } | 174 | } |
173 | 175 | ||
174 | - if (WarplyManagerHelper.getLoyaltyBadge() != null) { | 176 | + if (WarplyManagerHelper.getDealsCouponsSum() > 0) { |
175 | - WarpUtils.log("LOYALTY_BADGE_COUNT: " + String.valueOf(WarplyManagerHelper.getLoyaltyBadge().getCouponCount())); | 177 | + mTvDealsValue.setText(String.format(getString(R.string.cos_value), String.valueOf(/*couponDfyValue*/ WarplyManagerHelper.getDealsCouponsSum()))); |
176 | - WarpUtils.log("LOYALTY_BADGE_SUM: " + String.valueOf(WarplyManagerHelper.getLoyaltyBadge().getValue())); | 178 | + mTvDealsValueAll.setText(String.format(getString(R.string.cos_deals_win_title_cos), String.valueOf(/*couponDfyValue*/WarplyManagerHelper.getDealsCouponsSum()))); |
179 | + } else { | ||
180 | + mClDealsBanner.setVisibility(View.GONE); | ||
177 | } | 181 | } |
178 | 182 | ||
183 | + if (WarplyManagerHelper.getLoyaltyBadge() != null) { | ||
184 | + if (WarplyManagerHelper.getLoyaltyBadge().getCouponCount() > 0) { | ||
179 | mTvGiftsValue.setText(String.format(getString(R.string.cos_value), String.valueOf(WarplyManagerHelper.getLoyaltyBadge().getValue()))); | 185 | mTvGiftsValue.setText(String.format(getString(R.string.cos_value), String.valueOf(WarplyManagerHelper.getLoyaltyBadge().getValue()))); |
180 | mTvGiftsValueAll.setText(String.format(getString(R.string.cos_deals_win_title), String.valueOf(WarplyManagerHelper.getLoyaltyBadge().getValue()), String.valueOf(WarplyManagerHelper.getLoyaltyBadge().getCouponCount()))); | 186 | mTvGiftsValueAll.setText(String.format(getString(R.string.cos_deals_win_title), String.valueOf(WarplyManagerHelper.getLoyaltyBadge().getValue()), String.valueOf(WarplyManagerHelper.getLoyaltyBadge().getCouponCount()))); |
181 | - mTvDealsValue.setText(String.format(getString(R.string.cos_value), String.valueOf(/*couponDfyValue*/ WarplyManagerHelper.getDealsCouponsSum()))); | 187 | + } else { |
182 | - mTvDealsValueAll.setText(String.format(getString(R.string.cos_deals_win_title_cos), String.valueOf(/*couponDfyValue*/WarplyManagerHelper.getDealsCouponsSum()))); | 188 | + mClGiftsBanner.setVisibility(View.GONE); |
189 | + } | ||
190 | + } else { | ||
191 | + mClGiftsBanner.setVisibility(View.GONE); | ||
192 | + } | ||
193 | + | ||
183 | if (WarplyManagerHelper.getActiveDFYCoupons() != null && WarplyManagerHelper.getActiveDFYCoupons().size() > 0) { | 194 | if (WarplyManagerHelper.getActiveDFYCoupons() != null && WarplyManagerHelper.getActiveDFYCoupons().size() > 0) { |
184 | String codes = ""; | 195 | String codes = ""; |
185 | if (WarplyManagerHelper.getActiveDFYCoupons().size() == 1) { | 196 | if (WarplyManagerHelper.getActiveDFYCoupons().size() == 1) { |
... | @@ -208,6 +219,7 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener { | ... | @@ -208,6 +219,7 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener { |
208 | // e.printStackTrace(); | 219 | // e.printStackTrace(); |
209 | // } | 220 | // } |
210 | } else { | 221 | } else { |
222 | + mTvActiveCouponsHeader.setVisibility(View.GONE); | ||
211 | mIvDealsLogo.setVisibility(View.GONE); | 223 | mIvDealsLogo.setVisibility(View.GONE); |
212 | mClDealsView.setVisibility(View.GONE); | 224 | mClDealsView.setVisibility(View.GONE); |
213 | } | 225 | } | ... | ... |
... | @@ -183,7 +183,15 @@ public class TelcoActivity extends Activity implements View.OnClickListener { | ... | @@ -183,7 +183,15 @@ public class TelcoActivity extends Activity implements View.OnClickListener { |
183 | .setDataCategory(mCCMS.getDataCategory()) | 183 | .setDataCategory(mCCMS.getDataCategory()) |
184 | .setMinsValue(mCCMS.getMinsValue()) | 184 | .setMinsValue(mCCMS.getMinsValue()) |
185 | .setDataValue(mCCMS.getDataValue()) | 185 | .setDataValue(mCCMS.getDataValue()) |
186 | - .setProvStepValueMins(mCCMS.getProvStepValueMins()), | 186 | + .setProvStepValueMins(mCCMS.getProvStepValueMins()) |
187 | + .setOfferAudienceLevel(mCCMS.getOfferAudienceLevel()) | ||
188 | + .setUACIOfferTrackingCode(mCCMS.getUACIOfferTrackingCode()) | ||
189 | + .setOfferCode1(mCCMS.getOfferCode1()) | ||
190 | + .setScore(mCCMS.getScore()) | ||
191 | + .setZone(mCCMS.getZone()) | ||
192 | + .setWave(mCCMS.getWave()) | ||
193 | + .setValidity(mCCMS.getValidity()) | ||
194 | + .setTreatmentCode(mCCMS.getTreatmentCode()), | ||
187 | mSubmitCallback); | 195 | mSubmitCallback); |
188 | } | 196 | } |
189 | Thread.currentThread().interrupt(); | 197 | Thread.currentThread().interrupt(); |
... | @@ -250,25 +258,25 @@ public class TelcoActivity extends Activity implements View.OnClickListener { | ... | @@ -250,25 +258,25 @@ public class TelcoActivity extends Activity implements View.OnClickListener { |
250 | errorActivatingDialog(); | 258 | errorActivatingDialog(); |
251 | }); | 259 | }); |
252 | 260 | ||
253 | - if (status == 1) { | 261 | +// if (status == 1) { |
254 | - new Thread(() -> { | 262 | +// new Thread(() -> { |
255 | - if (!Thread.currentThread().isInterrupted()) { | 263 | +// if (!Thread.currentThread().isInterrupted()) { |
256 | - WarplyManager.postEvent(new CosmotePostEventRequest() | 264 | +// WarplyManager.postEvent(new CosmotePostEventRequest() |
257 | - .setCommunicationUuid(mLoyalty.getSessionUUID()) | 265 | +// .setCommunicationUuid(mLoyalty.getSessionUUID()) |
258 | - .setUserMsisdn(mSender) | 266 | +// .setUserMsisdn(mSender) |
259 | - .setOfferAudienceLevel(mCCMS.getOfferAudienceLevel()) | 267 | +// .setOfferAudienceLevel(mCCMS.getOfferAudienceLevel()) |
260 | - .setUACIOfferTrackingCode(mCCMS.getUACIOfferTrackingCode()) | 268 | +// .setUACIOfferTrackingCode(mCCMS.getUACIOfferTrackingCode()) |
261 | - .setOfferCode1(mCCMS.getOfferCode1()) | 269 | +// .setOfferCode1(mCCMS.getOfferCode1()) |
262 | - .setScore(mCCMS.getScore()) | 270 | +// .setScore(mCCMS.getScore()) |
263 | - .setZone(mCCMS.getZone()) | 271 | +// .setZone(mCCMS.getZone()) |
264 | - .setWave(mCCMS.getWave()) | 272 | +// .setWave(mCCMS.getWave()) |
265 | - .setValidity(mCCMS.getValidity()) | 273 | +// .setValidity(mCCMS.getValidity()) |
266 | - .setTreatmentCode(mCCMS.getTreatmentCode()), | 274 | +// .setTreatmentCode(mCCMS.getTreatmentCode()), |
267 | - mPostCallback); | 275 | +// mPostCallback); |
268 | - } | 276 | +// } |
269 | - Thread.currentThread().interrupt(); | 277 | +// Thread.currentThread().interrupt(); |
270 | - }).start(); | 278 | +// }).start(); |
271 | - } | 279 | +// } |
272 | } | 280 | } |
273 | 281 | ||
274 | @Override | 282 | @Override |
... | @@ -277,16 +285,16 @@ public class TelcoActivity extends Activity implements View.OnClickListener { | ... | @@ -277,16 +285,16 @@ public class TelcoActivity extends Activity implements View.OnClickListener { |
277 | } | 285 | } |
278 | }; | 286 | }; |
279 | 287 | ||
280 | - private CallbackReceiver<JSONObject> mPostCallback = new CallbackReceiver<JSONObject>() { | 288 | +// private CallbackReceiver<JSONObject> mPostCallback = new CallbackReceiver<JSONObject>() { |
281 | - @Override | 289 | +// @Override |
282 | - public void onSuccess(JSONObject result) { | 290 | +// public void onSuccess(JSONObject result) { |
283 | - Thread.currentThread().interrupt(); | 291 | +// Thread.currentThread().interrupt(); |
284 | - } | 292 | +// } |
285 | - | 293 | +// |
286 | - @Override | 294 | +// @Override |
287 | - public void onFailure(int errorCode) { | 295 | +// public void onFailure(int errorCode) { |
288 | - WarpUtils.log("POST_EVENT_ERROR " + String.valueOf(errorCode)); | 296 | +// WarpUtils.log("POST_EVENT_ERROR " + String.valueOf(errorCode)); |
289 | - Thread.currentThread().interrupt(); | 297 | +// Thread.currentThread().interrupt(); |
290 | - } | 298 | +// } |
291 | - }; | 299 | +// }; |
292 | } | 300 | } | ... | ... |
... | @@ -49,6 +49,7 @@ import androidx.work.WorkManager; | ... | @@ -49,6 +49,7 @@ import androidx.work.WorkManager; |
49 | 49 | ||
50 | import org.greenrobot.eventbus.EventBus; | 50 | import org.greenrobot.eventbus.EventBus; |
51 | import org.greenrobot.eventbus.Subscribe; | 51 | import org.greenrobot.eventbus.Subscribe; |
52 | +import org.json.JSONObject; | ||
52 | 53 | ||
53 | import java.security.SecureRandom; | 54 | import java.security.SecureRandom; |
54 | import java.util.concurrent.ThreadLocalRandom; | 55 | import java.util.concurrent.ThreadLocalRandom; |
... | @@ -113,6 +114,12 @@ public class WarpViewActivity extends WarpBaseActivity { | ... | @@ -113,6 +114,12 @@ public class WarpViewActivity extends WarpBaseActivity { |
113 | } | 114 | } |
114 | 115 | ||
115 | @Override | 116 | @Override |
117 | + protected void onDestroy() { | ||
118 | + super.onDestroy(); | ||
119 | + WarpUtils.setWebviewParams(this, new JSONObject()); | ||
120 | + } | ||
121 | + | ||
122 | + @Override | ||
116 | public boolean onKeyDown(int keyCode, @NonNull KeyEvent event) { | 123 | public boolean onKeyDown(int keyCode, @NonNull KeyEvent event) { |
117 | if (keyCode == KeyEvent.KEYCODE_BACK) { | 124 | if (keyCode == KeyEvent.KEYCODE_BACK) { |
118 | if (mWarpView.canGoBack()) { | 125 | if (mWarpView.canGoBack()) { | ... | ... |
... | @@ -155,7 +155,7 @@ public class CosmotePostEventRequest { | ... | @@ -155,7 +155,7 @@ public class CosmotePostEventRequest { |
155 | * Call this to set how often the cached data will be updated. | 155 | * Call this to set how often the cached data will be updated. |
156 | * | 156 | * |
157 | * @param updateInterval The time that data will be cached | 157 | * @param updateInterval The time that data will be cached |
158 | - * @return WarplyConsumerRequest | 158 | + * @return CosmotePostEventRequest |
159 | */ | 159 | */ |
160 | public CosmotePostEventRequest setCacheUpdateInterval(long updateInterval) { | 160 | public CosmotePostEventRequest setCacheUpdateInterval(long updateInterval) { |
161 | 161 | ||
... | @@ -181,7 +181,7 @@ public class CosmotePostEventRequest { | ... | @@ -181,7 +181,7 @@ public class CosmotePostEventRequest { |
181 | * | 181 | * |
182 | * @param useCache <p>true - the Application is using Cache</p> | 182 | * @param useCache <p>true - the Application is using Cache</p> |
183 | * <p>false - the Application is not using Cache</p> | 183 | * <p>false - the Application is not using Cache</p> |
184 | - * @return WarplyConsumerRequest | 184 | + * @return CosmotePostEventRequest |
185 | */ | 185 | */ |
186 | public CosmotePostEventRequest setUseCache(boolean useCache) { | 186 | public CosmotePostEventRequest setUseCache(boolean useCache) { |
187 | 187 | ||
... | @@ -335,7 +335,7 @@ public class CosmotePostEventRequest { | ... | @@ -335,7 +335,7 @@ public class CosmotePostEventRequest { |
335 | } | 335 | } |
336 | 336 | ||
337 | public String getSignature() { | 337 | public String getSignature() { |
338 | - String signature = mFilters != null && mFilters.size() > 0 ? String.valueOf(mFilters.hashCode()) : "default_consumer_request"; | 338 | + String signature = mFilters != null && mFilters.size() > 0 ? String.valueOf(mFilters.hashCode()) : "default_cosmote_post_event_request"; |
339 | try { | 339 | try { |
340 | byte[] hash = MessageDigest.getInstance("SHA-256").digest(signature.getBytes("UTF-8")); | 340 | byte[] hash = MessageDigest.getInstance("SHA-256").digest(signature.getBytes("UTF-8")); |
341 | signature = Base64.encodeToString(hash, Base64.NO_WRAP); | 341 | signature = Base64.encodeToString(hash, Base64.NO_WRAP); | ... | ... |
... | @@ -2,6 +2,7 @@ package ly.warp.sdk.io.request; | ... | @@ -2,6 +2,7 @@ package ly.warp.sdk.io.request; |
2 | 2 | ||
3 | import android.util.Base64; | 3 | import android.util.Base64; |
4 | 4 | ||
5 | +import org.json.JSONArray; | ||
5 | import org.json.JSONException; | 6 | import org.json.JSONException; |
6 | import org.json.JSONObject; | 7 | import org.json.JSONObject; |
7 | 8 | ||
... | @@ -42,6 +43,7 @@ public class CosmoteSubmitOrderRequest { | ... | @@ -42,6 +43,7 @@ public class CosmoteSubmitOrderRequest { |
42 | private final String KEY_MINS_VALUE = "minsValue"; | 43 | private final String KEY_MINS_VALUE = "minsValue"; |
43 | private final String KEY_DATA_VALUE = "dataValue"; | 44 | private final String KEY_DATA_VALUE = "dataValue"; |
44 | private final String KEY_PROV_STEP_VALUE_MINS = "provStepValueMins"; | 45 | private final String KEY_PROV_STEP_VALUE_MINS = "provStepValueMins"; |
46 | + private final String KEY_PARAMETERS = "parameters"; | ||
45 | 47 | ||
46 | // =========================================================== | 48 | // =========================================================== |
47 | // Fields | 49 | // Fields |
... | @@ -63,6 +65,14 @@ public class CosmoteSubmitOrderRequest { | ... | @@ -63,6 +65,14 @@ public class CosmoteSubmitOrderRequest { |
63 | private String mMinsValue = ""; | 65 | private String mMinsValue = ""; |
64 | private String mDataValue = ""; | 66 | private String mDataValue = ""; |
65 | private String mProvStepValueMins = ""; | 67 | private String mProvStepValueMins = ""; |
68 | + private String mOfferAudienceLevel = ""; | ||
69 | + private String mUACIOfferTrackingCode = ""; | ||
70 | + private String mOfferCode1 = ""; | ||
71 | + private String mScore = ""; | ||
72 | + private String mZone = ""; | ||
73 | + private String mWave = ""; | ||
74 | + private String mValidity = ""; | ||
75 | + private String mTreatmentCode = ""; | ||
66 | 76 | ||
67 | // =========================================================== | 77 | // =========================================================== |
68 | // Constructor | 78 | // Constructor |
... | @@ -178,6 +188,46 @@ public class CosmoteSubmitOrderRequest { | ... | @@ -178,6 +188,46 @@ public class CosmoteSubmitOrderRequest { |
178 | return this; | 188 | return this; |
179 | } | 189 | } |
180 | 190 | ||
191 | + public CosmoteSubmitOrderRequest setOfferAudienceLevel(String offerAudienceLevel) { | ||
192 | + this.mOfferAudienceLevel = offerAudienceLevel; | ||
193 | + return this; | ||
194 | + } | ||
195 | + | ||
196 | + public CosmoteSubmitOrderRequest setUACIOfferTrackingCode(String uaciOfferTrackingCode) { | ||
197 | + this.mUACIOfferTrackingCode = uaciOfferTrackingCode; | ||
198 | + return this; | ||
199 | + } | ||
200 | + | ||
201 | + public CosmoteSubmitOrderRequest setOfferCode1(String offerCode1) { | ||
202 | + this.mOfferCode1 = offerCode1; | ||
203 | + return this; | ||
204 | + } | ||
205 | + | ||
206 | + public CosmoteSubmitOrderRequest setScore(String score) { | ||
207 | + this.mScore = score; | ||
208 | + return this; | ||
209 | + } | ||
210 | + | ||
211 | + public CosmoteSubmitOrderRequest setZone(String zone) { | ||
212 | + this.mZone = zone; | ||
213 | + return this; | ||
214 | + } | ||
215 | + | ||
216 | + public CosmoteSubmitOrderRequest setWave(String wave) { | ||
217 | + this.mWave = wave; | ||
218 | + return this; | ||
219 | + } | ||
220 | + | ||
221 | + public CosmoteSubmitOrderRequest setValidity(String validity) { | ||
222 | + this.mValidity = validity; | ||
223 | + return this; | ||
224 | + } | ||
225 | + | ||
226 | + public CosmoteSubmitOrderRequest setTreatmentCode(String treatmentCode) { | ||
227 | + this.mTreatmentCode = treatmentCode; | ||
228 | + return this; | ||
229 | + } | ||
230 | + | ||
181 | /** | 231 | /** |
182 | * Call this to get how often the cached data will be updated. | 232 | * Call this to get how often the cached data will be updated. |
183 | * | 233 | * |
... | @@ -191,7 +241,7 @@ public class CosmoteSubmitOrderRequest { | ... | @@ -191,7 +241,7 @@ public class CosmoteSubmitOrderRequest { |
191 | * Call this to set how often the cached data will be updated. | 241 | * Call this to set how often the cached data will be updated. |
192 | * | 242 | * |
193 | * @param updateInterval The time that data will be cached | 243 | * @param updateInterval The time that data will be cached |
194 | - * @return CosmoteSharingRequest | 244 | + * @return CosmoteSubmitOrderRequest |
195 | */ | 245 | */ |
196 | public CosmoteSubmitOrderRequest setCacheUpdateInterval(long updateInterval) { | 246 | public CosmoteSubmitOrderRequest setCacheUpdateInterval(long updateInterval) { |
197 | 247 | ||
... | @@ -217,7 +267,7 @@ public class CosmoteSubmitOrderRequest { | ... | @@ -217,7 +267,7 @@ public class CosmoteSubmitOrderRequest { |
217 | * | 267 | * |
218 | * @param useCache <p>true - the Application is using Cache</p> | 268 | * @param useCache <p>true - the Application is using Cache</p> |
219 | * <p>false - the Application is not using Cache</p> | 269 | * <p>false - the Application is not using Cache</p> |
220 | - * @return CosmoteSharingRequest | 270 | + * @return CosmoteSubmitOrderRequest |
221 | */ | 271 | */ |
222 | public CosmoteSubmitOrderRequest setUseCache(boolean useCache) { | 272 | public CosmoteSubmitOrderRequest setUseCache(boolean useCache) { |
223 | 273 | ||
... | @@ -257,6 +307,123 @@ public class CosmoteSubmitOrderRequest { | ... | @@ -257,6 +307,123 @@ public class CosmoteSubmitOrderRequest { |
257 | extraData.putOpt(KEY_MINS_VALUE, mMinsValue); | 307 | extraData.putOpt(KEY_MINS_VALUE, mMinsValue); |
258 | extraData.putOpt(KEY_DATA_VALUE, mDataValue); | 308 | extraData.putOpt(KEY_DATA_VALUE, mDataValue); |
259 | extraData.putOpt(KEY_PROV_STEP_VALUE_MINS, mProvStepValueMins); | 309 | extraData.putOpt(KEY_PROV_STEP_VALUE_MINS, mProvStepValueMins); |
310 | + extraData.putOpt("InteractiveChannel", "COSMOTE_OMNI"); | ||
311 | + extraData.putOpt("InteractionPoint", mZone); | ||
312 | + extraData.putOpt("Session_ID", mCommunicationUuid); | ||
313 | + extraData.putOpt("OfferAudienceLevel", mOfferAudienceLevel); | ||
314 | + extraData.putOpt("MSISDN", mOfferAudienceLevel.equals("msisdn") ? mUserMsisdn : ""); | ||
315 | + extraData.putOpt("GUID", ""); | ||
316 | + | ||
317 | + JSONArray parameters = new JSONArray(); | ||
318 | + JSONObject param1 = new JSONObject(); | ||
319 | + param1.putOpt("Name", "UACIOfferTrackingCode"); | ||
320 | + param1.putOpt("Value", mUACIOfferTrackingCode); | ||
321 | + param1.putOpt("Type", "string"); | ||
322 | + parameters.put(param1); | ||
323 | + | ||
324 | + JSONObject param2 = new JSONObject(); | ||
325 | + param2.putOpt("Name", "UACICustomLoggerTableName"); | ||
326 | + param2.putOpt("Value", "VW_WHITELIST"); | ||
327 | + param2.putOpt("Type", "string"); | ||
328 | + parameters.put(param2); | ||
329 | + | ||
330 | + JSONObject param3 = new JSONObject(); | ||
331 | + param3.putOpt("Name", "MSISDN"); | ||
332 | + param3.putOpt("Value", mUserMsisdn); | ||
333 | + param3.putOpt("Type", "string"); | ||
334 | + parameters.put(param3); | ||
335 | + | ||
336 | + JSONObject param4 = new JSONObject(); | ||
337 | + param4.putOpt("Name", "OFFERCODE1"); | ||
338 | + param4.putOpt("Value", mOfferCode1); | ||
339 | + param4.putOpt("Type", "string"); | ||
340 | + parameters.put(param4); | ||
341 | + | ||
342 | + JSONObject param5 = new JSONObject(); | ||
343 | + param5.putOpt("Name", "SCORE"); | ||
344 | + param5.putOpt("Value", mScore); | ||
345 | + param5.putOpt("Type", "INT"); | ||
346 | + parameters.put(param5); | ||
347 | + | ||
348 | + JSONObject param6 = new JSONObject(); | ||
349 | + param6.putOpt("Name", "PREDICATE"); | ||
350 | + param6.putOpt("Value", "0"); | ||
351 | + param6.putOpt("Type", "string"); | ||
352 | + parameters.put(param6); | ||
353 | + | ||
354 | + JSONObject param7 = new JSONObject(); | ||
355 | + param7.putOpt("Name", "ZONE"); | ||
356 | + param7.putOpt("Value", mZone); | ||
357 | + param7.putOpt("Type", "string"); | ||
358 | + parameters.put(param7); | ||
359 | + | ||
360 | + JSONObject param8 = new JSONObject(); | ||
361 | + param8.putOpt("Name", "APPLICATIONNAME"); | ||
362 | + param8.putOpt("Value", mZone); | ||
363 | + param8.putOpt("Type", "string"); | ||
364 | + parameters.put(param8); | ||
365 | + | ||
366 | + JSONObject param9 = new JSONObject(); | ||
367 | + param9.putOpt("Name", "Session_ID"); | ||
368 | + param9.putOpt("Value", mCommunicationUuid); | ||
369 | + param9.putOpt("Type", "string"); | ||
370 | + parameters.put(param9); | ||
371 | + | ||
372 | + JSONObject param10 = new JSONObject(); | ||
373 | + param10.putOpt("Name", "CAMPAIGN_CODE"); | ||
374 | + param10.putOpt("Value", "MCC_00006"); | ||
375 | + param10.putOpt("Type", "string"); | ||
376 | + parameters.put(param10); | ||
377 | + | ||
378 | + JSONObject param11 = new JSONObject(); | ||
379 | + param11.putOpt("Name", "CAMPAIGN_TYPE"); | ||
380 | + param11.putOpt("Value", "Inbound"); | ||
381 | + param11.putOpt("Type", "string"); | ||
382 | + parameters.put(param11); | ||
383 | + | ||
384 | + JSONObject param12 = new JSONObject(); | ||
385 | + param12.putOpt("Name", "UACIResponseTypeCode"); | ||
386 | + param12.putOpt("Value", "CON"); | ||
387 | + param12.putOpt("Type", "string"); | ||
388 | + parameters.put(param12); | ||
389 | + | ||
390 | + JSONObject param13 = new JSONObject(); | ||
391 | + param13.putOpt("Name", "CHANNEL"); | ||
392 | + param13.putOpt("Value", "ONE_APP"); | ||
393 | + param13.putOpt("Type", "string"); | ||
394 | + parameters.put(param13); | ||
395 | + | ||
396 | + JSONObject param14 = new JSONObject(); | ||
397 | + param14.putOpt("Name", "WAVE"); | ||
398 | + param14.putOpt("Value", mWave); | ||
399 | + param14.putOpt("Type", "string"); | ||
400 | + parameters.put(param14); | ||
401 | + | ||
402 | + JSONObject param15 = new JSONObject(); | ||
403 | + param15.putOpt("Name", "RESPONSECHANNEL"); | ||
404 | + param15.putOpt("Value", "ONE_APP"); | ||
405 | + param15.putOpt("Type", "string"); | ||
406 | + parameters.put(param15); | ||
407 | + | ||
408 | + JSONObject param16 = new JSONObject(); | ||
409 | + param16.putOpt("Name", "VALIDITY"); | ||
410 | + param16.putOpt("Value", mValidity); | ||
411 | + param16.putOpt("Type", "INT"); | ||
412 | + parameters.put(param16); | ||
413 | + | ||
414 | + JSONObject param17 = new JSONObject(); | ||
415 | + param17.putOpt("Name", "TREATMENT_CODE"); | ||
416 | + param17.putOpt("Value", mTreatmentCode); | ||
417 | + param17.putOpt("Type", "string"); | ||
418 | + parameters.put(param17); | ||
419 | + | ||
420 | + JSONObject param18 = new JSONObject(); | ||
421 | + param18.putOpt("Name", "EventName"); | ||
422 | + param18.putOpt("Value", "INTEREST_P"); | ||
423 | + param18.putOpt("Type", "string"); | ||
424 | + parameters.put(param18); | ||
425 | + | ||
426 | + extraData.putOpt(KEY_PARAMETERS, parameters); | ||
260 | 427 | ||
261 | extraJson.putOpt(KEY_EXTRA_DATA, extraData); | 428 | extraJson.putOpt(KEY_EXTRA_DATA, extraData); |
262 | bodyJsonObject.putOpt(KEY_MAPP, extraJson); | 429 | bodyJsonObject.putOpt(KEY_MAPP, extraJson); |
... | @@ -268,7 +435,7 @@ public class CosmoteSubmitOrderRequest { | ... | @@ -268,7 +435,7 @@ public class CosmoteSubmitOrderRequest { |
268 | } | 435 | } |
269 | 436 | ||
270 | public String getSignature() { | 437 | public String getSignature() { |
271 | - String signature = mFilters != null && mFilters.size() > 0 ? String.valueOf(mFilters.hashCode()) : "default_cosmote_sharing_request"; | 438 | + String signature = mFilters != null && mFilters.size() > 0 ? String.valueOf(mFilters.hashCode()) : "default_cosmote_submit_order_request"; |
272 | try { | 439 | try { |
273 | byte[] hash = MessageDigest.getInstance("SHA-256").digest(signature.getBytes("UTF-8")); | 440 | byte[] hash = MessageDigest.getInstance("SHA-256").digest(signature.getBytes("UTF-8")); |
274 | signature = Base64.encodeToString(hash, Base64.NO_WRAP); | 441 | signature = Base64.encodeToString(hash, Base64.NO_WRAP); | ... | ... |
1 | +package ly.warp.sdk.io.request; | ||
2 | + | ||
3 | +import android.util.Base64; | ||
4 | + | ||
5 | +import org.json.JSONException; | ||
6 | +import org.json.JSONObject; | ||
7 | + | ||
8 | +import java.io.UnsupportedEncodingException; | ||
9 | +import java.security.MessageDigest; | ||
10 | +import java.security.NoSuchAlgorithmException; | ||
11 | +import java.util.HashMap; | ||
12 | + | ||
13 | +import ly.warp.sdk.utils.constants.WarpConstants; | ||
14 | + | ||
15 | +/** | ||
16 | + * Created by Panagiotis Triantafyllou on 02-Aug-22. | ||
17 | + */ | ||
18 | + | ||
19 | +public class PacingCalculateRequest { | ||
20 | + | ||
21 | + // =========================================================== | ||
22 | + // Constants | ||
23 | + // =========================================================== | ||
24 | + | ||
25 | + private final String KEY_MAPP = "consumer_data"; | ||
26 | + private final String KEY_ACTION = "action"; | ||
27 | + private final String KEY_ACTION_VALUE = "integration"; | ||
28 | + private final String KEY_METHOD = "method"; | ||
29 | + private final String KEY_METHOD_VALUE = "steps"; | ||
30 | + private final String KEY_OPERATION = "operation"; | ||
31 | + private final String KEY_OPERATION_VALUE = "add"; | ||
32 | + private final String KEY_DATA = "data"; | ||
33 | + | ||
34 | + // =========================================================== | ||
35 | + // Fields | ||
36 | + // =========================================================== | ||
37 | + | ||
38 | + private HashMap<String, String> mFilters; | ||
39 | + private long mCacheUpdateInterval = 0; | ||
40 | + private String mDate = ""; | ||
41 | + private int mCounter = 0; | ||
42 | + | ||
43 | + // =========================================================== | ||
44 | + // Constructor | ||
45 | + // =========================================================== | ||
46 | + | ||
47 | + /** | ||
48 | + * Default constructor of WarplyConsumerRequest, initializes an empty filters HashMap | ||
49 | + */ | ||
50 | + public PacingCalculateRequest() { | ||
51 | + mFilters = new HashMap<>(); | ||
52 | + } | ||
53 | + | ||
54 | + public PacingCalculateRequest(PacingCalculateRequest copy) { | ||
55 | + if (copy != null) { | ||
56 | + this.mFilters = copy.mFilters; | ||
57 | + this.mCacheUpdateInterval = copy.mCacheUpdateInterval; | ||
58 | + } | ||
59 | + } | ||
60 | + | ||
61 | + // =========================================================== | ||
62 | + // Methods for/from SuperClass/Interfaces | ||
63 | + // =========================================================== | ||
64 | + | ||
65 | + @Override | ||
66 | + public boolean equals(Object object) { | ||
67 | + if (object instanceof PacingCalculateRequest) { | ||
68 | + PacingCalculateRequest other = (PacingCalculateRequest) object; | ||
69 | + return other == this || (this.mFilters == other.mFilters || (this.mFilters != null && this.mFilters.equals(other.mFilters))); | ||
70 | + } | ||
71 | + return false; | ||
72 | + } | ||
73 | + | ||
74 | + @Override | ||
75 | + public int hashCode() { | ||
76 | + return mFilters.hashCode(); | ||
77 | + } | ||
78 | + | ||
79 | + // =========================================================== | ||
80 | + // Methods | ||
81 | + // =========================================================== | ||
82 | + | ||
83 | + // =========================================================== | ||
84 | + // Getter & Setter | ||
85 | + // =========================================================== | ||
86 | + | ||
87 | + public PacingCalculateRequest setDate(String date) { | ||
88 | + this.mDate = date; | ||
89 | + return this; | ||
90 | + } | ||
91 | + | ||
92 | + public PacingCalculateRequest setCounter(int counter) { | ||
93 | + this.mCounter = counter; | ||
94 | + return this; | ||
95 | + } | ||
96 | + | ||
97 | + /** | ||
98 | + * Call this to get how often the cached data will be updated. | ||
99 | + * | ||
100 | + * @return mCacheUpdateInterval | ||
101 | + */ | ||
102 | + public long getCacheUpdateInterval() { | ||
103 | + return mCacheUpdateInterval; | ||
104 | + } | ||
105 | + | ||
106 | + /** | ||
107 | + * Call this to set how often the cached data will be updated. | ||
108 | + * | ||
109 | + * @param updateInterval The time that data will be cached | ||
110 | + * @return PacingCalculateRequest | ||
111 | + */ | ||
112 | + public PacingCalculateRequest setCacheUpdateInterval(long updateInterval) { | ||
113 | + | ||
114 | + this.mCacheUpdateInterval = updateInterval; | ||
115 | + if (mCacheUpdateInterval < 0) { | ||
116 | + mCacheUpdateInterval = 0; | ||
117 | + } | ||
118 | + return this; | ||
119 | + } | ||
120 | + | ||
121 | + /** | ||
122 | + * Call this to check if the Application uses Cache | ||
123 | + * | ||
124 | + * @return <p>true - the Application is using Cache</p> | ||
125 | + * <p>false - the Application is not using Cache</p> | ||
126 | + */ | ||
127 | + public boolean isUseCache() { | ||
128 | + return mCacheUpdateInterval > 0; | ||
129 | + } | ||
130 | + | ||
131 | + /** | ||
132 | + * Call this to check whether the cached data need to be updated | ||
133 | + * | ||
134 | + * @param useCache <p>true - the Application is using Cache</p> | ||
135 | + * <p>false - the Application is not using Cache</p> | ||
136 | + * @return PacingCalculateRequest | ||
137 | + */ | ||
138 | + public PacingCalculateRequest setUseCache(boolean useCache) { | ||
139 | + | ||
140 | + if (useCache) { | ||
141 | + mCacheUpdateInterval = mCacheUpdateInterval > 0 ? mCacheUpdateInterval | ||
142 | + : WarpConstants.INBOX_UPDATE_INTERVAL; | ||
143 | + } else { | ||
144 | + mCacheUpdateInterval = 0; | ||
145 | + } | ||
146 | + return this; | ||
147 | + } | ||
148 | + | ||
149 | + /** | ||
150 | + * Call this to build the offers Json object | ||
151 | + * | ||
152 | + * @return bodyJsonObject | ||
153 | + */ | ||
154 | + public JSONObject toJson() { | ||
155 | + JSONObject bodyJsonObject = new JSONObject(); | ||
156 | + try { | ||
157 | + JSONObject extraJson = new JSONObject(); | ||
158 | + extraJson.putOpt(KEY_ACTION, KEY_ACTION_VALUE); | ||
159 | + extraJson.putOpt(KEY_METHOD, KEY_METHOD_VALUE); | ||
160 | + extraJson.putOpt(KEY_OPERATION, KEY_OPERATION_VALUE); | ||
161 | + | ||
162 | + JSONObject data = new JSONObject(); | ||
163 | + data.putOpt("event", "steps"); | ||
164 | + data.putOpt("type", "counter"); | ||
165 | + data.putOpt("counter", mCounter); | ||
166 | + data.putOpt("date", mDate); | ||
167 | + | ||
168 | + extraJson.putOpt(KEY_DATA, data); | ||
169 | + bodyJsonObject.putOpt(KEY_MAPP, extraJson); | ||
170 | + } catch (JSONException e) { | ||
171 | + if (WarpConstants.DEBUG) | ||
172 | + e.printStackTrace(); | ||
173 | + } | ||
174 | + return bodyJsonObject; | ||
175 | + } | ||
176 | + | ||
177 | + public String getSignature() { | ||
178 | + String signature = mFilters != null && mFilters.size() > 0 ? String.valueOf(mFilters.hashCode()) : "default_pacing_calculate_request"; | ||
179 | + try { | ||
180 | + byte[] hash = MessageDigest.getInstance("SHA-256").digest(signature.getBytes("UTF-8")); | ||
181 | + signature = Base64.encodeToString(hash, Base64.NO_WRAP); | ||
182 | + } catch (NullPointerException | NoSuchAlgorithmException | ||
183 | + | UnsupportedEncodingException e) { | ||
184 | + e.printStackTrace(); | ||
185 | + } | ||
186 | + return signature; | ||
187 | + } | ||
188 | +} |
1 | +package ly.warp.sdk.services; | ||
2 | + | ||
3 | +import android.app.Service; | ||
4 | +import android.content.Context; | ||
5 | +import android.content.Intent; | ||
6 | +import android.hardware.Sensor; | ||
7 | +import android.hardware.SensorEvent; | ||
8 | +import android.hardware.SensorEventListener; | ||
9 | +import android.hardware.SensorManager; | ||
10 | +import android.os.IBinder; | ||
11 | + | ||
12 | +import androidx.annotation.NonNull; | ||
13 | +import androidx.annotation.Nullable; | ||
14 | +import androidx.work.Worker; | ||
15 | +import androidx.work.WorkerParameters; | ||
16 | + | ||
17 | +import org.greenrobot.eventbus.EventBus; | ||
18 | +import org.json.JSONObject; | ||
19 | + | ||
20 | +import java.text.ParseException; | ||
21 | +import java.text.SimpleDateFormat; | ||
22 | +import java.util.Date; | ||
23 | +import java.util.Locale; | ||
24 | + | ||
25 | +import ly.warp.sdk.io.callbacks.CallbackReceiver; | ||
26 | +import ly.warp.sdk.io.callbacks.WarplyHealthCallback; | ||
27 | +import ly.warp.sdk.io.models.ContexualEventModel; | ||
28 | +import ly.warp.sdk.io.request.PacingCalculateRequest; | ||
29 | +import ly.warp.sdk.utils.WarpUtils; | ||
30 | +import ly.warp.sdk.utils.managers.WarplyEventBusManager; | ||
31 | +import ly.warp.sdk.utils.managers.WarplyHealthManager; | ||
32 | +import ly.warp.sdk.utils.managers.WarplyManager; | ||
33 | + | ||
34 | +/** | ||
35 | + * Created by Panagiotis Triantafyllou on 03/Aug/2022. | ||
36 | + */ | ||
37 | +public class WarplyHealthService extends /*Worker*/ Service implements SensorEventListener { | ||
38 | + | ||
39 | + // =========================================================== | ||
40 | + // Constants | ||
41 | + // =========================================================== | ||
42 | + | ||
43 | + // =========================================================== | ||
44 | + // Fields | ||
45 | + // =========================================================== | ||
46 | + | ||
47 | + private Context mContext; | ||
48 | + private SensorManager mSensorManager; | ||
49 | + private Sensor mSensor; | ||
50 | + private int mSteps = 0; | ||
51 | + private final int ACCEL_RING_SIZE = 50; | ||
52 | + private final int VEL_RING_SIZE = 10; | ||
53 | + // change this threshold according to your sensitivity preferences | ||
54 | + private final float STEP_THRESHOLD = 20f; | ||
55 | + private final int STEP_DELAY_NS = 250000000; | ||
56 | + private int accelRingCounter = 0; | ||
57 | + private float[] accelRingX = new float[ACCEL_RING_SIZE]; | ||
58 | + private float[] accelRingY = new float[ACCEL_RING_SIZE]; | ||
59 | + private float[] accelRingZ = new float[ACCEL_RING_SIZE]; | ||
60 | + private int velRingCounter = 0; | ||
61 | + private float[] velRing = new float[VEL_RING_SIZE]; | ||
62 | + private long lastStepTimeNs = 0; | ||
63 | + private float oldVelocityEstimate = 0; | ||
64 | + // if we want to send the steps back to an activity/fragment/service etc | ||
65 | +// private static WarplyHealthCallback mHealthCallback; | ||
66 | + | ||
67 | + // =========================================================== | ||
68 | + // Contructors | ||
69 | + // =========================================================== | ||
70 | + | ||
71 | +// public WarplyHealthService(@NonNull Context context, @NonNull WorkerParameters workerParams) { | ||
72 | +// super(context, workerParams); | ||
73 | +// | ||
74 | +// mContext = context; | ||
75 | +// mSensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE); | ||
76 | +// mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); | ||
77 | +// registerStepSensor(); | ||
78 | +// } | ||
79 | + | ||
80 | + // =========================================================== | ||
81 | + // Methods for/from SuperClass/Interfaces | ||
82 | + // =========================================================== | ||
83 | + | ||
84 | + | ||
85 | + @Override | ||
86 | + public void onCreate() { | ||
87 | + super.onCreate(); | ||
88 | + | ||
89 | + mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); | ||
90 | + mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); | ||
91 | + registerStepSensor(); | ||
92 | + } | ||
93 | + | ||
94 | + @Override | ||
95 | + public int onStartCommand(Intent intent, int flags, int startId) { | ||
96 | + new Thread( | ||
97 | + () -> { | ||
98 | + while (true) { | ||
99 | + sendSteps(); | ||
100 | + try { | ||
101 | + Thread.sleep(10000); | ||
102 | + } catch (InterruptedException e) { | ||
103 | + e.printStackTrace(); | ||
104 | + } | ||
105 | + } | ||
106 | + } | ||
107 | + ).start(); | ||
108 | + | ||
109 | + return super.onStartCommand(intent, flags, startId); | ||
110 | + } | ||
111 | + | ||
112 | + @Override | ||
113 | + public void onDestroy() { | ||
114 | + super.onDestroy(); | ||
115 | + | ||
116 | + unregisterStepSensor(); | ||
117 | + } | ||
118 | + | ||
119 | + @Nullable | ||
120 | + @Override | ||
121 | + public IBinder onBind(Intent intent) { | ||
122 | + return null; | ||
123 | + } | ||
124 | + | ||
125 | +// @NonNull | ||
126 | +// @Override | ||
127 | +// public Result doWork() { | ||
128 | +// sendSteps(); | ||
129 | +// return Result.success(); | ||
130 | +// } | ||
131 | + | ||
132 | +// @Override | ||
133 | +// public void onStopped() { | ||
134 | +// super.onStopped(); | ||
135 | +// | ||
136 | +// unregisterStepSensor(); | ||
137 | +// | ||
138 | +// if (WarpUtils.getStepsCounter(mContext) > 0) { | ||
139 | +// sendSteps(); | ||
140 | +// } | ||
141 | +// } | ||
142 | + | ||
143 | + @Override | ||
144 | + public void onSensorChanged(SensorEvent sensorEvent) { | ||
145 | + if (sensorEvent.sensor.getType() == Sensor.TYPE_ACCELEROMETER) { | ||
146 | + updateSteps( | ||
147 | + sensorEvent.timestamp, | ||
148 | + sensorEvent.values[0], | ||
149 | + sensorEvent.values[1], | ||
150 | + sensorEvent.values[2]); | ||
151 | + } | ||
152 | + } | ||
153 | + | ||
154 | + @Override | ||
155 | + public void onAccuracyChanged(Sensor sensor, int i) { | ||
156 | + | ||
157 | + } | ||
158 | + | ||
159 | + // =========================================================== | ||
160 | + // Methods | ||
161 | + // =========================================================== | ||
162 | + | ||
163 | + public void registerStepSensor() { | ||
164 | + mSensorManager.registerListener(this, mSensor, SensorManager.SENSOR_DELAY_GAME); | ||
165 | + } | ||
166 | + | ||
167 | + public void unregisterStepSensor() { | ||
168 | + mSensorManager.unregisterListener(this); | ||
169 | + } | ||
170 | + | ||
171 | + private void updateSteps(long timeNs, float x, float y, float z) { | ||
172 | + float[] currentAccel = new float[3]; | ||
173 | + currentAccel[0] = x; | ||
174 | + currentAccel[1] = y; | ||
175 | + currentAccel[2] = z; | ||
176 | + | ||
177 | + // First step is to update our guess of where the global z vector is. | ||
178 | + accelRingCounter++; | ||
179 | + accelRingX[accelRingCounter % ACCEL_RING_SIZE] = currentAccel[0]; | ||
180 | + accelRingY[accelRingCounter % ACCEL_RING_SIZE] = currentAccel[1]; | ||
181 | + accelRingZ[accelRingCounter % ACCEL_RING_SIZE] = currentAccel[2]; | ||
182 | + | ||
183 | + float[] worldZ = new float[3]; | ||
184 | + worldZ[0] = sum(accelRingX) / Math.min(accelRingCounter, ACCEL_RING_SIZE); | ||
185 | + worldZ[1] = sum(accelRingY) / Math.min(accelRingCounter, ACCEL_RING_SIZE); | ||
186 | + worldZ[2] = sum(accelRingZ) / Math.min(accelRingCounter, ACCEL_RING_SIZE); | ||
187 | + | ||
188 | + float normalization_factor = norm(worldZ); | ||
189 | + | ||
190 | + worldZ[0] = worldZ[0] / normalization_factor; | ||
191 | + worldZ[1] = worldZ[1] / normalization_factor; | ||
192 | + worldZ[2] = worldZ[2] / normalization_factor; | ||
193 | + | ||
194 | + float currentZ = dot(worldZ, currentAccel) - normalization_factor; | ||
195 | + velRingCounter++; | ||
196 | + velRing[velRingCounter % VEL_RING_SIZE] = currentZ; | ||
197 | + | ||
198 | + float velocityEstimate = sum(velRing); | ||
199 | + | ||
200 | + if (velocityEstimate > STEP_THRESHOLD | ||
201 | + && oldVelocityEstimate <= STEP_THRESHOLD | ||
202 | + && (timeNs - lastStepTimeNs > STEP_DELAY_NS)) { | ||
203 | + mSteps++; | ||
204 | + WarpUtils.setStepsCounter(mContext, mSteps); | ||
205 | + | ||
206 | + // if we want to send the steps back to an activity/fragment/service etc | ||
207 | +// mHealthCallback.onStepCount(mSteps); | ||
208 | + lastStepTimeNs = timeNs; | ||
209 | + } | ||
210 | + oldVelocityEstimate = velocityEstimate; | ||
211 | + } | ||
212 | + | ||
213 | + private float sum(float[] array) { | ||
214 | + float retval = 0; | ||
215 | + for (float v : array) { | ||
216 | + retval += v; | ||
217 | + } | ||
218 | + return retval; | ||
219 | + } | ||
220 | + | ||
221 | + private float[] cross(float[] arrayA, float[] arrayB) { | ||
222 | + float[] retArray = new float[3]; | ||
223 | + retArray[0] = arrayA[1] * arrayB[2] - arrayA[2] * arrayB[1]; | ||
224 | + retArray[1] = arrayA[2] * arrayB[0] - arrayA[0] * arrayB[2]; | ||
225 | + retArray[2] = arrayA[0] * arrayB[1] - arrayA[1] * arrayB[0]; | ||
226 | + return retArray; | ||
227 | + } | ||
228 | + | ||
229 | + private float norm(float[] array) { | ||
230 | + float retval = 0; | ||
231 | + for (float v : array) { | ||
232 | + retval += v * v; | ||
233 | + } | ||
234 | + return (float) Math.sqrt(retval); | ||
235 | + } | ||
236 | + | ||
237 | + private float dot(float[] a, float[] b) { | ||
238 | + return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; | ||
239 | + } | ||
240 | + | ||
241 | + private float[] normalize(float[] a) { | ||
242 | + float[] retval = new float[a.length]; | ||
243 | + float norm = norm(a); | ||
244 | + for (int i = 0; i < a.length; i++) { | ||
245 | + retval[i] = a[i] / norm; | ||
246 | + } | ||
247 | + return retval; | ||
248 | + } | ||
249 | + | ||
250 | + private void sendSteps() { | ||
251 | + String date = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss", Locale.getDefault()).format(new Date()); | ||
252 | + | ||
253 | + WarplyManager.setPacingDetails(new PacingCalculateRequest() | ||
254 | + .setCounter(WarpUtils.getStepsCounter(mContext)) | ||
255 | + .setDate(date), | ||
256 | + new CallbackReceiver<JSONObject>() { | ||
257 | + @Override | ||
258 | + public void onSuccess(JSONObject result) { | ||
259 | + WarpUtils.log("Warply Health Service success"); | ||
260 | + int status = result.optInt("status", 2); | ||
261 | + if (status == 1) { | ||
262 | + mSteps = 0; | ||
263 | + WarpUtils.setStepsCounter(mContext, 0); | ||
264 | + } | ||
265 | + } | ||
266 | + | ||
267 | + @Override | ||
268 | + public void onFailure(int errorCode) { | ||
269 | + WarpUtils.log("Warply Health Service error: " + String.valueOf(errorCode)); | ||
270 | + } | ||
271 | + }); | ||
272 | + } | ||
273 | +} |
... | @@ -133,6 +133,10 @@ public class WarpUtils { | ... | @@ -133,6 +133,10 @@ public class WarpUtils { |
133 | + "more_popup"; | 133 | + "more_popup"; |
134 | private static final String PREFERENCES_KEY_USER_TAG = PREFERENCES_PREFIX | 134 | private static final String PREFERENCES_KEY_USER_TAG = PREFERENCES_PREFIX |
135 | + "user_badge"; | 135 | + "user_badge"; |
136 | + private static final String PREFERENCES_KEY_WEBVIEW_PARAMS = PREFERENCES_PREFIX | ||
137 | + + "webview_params"; | ||
138 | + private static final String PREFERENCES_STEPS_COUNTER = PREFERENCES_PREFIX | ||
139 | + + "steps_counter"; | ||
136 | 140 | ||
137 | private static SharedPreferences _prefs; | 141 | private static SharedPreferences _prefs; |
138 | 142 | ||
... | @@ -586,6 +590,28 @@ public class WarpUtils { | ... | @@ -586,6 +590,28 @@ public class WarpUtils { |
586 | editor.apply(); | 590 | editor.apply(); |
587 | } | 591 | } |
588 | 592 | ||
593 | + public static void setWebviewParams(Context context, JSONObject params) { | ||
594 | + SharedPreferences.Editor editor = getPreferences(context).edit(); | ||
595 | + editor.putString(PREFERENCES_KEY_WEBVIEW_PARAMS, params.toString()); | ||
596 | + editor.apply(); | ||
597 | + } | ||
598 | + | ||
599 | + public static String getWebviewParams(Context context) { | ||
600 | + SharedPreferences prefs = getPreferences(context); | ||
601 | + return prefs.getString(PREFERENCES_KEY_WEBVIEW_PARAMS, ""); | ||
602 | + } | ||
603 | + | ||
604 | + public static void setStepsCounter(Context context, int counter) { | ||
605 | + SharedPreferences.Editor editor = getPreferences(context).edit(); | ||
606 | + editor.putInt(PREFERENCES_STEPS_COUNTER, counter); | ||
607 | + editor.apply(); | ||
608 | + } | ||
609 | + | ||
610 | + public static int getStepsCounter(Context context) { | ||
611 | + SharedPreferences prefs = getPreferences(context); | ||
612 | + return prefs.getInt(PREFERENCES_STEPS_COUNTER, 0); | ||
613 | + } | ||
614 | + | ||
589 | public static JSONObject getDeviceInfoObject(Context context) { | 615 | public static JSONObject getDeviceInfoObject(Context context) { |
590 | SharedPreferences prefs = getPreferences(context); | 616 | SharedPreferences prefs = getPreferences(context); |
591 | try { | 617 | try { | ... | ... |
... | @@ -34,6 +34,8 @@ import androidx.appcompat.app.AlertDialog; | ... | @@ -34,6 +34,8 @@ import androidx.appcompat.app.AlertDialog; |
34 | import androidx.work.OneTimeWorkRequest; | 34 | import androidx.work.OneTimeWorkRequest; |
35 | import androidx.work.WorkManager; | 35 | import androidx.work.WorkManager; |
36 | 36 | ||
37 | +import org.json.JSONArray; | ||
38 | +import org.json.JSONException; | ||
37 | import org.json.JSONObject; | 39 | import org.json.JSONObject; |
38 | 40 | ||
39 | import java.io.Serializable; | 41 | import java.io.Serializable; |
... | @@ -108,20 +110,31 @@ public class WarplyManagerHelper { | ... | @@ -108,20 +110,31 @@ public class WarplyManagerHelper { |
108 | */ | 110 | */ |
109 | public static String constructCampaignUrl(Campaign item) { | 111 | public static String constructCampaignUrl(Campaign item) { |
110 | item.setNew(false); | 112 | item.setNew(false); |
111 | - String url = item.getIndexUrl() | 113 | + String url = item.getIndexUrl(); |
112 | - + "?web_id=" + WarpUtils.getWebId(Warply.getWarplyContext()) | 114 | +// + "?web_id=" + WarpUtils.getWebId(Warply.getWarplyContext()) |
113 | - + "&app_uuid=" + WarplyProperty.getAppUuid(Warply.getWarplyContext()) | 115 | +// + "&app_uuid=" + WarplyProperty.getAppUuid(Warply.getWarplyContext()) |
114 | - + "&api_key=" + WarpUtils.getApiKey(Warply.getWarplyContext()) | 116 | +// + "&api_key=" + WarpUtils.getApiKey(Warply.getWarplyContext()) |
115 | - + "&session_uuid=" + item.getSessionUUID() | 117 | +// + "&session_uuid=" + item.getSessionUUID() |
116 | - + "&access_token=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("access_token") | 118 | +// + "&access_token=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("access_token") |
117 | - + "&refresh_token=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("refresh_token") | 119 | +// + "&refresh_token=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("refresh_token") |
118 | - + "&client_id=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_id") | 120 | +// + "&client_id=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_id") |
119 | - + "&client_secret=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_secret"); | 121 | +// + "&client_secret=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_secret"); |
120 | - | 122 | + |
121 | -// if (mConsumer != null) | 123 | + JSONObject params = new JSONObject(); |
122 | -// url = url + "&auth_token=" + (mConsumer.getUuid()); | 124 | + try { |
123 | -// else | 125 | + params.putOpt("web_id", WarpUtils.getWebId(Warply.getWarplyContext())); |
124 | -// url = url + "&auth_token="; | 126 | + params.putOpt("app_uuid", WarplyProperty.getAppUuid(Warply.getWarplyContext())); |
127 | + params.putOpt("api_key", WarpUtils.getApiKey(Warply.getWarplyContext())); | ||
128 | + params.putOpt("session_uuid", item.getSessionUUID()); | ||
129 | + params.putOpt("access_token", WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("access_token")); | ||
130 | + params.putOpt("refresh_token", WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("refresh_token")); | ||
131 | + params.putOpt("client_id", WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_id")); | ||
132 | + params.putOpt("client_secret", WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_secret")); | ||
133 | + } catch (JSONException e) { | ||
134 | + e.printStackTrace(); | ||
135 | + } | ||
136 | + | ||
137 | + WarpUtils.setWebviewParams(Warply.getWarplyContext(), params); | ||
125 | 138 | ||
126 | return url; | 139 | return url; |
127 | } | 140 | } |
... | @@ -296,43 +309,75 @@ public class WarplyManagerHelper { | ... | @@ -296,43 +309,75 @@ public class WarplyManagerHelper { |
296 | assets = assets.substring(0, assets.length() - 1); | 309 | assets = assets.substring(0, assets.length() - 1); |
297 | } | 310 | } |
298 | } | 311 | } |
299 | - String url = item.getIndexUrl() | 312 | + String url = item.getIndexUrl(); |
300 | - + "?web_id=" + WarpUtils.getWebId(Warply.getWarplyContext()) | 313 | +// + "?web_id=" + WarpUtils.getWebId(Warply.getWarplyContext()) |
301 | - + "&app_uuid=" + WarplyProperty.getAppUuid(Warply.getWarplyContext()) | 314 | +// + "&app_uuid=" + WarplyProperty.getAppUuid(Warply.getWarplyContext()) |
302 | - + "&api_key=" + WarpUtils.getApiKey(Warply.getWarplyContext()) | 315 | +// + "&api_key=" + WarpUtils.getApiKey(Warply.getWarplyContext()) |
303 | - + "&session_uuid=" + item.getSessionUUID() | 316 | +// + "&session_uuid=" + item.getSessionUUID() |
304 | - + "&access_token=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("access_token") | 317 | +// + "&access_token=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("access_token") |
305 | - + "&refresh_token=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("refresh_token") | 318 | +// + "&refresh_token=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("refresh_token") |
306 | - + "&client_id=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_id") | 319 | +// + "&client_id=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_id") |
307 | - + "&client_secret=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_secret") | 320 | +// + "&client_secret=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_secret") |
308 | - + "&Session_ID=" + ccmsItem.getSessionId() | 321 | +// + "&Session_ID=" + ccmsItem.getSessionId() |
309 | - + "&businessService=" + ccmsItem.getBusinessService() | 322 | +// + "&businessService=" + ccmsItem.getBusinessService() |
310 | - + "&offerName=" + ccmsItem.getOfferName() | 323 | +// + "&offerName=" + ccmsItem.getOfferName() |
311 | - + "&productType=" + ccmsItem.getProductType() | 324 | +// + "&productType=" + ccmsItem.getProductType() |
312 | - + "&provDuration=" + ccmsItem.getProvDuration() | 325 | +// + "&provDuration=" + ccmsItem.getProvDuration() |
313 | - + "&noOfRecurrance=" + ccmsItem.getNoOfRecurrance() | 326 | +// + "&noOfRecurrance=" + ccmsItem.getNoOfRecurrance() |
314 | - + "&price=" + ccmsItem.getPrice() | 327 | +// + "&price=" + ccmsItem.getPrice() |
315 | - + "&discount=" + ccmsItem.getDiscount() | 328 | +// + "&discount=" + ccmsItem.getDiscount() |
316 | - + "&voiceCategory=" + ccmsItem.getVoiceCategory() | 329 | +// + "&voiceCategory=" + ccmsItem.getVoiceCategory() |
317 | - + "&dataCategory=" + ccmsItem.getDataCategory() | 330 | +// + "&dataCategory=" + ccmsItem.getDataCategory() |
318 | - + "&minsValue=" + ccmsItem.getMinsValue() | 331 | +// + "&minsValue=" + ccmsItem.getMinsValue() |
319 | - + "&dataValue=" + ccmsItem.getDataValue() | 332 | +// + "&dataValue=" + ccmsItem.getDataValue() |
320 | - + "&provStepValueMins=" + ccmsItem.getProvStepValueMins() | 333 | +// + "&provStepValueMins=" + ccmsItem.getProvStepValueMins() |
321 | - + "&UACIOfferTrackingCode=" + ccmsItem.getUACIOfferTrackingCode() | 334 | +// + "&UACIOfferTrackingCode=" + ccmsItem.getUACIOfferTrackingCode() |
322 | - + "&OFFERCODE1=" + ccmsItem.getOfferCode1() | 335 | +// + "&OFFERCODE1=" + ccmsItem.getOfferCode1() |
323 | - + "&SCORE=" + ccmsItem.getScore() | 336 | +// + "&SCORE=" + ccmsItem.getScore() |
324 | - + "&WAVE=" + ccmsItem.getWave() | 337 | +// + "&WAVE=" + ccmsItem.getWave() |
325 | - + "&VALIDITY=" + ccmsItem.getValidity() | 338 | +// + "&VALIDITY=" + ccmsItem.getValidity() |
326 | - + "&TREATMENT_CODE=" + ccmsItem.getTreatmentCode() | 339 | +// + "&TREATMENT_CODE=" + ccmsItem.getTreatmentCode() |
327 | - + "&OfferAudienceLevel=" + ccmsItem.getOfferAudienceLevel() | 340 | +// + "&OfferAudienceLevel=" + ccmsItem.getOfferAudienceLevel() |
328 | - + "&ASSETS=" + assets | 341 | +// + "&ASSETS=" + assets |
329 | - + "&ZONE=" + ccmsItem.getZone(); | 342 | +// + "&ZONE=" + ccmsItem.getZone(); |
330 | - | 343 | + |
331 | - | 344 | + JSONObject params = new JSONObject(); |
332 | -// if (mConsumer != null) | 345 | + try { |
333 | -// url = url + "&auth_token=" + (mConsumer.getUuid()); | 346 | + params.putOpt("web_id", WarpUtils.getWebId(Warply.getWarplyContext())); |
334 | -// else | 347 | + params.putOpt("app_uuid", WarplyProperty.getAppUuid(Warply.getWarplyContext())); |
335 | -// url = url + "&auth_token="; | 348 | + params.putOpt("api_key", WarpUtils.getApiKey(Warply.getWarplyContext())); |
349 | + params.putOpt("session_uuid", item.getSessionUUID()); | ||
350 | + params.putOpt("access_token", WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("access_token")); | ||
351 | + params.putOpt("refresh_token", WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("refresh_token")); | ||
352 | + params.putOpt("client_id", WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_id")); | ||
353 | + params.putOpt("client_secret", WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_secret")); | ||
354 | + params.putOpt("Session_ID", ccmsItem.getSessionId()); | ||
355 | + params.putOpt("businessService", ccmsItem.getBusinessService()); | ||
356 | + params.putOpt("offerName", ccmsItem.getOfferName()); | ||
357 | + params.putOpt("productType", ccmsItem.getProductType()); | ||
358 | + params.putOpt("provDuration", ccmsItem.getProvDuration()); | ||
359 | + params.putOpt("noOfRecurrance", ccmsItem.getNoOfRecurrance()); | ||
360 | + params.putOpt("price", ccmsItem.getPrice()); | ||
361 | + params.putOpt("discount", ccmsItem.getDiscount()); | ||
362 | + params.putOpt("voiceCategory", ccmsItem.getVoiceCategory()); | ||
363 | + params.putOpt("dataCategory", ccmsItem.getDataCategory()); | ||
364 | + params.putOpt("minsValue", ccmsItem.getMinsValue()); | ||
365 | + params.putOpt("dataValue", ccmsItem.getDataValue()); | ||
366 | + params.putOpt("provStepValueMins", ccmsItem.getProvStepValueMins()); | ||
367 | + params.putOpt("UACIOfferTrackingCode", ccmsItem.getUACIOfferTrackingCode()); | ||
368 | + params.putOpt("OFFERCODE1", ccmsItem.getOfferCode1()); | ||
369 | + params.putOpt("SCORE", ccmsItem.getScore()); | ||
370 | + params.putOpt("WAVE", ccmsItem.getWave()); | ||
371 | + params.putOpt("VALIDITY", ccmsItem.getValidity()); | ||
372 | + params.putOpt("TREATMENT_CODE", ccmsItem.getTreatmentCode()); | ||
373 | + params.putOpt("OfferAudienceLevel", ccmsItem.getOfferAudienceLevel()); | ||
374 | + params.putOpt("ASSETS", assets); | ||
375 | + params.putOpt("ZONE", ccmsItem.getZone()); | ||
376 | + } catch (JSONException e) { | ||
377 | + e.printStackTrace(); | ||
378 | + } | ||
379 | + | ||
380 | + WarpUtils.setWebviewParams(Warply.getWarplyContext(), params); | ||
336 | 381 | ||
337 | return url; | 382 | return url; |
338 | } | 383 | } |
... | @@ -362,37 +407,75 @@ public class WarplyManagerHelper { | ... | @@ -362,37 +407,75 @@ public class WarplyManagerHelper { |
362 | } | 407 | } |
363 | } | 408 | } |
364 | 409 | ||
365 | - url = camp.getIndexUrl() | 410 | + url = camp.getIndexUrl(); |
366 | - + "?web_id=" + WarpUtils.getWebId(Warply.getWarplyContext()) | 411 | +// + "?web_id=" + WarpUtils.getWebId(Warply.getWarplyContext()) |
367 | - + "&app_uuid=" + WarplyProperty.getAppUuid(Warply.getWarplyContext()) | 412 | +// + "&app_uuid=" + WarplyProperty.getAppUuid(Warply.getWarplyContext()) |
368 | - + "&api_key=" + WarpUtils.getApiKey(Warply.getWarplyContext()) | 413 | +// + "&api_key=" + WarpUtils.getApiKey(Warply.getWarplyContext()) |
369 | - + "&session_uuid=" + camp.getSessionUUID() | 414 | +// + "&session_uuid=" + camp.getSessionUUID() |
370 | - + "&access_token=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("access_token") | 415 | +// + "&access_token=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("access_token") |
371 | - + "&refresh_token=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("refresh_token") | 416 | +// + "&refresh_token=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("refresh_token") |
372 | - + "&client_id=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_id") | 417 | +// + "&client_id=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_id") |
373 | - + "&client_secret=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_secret") | 418 | +// + "&client_secret=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_secret") |
374 | - + "&Session_ID=" + item.getSessionId() | 419 | +// + "&Session_ID=" + item.getSessionId() |
375 | - + "&businessService=" + item.getBusinessService() | 420 | +// + "&businessService=" + item.getBusinessService() |
376 | - + "&offerName=" + item.getOfferName() | 421 | +// + "&offerName=" + item.getOfferName() |
377 | - + "&productType=" + item.getProductType() | 422 | +// + "&productType=" + item.getProductType() |
378 | - + "&provDuration=" + item.getProvDuration() | 423 | +// + "&provDuration=" + item.getProvDuration() |
379 | - + "&noOfRecurrance=" + item.getNoOfRecurrance() | 424 | +// + "&noOfRecurrance=" + item.getNoOfRecurrance() |
380 | - + "&price=" + item.getPrice() | 425 | +// + "&price=" + item.getPrice() |
381 | - + "&discount=" + item.getDiscount() | 426 | +// + "&discount=" + item.getDiscount() |
382 | - + "&voiceCategory=" + item.getVoiceCategory() | 427 | +// + "&voiceCategory=" + item.getVoiceCategory() |
383 | - + "&dataCategory=" + item.getDataCategory() | 428 | +// + "&dataCategory=" + item.getDataCategory() |
384 | - + "&minsValue=" + item.getMinsValue() | 429 | +// + "&minsValue=" + item.getMinsValue() |
385 | - + "&dataValue=" + item.getDataValue() | 430 | +// + "&dataValue=" + item.getDataValue() |
386 | - + "&provStepValueMins=" + item.getProvStepValueMins() | 431 | +// + "&provStepValueMins=" + item.getProvStepValueMins() |
387 | - + "&UACIOfferTrackingCode=" + item.getUACIOfferTrackingCode() | 432 | +// + "&UACIOfferTrackingCode=" + item.getUACIOfferTrackingCode() |
388 | - + "&OFFERCODE1=" + item.getOfferCode1() | 433 | +// + "&OFFERCODE1=" + item.getOfferCode1() |
389 | - + "&SCORE=" + item.getScore() | 434 | +// + "&SCORE=" + item.getScore() |
390 | - + "&WAVE=" + item.getWave() | 435 | +// + "&WAVE=" + item.getWave() |
391 | - + "&VALIDITY=" + item.getValidity() | 436 | +// + "&VALIDITY=" + item.getValidity() |
392 | - + "&TREATMENT_CODE=" + item.getTreatmentCode() | 437 | +// + "&TREATMENT_CODE=" + item.getTreatmentCode() |
393 | - + "&OfferAudienceLevel=" + item.getOfferAudienceLevel() | 438 | +// + "&OfferAudienceLevel=" + item.getOfferAudienceLevel() |
394 | - + "&ASSETS=" + assets | 439 | +// + "&ASSETS=" + assets |
395 | - + "&ZONE=" + item.getZone(); | 440 | +// + "&ZONE=" + item.getZone(); |
441 | + | ||
442 | + JSONObject params = new JSONObject(); | ||
443 | + try { | ||
444 | + params.putOpt("web_id", WarpUtils.getWebId(Warply.getWarplyContext())); | ||
445 | + params.putOpt("app_uuid", WarplyProperty.getAppUuid(Warply.getWarplyContext())); | ||
446 | + params.putOpt("api_key", WarpUtils.getApiKey(Warply.getWarplyContext())); | ||
447 | + params.putOpt("session_uuid", camp.getSessionUUID()); | ||
448 | + params.putOpt("access_token", WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("access_token")); | ||
449 | + params.putOpt("refresh_token", WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("refresh_token")); | ||
450 | + params.putOpt("client_id", WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_id")); | ||
451 | + params.putOpt("client_secret", WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_secret")); | ||
452 | + params.putOpt("Session_ID", item.getSessionId()); | ||
453 | + params.putOpt("businessService", item.getBusinessService()); | ||
454 | + params.putOpt("offerName", item.getOfferName()); | ||
455 | + params.putOpt("productType", item.getProductType()); | ||
456 | + params.putOpt("provDuration", item.getProvDuration()); | ||
457 | + params.putOpt("noOfRecurrance", item.getNoOfRecurrance()); | ||
458 | + params.putOpt("price", item.getPrice()); | ||
459 | + params.putOpt("discount", item.getDiscount()); | ||
460 | + params.putOpt("voiceCategory", item.getVoiceCategory()); | ||
461 | + params.putOpt("dataCategory", item.getDataCategory()); | ||
462 | + params.putOpt("minsValue", item.getMinsValue()); | ||
463 | + params.putOpt("dataValue", item.getDataValue()); | ||
464 | + params.putOpt("provStepValueMins", item.getProvStepValueMins()); | ||
465 | + params.putOpt("UACIOfferTrackingCode", item.getUACIOfferTrackingCode()); | ||
466 | + params.putOpt("OFFERCODE1", item.getOfferCode1()); | ||
467 | + params.putOpt("SCORE", item.getScore()); | ||
468 | + params.putOpt("WAVE", item.getWave()); | ||
469 | + params.putOpt("VALIDITY", item.getValidity()); | ||
470 | + params.putOpt("TREATMENT_CODE", item.getTreatmentCode()); | ||
471 | + params.putOpt("OfferAudienceLevel", item.getOfferAudienceLevel()); | ||
472 | + params.putOpt("ASSETS", assets); | ||
473 | + params.putOpt("ZONE", item.getZone()); | ||
474 | + } catch (JSONException e) { | ||
475 | + e.printStackTrace(); | ||
476 | + } | ||
477 | + | ||
478 | + WarpUtils.setWebviewParams(Warply.getWarplyContext(), params); | ||
396 | break; | 479 | break; |
397 | } | 480 | } |
398 | } | 481 | } |
... | @@ -404,11 +487,6 @@ public class WarplyManagerHelper { | ... | @@ -404,11 +487,6 @@ public class WarplyManagerHelper { |
404 | } | 487 | } |
405 | } | 488 | } |
406 | 489 | ||
407 | -// if (mConsumer != null) | ||
408 | -// url = url + "&auth_token=" + (mConsumer.getUuid()); | ||
409 | -// else | ||
410 | -// url = url + "&auth_token="; | ||
411 | - | ||
412 | return url; | 490 | return url; |
413 | } | 491 | } |
414 | 492 | ||
... | @@ -432,37 +510,75 @@ public class WarplyManagerHelper { | ... | @@ -432,37 +510,75 @@ public class WarplyManagerHelper { |
432 | } | 510 | } |
433 | } | 511 | } |
434 | 512 | ||
435 | - String url = camp.getIndexUrl() | 513 | + String url = camp.getIndexUrl(); |
436 | - + "?web_id=" + WarpUtils.getWebId(Warply.getWarplyContext()) | 514 | +// + "?web_id=" + WarpUtils.getWebId(Warply.getWarplyContext()) |
437 | - + "&app_uuid=" + WarplyProperty.getAppUuid(Warply.getWarplyContext()) | 515 | +// + "&app_uuid=" + WarplyProperty.getAppUuid(Warply.getWarplyContext()) |
438 | - + "&api_key=" + WarpUtils.getApiKey(Warply.getWarplyContext()) | 516 | +// + "&api_key=" + WarpUtils.getApiKey(Warply.getWarplyContext()) |
439 | - + "&session_uuid=" + camp.getSessionUUID() | 517 | +// + "&session_uuid=" + camp.getSessionUUID() |
440 | - + "&access_token=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("access_token") | 518 | +// + "&access_token=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("access_token") |
441 | - + "&refresh_token=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("refresh_token") | 519 | +// + "&refresh_token=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("refresh_token") |
442 | - + "&client_id=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_id") | 520 | +// + "&client_id=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_id") |
443 | - + "&client_secret=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_secret") | 521 | +// + "&client_secret=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_secret") |
444 | - + "&Session_ID=" + item.getSessionId() | 522 | +// + "&Session_ID=" + item.getSessionId() |
445 | - + "&businessService=" + item.getBusinessService() | 523 | +// + "&businessService=" + item.getBusinessService() |
446 | - + "&offerName=" + item.getOfferName() | 524 | +// + "&offerName=" + item.getOfferName() |
447 | - + "&productType=" + item.getProductType() | 525 | +// + "&productType=" + item.getProductType() |
448 | - + "&provDuration=" + item.getProvDuration() | 526 | +// + "&provDuration=" + item.getProvDuration() |
449 | - + "&noOfRecurrance=" + item.getNoOfRecurrance() | 527 | +// + "&noOfRecurrance=" + item.getNoOfRecurrance() |
450 | - + "&price=" + item.getPrice() | 528 | +// + "&price=" + item.getPrice() |
451 | - + "&discount=" + item.getDiscount() | 529 | +// + "&discount=" + item.getDiscount() |
452 | - + "&voiceCategory=" + item.getVoiceCategory() | 530 | +// + "&voiceCategory=" + item.getVoiceCategory() |
453 | - + "&dataCategory=" + item.getDataCategory() | 531 | +// + "&dataCategory=" + item.getDataCategory() |
454 | - + "&minsValue=" + item.getMinsValue() | 532 | +// + "&minsValue=" + item.getMinsValue() |
455 | - + "&dataValue=" + item.getDataValue() | 533 | +// + "&dataValue=" + item.getDataValue() |
456 | - + "&provStepValueMins=" + item.getProvStepValueMins() | 534 | +// + "&provStepValueMins=" + item.getProvStepValueMins() |
457 | - + "&UACIOfferTrackingCode=" + item.getUACIOfferTrackingCode() | 535 | +// + "&UACIOfferTrackingCode=" + item.getUACIOfferTrackingCode() |
458 | - + "&OFFERCODE1=" + item.getOfferCode1() | 536 | +// + "&OFFERCODE1=" + item.getOfferCode1() |
459 | - + "&SCORE=" + item.getScore() | 537 | +// + "&SCORE=" + item.getScore() |
460 | - + "&WAVE=" + item.getWave() | 538 | +// + "&WAVE=" + item.getWave() |
461 | - + "&VALIDITY=" + item.getValidity() | 539 | +// + "&VALIDITY=" + item.getValidity() |
462 | - + "&TREATMENT_CODE=" + item.getTreatmentCode() | 540 | +// + "&TREATMENT_CODE=" + item.getTreatmentCode() |
463 | - + "&OfferAudienceLevel=" + item.getOfferAudienceLevel() | 541 | +// + "&OfferAudienceLevel=" + item.getOfferAudienceLevel() |
464 | - + "&ASSETS=" + assets | 542 | +// + "&ASSETS=" + assets |
465 | - + "&ZONE=" + item.getZone(); | 543 | +// + "&ZONE=" + item.getZone(); |
544 | + | ||
545 | + JSONObject params = new JSONObject(); | ||
546 | + try { | ||
547 | + params.putOpt("web_id", WarpUtils.getWebId(Warply.getWarplyContext())); | ||
548 | + params.putOpt("app_uuid", WarplyProperty.getAppUuid(Warply.getWarplyContext())); | ||
549 | + params.putOpt("api_key", WarpUtils.getApiKey(Warply.getWarplyContext())); | ||
550 | + params.putOpt("session_uuid", camp.getSessionUUID()); | ||
551 | + params.putOpt("access_token", WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("access_token")); | ||
552 | + params.putOpt("refresh_token", WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("refresh_token")); | ||
553 | + params.putOpt("client_id", WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_id")); | ||
554 | + params.putOpt("client_secret", WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_secret")); | ||
555 | + params.putOpt("Session_ID", item.getSessionId()); | ||
556 | + params.putOpt("businessService", item.getBusinessService()); | ||
557 | + params.putOpt("offerName", item.getOfferName()); | ||
558 | + params.putOpt("productType", item.getProductType()); | ||
559 | + params.putOpt("provDuration", item.getProvDuration()); | ||
560 | + params.putOpt("noOfRecurrance", item.getNoOfRecurrance()); | ||
561 | + params.putOpt("price", item.getPrice()); | ||
562 | + params.putOpt("discount", item.getDiscount()); | ||
563 | + params.putOpt("voiceCategory", item.getVoiceCategory()); | ||
564 | + params.putOpt("dataCategory", item.getDataCategory()); | ||
565 | + params.putOpt("minsValue", item.getMinsValue()); | ||
566 | + params.putOpt("dataValue", item.getDataValue()); | ||
567 | + params.putOpt("provStepValueMins", item.getProvStepValueMins()); | ||
568 | + params.putOpt("UACIOfferTrackingCode", item.getUACIOfferTrackingCode()); | ||
569 | + params.putOpt("OFFERCODE1", item.getOfferCode1()); | ||
570 | + params.putOpt("SCORE", item.getScore()); | ||
571 | + params.putOpt("WAVE", item.getWave()); | ||
572 | + params.putOpt("VALIDITY", item.getValidity()); | ||
573 | + params.putOpt("TREATMENT_CODE", item.getTreatmentCode()); | ||
574 | + params.putOpt("OfferAudienceLevel", item.getOfferAudienceLevel()); | ||
575 | + params.putOpt("ASSETS", assets); | ||
576 | + params.putOpt("ZONE", item.getZone()); | ||
577 | + } catch (JSONException e) { | ||
578 | + e.printStackTrace(); | ||
579 | + } | ||
580 | + | ||
581 | + WarpUtils.setWebviewParams(Warply.getWarplyContext(), params); | ||
466 | 582 | ||
467 | context.startActivity(WarpViewActivity.createIntentFromURL(context, url)); | 583 | context.startActivity(WarpViewActivity.createIntentFromURL(context, url)); |
468 | break; | 584 | break; | ... | ... |
... | @@ -127,8 +127,8 @@ public class WarplyHealthManager implements SensorEventListener { | ... | @@ -127,8 +127,8 @@ public class WarplyHealthManager implements SensorEventListener { |
127 | if (velocityEstimate > STEP_THRESHOLD | 127 | if (velocityEstimate > STEP_THRESHOLD |
128 | && oldVelocityEstimate <= STEP_THRESHOLD | 128 | && oldVelocityEstimate <= STEP_THRESHOLD |
129 | && (timeNs - lastStepTimeNs > STEP_DELAY_NS)) { | 129 | && (timeNs - lastStepTimeNs > STEP_DELAY_NS)) { |
130 | - //TODO: if we want to send the steps back to an activity/fragment/service etc | ||
131 | mSteps++; | 130 | mSteps++; |
131 | + // if we want to send the steps back to an activity/fragment/service etc | ||
132 | mHealthCallback.onStepCount(mSteps); | 132 | mHealthCallback.onStepCount(mSteps); |
133 | lastStepTimeNs = timeNs; | 133 | lastStepTimeNs = timeNs; |
134 | } | 134 | } | ... | ... |
... | @@ -30,6 +30,8 @@ import org.json.JSONException; | ... | @@ -30,6 +30,8 @@ import org.json.JSONException; |
30 | import org.json.JSONObject; | 30 | import org.json.JSONObject; |
31 | 31 | ||
32 | import java.util.ArrayList; | 32 | import java.util.ArrayList; |
33 | +import java.util.Collections; | ||
34 | +import java.util.Comparator; | ||
33 | 35 | ||
34 | import ly.warp.sdk.Warply; | 36 | import ly.warp.sdk.Warply; |
35 | import ly.warp.sdk.db.WarplyDBHelper; | 37 | import ly.warp.sdk.db.WarplyDBHelper; |
... | @@ -78,6 +80,7 @@ import ly.warp.sdk.io.request.CosmotePostEventRequest; | ... | @@ -78,6 +80,7 @@ import ly.warp.sdk.io.request.CosmotePostEventRequest; |
78 | import ly.warp.sdk.io.request.CosmoteRetrieveSharingRequest; | 80 | import ly.warp.sdk.io.request.CosmoteRetrieveSharingRequest; |
79 | import ly.warp.sdk.io.request.CosmoteSharingRequest; | 81 | import ly.warp.sdk.io.request.CosmoteSharingRequest; |
80 | import ly.warp.sdk.io.request.CosmoteSubmitOrderRequest; | 82 | import ly.warp.sdk.io.request.CosmoteSubmitOrderRequest; |
83 | +import ly.warp.sdk.io.request.PacingCalculateRequest; | ||
81 | import ly.warp.sdk.io.request.PacingDetailsRequest; | 84 | import ly.warp.sdk.io.request.PacingDetailsRequest; |
82 | import ly.warp.sdk.io.request.WarplyAddAddressRequest; | 85 | import ly.warp.sdk.io.request.WarplyAddAddressRequest; |
83 | import ly.warp.sdk.io.request.WarplyAddCardRequest; | 86 | import ly.warp.sdk.io.request.WarplyAddCardRequest; |
... | @@ -1371,6 +1374,7 @@ public class WarplyManager { | ... | @@ -1371,6 +1374,7 @@ public class WarplyManager { |
1371 | @Override | 1374 | @Override |
1372 | public void onSuccess(CampaignList result) { | 1375 | public void onSuccess(CampaignList result) { |
1373 | mNewCampaignList.addAll(result); | 1376 | mNewCampaignList.addAll(result); |
1377 | + Collections.sort(mNewCampaignList, (obj1, obj2) -> Integer.compare(obj1.getSorting(), obj2.getSorting())); | ||
1374 | CampaignList campaignLoyaltyList = new CampaignList(); | 1378 | CampaignList campaignLoyaltyList = new CampaignList(); |
1375 | campaignLoyaltyList.clear(); | 1379 | campaignLoyaltyList.clear(); |
1376 | for (Campaign camp : mNewCampaignList) { | 1380 | for (Campaign camp : mNewCampaignList) { |
... | @@ -2301,6 +2305,23 @@ public class WarplyManager { | ... | @@ -2301,6 +2305,23 @@ public class WarplyManager { |
2301 | 2305 | ||
2302 | @Override | 2306 | @Override |
2303 | public void onFailure(int errorCode) { | 2307 | public void onFailure(int errorCode) { |
2308 | + if (errorCode == 401) { | ||
2309 | + refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() { | ||
2310 | + @Override | ||
2311 | + public void onSuccess(JSONObject result) { | ||
2312 | + int status = result.optInt("status", 2); | ||
2313 | + if (status == 1) | ||
2314 | + submitOrder(request, receiver); | ||
2315 | + else | ||
2316 | + receiver.onFailure(status); | ||
2317 | + } | ||
2318 | + | ||
2319 | + @Override | ||
2320 | + public void onFailure(int errorCode) { | ||
2321 | + receiver.onFailure(errorCode); | ||
2322 | + } | ||
2323 | + }); | ||
2324 | + } else | ||
2304 | receiver.onFailure(errorCode); | 2325 | receiver.onFailure(errorCode); |
2305 | } | 2326 | } |
2306 | }); | 2327 | }); |
... | @@ -2359,6 +2380,62 @@ public class WarplyManager { | ... | @@ -2359,6 +2380,62 @@ public class WarplyManager { |
2359 | 2380 | ||
2360 | @Override | 2381 | @Override |
2361 | public void onFailure(int errorCode) { | 2382 | public void onFailure(int errorCode) { |
2383 | + if (errorCode == 401) { | ||
2384 | + refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() { | ||
2385 | + @Override | ||
2386 | + public void onSuccess(JSONObject result) { | ||
2387 | + int status = result.optInt("status", 2); | ||
2388 | + if (status == 1) | ||
2389 | + postEvent(request, receiver); | ||
2390 | + else | ||
2391 | + receiver.onFailure(status); | ||
2392 | + } | ||
2393 | + | ||
2394 | + @Override | ||
2395 | + public void onFailure(int errorCode) { | ||
2396 | + receiver.onFailure(errorCode); | ||
2397 | + } | ||
2398 | + }); | ||
2399 | + } else | ||
2400 | + receiver.onFailure(errorCode); | ||
2401 | + } | ||
2402 | + }); | ||
2403 | + } | ||
2404 | + | ||
2405 | + public static void setPacingDetails(PacingCalculateRequest request, final CallbackReceiver<JSONObject> receiver) { | ||
2406 | + WarpUtils.log("************* WARPLY Post Event Request ********************"); | ||
2407 | + WarpUtils.log("[WARP Trace] WARPLY Post Event Request is active"); | ||
2408 | + WarpUtils.log("**************************************************"); | ||
2409 | + | ||
2410 | + Warply.postReceiveMicroappData(true, "context", request.toJson(), new CallbackReceiver<JSONObject>() { | ||
2411 | + @Override | ||
2412 | + public void onSuccess(JSONObject result) { | ||
2413 | + int status = result.optInt("status", 2); | ||
2414 | + if (status == 1) { | ||
2415 | + receiver.onSuccess(result); | ||
2416 | + } else | ||
2417 | + receiver.onFailure(status); | ||
2418 | + } | ||
2419 | + | ||
2420 | + @Override | ||
2421 | + public void onFailure(int errorCode) { | ||
2422 | + if (errorCode == 401) { | ||
2423 | + refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() { | ||
2424 | + @Override | ||
2425 | + public void onSuccess(JSONObject result) { | ||
2426 | + int status = result.optInt("status", 2); | ||
2427 | + if (status == 1) | ||
2428 | + setPacingDetails(request, receiver); | ||
2429 | + else | ||
2430 | + receiver.onFailure(status); | ||
2431 | + } | ||
2432 | + | ||
2433 | + @Override | ||
2434 | + public void onFailure(int errorCode) { | ||
2435 | + receiver.onFailure(errorCode); | ||
2436 | + } | ||
2437 | + }); | ||
2438 | + } else | ||
2362 | receiver.onFailure(errorCode); | 2439 | receiver.onFailure(errorCode); |
2363 | } | 2440 | } |
2364 | }); | 2441 | }); | ... | ... |
... | @@ -35,13 +35,8 @@ import android.content.pm.ApplicationInfo; | ... | @@ -35,13 +35,8 @@ import android.content.pm.ApplicationInfo; |
35 | import android.net.Uri; | 35 | import android.net.Uri; |
36 | import android.net.http.SslError; | 36 | import android.net.http.SslError; |
37 | import android.os.Build; | 37 | import android.os.Build; |
38 | - | ||
39 | -import androidx.core.content.ContextCompat; | ||
40 | -import androidx.work.WorkManager; | ||
41 | - | ||
42 | import android.text.TextUtils; | 38 | import android.text.TextUtils; |
43 | import android.util.AttributeSet; | 39 | import android.util.AttributeSet; |
44 | -import android.util.Log; | ||
45 | import android.webkit.GeolocationPermissions.Callback; | 40 | import android.webkit.GeolocationPermissions.Callback; |
46 | import android.webkit.JavascriptInterface; | 41 | import android.webkit.JavascriptInterface; |
47 | import android.webkit.SslErrorHandler; | 42 | import android.webkit.SslErrorHandler; |
... | @@ -51,6 +46,10 @@ import android.webkit.WebView; | ... | @@ -51,6 +46,10 @@ import android.webkit.WebView; |
51 | import android.webkit.WebViewClient; | 46 | import android.webkit.WebViewClient; |
52 | import android.widget.Toast; | 47 | import android.widget.Toast; |
53 | 48 | ||
49 | +import androidx.core.content.ContextCompat; | ||
50 | +import androidx.work.PeriodicWorkRequest; | ||
51 | +import androidx.work.WorkManager; | ||
52 | + | ||
54 | import org.greenrobot.eventbus.EventBus; | 53 | import org.greenrobot.eventbus.EventBus; |
55 | import org.json.JSONArray; | 54 | import org.json.JSONArray; |
56 | import org.json.JSONException; | 55 | import org.json.JSONException; |
... | @@ -61,14 +60,13 @@ import java.net.URLDecoder; | ... | @@ -61,14 +60,13 @@ import java.net.URLDecoder; |
61 | import java.util.HashMap; | 60 | import java.util.HashMap; |
62 | import java.util.LinkedHashMap; | 61 | import java.util.LinkedHashMap; |
63 | import java.util.Map; | 62 | import java.util.Map; |
63 | +import java.util.concurrent.TimeUnit; | ||
64 | 64 | ||
65 | import ly.warp.sdk.Warply; | 65 | import ly.warp.sdk.Warply; |
66 | import ly.warp.sdk.io.models.CouponEventModel; | 66 | import ly.warp.sdk.io.models.CouponEventModel; |
67 | import ly.warp.sdk.io.models.QuestionnaireEventModel; | 67 | import ly.warp.sdk.io.models.QuestionnaireEventModel; |
68 | -import ly.warp.sdk.io.models.WarplyPacingCardEventModel; | ||
69 | -import ly.warp.sdk.io.models.WarplyPacingCardServiceEnabledModel; | ||
70 | import ly.warp.sdk.io.models.WarplyPacingEventModel; | 68 | import ly.warp.sdk.io.models.WarplyPacingEventModel; |
71 | -import ly.warp.sdk.services.UpdateUserLocationService; | 69 | +import ly.warp.sdk.services.WarplyHealthService; |
72 | import ly.warp.sdk.utils.WarpUtils; | 70 | import ly.warp.sdk.utils.WarpUtils; |
73 | import ly.warp.sdk.utils.WarplyProperty; | 71 | import ly.warp.sdk.utils.WarplyProperty; |
74 | import ly.warp.sdk.utils.WarplyUrlHandler; | 72 | import ly.warp.sdk.utils.WarplyUrlHandler; |
... | @@ -84,6 +82,7 @@ public class WarpView extends WebView { | ... | @@ -84,6 +82,7 @@ public class WarpView extends WebView { |
84 | private static final String URL_ACTION_MAIL = "mailto"; | 82 | private static final String URL_ACTION_MAIL = "mailto"; |
85 | private static final String URL_ACTION_MARKET = "market"; | 83 | private static final String URL_ACTION_MARKET = "market"; |
86 | private static final String URL_ACTION_MARKET_AUTHORITY = "play.google.com"; | 84 | private static final String URL_ACTION_MARKET_AUTHORITY = "play.google.com"; |
85 | + private static final String TAG_STEPS_WORKER = "ly.warp.sdk.services.WarplyHealthService"; | ||
87 | 86 | ||
88 | // =========================================================== | 87 | // =========================================================== |
89 | // Fields | 88 | // Fields |
... | @@ -371,11 +370,6 @@ public class WarpView extends WebView { | ... | @@ -371,11 +370,6 @@ public class WarpView extends WebView { |
371 | public class JSInterface { | 370 | public class JSInterface { |
372 | @JavascriptInterface | 371 | @JavascriptInterface |
373 | public void sendMessage(String message) { | 372 | public void sendMessage(String message) { |
374 | -// Intent intent = new Intent(android.content.Intent.ACTION_SEND); | ||
375 | -// intent.setType("text/plain"); | ||
376 | -// intent.putExtra(android.content.Intent.EXTRA_TEXT, message); | ||
377 | -// getContext().startActivity(Intent.createChooser(intent, "Άνοιγμα με")); | ||
378 | - | ||
379 | if (message.contains("event")) { | 373 | if (message.contains("event")) { |
380 | String[] parts = message.split(":"); | 374 | String[] parts = message.split(":"); |
381 | if (parts[1].equals("closeArtwork")) { | 375 | if (parts[1].equals("closeArtwork")) { |
... | @@ -423,10 +417,20 @@ public class WarpView extends WebView { | ... | @@ -423,10 +417,20 @@ public class WarpView extends WebView { |
423 | pacingService.setEnabled(true); | 417 | pacingService.setEnabled(true); |
424 | EventBus.getDefault().post(new WarplyEventBusManager(pacingService)); | 418 | EventBus.getDefault().post(new WarplyEventBusManager(pacingService)); |
425 | }*/ else if (parts[1].equals("steps") && parts[2].equals("shortcutEnabled")) { | 419 | }*/ else if (parts[1].equals("steps") && parts[2].equals("shortcutEnabled")) { |
420 | +// PeriodicWorkRequest stepsWorker = new PeriodicWorkRequest.Builder(WarplyHealthService.class, 15, TimeUnit.MINUTES) | ||
421 | +// .build(); | ||
422 | +// WorkManager.getInstance(Warply.getWarplyContext()).enqueue(stepsWorker); | ||
423 | + Intent stepsServiceIntent = new Intent(Warply.getWarplyContext(), WarplyHealthService.class); | ||
424 | + Warply.getWarplyContext().startService(stepsServiceIntent); | ||
425 | + | ||
426 | WarplyPacingEventModel pacingVisible = new WarplyPacingEventModel(); | 426 | WarplyPacingEventModel pacingVisible = new WarplyPacingEventModel(); |
427 | pacingVisible.setVisible(true); | 427 | pacingVisible.setVisible(true); |
428 | EventBus.getDefault().post(new WarplyEventBusManager(pacingVisible)); | 428 | EventBus.getDefault().post(new WarplyEventBusManager(pacingVisible)); |
429 | } else if (parts[1].equals("steps") && parts[2].equals("shortcutDisabled")) { | 429 | } else if (parts[1].equals("steps") && parts[2].equals("shortcutDisabled")) { |
430 | +// WorkManager.getInstance(Warply.getWarplyContext()).cancelAllWork(); | ||
431 | + Intent stepsServiceIntent = new Intent(Warply.getWarplyContext(), WarplyHealthService.class); | ||
432 | + Warply.getWarplyContext().stopService(stepsServiceIntent); | ||
433 | + | ||
430 | WarplyPacingEventModel pacingVisible = new WarplyPacingEventModel(); | 434 | WarplyPacingEventModel pacingVisible = new WarplyPacingEventModel(); |
431 | pacingVisible.setVisible(false); | 435 | pacingVisible.setVisible(false); |
432 | EventBus.getDefault().post(new WarplyEventBusManager(pacingVisible)); | 436 | EventBus.getDefault().post(new WarplyEventBusManager(pacingVisible)); |
... | @@ -500,7 +504,10 @@ public class WarpView extends WebView { | ... | @@ -500,7 +504,10 @@ public class WarpView extends WebView { |
500 | 504 | ||
501 | @Override | 505 | @Override |
502 | public void onPageFinished(WebView view, String url) { | 506 | public void onPageFinished(WebView view, String url) { |
507 | + String scriptSource = "passParams(" + WarpUtils.getWebviewParams(getContext()) + ");"; | ||
508 | + view.evaluateJavascript(scriptSource, s -> { | ||
503 | 509 | ||
510 | + }); | ||
504 | if (url.contains("about:blank")) { | 511 | if (url.contains("about:blank")) { |
505 | WarpView.this.clearHistory(); | 512 | WarpView.this.clearHistory(); |
506 | } | 513 | } | ... | ... |
... | @@ -386,6 +386,7 @@ | ... | @@ -386,6 +386,7 @@ |
386 | </androidx.constraintlayout.widget.ConstraintLayout> | 386 | </androidx.constraintlayout.widget.ConstraintLayout> |
387 | 387 | ||
388 | <TextView | 388 | <TextView |
389 | + android:id="@+id/tv_active_coupons_header" | ||
389 | android:layout_width="wrap_content" | 390 | android:layout_width="wrap_content" |
390 | android:layout_height="wrap_content" | 391 | android:layout_height="wrap_content" |
391 | android:layout_gravity="start" | 392 | android:layout_gravity="start" | ... | ... |
-
Please register or login to post a comment