Panagiotis Triantafyllou

pacing fixes

......@@ -36,7 +36,7 @@ public class SplashActivity extends BaseActivity {
public void onWarplyReady() {
if (!WarplyDBHelper.getInstance(SplashActivity.this).isTableNotEmpty("auth")) {
WarplyManager.getCosmoteUser(new WarplyCosmoteUserRequest()
.setGuid("6012049139"), //6012049321, 6012049322, 6012049323, 7000000831 history, 7000000826, 7000000831 shared coupons
.setGuid("7000000831"), //6012049321, 6012049322, 6012049323, 7000000831 history, 7000000826, 7000000831 shared coupons
mLoginReceiver);
} else {
startNextActivity();
......
......@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
ext {
PUBLISH_GROUP_ID = 'ly.warp'
PUBLISH_VERSION = '4.5.4-cosbeta70'
PUBLISH_VERSION = '4.5.4-cosbeta71'
PUBLISH_ARTIFACT_ID = 'warply-android-sdk'
}
......
......@@ -27,12 +27,11 @@ import java.util.Date;
import java.util.Locale;
import ly.warp.sdk.R;
import ly.warp.sdk.activities.BaseFragmentActivity;
import ly.warp.sdk.io.callbacks.CallbackReceiver;
import ly.warp.sdk.io.callbacks.WarplyHealthCallback;
import ly.warp.sdk.io.models.CouponsEventModel;
import ly.warp.sdk.io.models.HealthEventModel;
import ly.warp.sdk.io.models.PacingDetails;
import ly.warp.sdk.io.request.PacingCalculateRequest;
import ly.warp.sdk.io.request.PacingDetailsRequest;
import ly.warp.sdk.utils.WarpUtils;
import ly.warp.sdk.utils.WarplyManagerHelper;
import ly.warp.sdk.utils.managers.WarplyEventBusManager;
......@@ -60,7 +59,7 @@ public class WarplyHealthService extends Service implements SensorEventListener
private final int ACCEL_RING_SIZE = 50;
private final int VEL_RING_SIZE = 10;
// change this threshold according to your sensitivity preferences
private final float STEP_THRESHOLD = 10f; // default 40, cosmote default 20
private final float STEP_THRESHOLD = 18f; // default 40, cosmote default 20
private final int STEP_DELAY_NS = 250000000;
private int accelRingCounter = 0;
private float[] accelRingX = new float[ACCEL_RING_SIZE];
......@@ -70,6 +69,7 @@ public class WarplyHealthService extends Service implements SensorEventListener
private float[] velRing = new float[VEL_RING_SIZE];
private long lastStepTimeNs = 0;
private float oldVelocityEstimate = 0;
private double mPacingMeters = 0.0d;
// ===========================================================
// Contructors
......@@ -86,7 +86,7 @@ public class WarplyHealthService extends Service implements SensorEventListener
mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
registerStepSensor();
WarplyManager.getPacingDetails(new PacingDetailsRequest(), mPacingCallback);
}
@RequiresApi(api = Build.VERSION_CODES.O)
......@@ -142,6 +142,7 @@ public class WarplyHealthService extends Service implements SensorEventListener
// WarpUtils.setStepsMetersCounter(this, 0.0d);
WarplyManagerHelper.mStepsWebview = 0;
WarplyManagerHelper.mMetersWebview = 0.0d;
mPacingMeters = 0.0d;
sendSteps();
}
......@@ -211,14 +212,17 @@ public class WarplyHealthService extends Service implements SensorEventListener
if (velocityEstimate > STEP_THRESHOLD
&& oldVelocityEstimate <= STEP_THRESHOLD
&& (timeNs - lastStepTimeNs > STEP_DELAY_NS)) {
WarplyManagerHelper.mSteps++;
WarpUtils.setStepsCounter(this, WarplyManagerHelper.mSteps);
// mStepsAll++;
WarplyManagerHelper.mStepsWebview++;
WarplyManagerHelper.mSteps += WarplyManagerHelper.mStepsWebview;
WarpUtils.setStepsCounter(this, WarplyManagerHelper.mSteps);
WarplyManagerHelper.mMetersWebview = (WarplyManagerHelper.mStepsWebview * 0.762);
HealthEventModel healthSteps = new HealthEventModel();
// healthSteps.setMeters((mStepsAll * 0.762));
healthSteps.setMeters(WarplyManagerHelper.mMetersWebview);
// healthSteps.setMeters((mStepsAll * 0.762)); // 16/09/2022
// healthSteps.setMeters(WarplyManagerHelper.mMetersWebview); // 20/09/2022
double eventMeters = 0.0d;
eventMeters = mPacingMeters + WarplyManagerHelper.mMetersWebview;
healthSteps.setMeters(eventMeters);
EventBus.getDefault().post(new WarplyEventBusManager(healthSteps));
// WarpUtils.setStepsMetersCounter(this, (mStepsAll * 0.762));
......@@ -288,4 +292,17 @@ public class WarplyHealthService extends Service implements SensorEventListener
});
}
}
private CallbackReceiver<PacingDetails> mPacingCallback = new CallbackReceiver<PacingDetails>() {
@Override
public void onSuccess(PacingDetails result) {
mPacingMeters = result.getMeters().getDay().getValue();
registerStepSensor();
}
@Override
public void onFailure(int errorCode) {
registerStepSensor();
}
};
}
......
......@@ -530,7 +530,7 @@ public class WarpView extends WebView {
});
WarplyManagerHelper.mStepsWebview = 0;
WarplyManagerHelper.mMetersWebview = 0.0d;
WarpViewActivity.getMetersHandler().postDelayed(this, 1000);
WarpViewActivity.getMetersHandler().postDelayed(this, 300);
}
}, 1000);
......
......@@ -99,7 +99,8 @@
android:layout_below="@+id/tv_expired_title"
android:layout_marginHorizontal="8dp"
android:layout_marginTop="24dp"
android:orientation="vertical" />
android:orientation="vertical"
android:overScrollMode="never"/>
<LinearLayout
android:id="@+id/ll_show_more_expired"
......@@ -170,7 +171,8 @@
android:layout_below="@+id/tv_shared_title"
android:layout_marginHorizontal="8dp"
android:layout_marginTop="24dp"
android:orientation="vertical" />
android:orientation="vertical"
android:overScrollMode="never"/>
<LinearLayout
android:id="@+id/ll_show_more_shared"
......