Showing
10 changed files
with
270 additions
and
50 deletions
... | @@ -4,18 +4,18 @@ | ... | @@ -4,18 +4,18 @@ |
4 | <value> | 4 | <value> |
5 | <entry key="app"> | 5 | <entry key="app"> |
6 | <State> | 6 | <State> |
7 | - <targetSelectedWithDropDown> | 7 | + <runningDeviceTargetSelectedWithDropDown> |
8 | <Target> | 8 | <Target> |
9 | - <type value="QUICK_BOOT_TARGET" /> | 9 | + <type value="RUNNING_DEVICE_TARGET" /> |
10 | <deviceKey> | 10 | <deviceKey> |
11 | <Key> | 11 | <Key> |
12 | - <type value="VIRTUAL_DEVICE_PATH" /> | 12 | + <type value="SERIAL_NUMBER" /> |
13 | - <value value="$USER_HOME$/.android/avd/Pixel_7_v13.avd" /> | 13 | + <value value="R58M42EM7YT" /> |
14 | </Key> | 14 | </Key> |
15 | </deviceKey> | 15 | </deviceKey> |
16 | </Target> | 16 | </Target> |
17 | - </targetSelectedWithDropDown> | 17 | + </runningDeviceTargetSelectedWithDropDown> |
18 | - <timeTargetWasSelectedWithDropDown value="2024-07-09T11:41:15.263632Z" /> | 18 | + <timeTargetWasSelectedWithDropDown value="2024-07-26T13:26:33.140020Z" /> |
19 | </State> | 19 | </State> |
20 | </entry> | 20 | </entry> |
21 | </value> | 21 | </value> | ... | ... |
... | @@ -17,7 +17,8 @@ | ... | @@ -17,7 +17,8 @@ |
17 | <uses-permission android:name="android.permission.FOREGROUND_SERVICE_HEALTH" /> | 17 | <uses-permission android:name="android.permission.FOREGROUND_SERVICE_HEALTH" /> |
18 | <uses-permission android:name="android.permission.HIGH_SAMPLING_RATE_SENSORS" /> | 18 | <uses-permission android:name="android.permission.HIGH_SAMPLING_RATE_SENSORS" /> |
19 | <uses-permission android:name="android.permission.POST_NOTIFICATIONS" /> | 19 | <uses-permission android:name="android.permission.POST_NOTIFICATIONS" /> |
20 | - <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> | 20 | +<!-- <uses-permission android:name="android.permission.ACTIVITY_RECOGNITION" />--> |
21 | +<!-- <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />--> | ||
21 | 22 | ||
22 | <application android:largeHeap="true"> | 23 | <application android:largeHeap="true"> |
23 | <!-- <meta-data--> | 24 | <!-- <meta-data--> |
... | @@ -291,8 +292,8 @@ | ... | @@ -291,8 +292,8 @@ |
291 | android:name=".receivers.RestartHealthServiceReceiver" | 292 | android:name=".receivers.RestartHealthServiceReceiver" |
292 | android:exported="false"> | 293 | android:exported="false"> |
293 | <intent-filter> | 294 | <intent-filter> |
294 | - <action android:name="android.intent.action.BOOT_COMPLETED" /> | 295 | +<!-- <action android:name="android.intent.action.BOOT_COMPLETED" />--> |
295 | - <action android:name="android.intent.action.MY_PACKAGE_REPLACED" /> | 296 | + <action android:name="android.intent.action.RESTART" /> |
296 | </intent-filter> | 297 | </intent-filter> |
297 | </receiver> | 298 | </receiver> |
298 | 299 | ... | ... |
... | @@ -28,6 +28,8 @@ package ly.warp.sdk.activities; | ... | @@ -28,6 +28,8 @@ package ly.warp.sdk.activities; |
28 | import static ly.warp.sdk.utils.constants.WarpConstants.RANDOM_MAX; | 28 | import static ly.warp.sdk.utils.constants.WarpConstants.RANDOM_MAX; |
29 | import static ly.warp.sdk.utils.constants.WarpConstants.RANDOM_MIN; | 29 | import static ly.warp.sdk.utils.constants.WarpConstants.RANDOM_MIN; |
30 | 30 | ||
31 | +import android.Manifest; | ||
32 | +import android.app.ActivityManager; | ||
31 | import android.content.Context; | 33 | import android.content.Context; |
32 | import android.content.Intent; | 34 | import android.content.Intent; |
33 | import android.content.pm.PackageManager; | 35 | import android.content.pm.PackageManager; |
... | @@ -35,6 +37,8 @@ import android.graphics.Color; | ... | @@ -35,6 +37,8 @@ import android.graphics.Color; |
35 | import android.os.Build; | 37 | import android.os.Build; |
36 | import android.os.Bundle; | 38 | import android.os.Bundle; |
37 | import android.os.Handler; | 39 | import android.os.Handler; |
40 | +import android.os.PowerManager; | ||
41 | +import android.provider.Settings; | ||
38 | import android.text.TextUtils; | 42 | import android.text.TextUtils; |
39 | import android.view.KeyEvent; | 43 | import android.view.KeyEvent; |
40 | import android.view.View; | 44 | import android.view.View; |
... | @@ -44,6 +48,8 @@ import android.widget.ProgressBar; | ... | @@ -44,6 +48,8 @@ import android.widget.ProgressBar; |
44 | import android.widget.RelativeLayout; | 48 | import android.widget.RelativeLayout; |
45 | 49 | ||
46 | import androidx.annotation.NonNull; | 50 | import androidx.annotation.NonNull; |
51 | +import androidx.core.app.ActivityCompat; | ||
52 | +import androidx.core.content.ContextCompat; | ||
47 | import androidx.work.Constraints; | 53 | import androidx.work.Constraints; |
48 | import androidx.work.NetworkType; | 54 | import androidx.work.NetworkType; |
49 | import androidx.work.OneTimeWorkRequest; | 55 | import androidx.work.OneTimeWorkRequest; |
... | @@ -62,11 +68,14 @@ import ly.warp.sdk.Warply; | ... | @@ -62,11 +68,14 @@ import ly.warp.sdk.Warply; |
62 | import ly.warp.sdk.db.WarplyDBHelper; | 68 | import ly.warp.sdk.db.WarplyDBHelper; |
63 | import ly.warp.sdk.io.callbacks.CallbackReceiver; | 69 | import ly.warp.sdk.io.callbacks.CallbackReceiver; |
64 | import ly.warp.sdk.io.models.CouponList; | 70 | import ly.warp.sdk.io.models.CouponList; |
71 | +import ly.warp.sdk.io.models.LoyaltySDKFirebaseEventModel; | ||
72 | +import ly.warp.sdk.io.models.WarplyPacingEventModel; | ||
65 | import ly.warp.sdk.io.models.WarplyWebviewActivityCallbackEventModel; | 73 | import ly.warp.sdk.io.models.WarplyWebviewActivityCallbackEventModel; |
66 | import ly.warp.sdk.io.models.WarplyWebviewCallbackEventModel; | 74 | import ly.warp.sdk.io.models.WarplyWebviewCallbackEventModel; |
67 | import ly.warp.sdk.services.EventCampaignCouponService; | 75 | import ly.warp.sdk.services.EventCampaignCouponService; |
68 | import ly.warp.sdk.services.EventQuestionnaireService; | 76 | import ly.warp.sdk.services.EventQuestionnaireService; |
69 | import ly.warp.sdk.services.PushEventsClickedWorkerService; | 77 | import ly.warp.sdk.services.PushEventsClickedWorkerService; |
78 | +import ly.warp.sdk.services.WarplyHealthService; | ||
70 | import ly.warp.sdk.utils.WarpJSONParser; | 79 | import ly.warp.sdk.utils.WarpJSONParser; |
71 | import ly.warp.sdk.utils.WarpUtils; | 80 | import ly.warp.sdk.utils.WarpUtils; |
72 | import ly.warp.sdk.utils.WarplyPreferences; | 81 | import ly.warp.sdk.utils.WarplyPreferences; |
... | @@ -164,6 +173,24 @@ public class WarpViewActivity extends WarpBaseActivity { | ... | @@ -164,6 +173,24 @@ public class WarpViewActivity extends WarpBaseActivity { |
164 | webviewCallbackEventModel.setResponseCode(grantResults[0] == PackageManager.PERMISSION_GRANTED ? "allow" : "deny"); | 173 | webviewCallbackEventModel.setResponseCode(grantResults[0] == PackageManager.PERMISSION_GRANTED ? "allow" : "deny"); |
165 | EventBus.getDefault().post(new WarplyEventBusManager(webviewCallbackEventModel)); | 174 | EventBus.getDefault().post(new WarplyEventBusManager(webviewCallbackEventModel)); |
166 | } | 175 | } |
176 | + if (requestCode == 5001 && grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { | ||
177 | + if (!isMyServiceRunning(WarplyHealthService.class)) { | ||
178 | + LoyaltySDKFirebaseEventModel analyticsEvent = new LoyaltySDKFirebaseEventModel(); | ||
179 | + analyticsEvent.setEventName("loyalty_steps_activation"); | ||
180 | + EventBus.getDefault().post(new WarplyEventBusManager(analyticsEvent)); | ||
181 | + | ||
182 | + Intent stepsServiceIntent = new Intent(this, WarplyHealthService.class); | ||
183 | + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | ||
184 | + startForegroundService(stepsServiceIntent); | ||
185 | + } else { | ||
186 | + startService(stepsServiceIntent); | ||
187 | + } | ||
188 | + | ||
189 | + WarplyPacingEventModel pacingVisible = new WarplyPacingEventModel(); | ||
190 | + pacingVisible.setVisible(true); | ||
191 | + EventBus.getDefault().post(new WarplyEventBusManager(pacingVisible)); | ||
192 | + } | ||
193 | + } | ||
167 | } | 194 | } |
168 | 195 | ||
169 | @Override | 196 | @Override |
... | @@ -195,6 +222,60 @@ public class WarpViewActivity extends WarpBaseActivity { | ... | @@ -195,6 +222,60 @@ public class WarpViewActivity extends WarpBaseActivity { |
195 | // if (event.getPacingService() != null) | 222 | // if (event.getPacingService() != null) |
196 | // finish(); | 223 | // finish(); |
197 | if (event.getPacing() != null && !event.getPacing().isVisible()) finish(); | 224 | if (event.getPacing() != null && !event.getPacing().isVisible()) finish(); |
225 | + if (event.getHealth() != null) { | ||
226 | + if (event.getHealth().isActivated()) { | ||
227 | + WarpUtils.setIsStepsManuallyStopped(this, false); | ||
228 | +// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { | ||
229 | +// if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACTIVITY_RECOGNITION) != PackageManager.PERMISSION_GRANTED) { | ||
230 | +// ActivityCompat.requestPermissions(this, new String[]{ | ||
231 | +// Manifest.permission.ACTIVITY_RECOGNITION | ||
232 | +// }, 5001); | ||
233 | +// } else { | ||
234 | +// if (!isMyServiceRunning(WarplyHealthService.class)) { | ||
235 | +// LoyaltySDKFirebaseEventModel analyticsEvent = new LoyaltySDKFirebaseEventModel(); | ||
236 | +// analyticsEvent.setEventName("loyalty_steps_activation"); | ||
237 | +// EventBus.getDefault().post(new WarplyEventBusManager(analyticsEvent)); | ||
238 | +// | ||
239 | +// Intent stepsServiceIntent = new Intent(this, WarplyHealthService.class); | ||
240 | +// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | ||
241 | +// startForegroundService(stepsServiceIntent); | ||
242 | +// } else { | ||
243 | +// startService(stepsServiceIntent); | ||
244 | +// } | ||
245 | +// | ||
246 | +// WarplyPacingEventModel pacingVisible = new WarplyPacingEventModel(); | ||
247 | +// pacingVisible.setVisible(true); | ||
248 | +// EventBus.getDefault().post(new WarplyEventBusManager(pacingVisible)); | ||
249 | +// } | ||
250 | +// } | ||
251 | +// } else { | ||
252 | + if (!isMyServiceRunning(WarplyHealthService.class)) { | ||
253 | + LoyaltySDKFirebaseEventModel analyticsEvent = new LoyaltySDKFirebaseEventModel(); | ||
254 | + analyticsEvent.setEventName("loyalty_steps_activation"); | ||
255 | + EventBus.getDefault().post(new WarplyEventBusManager(analyticsEvent)); | ||
256 | + | ||
257 | + Intent stepsServiceIntent = new Intent(this, WarplyHealthService.class); | ||
258 | + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | ||
259 | + startForegroundService(stepsServiceIntent); | ||
260 | + } else { | ||
261 | + startService(stepsServiceIntent); | ||
262 | + } | ||
263 | + | ||
264 | + WarplyPacingEventModel pacingVisible = new WarplyPacingEventModel(); | ||
265 | + pacingVisible.setVisible(true); | ||
266 | + EventBus.getDefault().post(new WarplyEventBusManager(pacingVisible)); | ||
267 | + } | ||
268 | +// } | ||
269 | + } else { | ||
270 | + WarpUtils.setIsStepsManuallyStopped(this, true); | ||
271 | + Intent stepsServiceIntent = new Intent(this, WarplyHealthService.class); | ||
272 | + stopService(stepsServiceIntent); | ||
273 | + | ||
274 | + WarplyPacingEventModel pacingVisible = new WarplyPacingEventModel(); | ||
275 | + pacingVisible.setVisible(false); | ||
276 | + EventBus.getDefault().post(new WarplyEventBusManager(pacingVisible)); | ||
277 | + } | ||
278 | + } | ||
198 | } | 279 | } |
199 | 280 | ||
200 | // =========================================================== | 281 | // =========================================================== |
... | @@ -251,19 +332,19 @@ public class WarpViewActivity extends WarpBaseActivity { | ... | @@ -251,19 +332,19 @@ public class WarpViewActivity extends WarpBaseActivity { |
251 | if (intent.hasExtra("source") && intent.getStringExtra("source").equalsIgnoreCase("from_notification_status")) { | 332 | if (intent.hasExtra("source") && intent.getStringExtra("source").equalsIgnoreCase("from_notification_status")) { |
252 | JSONObject params = new JSONObject(); | 333 | JSONObject params = new JSONObject(); |
253 | try { | 334 | try { |
254 | - params.putOpt("web_id", WarpUtils.getWebId(Warply.getWarplyContext())); | 335 | + params.putOpt("web_id", WarpUtils.getWebId(this)); |
255 | - params.putOpt("app_uuid", WarplyProperty.getAppUuid(Warply.getWarplyContext())); | 336 | + params.putOpt("app_uuid", WarplyProperty.getAppUuid(this)); |
256 | - params.putOpt("api_key", WarpUtils.getApiKey(Warply.getWarplyContext())); | 337 | + params.putOpt("api_key", WarpUtils.getApiKey(this)); |
257 | params.putOpt("session_uuid", sessionUUID); | 338 | params.putOpt("session_uuid", sessionUUID); |
258 | - params.putOpt("access_token", WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("access_token")); | 339 | + params.putOpt("access_token", WarplyDBHelper.getInstance(this).getAuthValue("access_token")); |
259 | - params.putOpt("refresh_token", WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("refresh_token")); | 340 | + params.putOpt("refresh_token", WarplyDBHelper.getInstance(this).getAuthValue("refresh_token")); |
260 | - params.putOpt("client_id", WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_id")); | 341 | + params.putOpt("client_id", WarplyDBHelper.getInstance(this).getClientValue("client_id")); |
261 | - params.putOpt("client_secret", WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_secret")); | 342 | + params.putOpt("client_secret", WarplyDBHelper.getInstance(this).getClientValue("client_secret")); |
262 | } catch (JSONException e) { | 343 | } catch (JSONException e) { |
263 | e.printStackTrace(); | 344 | e.printStackTrace(); |
264 | } | 345 | } |
265 | 346 | ||
266 | - WarpUtils.setWebviewParams(Warply.getWarplyContext(), params); | 347 | + WarpUtils.setWebviewParams(this, params); |
267 | 348 | ||
268 | setUpPushEvents(sessionUUID); | 349 | setUpPushEvents(sessionUUID); |
269 | } | 350 | } |
... | @@ -341,4 +422,24 @@ public class WarpViewActivity extends WarpBaseActivity { | ... | @@ -341,4 +422,24 @@ public class WarpViewActivity extends WarpBaseActivity { |
341 | public static void setWebviewSupermarket(boolean isLoaded) { | 422 | public static void setWebviewSupermarket(boolean isLoaded) { |
342 | mWebviewSupermarket = isLoaded; | 423 | mWebviewSupermarket = isLoaded; |
343 | } | 424 | } |
425 | + | ||
426 | + private boolean isMyServiceRunning(Class<?> serviceClass) { | ||
427 | + ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); | ||
428 | + for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { | ||
429 | + if (serviceClass.getName().equals(service.service.getClassName())) { | ||
430 | + return true; | ||
431 | + } | ||
432 | + } | ||
433 | + return false; | ||
434 | + } | ||
435 | + | ||
436 | + private void checkBatteryOptimizationForWarplyHealth() { | ||
437 | + PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); | ||
438 | + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { | ||
439 | + if (!pm.isIgnoringBatteryOptimizations(getPackageName())) { | ||
440 | + Intent intent = new Intent(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS); | ||
441 | + startActivityForResult(intent, 6001); | ||
442 | + } | ||
443 | + } | ||
444 | + } | ||
344 | } | 445 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
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 25-July-24. | ||
31 | + */ | ||
32 | + | ||
33 | +public class WarplyHealthEventModel { | ||
34 | + private boolean activated; | ||
35 | + | ||
36 | + public WarplyHealthEventModel() { | ||
37 | + this.activated = true; | ||
38 | + } | ||
39 | + | ||
40 | + public boolean isActivated() { | ||
41 | + return activated; | ||
42 | + } | ||
43 | + | ||
44 | + public void setActivated(boolean activated) { | ||
45 | + this.activated = activated; | ||
46 | + } | ||
47 | +} |
1 | package ly.warp.sdk.receivers; | 1 | package ly.warp.sdk.receivers; |
2 | 2 | ||
3 | +import static ly.warp.sdk.services.WarplyHealthService.ACTION_RESTART_SERVICE; | ||
4 | + | ||
3 | import android.content.BroadcastReceiver; | 5 | import android.content.BroadcastReceiver; |
4 | import android.content.Context; | 6 | import android.content.Context; |
5 | import android.content.Intent; | 7 | import android.content.Intent; |
6 | -import android.os.Build; | ||
7 | 8 | ||
8 | -import ly.warp.sdk.services.WarplyHealthService; | 9 | +import androidx.work.OneTimeWorkRequest; |
10 | +import androidx.work.WorkManager; | ||
11 | + | ||
12 | +import java.util.concurrent.TimeUnit; | ||
13 | + | ||
14 | +import ly.warp.sdk.services.WarplyHealthWorker; | ||
9 | 15 | ||
10 | public class RestartHealthServiceReceiver extends BroadcastReceiver { | 16 | public class RestartHealthServiceReceiver extends BroadcastReceiver { |
11 | @Override | 17 | @Override |
12 | public void onReceive(Context context, Intent intent) { | 18 | public void onReceive(Context context, Intent intent) { |
13 | - if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction()) || | 19 | + if (intent != null && intent.getAction() != null && ACTION_RESTART_SERVICE.equals(intent.getAction())) { |
14 | - Intent.ACTION_MY_PACKAGE_REPLACED.equals(intent.getAction())) { | 20 | + scheduleWork(context); |
15 | - Intent stepsRestartServiceIntent = new Intent(context, WarplyHealthService.class); | ||
16 | - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | ||
17 | - context.startForegroundService(stepsRestartServiceIntent); | ||
18 | - } else { | ||
19 | - context.startService(stepsRestartServiceIntent); | ||
20 | } | 21 | } |
21 | } | 22 | } |
23 | + | ||
24 | + private void scheduleWork(Context context) { | ||
25 | + OneTimeWorkRequest workRequest = new OneTimeWorkRequest.Builder(WarplyHealthWorker.class) | ||
26 | + .setInitialDelay(2, TimeUnit.SECONDS) | ||
27 | + .build(); | ||
28 | + WorkManager.getInstance(context).enqueue(workRequest); | ||
22 | } | 29 | } |
23 | } | 30 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
This diff is collapsed. Click to expand it.
1 | +package ly.warp.sdk.services; | ||
2 | + | ||
3 | +import android.content.Context; | ||
4 | +import android.content.Intent; | ||
5 | +import android.os.Build; | ||
6 | + | ||
7 | +import androidx.annotation.NonNull; | ||
8 | +import androidx.work.Worker; | ||
9 | +import androidx.work.WorkerParameters; | ||
10 | + | ||
11 | +/** | ||
12 | + * Created by Panagiotis Triantafyllou on 26/Ιουλ/2024. | ||
13 | + */ | ||
14 | +public class WarplyHealthWorker extends Worker { | ||
15 | + | ||
16 | + public WarplyHealthWorker(@NonNull Context context, @NonNull WorkerParameters workerParams) { | ||
17 | + super(context, workerParams); | ||
18 | + } | ||
19 | + | ||
20 | + @NonNull | ||
21 | + @Override | ||
22 | + public Result doWork() { | ||
23 | + Context context = getApplicationContext(); | ||
24 | + Intent stepsRestartServiceIntent = new Intent(context, WarplyHealthService.class); | ||
25 | + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | ||
26 | + context.startForegroundService(stepsRestartServiceIntent); | ||
27 | + } else { | ||
28 | + context.startService(stepsRestartServiceIntent); | ||
29 | + } | ||
30 | + | ||
31 | + return Result.success(); | ||
32 | + } | ||
33 | +} |
... | @@ -157,6 +157,8 @@ public class WarpUtils { | ... | @@ -157,6 +157,8 @@ public class WarpUtils { |
157 | + "language"; | 157 | + "language"; |
158 | private static final String PREFERENCES_KEY_STEPS = PREFERENCES_PREFIX | 158 | private static final String PREFERENCES_KEY_STEPS = PREFERENCES_PREFIX |
159 | + "steps"; | 159 | + "steps"; |
160 | + private static final String PREFERENCES_KEY_STEPS_MANUALLY_STOPPED = PREFERENCES_PREFIX | ||
161 | + + "steps_manually_stopped"; | ||
160 | 162 | ||
161 | private static SharedPreferences _prefs; | 163 | private static SharedPreferences _prefs; |
162 | 164 | ||
... | @@ -166,9 +168,19 @@ public class WarpUtils { | ... | @@ -166,9 +168,19 @@ public class WarpUtils { |
166 | return getPreferences(context).getBoolean(PREFERENCES_KEY_STEPS, false); | 168 | return getPreferences(context).getBoolean(PREFERENCES_KEY_STEPS, false); |
167 | } | 169 | } |
168 | 170 | ||
169 | - public static void setIsSteps(Context context, boolean isSupermarket) { | 171 | + public static void setIsSteps(Context context, boolean isSteps) { |
170 | SharedPreferences.Editor editor = getPreferences(context).edit(); | 172 | SharedPreferences.Editor editor = getPreferences(context).edit(); |
171 | - editor.putBoolean(PREFERENCES_KEY_STEPS, isSupermarket); | 173 | + editor.putBoolean(PREFERENCES_KEY_STEPS, isSteps); |
174 | + editor.apply(); | ||
175 | + } | ||
176 | + | ||
177 | + public static boolean getIsStepsManuallyStopped(Context context) { | ||
178 | + return getPreferences(context).getBoolean(PREFERENCES_KEY_STEPS_MANUALLY_STOPPED, false); | ||
179 | + } | ||
180 | + | ||
181 | + public static void setIsStepsManuallyStopped(Context context, boolean isManuallyStopped) { | ||
182 | + SharedPreferences.Editor editor = getPreferences(context).edit(); | ||
183 | + editor.putBoolean(PREFERENCES_KEY_STEPS_MANUALLY_STOPPED, isManuallyStopped); | ||
172 | editor.apply(); | 184 | editor.apply(); |
173 | } | 185 | } |
174 | 186 | ... | ... |
... | @@ -27,6 +27,7 @@ import ly.warp.sdk.io.models.WarplyBoxAnalysisEventModel; | ... | @@ -27,6 +27,7 @@ import ly.warp.sdk.io.models.WarplyBoxAnalysisEventModel; |
27 | import ly.warp.sdk.io.models.WarplyCCMSEnabledModel; | 27 | import ly.warp.sdk.io.models.WarplyCCMSEnabledModel; |
28 | import ly.warp.sdk.io.models.WarplyCouponsChangedEventModel; | 28 | import ly.warp.sdk.io.models.WarplyCouponsChangedEventModel; |
29 | import ly.warp.sdk.io.models.WarplyDealsAnalysisEventModel; | 29 | import ly.warp.sdk.io.models.WarplyDealsAnalysisEventModel; |
30 | +import ly.warp.sdk.io.models.WarplyHealthEventModel; | ||
30 | import ly.warp.sdk.io.models.WarplyNavigateBackEventModel; | 31 | import ly.warp.sdk.io.models.WarplyNavigateBackEventModel; |
31 | import ly.warp.sdk.io.models.WarplyPacingCardEventModel; | 32 | import ly.warp.sdk.io.models.WarplyPacingCardEventModel; |
32 | import ly.warp.sdk.io.models.WarplyPacingCardServiceEnabledModel; | 33 | import ly.warp.sdk.io.models.WarplyPacingCardServiceEnabledModel; |
... | @@ -51,6 +52,7 @@ public class WarplyEventBusManager { | ... | @@ -51,6 +52,7 @@ public class WarplyEventBusManager { |
51 | private WarplyCCMSEnabledModel ccmsActivated; | 52 | private WarplyCCMSEnabledModel ccmsActivated; |
52 | private LoyaltyGiftsForYouOfferClickEvent giftsYou; | 53 | private LoyaltyGiftsForYouOfferClickEvent giftsYou; |
53 | private QuestionnaireEventModel questionnaire; | 54 | private QuestionnaireEventModel questionnaire; |
55 | + private WarplyHealthEventModel health; | ||
54 | private OpenMyRewardsEventModel openRewards; | 56 | private OpenMyRewardsEventModel openRewards; |
55 | private RewardsCouponsEventModel rewardsCoupons; | 57 | private RewardsCouponsEventModel rewardsCoupons; |
56 | private VouchersActivityEventModel vouchersActivity; | 58 | private VouchersActivityEventModel vouchersActivity; |
... | @@ -91,6 +93,10 @@ public class WarplyEventBusManager { | ... | @@ -91,6 +93,10 @@ public class WarplyEventBusManager { |
91 | this.questionnaire = questionnaire; | 93 | this.questionnaire = questionnaire; |
92 | } | 94 | } |
93 | 95 | ||
96 | + public WarplyEventBusManager(WarplyHealthEventModel health) { | ||
97 | + this.health = health; | ||
98 | + } | ||
99 | + | ||
94 | public WarplyEventBusManager(OpenMyRewardsEventModel openRewards) { | 100 | public WarplyEventBusManager(OpenMyRewardsEventModel openRewards) { |
95 | this.openRewards = openRewards; | 101 | this.openRewards = openRewards; |
96 | } | 102 | } |
... | @@ -276,6 +282,10 @@ public class WarplyEventBusManager { | ... | @@ -276,6 +282,10 @@ public class WarplyEventBusManager { |
276 | return questionnaire; | 282 | return questionnaire; |
277 | } | 283 | } |
278 | 284 | ||
285 | + public WarplyHealthEventModel getHealth() { | ||
286 | + return health; | ||
287 | + } | ||
288 | + | ||
279 | public VouchersActivityEventModel getVouchersActivity() { | 289 | public VouchersActivityEventModel getVouchersActivity() { |
280 | return vouchersActivity; | 290 | return vouchersActivity; |
281 | } | 291 | } | ... | ... |
... | @@ -103,6 +103,7 @@ import ly.warp.sdk.io.models.RefreshVouchersEventModel; | ... | @@ -103,6 +103,7 @@ import ly.warp.sdk.io.models.RefreshVouchersEventModel; |
103 | import ly.warp.sdk.io.models.UnifiedCoupon; | 103 | import ly.warp.sdk.io.models.UnifiedCoupon; |
104 | import ly.warp.sdk.io.models.WarplyCCMSEnabledModel; | 104 | import ly.warp.sdk.io.models.WarplyCCMSEnabledModel; |
105 | import ly.warp.sdk.io.models.WarplyCouponsChangedEventModel; | 105 | import ly.warp.sdk.io.models.WarplyCouponsChangedEventModel; |
106 | +import ly.warp.sdk.io.models.WarplyHealthEventModel; | ||
106 | import ly.warp.sdk.io.models.WarplyPacingCardEventModel; | 107 | import ly.warp.sdk.io.models.WarplyPacingCardEventModel; |
107 | import ly.warp.sdk.io.models.WarplyPacingEventModel; | 108 | import ly.warp.sdk.io.models.WarplyPacingEventModel; |
108 | import ly.warp.sdk.io.models.WarplyUnifiedActivatedEventModel; | 109 | import ly.warp.sdk.io.models.WarplyUnifiedActivatedEventModel; |
... | @@ -543,29 +544,37 @@ public class WarpView extends WebView implements DefaultLifecycleObserver { | ... | @@ -543,29 +544,37 @@ public class WarpView extends WebView implements DefaultLifecycleObserver { |
543 | pacingWidgetVisible.setVisible(true); | 544 | pacingWidgetVisible.setVisible(true); |
544 | EventBus.getDefault().post(new WarplyEventBusManager(pacingWidgetVisible)); | 545 | EventBus.getDefault().post(new WarplyEventBusManager(pacingWidgetVisible)); |
545 | } else if (parts[1].equals("steps") && parts[2].equals("shortcutEnabled")) { // This is for the pacing service | 546 | } else if (parts[1].equals("steps") && parts[2].equals("shortcutEnabled")) { // This is for the pacing service |
546 | - if (!isMyServiceRunning(WarplyHealthService.class)) { | 547 | +// if (!isMyServiceRunning(WarplyHealthService.class)) { |
547 | - LoyaltySDKFirebaseEventModel analyticsEvent = new LoyaltySDKFirebaseEventModel(); | 548 | +// LoyaltySDKFirebaseEventModel analyticsEvent = new LoyaltySDKFirebaseEventModel(); |
548 | - analyticsEvent.setEventName("loyalty_steps_activation"); | 549 | +// analyticsEvent.setEventName("loyalty_steps_activation"); |
549 | - EventBus.getDefault().post(new WarplyEventBusManager(analyticsEvent)); | 550 | +// EventBus.getDefault().post(new WarplyEventBusManager(analyticsEvent)); |
550 | - | 551 | +// |
551 | - Intent stepsServiceIntent = new Intent(Warply.getWarplyContext(), WarplyHealthService.class); | 552 | +// Intent stepsServiceIntent = new Intent(Warply.getWarplyContext(), WarplyHealthService.class); |
552 | - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | 553 | +// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { |
553 | - Warply.getWarplyContext().startForegroundService(stepsServiceIntent); | 554 | +// Warply.getWarplyContext().startForegroundService(stepsServiceIntent); |
554 | - } else { | 555 | +// } else { |
555 | - Warply.getWarplyContext().startService(stepsServiceIntent); | 556 | +// Warply.getWarplyContext().startService(stepsServiceIntent); |
556 | - } | 557 | +// } |
557 | - | 558 | +// |
558 | - WarplyPacingEventModel pacingVisible = new WarplyPacingEventModel(); | 559 | +// WarplyPacingEventModel pacingVisible = new WarplyPacingEventModel(); |
559 | - pacingVisible.setVisible(true); | 560 | +// pacingVisible.setVisible(true); |
560 | - EventBus.getDefault().post(new WarplyEventBusManager(pacingVisible)); | 561 | +// EventBus.getDefault().post(new WarplyEventBusManager(pacingVisible)); |
561 | - } | 562 | +// } |
563 | + | ||
564 | + WarplyHealthEventModel healthActive = new WarplyHealthEventModel(); | ||
565 | + healthActive.setActivated(true); | ||
566 | + EventBus.getDefault().post(new WarplyEventBusManager(healthActive)); | ||
562 | } else if (parts[1].equals("steps") && parts[2].equals("shortcutDisabled")) { // This is for the pacing service | 567 | } else if (parts[1].equals("steps") && parts[2].equals("shortcutDisabled")) { // This is for the pacing service |
563 | - Intent stepsServiceIntent = new Intent(Warply.getWarplyContext(), WarplyHealthService.class); | 568 | +// Intent stepsServiceIntent = new Intent(Warply.getWarplyContext(), WarplyHealthService.class); |
564 | - Warply.getWarplyContext().stopService(stepsServiceIntent); | 569 | +// Warply.getWarplyContext().stopService(stepsServiceIntent); |
565 | - | 570 | +// |
566 | - WarplyPacingEventModel pacingVisible = new WarplyPacingEventModel(); | 571 | +// WarplyPacingEventModel pacingVisible = new WarplyPacingEventModel(); |
567 | - pacingVisible.setVisible(false); | 572 | +// pacingVisible.setVisible(false); |
568 | - EventBus.getDefault().post(new WarplyEventBusManager(pacingVisible)); | 573 | +// EventBus.getDefault().post(new WarplyEventBusManager(pacingVisible)); |
574 | + | ||
575 | + WarplyHealthEventModel healthActive = new WarplyHealthEventModel(); | ||
576 | + healthActive.setActivated(false); | ||
577 | + EventBus.getDefault().post(new WarplyEventBusManager(healthActive)); | ||
569 | } else if (parts[1].equals("request") || parts[1].equals("response")) { | 578 | } else if (parts[1].equals("request") || parts[1].equals("response")) { |
570 | WarpUtils.log("**************** WARPLY Webview Log START *****************"); | 579 | WarpUtils.log("**************** WARPLY Webview Log START *****************"); |
571 | WarpUtils.log(message); | 580 | WarpUtils.log(message); | ... | ... |
-
Please register or login to post a comment