Panagiotis Triantafyllou

fixes

......@@ -133,6 +133,11 @@
android:permission="android.permission.BIND_JOB_SERVICE" />
<service
android:name="ly.warp.sdk.services.EventCampaignCouponService"
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" />
......
......@@ -339,6 +339,7 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener
mIvPopupClose.setOnClickListener(this);
if (mUniqueSectionList != null) {
try {
String firstKey = (String) mUniqueSectionList.keySet().toArray()[0];
if (mUniqueSectionList.get(firstKey) != null && mUniqueSectionList.get(firstKey).size() > 0) {
mTvResearchSection.setText(firstKey.substring(1));
......@@ -354,7 +355,11 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener
mLlResearchItems.setVisibility(View.VISIBLE);
}
} catch (IndexOutOfBoundsException ex) {
ex.printStackTrace();
}
try {
String secondKey = (String) mUniqueSectionList.keySet().toArray()[1];
if (mUniqueSectionList.get(secondKey) != null && mUniqueSectionList.get(secondKey).size() > 0) {
mTvExclusiveSection.setText(secondKey.substring(1));
......@@ -370,7 +375,11 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener
mLlExclusiveItems.setVisibility(View.VISIBLE);
}
} catch (IndexOutOfBoundsException ex) {
ex.printStackTrace();
}
try {
String thirdKey = (String) mUniqueSectionList.keySet().toArray()[2];
if (mUniqueSectionList.get(thirdKey) != null && mUniqueSectionList.get(thirdKey).size() > 0) {
mTvContestSection.setText(thirdKey.substring(1));
......@@ -386,6 +395,9 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener
mLlContestItems.setVisibility(View.VISIBLE);
}
} catch (IndexOutOfBoundsException ex) {
ex.printStackTrace();
}
if (mContextualList != null && mContextualList.size() > 0) {
mTvContextualSection.setText(getString(R.string.cos_mfy_other));
......@@ -409,6 +421,7 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener
mIvPopupClose.setOnClickListener(this);
if (mUniqueSectionList != null) {
try {
String firstKey = (String) mUniqueSectionList.keySet().toArray()[0];
if (mUniqueSectionList.get(firstKey) != null && mUniqueSectionList.get(firstKey).size() > 0) {
mTvResearchSection.setText(firstKey.substring(1));
......@@ -424,7 +437,11 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener
mLlResearchItems.setVisibility(View.VISIBLE);
}
} catch (IndexOutOfBoundsException ex) {
ex.printStackTrace();
}
try {
String secondKey = (String) mUniqueSectionList.keySet().toArray()[1];
if (mUniqueSectionList.get(secondKey) != null && mUniqueSectionList.get(secondKey).size() > 0) {
mTvExclusiveSection.setText(secondKey.substring(1));
......@@ -440,7 +457,11 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener
mLlExclusiveItems.setVisibility(View.VISIBLE);
}
} catch (IndexOutOfBoundsException ex) {
ex.printStackTrace();
}
try {
String thirdKey = (String) mUniqueSectionList.keySet().toArray()[2];
if (mUniqueSectionList.get(thirdKey) != null && mUniqueSectionList.get(thirdKey).size() > 0) {
mTvContestSection.setText(thirdKey.substring(1));
......@@ -456,6 +477,9 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener
mLlContestItems.setVisibility(View.VISIBLE);
}
} catch (IndexOutOfBoundsException ex) {
ex.printStackTrace();
}
if (mContextualList != null && mContextualList.size() > 0) {
mTvContextualSection.setText(getString(R.string.cos_mfy_other));
......
......@@ -102,6 +102,22 @@ public class ShopsActivity extends FragmentActivity implements View.OnClickListe
super.attachBaseContext(ViewPumpContextWrapper.wrap(newBase));
}
// @Override
// public void onRequestPermissionsResult(
// int requestCode,
// String permissions[],
// int[] grantResults) {
// switch (requestCode) {
// case REQUEST_PERMISSION_PHONE_STATE:
// if (grantResults.length > 0
// && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
// Toast.makeText(MainActivity.this, "Permission Granted!", Toast.LENGTH_SHORT).show();
// } else {
// Toast.makeText(MainActivity.this, "Permission Denied!", Toast.LENGTH_SHORT).show();
// }
// }
// }
@Override
public void onMapReady(@NonNull GoogleMap googleMap) {
mMap = googleMap;
......@@ -115,6 +131,9 @@ public class ShopsActivity extends FragmentActivity implements View.OnClickListe
}
} else {
mMap.setMyLocationEnabled(false);
// ActivityCompat.requestPermissions(this,
// new String[]{Manifest.permission.ACCESS_FINE_LOCATION,
// Manifest.permission.ACCESS_COARSE_LOCATION}, 501);
}
mMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
......
......@@ -64,6 +64,7 @@ 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.EventCampaignCouponService;
import ly.warp.sdk.services.EventQuestionnaireService;
import ly.warp.sdk.services.PushEventsClickedWorkerService;
import ly.warp.sdk.services.WarplyHealthService;
......@@ -151,9 +152,10 @@ public class WarpViewActivity extends WarpBaseActivity {
setResult(RESULT_OK, new Intent());
finish();
}
// if (event.getCoupon() != null) {
// WarplyManager.getUserCouponsWithCouponsets(new WarplyUserCouponsRequest(), mUserCouponsReceiver);
// }
if (event.getCoupon() != null) {
OneTimeWorkRequest mywork = new OneTimeWorkRequest.Builder(EventCampaignCouponService.class).build();
WorkManager.getInstance(WarpViewActivity.this).enqueue(mywork);
}
// if (event.getPacingCard() != null)
// finish();
// if (event.getPacingService() != null)
......
......@@ -198,14 +198,14 @@ public class Merchant implements Parcelable, Serializable, ClusterItem {
*/
public Merchant(JSONObject json) {
if (json != null) {
this.address = json.optString(ADDRESS);
this.address = json.isNull(ADDRESS) ? "" : json.optString(ADDRESS);
this.id = json.optString(ID);
this.store_id = json.optString(STORE_ID);
this.name = json.optString(NAME);
this.name = json.isNull(NAME) ? "" : json.optString(NAME);
this.logo = json.optString(LOGO);
this.website = json.optString(WEBSITE);
this.email = json.optString(EMAIL);
this.telephone = json.optString(TELEPHONE);
this.telephone = json.isNull(TELEPHONE) ? "" : json.optString(TELEPHONE);
this.category = json.optString(CATEGORY);
this.description = json.optString(DESCRIPTION);
this.short_description = json.optString(SHORT_DESCRIPTION);
......
package ly.warp.sdk.services;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.work.OneTimeWorkRequest;
import androidx.work.WorkManager;
import androidx.work.Worker;
import androidx.work.WorkerParameters;
import org.greenrobot.eventbus.EventBus;
import ly.warp.sdk.Warply;
import ly.warp.sdk.activities.CouponsetInfoActivity;
import ly.warp.sdk.io.callbacks.CallbackReceiver;
import ly.warp.sdk.io.models.CampaignList;
import ly.warp.sdk.io.models.CouponList;
import ly.warp.sdk.io.models.CouponsEventModel;
import ly.warp.sdk.io.models.LoyaltyEventModel;
import ly.warp.sdk.io.models.WarplyCouponsChangedEventModel;
import ly.warp.sdk.io.request.WarplyGetCampaignsRequest;
import ly.warp.sdk.io.request.WarplyUserCouponsRequest;
import ly.warp.sdk.utils.managers.WarplyEventBusManager;
import ly.warp.sdk.utils.managers.WarplyManager;
/**
* Created by Panagiotis Triantafyllou on 05/Sept/2022.
*/
public class EventCampaignCouponService extends Worker {
public EventCampaignCouponService(@NonNull Context context, @NonNull WorkerParameters workerParams) {
super(context, workerParams);
}
@NonNull
@Override
public Result doWork() {
WarplyManager.getUserCouponsWithCouponsets(new WarplyUserCouponsRequest(), mUserCouponsReceiver);
WarplyManager.getCampaigns(new WarplyGetCampaignsRequest().setLanguage("en"), mCampaignsCallback);
return Result.success();
}
private final CallbackReceiver<CouponList> mUserCouponsReceiver = new CallbackReceiver<CouponList>() {
@Override
public void onSuccess(CouponList result) {
WarplyCouponsChangedEventModel couponsChanged = new WarplyCouponsChangedEventModel();
couponsChanged.setChanged(true);
EventBus.getDefault().post(new WarplyEventBusManager(couponsChanged));
}
@Override
public void onFailure(int errorCode) {
Thread.currentThread().interrupt();
}
};
private CallbackReceiver<CampaignList> mCampaignsCallback = new CallbackReceiver<CampaignList>() {
@Override
public void onSuccess(CampaignList result) {
LoyaltyEventModel campaignsAdded = new LoyaltyEventModel();
EventBus.getDefault().post(new WarplyEventBusManager(campaignsAdded));
}
@Override
public void onFailure(int errorCode) {
Thread.currentThread().interrupt();
}
};
}
......@@ -346,7 +346,7 @@ public class FCMBaseMessagingService extends FirebaseMessagingService {
nm.notify(tag, uid, notification_build);
}*/
public void showNotification(Context context, PushCampaign pc, Intent newIntent, List<NotificationCompat.Action> actions, RemoteViews remoteViews, String tag, int id) {
public static void showNotification(Context context, PushCampaign pc, Intent newIntent, List<NotificationCompat.Action> actions, RemoteViews remoteViews, String tag, int id) {
SecureRandom randomGenerator = new SecureRandom();
int uid = randomGenerator.nextInt(1000);
......
......@@ -27,6 +27,8 @@ package ly.warp.sdk.utils;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
......@@ -43,6 +45,7 @@ import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import ly.warp.sdk.R;
import ly.warp.sdk.Warply;
......@@ -66,12 +69,14 @@ import ly.warp.sdk.io.models.LoyaltyBadgeModel;
import ly.warp.sdk.io.models.LoyaltyContextualOfferModel;
import ly.warp.sdk.io.models.LoyaltyGiftsForYouPackage;
import ly.warp.sdk.io.models.MerchantList;
import ly.warp.sdk.io.models.PushCampaign;
import ly.warp.sdk.io.models.WarplyCouponsChangedEventModel;
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.services.FCMBaseMessagingService;
import ly.warp.sdk.utils.managers.WarplyEventBusManager;
import ly.warp.sdk.utils.managers.WarplyManager;
......@@ -1129,6 +1134,42 @@ public class WarplyManagerHelper {
mDealsSum = sum;
}
public static boolean checkForLoyaltySDKNotification(Map<String, String> pushPayload) {
Bundle data = convertToBundle(pushPayload);
if (data == null || !data.containsKey("loyalty-action"))
return false;
PushCampaign pc = new PushCampaign(data);
WarpUtils.log("Received push with action: " + pc.getAction());
if (pc.getAction() == 0 && !pc.hasActions())
FCMBaseMessagingService.showCampaignNotification(Warply.getWarplyContext(), pc);
else
showDefaultNotification(Warply.getWarplyContext(), data);
return true;
}
private static Bundle convertToBundle(Map<String, String> data) {
Bundle bundle = new Bundle();
for (Map.Entry<String, String> entry : data.entrySet()) {
bundle.putString(entry.getKey(), entry.getValue());
}
return bundle;
}
private static void showDefaultNotification(Context context, Bundle data) {
PushCampaign pc = new PushCampaign(data);
if (pc != null) {
PackageManager pm = context.getPackageManager();
Intent newIntent = pm.getLaunchIntentForPackage(context.getPackageName());
FCMBaseMessagingService.showNotification(context, pc, newIntent, null, null, null, 0);
}
}
// ===========================================================
// Inner and Anonymous Classes
// ===========================================================
......
......@@ -418,7 +418,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[1].equals("steps") && parts[2].equals("widgetDisabled")) { // This is for the pacing widget
......
......@@ -52,7 +52,8 @@
android:layout_marginTop="4dp"
android:clipToPadding="false"
android:orientation="vertical"
android:paddingTop="44dp" />
android:paddingTop="44dp"
android:overScrollMode="never"/>
</RelativeLayout>
<TextView
......
......@@ -115,7 +115,8 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="-24dp"
android:fillViewport="true">
android:fillViewport="true"
android:overScrollMode="never">
<RelativeLayout
android:layout_width="match_parent"
......