Panagiotis Triantafyllou

fixes

Showing 26 changed files with 394 additions and 27 deletions
......@@ -36,7 +36,7 @@ public class SplashActivity extends BaseActivity {
public void onWarplyReady() {
if (!WarplyDBHelper.getInstance(SplashActivity.this).isTableNotEmpty("auth")) {
WarplyManager.getCosmoteUser(new WarplyCosmoteUserRequest()
.setGuid("6012049321"), //6012049321, 6012049322, 6012049323
.setGuid("6012049139"), //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-cosbeta56'
PUBLISH_VERSION = '4.5.4-cosbeta57'
PUBLISH_ARTIFACT_ID = 'warply-android-sdk'
}
......
......@@ -128,6 +128,11 @@
android:permission="android.permission.BIND_JOB_SERVICE" />
<service
android:name="ly.warp.sdk.services.EventCouponsService"
android:exported="false"
android:permission="android.permission.BIND_JOB_SERVICE" />
<service
android:name="ly.warp.sdk.services.EventCampaignService"
android:exported="false"
android:permission="android.permission.BIND_JOB_SERVICE" />
......
......@@ -167,6 +167,7 @@ public class ContextualActivity extends Activity implements View.OnClickListener
WarplyManager.submitOrder(new CosmoteSubmitOrderRequest()
.setCommunicationUuid("")
.setUserMsisdn(mSender)
.setSessionId(mCCMS.getSessionId())
.setBusinessService(mCCMS.getBusinessService())
.setOfferName(mCCMS.getOfferName())
.setProductType(mCCMS.getProductType())
......
......@@ -15,6 +15,8 @@ import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.core.content.ContextCompat;
import androidx.work.OneTimeWorkRequest;
import androidx.work.WorkManager;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
......@@ -31,6 +33,7 @@ import io.github.inflationx.viewpump.ViewPumpContextWrapper;
import ly.warp.sdk.R;
import ly.warp.sdk.io.models.Coupon;
import ly.warp.sdk.io.models.Couponset;
import ly.warp.sdk.services.EventCouponsService;
import ly.warp.sdk.utils.WarplyManagerHelper;
......@@ -50,7 +53,7 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener
private LinearLayout mLlGiftIt, mLlShops, mLlBarcodeShown, mLlBarcodeContainer, mLlTerms;
private Coupon mCoupon;
private Couponset mCouponset;
private boolean mIsBarcodeShown = false, mIsTermsShown = false;
private boolean mIsBarcodeShown = false, mIsTermsShown = false, mIsFromWallet = false;
// ===========================================================
// Methods for/from SuperClass/Interfaces
......@@ -62,6 +65,7 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener
setContentView(R.layout.activity_coupon_info);
mCoupon = (Coupon) getIntent().getSerializableExtra("coupon");
mIsFromWallet = getIntent().getBooleanExtra("isFromWallet", false);
mIvBack = findViewById(R.id.iv_coupon_info_back);
mTvTerms = findViewById(R.id.tv_terms);
......@@ -88,6 +92,17 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 1001) {
if (resultCode == RESULT_OK) {
OneTimeWorkRequest mywork = new OneTimeWorkRequest.Builder(EventCouponsService.class).build();
WorkManager.getInstance(this).enqueue(mywork);
onBackPressed();
}
}
}
@Override
public void onClick(View view) {
if (view.getId() == R.id.iv_coupon_info_back) {
onBackPressed();
......@@ -96,7 +111,11 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener
if (view.getId() == R.id.ll_gift_it) {
Intent intent = new Intent(CouponInfoActivity.this, CouponShareActivity.class);
intent.putExtra("coupon", (Serializable) mCoupon);
startActivity(intent);
intent.putExtra("isFromWallet", mIsFromWallet);
if (!mIsFromWallet)
startActivity(intent);
else
startActivityForResult(intent, 1001);
return;
}
if (view.getId() == R.id.ll_shops) {
......
......@@ -2,6 +2,7 @@ package ly.warp.sdk.activities;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
......@@ -58,6 +59,7 @@ public class CouponShareActivity extends Activity implements View.OnClickListene
private EditText mEdtReceiver;
private AlertDialog mAlertDialogSuccessSharing, mAlertDialogErrorSharing,
mAlertDialogCouponAskSharing, mAlertDialogWrongNumberSharing;
private boolean mIsFromWallet = false;
// ===========================================================
// Methods for/from SuperClass/Interfaces
......@@ -69,6 +71,7 @@ public class CouponShareActivity extends Activity implements View.OnClickListene
setContentView(R.layout.activity_coupon_share);
mCoupon = (Coupon) getIntent().getSerializableExtra("coupon");
mIsFromWallet = getIntent().getBooleanExtra("isFromWallet", false);
mIvBack = findViewById(R.id.iv_coupon_share_back);
mTvCouponTitle = findViewById(R.id.textView13);
......@@ -190,6 +193,10 @@ public class CouponShareActivity extends Activity implements View.OnClickListene
.setMessage(R.string.cos_dlg_positive_coupon_text)
.setPositiveButton(R.string.cos_dlg_positive_button2, (dialogPositive, whichPositive) -> {
dialogPositive.dismiss();
if (mIsFromWallet) {
setResult(RESULT_OK, new Intent());
onBackPressed();
}
})
.show();
}
......
......@@ -109,6 +109,7 @@ public class CouponsetInfoActivity extends Activity implements View.OnClickListe
.setCouponsetUuid(mCouponset.getUuid())
.setCommunicationUuid(mLoyalty.getSessionUUID())
.setHasContextualOffer(true)
.setSessionId(mCcms.getSessionId())
.setUserMsisdn(WarplyManagerHelper.getConsumer().getMsisdn()) //TODO: where to find the msisdn??
.setBusinessService(mCcms.getBusinessService())
.setOfferName(mCcms.getOfferName())
......
......@@ -80,6 +80,7 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene
filterItems();
if (WarplyManagerHelper.getSeasonalList() != null && WarplyManagerHelper.getSeasonalList().size() > 0) {
mHashSetSeasonalList.clear();
mHashSetSeasonalList.addAll(WarplyManagerHelper.getSeasonalList());
mSeasonalList.clear();
mSeasonalList.addAll(mHashSetSeasonalList);
......@@ -150,6 +151,7 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene
filterItems();
if (WarplyManagerHelper.getSeasonalList() != null && WarplyManagerHelper.getSeasonalList().size() > 0) {
mHashSetSeasonalList.clear();
mHashSetSeasonalList.addAll(WarplyManagerHelper.getSeasonalList());
mSeasonalList.clear();
mSeasonalList.addAll(mHashSetSeasonalList);
......
......@@ -21,6 +21,7 @@ import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import java.io.Serializable;
import java.text.ParseException;
......@@ -36,6 +37,7 @@ import io.github.inflationx.viewpump.ViewPumpContextWrapper;
import ly.warp.sdk.R;
import ly.warp.sdk.io.models.ActiveDFYCouponEventModel;
import ly.warp.sdk.io.models.ActiveDFYCouponModel;
import ly.warp.sdk.io.models.CouponList;
import ly.warp.sdk.io.models.WarplyDealsAnalysisEventModel;
import ly.warp.sdk.utils.WarpUtils;
import ly.warp.sdk.utils.WarplyManagerHelper;
......@@ -118,6 +120,18 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener {
}
@Override
protected void onStart() {
super.onStart();
EventBus.getDefault().register(this);
}
@Override
protected void onStop() {
super.onStop();
EventBus.getDefault().unregister(this);
}
@Override
public void onResume() {
super.onResume();
}
......@@ -167,6 +181,35 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener {
}
}
@Subscribe()
public void onMessageEvent(WarplyEventBusManager event) {
if (event.getCouponsAdded() != null) {
CouponList tempCouponList = new CouponList();
tempCouponList.clear();
tempCouponList.addAll(WarplyManagerHelper.getCouponList());
runOnUiThread(() -> {
if (tempCouponList != null && tempCouponList.size() > 0) {
mAdapterCoupons = new ActiveCouponAdapter(this, tempCouponList);
mRecyclerCoupons.setAdapter(mAdapterCoupons);
mAdapterCoupons.getPositionClicks()
.doOnNext(coupon -> {
Intent intent = new Intent(LoyaltyWallet.this, CouponInfoActivity.class);
intent.putExtra("coupon", (Serializable) coupon);
intent.putExtra("isFromWallet", true);
startActivityForResult(intent, 1002);
})
.doOnError(error -> {
})
.subscribe();
mAdapterCoupons.notifyDataSetChanged();
} else {
mRecyclerCoupons.setVisibility(View.GONE);
mTvActiveCouponsHeader.setVisibility(View.GONE);
}
});
}
}
@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(ViewPumpContextWrapper.wrap(newBase));
......@@ -188,7 +231,8 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener {
.doOnNext(coupon -> {
Intent intent = new Intent(LoyaltyWallet.this, CouponInfoActivity.class);
intent.putExtra("coupon", (Serializable) coupon);
startActivity(intent);
intent.putExtra("isFromWallet", true);
startActivityForResult(intent, 1002);
})
.doOnError(error -> {
})
......
......@@ -204,6 +204,7 @@ public class TelcoActivity extends Activity implements View.OnClickListener {
WarplyManager.submitOrder(new CosmoteSubmitOrderRequest()
.setCommunicationUuid(mLoyalty.getSessionUUID())
.setUserMsisdn(mSender)
.setSessionId(mCCMS.getSessionId())
.setBusinessService(mCCMS.getBusinessService())
.setOfferName(mCCMS.getOfferName())
.setProductType(mCCMS.getProductType())
......
......@@ -33,6 +33,7 @@ import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.View;
......@@ -78,6 +79,7 @@ public class WarpViewActivity extends WarpBaseActivity {
// ===========================================================
private WarpView mWarpView;
private static Handler metersHandler = new Handler();
// ===========================================================
// Methods for/from SuperClass/Interfaces
......@@ -116,6 +118,8 @@ public class WarpViewActivity extends WarpBaseActivity {
@Override
protected void onDestroy() {
super.onDestroy();
if (metersHandler != null)
metersHandler.removeCallbacksAndMessages(null);
WarpUtils.setWebviewParams(this, new JSONObject());
}
......@@ -278,4 +282,8 @@ public class WarpViewActivity extends WarpBaseActivity {
}
};
public static Handler getMetersHandler() {
return metersHandler;
}
}
\ No newline at end of file
......
/*
* Copyright 2010-2013 Warply Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE WARPLY LTD ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL WARPLY LTD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package ly.warp.sdk.io.models;
/**
* Created by Panagiotis Triantafyllou on 05-Sept-22.
*/
public class CouponsEventModel {
private boolean success;
public CouponsEventModel() {
this.success = true;
}
public boolean isSuccess() {
return success;
}
public void setSuccess(boolean success) {
this.success = success;
}
}
/*
* Copyright 2010-2013 Warply Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE WARPLY LTD ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL WARPLY LTD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package ly.warp.sdk.io.models;
/**
* Created by Panagiotis Triantafyllou on 05-Sept-22.
*/
public class HealthEventModel {
private double steps;
public HealthEventModel() {
this.steps = 0.0d;
}
public double getSteps() {
return steps;
}
public void setSteps(double steps) {
this.steps = steps;
}
}
/*
* Copyright 2010-2013 Warply Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE WARPLY LTD ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL WARPLY LTD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package ly.warp.sdk.io.models;
/**
* Created by Panagiotis Triantafyllou on 06-Sept-22.
*/
public class WarplyCouponsChangedEventModel {
private boolean changed;
public WarplyCouponsChangedEventModel() {
this.changed = true;
}
public boolean isChanged() {
return changed;
}
public void setChanged(boolean changed) {
this.changed = changed;
}
}
......@@ -73,6 +73,7 @@ public class CosmoteSubmitOrderRequest {
private String mWave = "";
private String mValidity = "";
private String mTreatmentCode = "";
private String mSessionId = "";
// ===========================================================
// Constructor
......@@ -228,6 +229,11 @@ public class CosmoteSubmitOrderRequest {
return this;
}
public CosmoteSubmitOrderRequest setSessionId(String sessionId) {
this.mSessionId = sessionId;
return this;
}
/**
* Call this to get how often the cached data will be updated.
*
......@@ -309,7 +315,7 @@ public class CosmoteSubmitOrderRequest {
extraData.putOpt(KEY_PROV_STEP_VALUE_MINS, mProvStepValueMins);
extraData.putOpt("InteractiveChannel", "COSMOTE_OMNI");
extraData.putOpt("InteractionPoint", mZone);
extraData.putOpt("Session_ID", mCommunicationUuid);
extraData.putOpt("Session_ID", mSessionId);
extraData.putOpt("OfferAudienceLevel", mOfferAudienceLevel);
extraData.putOpt("MSISDN", mOfferAudienceLevel.equals("msisdn") ? mUserMsisdn : "");
extraData.putOpt("GUID", "");
......@@ -365,7 +371,7 @@ public class CosmoteSubmitOrderRequest {
JSONObject param9 = new JSONObject();
param9.putOpt("Name", "Session_ID");
param9.putOpt("Value", mCommunicationUuid);
param9.putOpt("Value", mSessionId);
param9.putOpt("Type", "string");
parameters.put(param9);
......
......@@ -73,6 +73,7 @@ public class WarplyRedeemCouponRequest {
private String mWave = "";
private String mValidity = "";
private String mTreatmentCode = "";
private String mSessionId = "";
// ===========================================================
// Constructor
......@@ -238,6 +239,11 @@ public class WarplyRedeemCouponRequest {
return this;
}
public WarplyRedeemCouponRequest setSessionId(String sessionId) {
this.mSessionId = sessionId;
return this;
}
/**
* Call this to get how often the cached data will be updated.
*
......@@ -318,7 +324,7 @@ public class WarplyRedeemCouponRequest {
extraJson.putOpt(KEY_PROV_STEP_VALUE_MINS, mProvStepValueMins);
extraJson.putOpt("InteractiveChannel", "COSMOTE_OMNI");
extraJson.putOpt("InteractionPoint", mZone);
extraJson.putOpt("Session_ID", mCommunicationUuid);
extraJson.putOpt("Session_ID", mSessionId);
extraJson.putOpt("OfferAudienceLevel", mOfferAudienceLevel);
extraJson.putOpt("MSISDN", mOfferAudienceLevel.equals("msisdn") ? mUserMsisdn : "");
extraJson.putOpt("GUID", "");
......@@ -374,7 +380,7 @@ public class WarplyRedeemCouponRequest {
JSONObject param9 = new JSONObject();
param9.putOpt("Name", "Session_ID");
param9.putOpt("Value", mCommunicationUuid);
param9.putOpt("Value", mSessionId);
param9.putOpt("Type", "string");
parameters.put(param9);
......
package ly.warp.sdk.services;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.work.Worker;
import androidx.work.WorkerParameters;
import org.greenrobot.eventbus.EventBus;
import ly.warp.sdk.io.models.CouponsEventModel;
import ly.warp.sdk.utils.managers.WarplyEventBusManager;
/**
* Created by Panagiotis Triantafyllou on 05/Sept/2022.
*/
public class EventCouponsService extends Worker {
public EventCouponsService(@NonNull Context context, @NonNull WorkerParameters workerParams) {
super(context, workerParams);
}
@NonNull
@Override
public Result doWork() {
CouponsEventModel couponsAdded = new CouponsEventModel();
EventBus.getDefault().post(new WarplyEventBusManager(couponsAdded));
return Result.success();
}
}
......@@ -38,10 +38,10 @@ public class EventQuestionnaireService extends Worker {
if (result != null) {
JSONObject profMetadata = WarpJSONParser.getJSONFromString(result.getProfileMetadata());
if (profMetadata != null) {
if (profMetadata.has("nonTelco") && profMetadata.optBoolean("nonTelco")) {
WarpUtils.setUserNonTelco(Warply.getWarplyContext(), profMetadata.optBoolean("nonTelco"));
}
if (profMetadata != null && profMetadata.has("nonTelco")) {
WarpUtils.setUserNonTelco(Warply.getWarplyContext(), profMetadata.optBoolean("nonTelco"));
} else {
WarpUtils.setUserNonTelco(Warply.getWarplyContext(), false);
}
}
......
......@@ -19,6 +19,7 @@ import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.core.app.NotificationCompat;
import org.greenrobot.eventbus.EventBus;
import org.json.JSONObject;
import java.text.SimpleDateFormat;
......@@ -28,8 +29,12 @@ 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.request.PacingCalculateRequest;
import ly.warp.sdk.utils.WarpUtils;
import ly.warp.sdk.utils.managers.WarplyEventBusManager;
import ly.warp.sdk.utils.managers.WarplyManager;
/**
......@@ -50,6 +55,7 @@ public class WarplyHealthService extends Service implements SensorEventListener
private SensorManager mSensorManager;
private Sensor mSensor;
private int mSteps = 0;
private double mStepsAll = 0.0d;
private final int ACCEL_RING_SIZE = 50;
private final int VEL_RING_SIZE = 10;
// change this threshold according to your sensitivity preferences
......@@ -114,7 +120,7 @@ public class WarplyHealthService extends Service implements SensorEventListener
while (true) {
sendSteps();
try {
Thread.sleep(10000); //900000
Thread.sleep(900000);
} catch (InterruptedException e) {
e.printStackTrace();
}
......@@ -131,6 +137,8 @@ public class WarplyHealthService extends Service implements SensorEventListener
super.onDestroy();
unregisterStepSensor();
mStepsAll = 0.0d;
WarpUtils.setStepsMetersCounter(this, 0.0d);
sendSteps();
}
......@@ -201,6 +209,11 @@ public class WarplyHealthService extends Service implements SensorEventListener
&& oldVelocityEstimate <= STEP_THRESHOLD
&& (timeNs - lastStepTimeNs > STEP_DELAY_NS)) {
mSteps++;
mStepsAll++;
HealthEventModel healthSteps = new HealthEventModel();
healthSteps.setSteps((mStepsAll * 0.762));
EventBus.getDefault().post(new WarplyEventBusManager(healthSteps));
WarpUtils.setStepsMetersCounter(this, (mStepsAll * 0.762));
WarpUtils.setStepsCounter(this, mSteps);
lastStepTimeNs = timeNs;
......
......@@ -139,6 +139,8 @@ public class WarpUtils {
+ "steps_counter";
private static final String PREFERENCES_KEY_USER_NON_TELCO = PREFERENCES_PREFIX
+ "user_non_telco";
private static final String PREFERENCES_STEPS_METERS_COUNTER = PREFERENCES_PREFIX
+ "steps_meters_counter";
private static SharedPreferences _prefs;
......@@ -624,6 +626,17 @@ public class WarpUtils {
return prefs.getInt(PREFERENCES_STEPS_COUNTER, 0);
}
public static void setStepsMetersCounter(Context context, double counter) {
SharedPreferences.Editor editor = getPreferences(context).edit();
editor.putLong(PREFERENCES_STEPS_METERS_COUNTER, Double.doubleToRawLongBits(counter));
editor.apply();
}
public static double getStepsMetersCounter(Context context) {
SharedPreferences prefs = getPreferences(context);
return Double.longBitsToDouble(prefs.getLong(PREFERENCES_STEPS_METERS_COUNTER, 0));
}
public static JSONObject getDeviceInfoObject(Context context) {
SharedPreferences prefs = getPreferences(context);
try {
......
......@@ -67,6 +67,7 @@ import ly.warp.sdk.io.models.MerchantList;
import ly.warp.sdk.io.request.CosmoteRetrieveSharingRequest;
import ly.warp.sdk.io.request.CosmoteSharingRequest;
import ly.warp.sdk.io.request.WarplyIntegrationRequest;
import ly.warp.sdk.io.request.WarplyUserCouponsRequest;
import ly.warp.sdk.services.EventService;
import ly.warp.sdk.utils.managers.WarplyManager;
......@@ -198,9 +199,20 @@ public class WarplyManagerHelper {
@Override
public void onSuccess(JSONObject result) {
int status = result.optInt("status", 2);
if (status == 1)
if (status == 1) {
WarplyManager.getUserCouponsWithCouponsets(new WarplyUserCouponsRequest(), new CallbackReceiver<CouponList>() {
@Override
public void onSuccess(CouponList result) {
}
@Override
public void onFailure(int errorCode) {
}
});
acceptSharingDialog(context);
else
} else
errorSharingDialog(context);
}
......
......@@ -5,12 +5,15 @@ import java.util.HashMap;
import ly.warp.sdk.io.models.ActiveDFYCouponEventModel;
import ly.warp.sdk.io.models.ContexualEventModel;
import ly.warp.sdk.io.models.CouponEventModel;
import ly.warp.sdk.io.models.CouponsEventModel;
import ly.warp.sdk.io.models.HealthEventModel;
import ly.warp.sdk.io.models.LoyaltyContextualOfferModel;
import ly.warp.sdk.io.models.LoyaltyEventModel;
import ly.warp.sdk.io.models.LoyaltyGiftsForYouOfferClickEvent;
import ly.warp.sdk.io.models.LoyaltySDKFirebaseEventModel;
import ly.warp.sdk.io.models.QuestionnaireEventModel;
import ly.warp.sdk.io.models.WarplyCCMSEnabledModel;
import ly.warp.sdk.io.models.WarplyCouponsChangedEventModel;
import ly.warp.sdk.io.models.WarplyDealsAnalysisEventModel;
import ly.warp.sdk.io.models.WarplyPacingCardEventModel;
import ly.warp.sdk.io.models.WarplyPacingCardServiceEnabledModel;
......@@ -34,7 +37,10 @@ public class WarplyEventBusManager {
private CouponEventModel coupon;
private ActiveDFYCouponEventModel activeCoupon;
private ContexualEventModel ccmsAdded;
private CouponsEventModel couponsAdded;
private LoyaltyEventModel campaignsAdded;
private HealthEventModel healthAdded;
private WarplyCouponsChangedEventModel couponsChanged;
public WarplyEventBusManager() {
......@@ -52,6 +58,14 @@ public class WarplyEventBusManager {
this.ccmsAdded = ccmsAdded;
}
public WarplyEventBusManager(CouponsEventModel couponsAdded) {
this.couponsAdded = couponsAdded;
}
public WarplyEventBusManager(HealthEventModel healthAdded) {
this.healthAdded = healthAdded;
}
public WarplyEventBusManager(LoyaltyEventModel campaignsAdded) {
this.campaignsAdded = campaignsAdded;
}
......@@ -60,6 +74,10 @@ public class WarplyEventBusManager {
this.coupon = coupon;
}
public WarplyEventBusManager(WarplyCouponsChangedEventModel couponsChanged) {
this.couponsChanged = couponsChanged;
}
public WarplyEventBusManager(ActiveDFYCouponEventModel activeCoupon) {
this.activeCoupon = activeCoupon;
}
......@@ -174,7 +192,19 @@ public class WarplyEventBusManager {
return ccmsAdded;
}
public CouponsEventModel getCouponsAdded() {
return couponsAdded;
}
public LoyaltyEventModel getCampaignsAdded() {
return campaignsAdded;
}
public HealthEventModel getHealthAdded() {
return healthAdded;
}
public WarplyCouponsChangedEventModel getCouponsChanged() {
return couponsChanged;
}
}
......
......@@ -32,6 +32,7 @@ import android.util.Log;
import androidx.appcompat.app.AlertDialog;
import org.greenrobot.eventbus.EventBus;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
......@@ -83,6 +84,7 @@ import ly.warp.sdk.io.models.SharingList;
import ly.warp.sdk.io.models.TagsCategoriesList;
import ly.warp.sdk.io.models.TagsList;
import ly.warp.sdk.io.models.TransactionsList;
import ly.warp.sdk.io.models.WarplyCouponsChangedEventModel;
import ly.warp.sdk.io.request.CosmoteCouponSharingRequest;
import ly.warp.sdk.io.request.CosmotePostEventRequest;
import ly.warp.sdk.io.request.CosmoteRetrieveSharingRequest;
......@@ -812,10 +814,10 @@ public class WarplyManager {
if (result != null) {
JSONObject profMetadata = WarpJSONParser.getJSONFromString(result.getProfileMetadata());
if (profMetadata != null) {
if (profMetadata.has("nonTelco") && profMetadata.optBoolean("nonTelco")) {
WarpUtils.setUserNonTelco(Warply.getWarplyContext(), profMetadata.optBoolean("nonTelco"));
}
if (profMetadata != null && profMetadata.has("nonTelco")) {
WarpUtils.setUserNonTelco(Warply.getWarplyContext(), profMetadata.optBoolean("nonTelco"));
} else {
WarpUtils.setUserNonTelco(Warply.getWarplyContext(), false);
}
}
......@@ -2235,6 +2237,9 @@ public class WarplyManager {
mActiveCouponList.add(coupon);
}
WarplyCouponsChangedEventModel couponsChanged = new WarplyCouponsChangedEventModel();
couponsChanged.setChanged(true);
EventBus.getDefault().post(new WarplyEventBusManager(couponsChanged));
receiver.onSuccess(mActiveCouponList);
}
......@@ -2316,10 +2321,10 @@ public class WarplyManager {
if (result != null) {
JSONObject profMetadata = WarpJSONParser.getJSONFromString(result.getProfileMetadata());
if (profMetadata != null) {
if (profMetadata.has("nonTelco") && profMetadata.optBoolean("nonTelco")) {
WarpUtils.setUserNonTelco(Warply.getWarplyContext(), profMetadata.optBoolean("nonTelco"));
}
if (profMetadata != null && profMetadata.has("nonTelco")) {
WarpUtils.setUserNonTelco(Warply.getWarplyContext(), profMetadata.optBoolean("nonTelco"));
} else {
WarpUtils.setUserNonTelco(Warply.getWarplyContext(), false);
}
}
......
......@@ -35,6 +35,7 @@ import android.content.pm.ApplicationInfo;
import android.net.Uri;
import android.net.http.SslError;
import android.os.Build;
import android.os.Handler;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.webkit.GeolocationPermissions.Callback;
......@@ -63,6 +64,7 @@ import java.util.Map;
import java.util.concurrent.TimeUnit;
import ly.warp.sdk.Warply;
import ly.warp.sdk.activities.WarpViewActivity;
import ly.warp.sdk.io.models.CouponEventModel;
import ly.warp.sdk.io.models.QuestionnaireEventModel;
import ly.warp.sdk.io.models.WarplyPacingEventModel;
......@@ -508,6 +510,19 @@ public class WarpView extends WebView {
view.evaluateJavascript(scriptSource, s -> {
});
WarpViewActivity.getMetersHandler().postDelayed(new Runnable() {
@Override
public void run() {
String tempMeters = String.valueOf(WarpUtils.getStepsMetersCounter(getContext()));
String scriptSourceMeters = "passMeters(" + tempMeters + ");";
WarpView.this.evaluateJavascript(scriptSourceMeters, s -> {
});
WarpViewActivity.getMetersHandler().postDelayed(this, 1000);
}
}, 1000);
if (url.contains("about:blank")) {
WarpView.this.clearHistory();
}
......
......@@ -20,6 +20,13 @@
android:background="@drawable/selector_cos_campaign">
<androidx.constraintlayout.widget.Guideline
android:id="@+id/gl_vertical_54_percent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.54" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/gl_vertical_80_percent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
......@@ -30,10 +37,10 @@
android:id="@+id/iv_campaign_logo"
android:layout_width="0dp"
android:layout_height="0dp"
android:scaleType="centerCrop"
android:scaleType="centerInside"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintStart_toEndOf="@+id/gl_vertical_54_percent"
app:layout_constraintTop_toTopOf="parent"
tools:src="@drawable/ic_cosmote_logo_horizontal_grey" />
......
......@@ -13,7 +13,7 @@
<string name="cos_profile_type">Traveller</string>
<string name="header_add">Προσθήκη</string>
<string name="cos_profile_reward">My Loyalty\nWallet</string>
<string name="cos_profile_title">For You</string>
<string name="cos_profile_title">Tα προνόμιά μου</string>
<string name="cos_deals_title">Deals for You</string>
<string name="cos_profile_more">Δες περισσότερα</string>
<string name="cos_gifts_title">GIFTS for YOU</string>
......