Panagiotis Triantafyllou

push services fix for android 12, steps demo activity

...@@ -57,6 +57,11 @@ ...@@ -57,6 +57,11 @@
57 android:screenOrientation="portrait" /> 57 android:screenOrientation="portrait" />
58 58
59 <activity 59 <activity
60 + android:name="ly.warp.sdk.activities.StepsActivity"
61 + android:exported="false"
62 + android:screenOrientation="portrait" />
63 +
64 + <activity
60 android:name="ly.warp.sdk.activities.PastCouponsActivity" 65 android:name="ly.warp.sdk.activities.PastCouponsActivity"
61 android:exported="false" 66 android:exported="false"
62 android:screenOrientation="portrait" /> 67 android:screenOrientation="portrait" />
......
1 +package ly.warp.sdk.activities;
2 +
3 +import android.app.Activity;
4 +import android.os.Bundle;
5 +import android.view.View;
6 +import android.widget.ImageView;
7 +import android.widget.TextView;
8 +
9 +import ly.warp.sdk.R;
10 +import ly.warp.sdk.io.callbacks.WarplyHealthCallback;
11 +import ly.warp.sdk.utils.managers.WarplyHealthManager;
12 +
13 +
14 +public class StepsActivity extends Activity implements View.OnClickListener {
15 +
16 + // ===========================================================
17 + // Constants
18 + // ===========================================================
19 +
20 + // ===========================================================
21 + // Fields
22 + // ===========================================================
23 +
24 + private TextView mTvStepsValue;
25 + private ImageView mIvBack;
26 +
27 + // ===========================================================
28 + // Methods for/from SuperClass/Interfaces
29 + // ===========================================================
30 +
31 + @Override
32 + public void onCreate(Bundle savedInstanceState) {
33 + super.onCreate(savedInstanceState);
34 + setContentView(R.layout.activity_steps);
35 +
36 + mIvBack = findViewById(R.id.iv_back);
37 + mTvStepsValue = findViewById(R.id.tv_counter_value);
38 +
39 + initViews();
40 + }
41 +
42 + @Override
43 + protected void onStart() {
44 + super.onStart();
45 + WarplyHealthManager
46 + .getInstance(this, mWarplyHealthCallback)
47 + .registerStepSensor();
48 + }
49 +
50 + @Override
51 + public void onResume() {
52 + super.onResume();
53 + }
54 +
55 + @Override
56 + protected void onStop() {
57 + super.onStop();
58 + WarplyHealthManager
59 + .getInstance(this)
60 + .unregisterStepSensor();
61 + }
62 +
63 + @Override
64 + public void onClick(View view) {
65 + if (view.getId() == R.id.iv_back) {
66 + onBackPressed();
67 + }
68 + }
69 +
70 + // ===========================================================
71 + // Methods
72 + // ===========================================================
73 +
74 + private void initViews() {
75 + mIvBack.setOnClickListener(this);
76 + }
77 +
78 + private final WarplyHealthCallback mWarplyHealthCallback = new WarplyHealthCallback() {
79 + @Override
80 + public void onStepCount(long stepsCount) {
81 + mTvStepsValue.setText(String.valueOf(stepsCount));
82 + }
83 + };
84 +
85 + // ===========================================================
86 + // Inner and Anonymous Classes
87 + // ===========================================================
88 +
89 +}
...@@ -19,6 +19,7 @@ import androidx.recyclerview.widget.RecyclerView; ...@@ -19,6 +19,7 @@ import androidx.recyclerview.widget.RecyclerView;
19 import ly.warp.sdk.R; 19 import ly.warp.sdk.R;
20 import ly.warp.sdk.activities.ActiveCouponsActivity; 20 import ly.warp.sdk.activities.ActiveCouponsActivity;
21 import ly.warp.sdk.activities.BillPaymentActivity; 21 import ly.warp.sdk.activities.BillPaymentActivity;
22 +import ly.warp.sdk.activities.StepsActivity;
22 import ly.warp.sdk.activities.WarpViewActivity; 23 import ly.warp.sdk.activities.WarpViewActivity;
23 import ly.warp.sdk.utils.WarplyManagerHelper; 24 import ly.warp.sdk.utils.WarplyManagerHelper;
24 import ly.warp.sdk.views.adapters.HomeCampaignAdapter; 25 import ly.warp.sdk.views.adapters.HomeCampaignAdapter;
...@@ -31,6 +32,7 @@ public class HomeFragment extends Fragment implements View.OnClickListener { ...@@ -31,6 +32,7 @@ public class HomeFragment extends Fragment implements View.OnClickListener {
31 private LinearLayout mLlBillPayment; 32 private LinearLayout mLlBillPayment;
32 private TextView mTvUsername, mTvActiveCoupons; 33 private TextView mTvUsername, mTvActiveCoupons;
33 private ConstraintLayout mClActiveCoupons; 34 private ConstraintLayout mClActiveCoupons;
35 + private ImageView mIvStepsActivity;
34 36
35 @Override 37 @Override
36 public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 38 public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
...@@ -66,6 +68,9 @@ public class HomeFragment extends Fragment implements View.OnClickListener { ...@@ -66,6 +68,9 @@ public class HomeFragment extends Fragment implements View.OnClickListener {
66 mLlBillPayment = view.findViewById(R.id.ll_bill_payment); 68 mLlBillPayment = view.findViewById(R.id.ll_bill_payment);
67 mLlBillPayment.setOnClickListener(this); 69 mLlBillPayment.setOnClickListener(this);
68 70
71 + mIvStepsActivity = view.findViewById(R.id.iv_settings);
72 + mIvStepsActivity.setOnClickListener(this);
73 +
69 mTvUsername = view.findViewById(R.id.welcome_user_txt); 74 mTvUsername = view.findViewById(R.id.welcome_user_txt);
70 if (WarplyManagerHelper.getConsumer() != null) 75 if (WarplyManagerHelper.getConsumer() != null)
71 mTvUsername.setText(String.format(getResources().getString(R.string.welcome_user), 76 mTvUsername.setText(String.format(getResources().getString(R.string.welcome_user),
...@@ -100,6 +105,11 @@ public class HomeFragment extends Fragment implements View.OnClickListener { ...@@ -100,6 +105,11 @@ public class HomeFragment extends Fragment implements View.OnClickListener {
100 Intent intent = new Intent(getContext(), ActiveCouponsActivity.class); 105 Intent intent = new Intent(getContext(), ActiveCouponsActivity.class);
101 intent.putExtra("couponlist", WarplyManagerHelper.getCouponList()); 106 intent.putExtra("couponlist", WarplyManagerHelper.getCouponList());
102 startActivity(intent); 107 startActivity(intent);
108 + return;
109 + }
110 + if (view.getId() == R.id.iv_settings) {
111 + Intent intent = new Intent(getContext(), StepsActivity.class);
112 + startActivity(intent);
103 } 113 }
104 } 114 }
105 115
......
...@@ -214,7 +214,11 @@ public class FCMBaseMessagingService extends FirebaseMessagingService { ...@@ -214,7 +214,11 @@ public class FCMBaseMessagingService extends FirebaseMessagingService {
214 b.setContentTitle(pc.getTitle()); 214 b.setContentTitle(pc.getTitle());
215 b.setContentText(pc.getSubtitle()); 215 b.setContentText(pc.getSubtitle());
216 b.setSubText(pc.getContent()); 216 b.setSubText(pc.getContent());
217 - b.setContentIntent(PendingIntent.getActivity(context, uid, newIntent, PendingIntent.FLAG_ONE_SHOT)); 217 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
218 + b.setContentIntent(PendingIntent.getActivity(context, uid, newIntent, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_MUTABLE));
219 + } else {
220 + b.setContentIntent(PendingIntent.getActivity(context, uid, newIntent, PendingIntent.FLAG_ONE_SHOT));
221 + }
218 b.setAutoCancel(true); 222 b.setAutoCancel(true);
219 b.setOngoing(true); 223 b.setOngoing(true);
220 b.setAutoCancel(true); 224 b.setAutoCancel(true);
...@@ -331,8 +335,12 @@ public class FCMBaseMessagingService extends FirebaseMessagingService { ...@@ -331,8 +335,12 @@ public class FCMBaseMessagingService extends FirebaseMessagingService {
331 builder.setOngoing(true); 335 builder.setOngoing(true);
332 336
333 newIntent.setAction(Long.toString(System.currentTimeMillis())); 337 newIntent.setAction(Long.toString(System.currentTimeMillis()));
334 - PendingIntent pi = PendingIntent.getActivity(context, uid, newIntent, 338 + PendingIntent pi;
335 - PendingIntent.FLAG_ONE_SHOT); 339 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
340 + pi = PendingIntent.getActivity(context, uid, newIntent, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_MUTABLE);
341 + } else {
342 + pi = PendingIntent.getActivity(context, uid, newIntent, PendingIntent.FLAG_ONE_SHOT);
343 + }
336 builder.setContentIntent(pi); 344 builder.setContentIntent(pi);
337 345
338 NotificationManager nm = (NotificationManager) context 346 NotificationManager nm = (NotificationManager) context
...@@ -390,7 +398,11 @@ public class FCMBaseMessagingService extends FirebaseMessagingService { ...@@ -390,7 +398,11 @@ public class FCMBaseMessagingService extends FirebaseMessagingService {
390 b.setContentTitle(pc.getTitle()); 398 b.setContentTitle(pc.getTitle());
391 b.setContentText(pc.getSubtitle()); 399 b.setContentText(pc.getSubtitle());
392 b.setSubText(pc.getContent()); 400 b.setSubText(pc.getContent());
393 - b.setContentIntent(PendingIntent.getActivity(context, uid, newIntent, PendingIntent.FLAG_ONE_SHOT)); 401 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
402 + b.setContentIntent(PendingIntent.getActivity(context, uid, newIntent, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_MUTABLE));
403 + } else {
404 + b.setContentIntent(PendingIntent.getActivity(context, uid, newIntent, PendingIntent.FLAG_ONE_SHOT));
405 + }
394 b.setAutoCancel(true); 406 b.setAutoCancel(true);
395 b.setOngoing(true); 407 b.setOngoing(true);
396 b.setAutoCancel(true); 408 b.setAutoCancel(true);
...@@ -433,7 +445,12 @@ public class FCMBaseMessagingService extends FirebaseMessagingService { ...@@ -433,7 +445,12 @@ public class FCMBaseMessagingService extends FirebaseMessagingService {
433 // Do not allow sound or anything else. 445 // Do not allow sound or anything else.
434 446
435 newIntent.setAction(Long.toString(System.currentTimeMillis())); 447 newIntent.setAction(Long.toString(System.currentTimeMillis()));
436 - PendingIntent pi = PendingIntent.getActivity(context, uid, newIntent, PendingIntent.FLAG_ONE_SHOT); 448 + PendingIntent pi;
449 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
450 + pi = PendingIntent.getActivity(context, uid, newIntent, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_MUTABLE);
451 + } else {
452 + pi = PendingIntent.getActivity(context, uid, newIntent, PendingIntent.FLAG_ONE_SHOT);
453 + }
437 b.setContentIntent(pi); 454 b.setContentIntent(pi);
438 455
439 NotificationManager nm = (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE); 456 NotificationManager nm = (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE);
......
...@@ -259,7 +259,11 @@ public class HMSBaseMessagingService extends HmsMessageService { ...@@ -259,7 +259,11 @@ public class HMSBaseMessagingService extends HmsMessageService {
259 b.setContentTitle(pc.getTitle()); 259 b.setContentTitle(pc.getTitle());
260 b.setContentText(pc.getSubtitle()); 260 b.setContentText(pc.getSubtitle());
261 b.setSubText(pc.getContent()); 261 b.setSubText(pc.getContent());
262 - b.setContentIntent(PendingIntent.getActivity(context, uid, newIntent, PendingIntent.FLAG_ONE_SHOT)); 262 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
263 + b.setContentIntent(PendingIntent.getActivity(context, uid, newIntent, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_MUTABLE));
264 + } else {
265 + b.setContentIntent(PendingIntent.getActivity(context, uid, newIntent, PendingIntent.FLAG_ONE_SHOT));
266 + }
263 b.setAutoCancel(true); 267 b.setAutoCancel(true);
264 b.setOngoing(true); 268 b.setOngoing(true);
265 b.setAutoCancel(true); 269 b.setAutoCancel(true);
...@@ -374,8 +378,12 @@ public class HMSBaseMessagingService extends HmsMessageService { ...@@ -374,8 +378,12 @@ public class HMSBaseMessagingService extends HmsMessageService {
374 builder.setOngoing(true); 378 builder.setOngoing(true);
375 379
376 newIntent.setAction(Long.toString(System.currentTimeMillis())); 380 newIntent.setAction(Long.toString(System.currentTimeMillis()));
377 - PendingIntent pi = PendingIntent.getActivity(context, uid, newIntent, 381 + PendingIntent pi;
378 - PendingIntent.FLAG_ONE_SHOT); 382 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
383 + pi = PendingIntent.getActivity(context, uid, newIntent, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_MUTABLE);
384 + } else {
385 + pi = PendingIntent.getActivity(context, uid, newIntent, PendingIntent.FLAG_ONE_SHOT);
386 + }
379 builder.setContentIntent(pi); 387 builder.setContentIntent(pi);
380 388
381 NotificationManager nm = (NotificationManager) context 389 NotificationManager nm = (NotificationManager) context
...@@ -433,7 +441,11 @@ public class HMSBaseMessagingService extends HmsMessageService { ...@@ -433,7 +441,11 @@ public class HMSBaseMessagingService extends HmsMessageService {
433 b.setContentTitle(pc.getTitle()); 441 b.setContentTitle(pc.getTitle());
434 b.setContentText(pc.getSubtitle()); 442 b.setContentText(pc.getSubtitle());
435 b.setSubText(pc.getContent()); 443 b.setSubText(pc.getContent());
436 - b.setContentIntent(PendingIntent.getActivity(context, uid, newIntent, PendingIntent.FLAG_ONE_SHOT)); 444 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
445 + b.setContentIntent(PendingIntent.getActivity(context, uid, newIntent, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_MUTABLE));
446 + } else {
447 + b.setContentIntent(PendingIntent.getActivity(context, uid, newIntent, PendingIntent.FLAG_ONE_SHOT));
448 + }
437 b.setAutoCancel(true); 449 b.setAutoCancel(true);
438 b.setOngoing(true); 450 b.setOngoing(true);
439 b.setAutoCancel(true); 451 b.setAutoCancel(true);
...@@ -475,8 +487,12 @@ public class HMSBaseMessagingService extends HmsMessageService { ...@@ -475,8 +487,12 @@ public class HMSBaseMessagingService extends HmsMessageService {
475 // Do not allow sound or anything else. 487 // Do not allow sound or anything else.
476 488
477 newIntent.setAction(Long.toString(System.currentTimeMillis())); 489 newIntent.setAction(Long.toString(System.currentTimeMillis()));
478 - PendingIntent pi = PendingIntent.getActivity(context, uid, newIntent, 490 + PendingIntent pi;
479 - PendingIntent.FLAG_ONE_SHOT); 491 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
492 + pi = PendingIntent.getActivity(context, uid, newIntent, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_MUTABLE);
493 + } else {
494 + pi = PendingIntent.getActivity(context, uid, newIntent, PendingIntent.FLAG_ONE_SHOT);
495 + }
480 b.setContentIntent(pi); 496 b.setContentIntent(pi);
481 497
482 NotificationManager nm = (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE); 498 NotificationManager nm = (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE);
......
...@@ -194,7 +194,11 @@ public abstract class WarpBaseIntentService extends GCMBaseIntentService { ...@@ -194,7 +194,11 @@ public abstract class WarpBaseIntentService extends GCMBaseIntentService {
194 b.setContentTitle(pc.getTitle()); 194 b.setContentTitle(pc.getTitle());
195 b.setContentText(pc.getSubtitle()); 195 b.setContentText(pc.getSubtitle());
196 b.setSubText(pc.getContent()); 196 b.setSubText(pc.getContent());
197 - b.setContentIntent(PendingIntent.getActivity(context, uid, newIntent, PendingIntent.FLAG_ONE_SHOT)); 197 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
198 + b.setContentIntent(PendingIntent.getActivity(context, uid, newIntent, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_MUTABLE));
199 + } else {
200 + b.setContentIntent(PendingIntent.getActivity(context, uid, newIntent, PendingIntent.FLAG_ONE_SHOT));
201 + }
198 b.setAutoCancel(true); 202 b.setAutoCancel(true);
199 b.setOngoing(true); 203 b.setOngoing(true);
200 b.setAutoCancel(true); 204 b.setAutoCancel(true);
...@@ -310,8 +314,12 @@ public abstract class WarpBaseIntentService extends GCMBaseIntentService { ...@@ -310,8 +314,12 @@ public abstract class WarpBaseIntentService extends GCMBaseIntentService {
310 builder.setOngoing(true); 314 builder.setOngoing(true);
311 315
312 newIntent.setAction(Long.toString(System.currentTimeMillis())); 316 newIntent.setAction(Long.toString(System.currentTimeMillis()));
313 - PendingIntent pi = PendingIntent.getActivity(context, uid, newIntent, 317 + PendingIntent pi;
314 - PendingIntent.FLAG_ONE_SHOT); 318 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
319 + pi = PendingIntent.getActivity(context, uid, newIntent, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_MUTABLE);
320 + } else {
321 + pi = PendingIntent.getActivity(context, uid, newIntent, PendingIntent.FLAG_ONE_SHOT);
322 + }
315 builder.setContentIntent(pi); 323 builder.setContentIntent(pi);
316 324
317 NotificationManager nm = (NotificationManager) context 325 NotificationManager nm = (NotificationManager) context
...@@ -369,7 +377,11 @@ public abstract class WarpBaseIntentService extends GCMBaseIntentService { ...@@ -369,7 +377,11 @@ public abstract class WarpBaseIntentService extends GCMBaseIntentService {
369 b.setContentTitle(pc.getTitle()); 377 b.setContentTitle(pc.getTitle());
370 b.setContentText(pc.getSubtitle()); 378 b.setContentText(pc.getSubtitle());
371 b.setSubText(pc.getContent()); 379 b.setSubText(pc.getContent());
372 - b.setContentIntent(PendingIntent.getActivity(context, uid, newIntent, PendingIntent.FLAG_ONE_SHOT)); 380 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
381 + b.setContentIntent(PendingIntent.getActivity(context, uid, newIntent, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_MUTABLE));
382 + } else {
383 + b.setContentIntent(PendingIntent.getActivity(context, uid, newIntent, PendingIntent.FLAG_ONE_SHOT));
384 + }
373 b.setAutoCancel(true); 385 b.setAutoCancel(true);
374 b.setOngoing(true); 386 b.setOngoing(true);
375 b.setAutoCancel(true); 387 b.setAutoCancel(true);
...@@ -411,8 +423,12 @@ public abstract class WarpBaseIntentService extends GCMBaseIntentService { ...@@ -411,8 +423,12 @@ public abstract class WarpBaseIntentService extends GCMBaseIntentService {
411 // Do not allow sound or anything else. 423 // Do not allow sound or anything else.
412 424
413 newIntent.setAction(Long.toString(System.currentTimeMillis())); 425 newIntent.setAction(Long.toString(System.currentTimeMillis()));
414 - PendingIntent pi = PendingIntent.getActivity(context, uid, newIntent, 426 + PendingIntent pi;
415 - PendingIntent.FLAG_ONE_SHOT); 427 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
428 + pi = PendingIntent.getActivity(context, uid, newIntent, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_MUTABLE);
429 + } else {
430 + pi = PendingIntent.getActivity(context, uid, newIntent, PendingIntent.FLAG_ONE_SHOT);
431 + }
416 b.setContentIntent(pi); 432 b.setContentIntent(pi);
417 433
418 NotificationManager nm = (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE); 434 NotificationManager nm = (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE);
......
...@@ -10,6 +10,7 @@ import ly.warp.sdk.io.callbacks.WarplyHealthCallback; ...@@ -10,6 +10,7 @@ import ly.warp.sdk.io.callbacks.WarplyHealthCallback;
10 10
11 /** 11 /**
12 * Created by Panagiotis Triantafyllou on 27/Απρ/2022. 12 * Created by Panagiotis Triantafyllou on 27/Απρ/2022.
13 + *
13 * @guide http://www.gadgetsaint.com/android/create-pedometer-step-counter-android/#.Weg2KmiCyM8 14 * @guide http://www.gadgetsaint.com/android/create-pedometer-step-counter-android/#.Weg2KmiCyM8
14 */ 15 */
15 public class WarplyHealthManager implements SensorEventListener { 16 public class WarplyHealthManager implements SensorEventListener {
...@@ -41,7 +42,7 @@ public class WarplyHealthManager implements SensorEventListener { ...@@ -41,7 +42,7 @@ public class WarplyHealthManager implements SensorEventListener {
41 private float oldVelocityEstimate = 0; 42 private float oldVelocityEstimate = 0;
42 43
43 //TODO: if we want to send the steps back to an activity/fragment/service etc 44 //TODO: if we want to send the steps back to an activity/fragment/service etc
44 -// private WarplyHealthCallback mHealthCallback; 45 + private static WarplyHealthCallback mHealthCallback;
45 46
46 // =========================================================== 47 // ===========================================================
47 // Methods for/from SuperClass/Interfaces 48 // Methods for/from SuperClass/Interfaces
...@@ -76,6 +77,16 @@ public class WarplyHealthManager implements SensorEventListener { ...@@ -76,6 +77,16 @@ public class WarplyHealthManager implements SensorEventListener {
76 return mWarplyHealthManagerInstance; 77 return mWarplyHealthManagerInstance;
77 } 78 }
78 79
80 + public static WarplyHealthManager getInstance(Context context, WarplyHealthCallback callback) {
81 + if (mWarplyHealthManagerInstance == null) {
82 + mWarplyHealthManagerInstance = new WarplyHealthManager();
83 + mSensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
84 + mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
85 + mHealthCallback = callback;
86 + }
87 + return mWarplyHealthManagerInstance;
88 + }
89 +
79 public void registerStepSensor() { 90 public void registerStepSensor() {
80 mSensorManager.registerListener(mWarplyHealthManagerInstance, mSensor, SensorManager.SENSOR_DELAY_GAME); 91 mSensorManager.registerListener(mWarplyHealthManagerInstance, mSensor, SensorManager.SENSOR_DELAY_GAME);
81 } 92 }
...@@ -118,7 +129,7 @@ public class WarplyHealthManager implements SensorEventListener { ...@@ -118,7 +129,7 @@ public class WarplyHealthManager implements SensorEventListener {
118 && (timeNs - lastStepTimeNs > STEP_DELAY_NS)) { 129 && (timeNs - lastStepTimeNs > STEP_DELAY_NS)) {
119 //TODO: if we want to send the steps back to an activity/fragment/service etc 130 //TODO: if we want to send the steps back to an activity/fragment/service etc
120 mSteps++; 131 mSteps++;
121 -// mHealthCallback.onStepCount(mSteps); 132 + mHealthCallback.onStepCount(mSteps);
122 lastStepTimeNs = timeNs; 133 lastStepTimeNs = timeNs;
123 } 134 }
124 oldVelocityEstimate = velocityEstimate; 135 oldVelocityEstimate = velocityEstimate;
......
1 +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
2 + xmlns:app="http://schemas.android.com/apk/res-auto"
3 + android:layout_width="match_parent"
4 + android:layout_height="match_parent"
5 + android:background="@color/grey4">
6 +
7 + <androidx.constraintlayout.widget.ConstraintLayout
8 + android:id="@+id/cl_loyalty_wallet_header"
9 + android:layout_width="match_parent"
10 + android:layout_height="50dp"
11 + android:background="@android:color/white">
12 +
13 + <ImageView
14 + android:id="@+id/iv_back"
15 + android:layout_width="20dp"
16 + android:layout_height="20dp"
17 + android:layout_marginStart="16dp"
18 + android:src="@drawable/ic_back"
19 + app:layout_constraintBottom_toBottomOf="parent"
20 + app:layout_constraintStart_toStartOf="parent"
21 + app:layout_constraintTop_toTopOf="parent" />
22 +
23 + <TextView
24 + android:layout_width="wrap_content"
25 + android:layout_height="wrap_content"
26 + android:text="Steps"
27 + android:textColor="@color/grey"
28 + android:textSize="17sp"
29 + android:textStyle="bold"
30 + app:layout_constraintBottom_toBottomOf="parent"
31 + app:layout_constraintEnd_toEndOf="parent"
32 + app:layout_constraintStart_toStartOf="parent"
33 + app:layout_constraintTop_toTopOf="parent" />
34 + </androidx.constraintlayout.widget.ConstraintLayout>
35 +
36 + <TextView
37 + android:id="@+id/tv_counter"
38 + android:layout_width="wrap_content"
39 + android:layout_height="wrap_content"
40 + android:layout_centerInParent="true"
41 + android:text="Counter"
42 + android:textSize="18sp" />
43 +
44 + <TextView
45 + android:id="@+id/tv_counter_value"
46 + android:layout_width="wrap_content"
47 + android:layout_height="wrap_content"
48 + android:layout_below="@+id/tv_counter"
49 + android:layout_centerInParent="true"
50 + android:textColor="@color/grey"
51 + android:textSize="17sp"
52 + android:textStyle="bold"
53 + android:text="0" />
54 +
55 +</RelativeLayout>