Panagiotis Triantafyllou

vouchers part1

......@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
ext {
PUBLISH_GROUP_ID = 'ly.warp'
PUBLISH_VERSION = '4.5.4.6rc79'
PUBLISH_VERSION = '4.5.4.6rc80'
PUBLISH_ARTIFACT_ID = 'warply-android-sdk'
}
......
......@@ -184,6 +184,11 @@
android:permission="android.permission.BIND_JOB_SERVICE" />
<service
android:name="ly.warp.sdk.services.VouchersFetchedService"
android:exported="false"
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" />
......
......@@ -186,6 +186,7 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener, Vie
@Override
public void onDestroy() {
super.onDestroy();
WarplyManagerHelper.clearShowVouchersBanner();
EventBus.getDefault().unregister(this);
}
......@@ -354,6 +355,18 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener, Vie
@Subscribe()
public void onMessageEvent(WarplyEventBusManager event) {
if (event.getVouchersFetched() != null) {
WarpUtils.log(String.valueOf(event.getVouchersFetched().isFetched()));
WarpUtils.log(WarplyManagerHelper.getShowVouchersBanner());
if (WarplyManagerHelper.getShowVouchersBanner().equals("true")) {
//TODO: hide spinner and enable button
} else {
//.equals("false)
//TODO: hide it completely or leave it disabled??
}
return;
}
if (event.getUnifiedCouponsAdded() != null) {
mUnifiedPressed = false;
if (WarplyManagerHelper.getMarketCouponsList() != null && WarplyManagerHelper.getMarketCouponsList().size() > 0) {
......@@ -510,6 +523,15 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener, Vie
// ===========================================================
private void initViews() {
if (TextUtils.isEmpty(WarplyManagerHelper.getShowVouchersBanner())) {
//TODO: show spinner
} else if (WarplyManagerHelper.getShowVouchersBanner().equals("true")) {
//TODO: hide spinner and enable button
} else {
//.equals("false)
//TODO: hide it completely or leave it disabled??
}
if (WarpUtils.getUserNonTelco(this)) {
nonTelcoDialog();
}
......
/*
* 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 19-Oct-23.
*/
public class VouchersActivityEventModel {
private boolean openActivity;
public VouchersActivityEventModel() {
this.openActivity = true;
}
public boolean isOpened() {
return openActivity;
}
public void setOpened(boolean openActivity) {
this.openActivity = openActivity;
}
}
/*
* 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 19-Oct-23.
*/
public class VouchersFetchedEventModel {
private boolean fetched;
public VouchersFetchedEventModel() {
this.fetched = true;
}
public boolean isFetched() {
return fetched;
}
public void setFetched(boolean fetched) {
this.fetched = fetched;
}
}
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.io.models.VouchersFetchedEventModel;
import ly.warp.sdk.utils.managers.WarplyEventBusManager;
/**
* Created by Panagiotis Triantafyllou on 19/Oct/2023.
*/
public class VouchersFetchedService extends Worker {
public VouchersFetchedService(@NonNull Context context, @NonNull WorkerParameters workerParams) {
super(context, workerParams);
}
@NonNull
@Override
public Result doWork() {
VouchersFetchedEventModel vouchersFetched = new VouchersFetchedEventModel();
EventBus.getDefault().post(new WarplyEventBusManager(vouchersFetched));
return Result.success();
}
}
......@@ -88,7 +88,9 @@ import ly.warp.sdk.io.request.WarplyEditConsumerRequest;
import ly.warp.sdk.io.request.WarplyIntegrationRequest;
import ly.warp.sdk.io.request.WarplyUserCouponsRequest;
import ly.warp.sdk.services.EventService;
import ly.warp.sdk.services.EventUnifiedCouponsService;
import ly.warp.sdk.services.FCMBaseMessagingService;
import ly.warp.sdk.services.VouchersFetchedService;
import ly.warp.sdk.services.WarplyHealthService;
import ly.warp.sdk.utils.managers.WarplyAnalyticsManager;
import ly.warp.sdk.utils.managers.WarplyEventBusManager;
......@@ -134,6 +136,7 @@ public class WarplyManagerHelper {
public static int mSteps = 0;
private static ArrayList<UnifiedCoupon> mMarketCoupons = new ArrayList<>(),
mMarketCouponsList = new ArrayList<>();
private static String showVouchersBanner = "";
// ===========================================================
// Methods for/from SuperClass/Interfaces
......@@ -1406,6 +1409,25 @@ public class WarplyManagerHelper {
return false;
}
public static void clearShowVouchersBanner() {
showVouchersBanner = "";
}
public static void setShowVouchersBanner(boolean show) {
showVouchersBanner = String.valueOf(show);
}
public static String getShowVouchersBanner() {
return showVouchersBanner;
}
public static void setVouchersFetched(boolean success) {
setShowVouchersBanner(success);
OneTimeWorkRequest mywork = new OneTimeWorkRequest.Builder(VouchersFetchedService.class).build();
WorkManager.getInstance(Warply.getWarplyContext()).enqueue(mywork);
}
// ===========================================================
// Inner and Anonymous Classes
// ===========================================================
......
......@@ -16,6 +16,7 @@ import ly.warp.sdk.io.models.LoyaltySDKSessionExpiredEventModel;
import ly.warp.sdk.io.models.QuestionnaireEventModel;
import ly.warp.sdk.io.models.RefreshUnifiedCouponsEventModel;
import ly.warp.sdk.io.models.UnifiedCouponsEventModel;
import ly.warp.sdk.io.models.VouchersFetchedEventModel;
import ly.warp.sdk.io.models.WarplyCCMSEnabledModel;
import ly.warp.sdk.io.models.WarplyCouponsChangedEventModel;
import ly.warp.sdk.io.models.WarplyDealsAnalysisEventModel;
......@@ -41,6 +42,7 @@ public class WarplyEventBusManager {
private WarplyCCMSEnabledModel ccmsActivated;
private LoyaltyGiftsForYouOfferClickEvent giftsYou;
private QuestionnaireEventModel questionnaire;
private VouchersFetchedEventModel vouchersFetched;
private CouponEventModel coupon;
private ActiveDFYCouponEventModel activeCoupon;
private ContexualEventModel ccmsAdded;
......@@ -74,6 +76,10 @@ public class WarplyEventBusManager {
this.questionnaire = questionnaire;
}
public WarplyEventBusManager(VouchersFetchedEventModel vouchersFetched) {
this.vouchersFetched = vouchersFetched;
}
public WarplyEventBusManager(WarplyWebviewCallbackEventModel webviewCallback) {
this.webviewCallback = webviewCallback;
}
......@@ -220,6 +226,10 @@ public class WarplyEventBusManager {
return questionnaire;
}
public VouchersFetchedEventModel getVouchersFetched() {
return vouchersFetched;
}
public CouponEventModel getCoupon() {
return coupon;
}
......