Panagiotis Triantafyllou

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("7000001025"), //6012049321, 6012049322, 6012049323
.setGuid("7000001018"), //6012049321, 6012049322, 6012049323
mLoginReceiver);
} else {
startNextActivity();
......
......@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
ext {
PUBLISH_GROUP_ID = 'ly.warp'
PUBLISH_VERSION = '4.5.4-cosbeta58'
PUBLISH_VERSION = '4.5.4-cosbeta59i'
PUBLISH_ARTIFACT_ID = 'warply-android-sdk'
}
......
......@@ -53,17 +53,23 @@ import org.greenrobot.eventbus.Subscribe;
import org.json.JSONObject;
import java.security.SecureRandom;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.TimeUnit;
import ly.warp.sdk.Warply;
import ly.warp.sdk.io.callbacks.CallbackReceiver;
import ly.warp.sdk.io.models.CouponList;
import ly.warp.sdk.io.request.PacingCalculateRequest;
import ly.warp.sdk.io.request.WarplyUserCouponsRequest;
import ly.warp.sdk.services.EventQuestionnaireService;
import ly.warp.sdk.services.PushEventsClickedWorkerService;
import ly.warp.sdk.services.WarplyHealthService;
import ly.warp.sdk.utils.WarpJSONParser;
import ly.warp.sdk.utils.WarpUtils;
import ly.warp.sdk.utils.WarplyManagerHelper;
import ly.warp.sdk.utils.WarplyPreferences;
import ly.warp.sdk.utils.WarplyProperty;
import ly.warp.sdk.utils.managers.WarplyAnalyticsManager;
......@@ -120,6 +126,7 @@ public class WarpViewActivity extends WarpBaseActivity {
super.onDestroy();
if (metersHandler != null)
metersHandler.removeCallbacksAndMessages(null);
sendSteps();
WarpUtils.setWebviewParams(this, new JSONObject());
}
......@@ -144,9 +151,9 @@ public class WarpViewActivity extends WarpBaseActivity {
setResult(RESULT_OK, new Intent());
finish();
}
if (event.getCoupon() != null) {
WarplyManager.getUserCouponsWithCouponsets(new WarplyUserCouponsRequest(), mUserCouponsReceiver);
}
// if (event.getCoupon() != null) {
// WarplyManager.getUserCouponsWithCouponsets(new WarplyUserCouponsRequest(), mUserCouponsReceiver);
// }
// if (event.getPacingCard() != null)
// finish();
// if (event.getPacingService() != null)
......@@ -286,4 +293,29 @@ public class WarpViewActivity extends WarpBaseActivity {
public static Handler getMetersHandler() {
return metersHandler;
}
private void sendSteps() {
String date = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss", Locale.getDefault()).format(new Date());
if (WarpUtils.getStepsCounter(this) > 0) {
WarplyManager.setPacingDetails(new PacingCalculateRequest()
.setCounter(WarpUtils.getStepsCounter(this))
.setDate(date),
new CallbackReceiver<JSONObject>() {
@Override
public void onSuccess(JSONObject result) {
int status = result.optInt("status", 2);
if (status == 1) {
WarplyManagerHelper.mSteps = 0;
WarpUtils.setStepsCounter(WarpViewActivity.this, 0);
}
}
@Override
public void onFailure(int errorCode) {
WarpUtils.log("Warply Health Service error: " + String.valueOf(errorCode));
}
});
}
}
}
\ No newline at end of file
......
......@@ -34,6 +34,7 @@ import ly.warp.sdk.io.models.CouponsEventModel;
import ly.warp.sdk.io.models.HealthEventModel;
import ly.warp.sdk.io.request.PacingCalculateRequest;
import ly.warp.sdk.utils.WarpUtils;
import ly.warp.sdk.utils.WarplyManagerHelper;
import ly.warp.sdk.utils.managers.WarplyEventBusManager;
import ly.warp.sdk.utils.managers.WarplyManager;
......@@ -54,7 +55,7 @@ public class WarplyHealthService extends Service implements SensorEventListener
private SensorManager mSensorManager;
private Sensor mSensor;
private int mSteps = 0;
// private int mSteps = 0;
private double mStepsAll = 0.0d;
private final int ACCEL_RING_SIZE = 50;
private final int VEL_RING_SIZE = 10;
......@@ -139,6 +140,8 @@ public class WarplyHealthService extends Service implements SensorEventListener
unregisterStepSensor();
mStepsAll = 0.0d;
WarpUtils.setStepsMetersCounter(this, 0.0d);
WarplyManagerHelper.mStepsWebview = 0;
WarplyManagerHelper.mMetersWebview = 0.0d;
sendSteps();
}
......@@ -208,13 +211,15 @@ public class WarplyHealthService extends Service implements SensorEventListener
if (velocityEstimate > STEP_THRESHOLD
&& oldVelocityEstimate <= STEP_THRESHOLD
&& (timeNs - lastStepTimeNs > STEP_DELAY_NS)) {
mSteps++;
WarplyManagerHelper.mSteps++;
mStepsAll++;
WarplyManagerHelper.mStepsWebview++;
WarplyManagerHelper.mMetersWebview = (WarplyManagerHelper.mStepsWebview * 0.762);
HealthEventModel healthSteps = new HealthEventModel();
healthSteps.setMeters((mStepsAll * 0.762));
EventBus.getDefault().post(new WarplyEventBusManager(healthSteps));
WarpUtils.setStepsMetersCounter(this, (mStepsAll * 0.762));
WarpUtils.setStepsCounter(this, mSteps);
WarpUtils.setStepsCounter(this, WarplyManagerHelper.mSteps);
lastStepTimeNs = timeNs;
}
......@@ -270,7 +275,7 @@ public class WarplyHealthService extends Service implements SensorEventListener
public void onSuccess(JSONObject result) {
int status = result.optInt("status", 2);
if (status == 1) {
mSteps = 0;
WarplyManagerHelper.mSteps = 0;
WarpUtils.setStepsCounter(WarplyHealthService.this, 0);
}
}
......
......@@ -103,6 +103,9 @@ public class WarplyManagerHelper {
private static LoyaltyBadgeModel mLoyaltyBadge = new LoyaltyBadgeModel();
private static float mDealsSum = 0.0f;
private static MerchantList mMerchantList = new MerchantList();
public static double mMetersWebview = 0.0d;
public static int mStepsWebview = 0;
public static int mSteps = 0;
// ===========================================================
// Methods for/from SuperClass/Interfaces
......@@ -727,7 +730,8 @@ public class WarplyManagerHelper {
*/
public static void setCCMSLoyaltyCampaigns(ArrayList<LoyaltyContextualOfferModel> list) {
mCCMSList.clear();
mCCMSList.addAll(list);
// mCCMSList.addAll(list);
mCCMSList = list;
OneTimeWorkRequest mywork = new OneTimeWorkRequest.Builder(EventService.class).build();
WorkManager.getInstance(Warply.getWarplyContext()).enqueue(mywork);
......
......@@ -1523,6 +1523,45 @@ public class WarplyManager {
// " \"zone\": \"COSMOTE_APP_LOYALTY_PROMO\"\n" +
// " },\n" +
// " {\n" +
// " \"UACIOfferTrackingCode\": \"546d.ea1.ffffffffcc4c34b3.c64ed53\",\n" +
// " \"businessAdditionalId\": \"\",\n" +
// " \"dataCategory\": \"Data\",\n" +
// " \"dataValue\": \"1\",\n" +
// " \"description\": \"5days1000 3744\",\n" +
// " \"discount\": \"None\",\n" +
// " \"duration\": \"5\",\n" +
// " \"eligibleAssets\": [],\n" +
// " \"giftType\": \"GB\",\n" +
// " \"giftValue\": \"1\",\n" +
// " \"id\": \"000003744\",\n" +
// " \"imageOfferUrl\": \"https://uatatg.cosmote.gr/images/ContexualOffers//testOffer/x3_detailed_default.png\",\n" +
// " \"imageUrl\": \"https://uatatg.cosmote.gr/images/ContexualOffers//testOffer/x3_store_default.png\",\n" +
// " \"loyaltyCampaignId\": \"NA\",\n" +
// " \"minsValue\": \"None\",\n" +
// " \"noOfRecurrance\": \"5\",\n" +
// " \"notificationMessage\": \"5days1000 3744\",\n" +
// " \"offerAudienceLevel\": \"guid\",\n" +
// " \"offerCode1\": \"000003744\",\n" +
// " \"offerName\": \"White_Label_5days1000 3744\",\n" +
// " \"price\": \"0\",\n" +
// " \"productType\": \"White Label\",\n" +
// " \"provDuration\": \"1.0\",\n" +
// " \"score\": \"50\",\n" +
// " \"sessionId\": \"COSMOTE_APP_BALANCES.6945251078.20220908115231\",\n" +
// " \"treatmentCode\": \"546d.ea1.ffffffffcc4c34b3.c64ed53\",\n" +
// " \"validity\": \"0\",\n" +
// " \"wave\": \"1\",\n" +
// " \"voiceCategory\": \"None\",\n" +
// " \"validity\": \"5\",\n" +
// " \"imageUrl\": \"https://www.cosmotetvott.gr/assets/images/ogImage.jpg\",\n" +
// " \"title\": \"White_Label_5days1000 3744\",\n" +
// " \"titleOffer\": \"5days1000 3744\",\n" +
// " \"termsAndConditions\": \"5days1000 3744\",\n" +
// " \"subtitle\": \"5days1000 3744\",\n" +
// " \"description\": \"Test6\",\n" +
// " \"zone\": \"COSMOTE_APP_GIFTS4U\"\n" +
// " },\n" +
// " {\n" +
// " \"UACIOfferTrackingCode\": \"51ed.e10.2c006f18.71e96d08\",\n" +
// " \"businessAdditionalId\": \"\",\n" +
// " \"dataCategory\": \"Data\",\n" +
......
......@@ -70,6 +70,7 @@ import ly.warp.sdk.io.models.QuestionnaireEventModel;
import ly.warp.sdk.io.models.WarplyPacingEventModel;
import ly.warp.sdk.services.WarplyHealthService;
import ly.warp.sdk.utils.WarpUtils;
import ly.warp.sdk.utils.WarplyManagerHelper;
import ly.warp.sdk.utils.WarplyProperty;
import ly.warp.sdk.utils.WarplyUrlHandler;
import ly.warp.sdk.utils.constants.WarpConstants;
......@@ -405,7 +406,7 @@ public class WarpView extends WebView {
EventBus.getDefault().post(new WarplyEventBusManager(questionnaireEvent));
}
} else if (parts[1].equals("couponRetrieved")) {
EventBus.getDefault().post(new WarplyEventBusManager(new CouponEventModel()));
// EventBus.getDefault().post(new WarplyEventBusManager(new CouponEventModel()));
} else if (parts[1].equals("couponShared")) {
// EventBus.getDefault().post(new WarplyEventBusManager(new CouponEventModel()));
} /*else if (parts[2].equals("serviceDisabled")) {
......@@ -514,11 +515,13 @@ public class WarpView extends WebView {
WarpViewActivity.getMetersHandler().postDelayed(new Runnable() {
@Override
public void run() {
String tempMeters = String.valueOf(WarpUtils.getStepsMetersCounter(getContext()));
String tempMeters = String.valueOf(WarplyManagerHelper.mMetersWebview);
String scriptSourceMeters = "passMeters(" + tempMeters + ");";
WarpView.this.evaluateJavascript(scriptSourceMeters, s -> {
});
WarplyManagerHelper.mStepsWebview = 0;
WarplyManagerHelper.mMetersWebview = 0.0d;
WarpViewActivity.getMetersHandler().postDelayed(this, 1000);
}
}, 1000);
......