Panagiotis Triantafyllou

campaigns

......@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
ext {
PUBLISH_GROUP_ID = 'ly.warp'
PUBLISH_VERSION = '4.5.4-cosbeta18'
PUBLISH_VERSION = '4.5.4-cosbeta19'
PUBLISH_ARTIFACT_ID = 'warply-android-sdk'
}
......
......@@ -96,8 +96,8 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene
mTvTitle.setText(getIntent().getStringExtra("title"));
mIvPopupClose.setOnClickListener(this);
if (WarpUtils.getGiftsPopup(this))
mLlGiftsPopup.setVisibility(View.VISIBLE);
// if (WarpUtils.getGiftsPopup(this))
// mLlGiftsPopup.setVisibility(View.VISIBLE);
if (mData != null && mData.size() > 0) {
mRecyclerMergedGifts.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
......@@ -114,7 +114,7 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene
String value = WarpJSONParser.getJSONFromString(dataItem.getCampaign().getExtraFields()).optString("loyaltyCampaignId");
for (LoyaltyContextualOfferModel ccms : WarplyManagerHelper.getCCMSLoyaltyCampaigns()) {
if (ccms.getLoyaltyCampaignId().equals(value)) {
startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCcmsUrl(dataItem.getCampaign(), ccms.getSessionId())));
startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCcmsUrl(dataItem.getCampaign(), ccms)));
return;
}
}
......
......@@ -13,6 +13,9 @@ import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import org.greenrobot.eventbus.EventBus;
import java.io.Serializable;
......@@ -43,17 +46,15 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener {
// Fields
// ===========================================================
private ImageView mIvBack, mIvDealsLogo;
private ImageView mIvBack, mIvDealsLogo, mIvProfilePhoto;
private TextView mTvUsername, mTvDealsValue, mTvDealsValueAll,
mTvUserBadge, mTvGiftsValue, mTvGiftsValueAll, mTvActiveCode, mTvActiveDate;
private ConstraintLayout mClDealsBanner, mClDealsView,
mClGiftsBanner;
private LinearLayout mLlQuestionnaire, mLlUserBadge;
float couponValue = 0.0f, couponDfyValue = 0.0f;
int couponCount = 0;
private float couponDfyValue = 0.0f;
private RecyclerView mRecyclerCoupons;
private ActiveCouponAdapter mAdapterCoupons;
private CouponList cpnlist = new CouponList();
// ===========================================================
// Methods for/from SuperClass/Interfaces
......@@ -79,6 +80,7 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener {
mTvActiveDate = findViewById(R.id.tv_active_deals_date_text);
mIvDealsLogo = findViewById(R.id.dfy_logo);
mClDealsView = findViewById(R.id.cl_mygifts);
mIvProfilePhoto = findViewById(R.id.iv_profile_photo);
if (WarplyManagerHelper.getActiveDFYCoupons() != null) {
Collections.sort(WarplyManagerHelper.getActiveDFYCoupons(), new Comparator<ActiveDFYCouponModel>() {
......@@ -87,33 +89,18 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener {
}
});
for (ActiveDFYCouponModel dfycoupon : WarplyManagerHelper.getActiveDFYCoupons()) {
try {
couponDfyValue += Float.parseFloat(dfycoupon.getValue());
} catch (NumberFormatException e) {
}
}
// for (ActiveDFYCouponModel dfycoupon : WarplyManagerHelper.getActiveDFYCoupons()) {
// try {
// couponDfyValue += Float.parseFloat(dfycoupon.getValue());
// } catch (NumberFormatException e) {
//
// }
// }
}
if (WarplyManagerHelper.getCouponList() != null) {
for (Coupon coupon : WarplyManagerHelper.getCouponList()) {
if (coupon.getStatus() == 1) {
try {
cpnlist.add(coupon);
couponCount += 1;
couponValue += Float.parseFloat(coupon.getDiscount());
} catch (NumberFormatException e) {
cpnlist.remove(coupon);
couponCount -= 1;
}
}
}
mRecyclerCoupons = findViewById(R.id.rv_active_coupons);
mRecyclerCoupons.setNestedScrollingEnabled(false);
mRecyclerCoupons.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
}
mRecyclerCoupons = findViewById(R.id.rv_active_coupons);
mRecyclerCoupons.setNestedScrollingEnabled(false);
mRecyclerCoupons.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
initViews();
}
......@@ -149,22 +136,24 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener {
// ===========================================================
private void initViews() {
mAdapterCoupons = new ActiveCouponAdapter(this, cpnlist);
mRecyclerCoupons.setAdapter(mAdapterCoupons);
mAdapterCoupons.getPositionClicks()
.doOnNext(coupon -> {
Intent intent = new Intent(LoyaltyWallet.this, CouponInfoActivity.class);
intent.putExtra("coupon", (Serializable) coupon);
startActivity(intent);
})
.doOnError(error -> {
})
.subscribe();
mTvGiftsValue.setText(String.format(getString(R.string.cos_value), String.valueOf(couponValue)));
mTvGiftsValueAll.setText(String.format(getString(R.string.cos_deals_win_title), String.valueOf(couponValue), String.valueOf(couponCount)));
mTvDealsValue.setText(String.format(getString(R.string.cos_value), String.valueOf(couponDfyValue)));
mTvDealsValueAll.setText(String.format(getString(R.string.cos_deals_win_title_cos), String.valueOf(couponDfyValue)));
if (WarplyManagerHelper.getCouponList() != null) {
mAdapterCoupons = new ActiveCouponAdapter(this, WarplyManagerHelper.getCouponList());
mRecyclerCoupons.setAdapter(mAdapterCoupons);
mAdapterCoupons.getPositionClicks()
.doOnNext(coupon -> {
Intent intent = new Intent(LoyaltyWallet.this, CouponInfoActivity.class);
intent.putExtra("coupon", (Serializable) coupon);
startActivity(intent);
})
.doOnError(error -> {
})
.subscribe();
}
mTvGiftsValue.setText(String.format(getString(R.string.cos_value), String.valueOf(WarplyManagerHelper.getLoyaltyBadge().getValue())));
mTvGiftsValueAll.setText(String.format(getString(R.string.cos_deals_win_title), String.valueOf(WarplyManagerHelper.getLoyaltyBadge().getValue()), String.valueOf(WarplyManagerHelper.getLoyaltyBadge().getCouponCount())));
mTvDealsValue.setText(String.format(getString(R.string.cos_value), String.valueOf(/*couponDfyValue*/ WarplyManagerHelper.getDealsCouponsSum())));
mTvDealsValueAll.setText(String.format(getString(R.string.cos_deals_win_title_cos), String.valueOf(/*couponDfyValue*/WarplyManagerHelper.getDealsCouponsSum())));
if (WarplyManagerHelper.getActiveDFYCoupons() != null && WarplyManagerHelper.getActiveDFYCoupons().size() > 0) {
mTvActiveCode.setText(WarplyManagerHelper.getActiveDFYCoupons().get(0).getCode());
......@@ -189,6 +178,17 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener {
mTvUsername.setText(String.format(getResources().getString(R.string.cos_profile_loyalty_name),
WarplyManagerHelper.getConsumer().getFirstName(), WarplyManagerHelper.getConsumer().getLastName()));
if (!TextUtils.isEmpty(WarplyManagerHelper.getConsumer().getImageUrl()) && !WarplyManagerHelper.getConsumer().getImageUrl().equals("null")) {
Glide.with(this)
.load(WarplyManagerHelper.getConsumer().getImageUrl())
.diskCacheStrategy(DiskCacheStrategy.DATA)
.into(mIvProfilePhoto);
} else {
Glide.with(this)
.load(R.drawable.ic_default_photo)
.into(mIvProfilePhoto);
}
if (!TextUtils.isEmpty(WarplyManagerHelper.getUserTag())) {
mTvUserBadge.setText(WarplyManagerHelper.getUserTag());
mLlQuestionnaire.setVisibility(View.GONE);
......
......@@ -81,8 +81,8 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener
mTvTitle.setText(getIntent().getStringExtra("title"));
mIvPopupClose.setOnClickListener(this);
if (WarpUtils.getMorePopup(this))
mLlMorePopup.setVisibility(View.VISIBLE);
// if (WarpUtils.getMorePopup(this))
// mLlMorePopup.setVisibility(View.VISIBLE);
if (WarplyManagerHelper.getUniqueCampaignList().get("more_for_you") != null && WarplyManagerHelper.getUniqueCampaignList().get("more_for_you").size() > 0) {
mRecyclerMore.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
......
......@@ -81,8 +81,6 @@ public class WarpViewActivity extends WarpBaseActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_loyalty_wallet);
WarplySessionManager.onCreateActivity(this);
initViews();
Warply.getInitializer(this).init();
......
......@@ -111,15 +111,35 @@ public class VolleyTransformer implements Listener<JSONObject>, ErrorListener {
if (mListener == null)
return;
WarpUtils.log("**************** WARPLY Reponse *****************");
WarpUtils.log("**************** WARPLY Response *****************");
WarpUtils.verbose("[WARP Trace] HTTP Web Id: "
+ WarpUtils.getWebId(Warply.INSTANCE.mContext.get()));
WarpUtils.verbose("[WARP Trace] HTTP API Key: "
+ WarplyProperty.getAppUuid(Warply.INSTANCE.mContext.get()));
if (response != null) {
try {
WarpUtils.log("[WARP Trace] Request: " + response.toString(2));
} catch (JSONException e) {
// WarpUtils.log("[WARP Trace] Request: " + response.toString(2));
WarpUtils.log("[WARP Trace] Response: ");
// if (response.toString().length() > 4000) {
// for (int i = 0; i < response.toString().length(); i += 4000) {
// if (i + 4000 < response.toString().length())
// WarpUtils.log(response.toString().substring(i, i + 4000));
// else
// WarpUtils.log(response.toString().substring(i, response.toString().length()));
// }
for (int i = 0, length = response.toString().length(); i < length; i++) {
int newline = response.toString().indexOf('\n', i);
newline = newline != -1 ? newline : length;
do {
int end = Math.min(newline, i + 4000);
WarpUtils.log(response.toString().substring(i, end));
i = end;
} while (i < newline);
}
// } else
// WarpUtils.log("[WARP Trace] Request: " + response.toString(2));
} catch (/*JSONException*/ Exception e) {
WarpUtils.warn(
"[WARP Trace] Failed conversting JSON to string", e);
}
......
......@@ -81,6 +81,7 @@ public class WarplyManagerHelper {
private static AlertDialog mAlertDialogSharing, mAlertDialogAcceptSharing, mAlertDialogRejectSharing,
mAlertDialogReturnSharing, mAlertDialogErrorSharing;
private static LoyaltyBadgeModel mLoyaltyBadge = new LoyaltyBadgeModel();
private static float mDealsSum = 0.0f;
// ===========================================================
// Methods for/from SuperClass/Interfaces
......@@ -251,7 +252,8 @@ public class WarplyManagerHelper {
/**
* Open CCMS campaign
*/
public static String constructCcmsUrl(Campaign item, String sessionId) {
public static String constructCcmsUrl(Campaign item, LoyaltyContextualOfferModel ccmsItem) {
Log.v("CCMS_PRESSED", ccmsItem.getId() + " " + ccmsItem.getOfferName());
item.setNew(false);
String url = item.getIndexUrl()
+ "?web_id=" + WarpUtils.getWebId(Warply.getWarplyContext())
......@@ -262,7 +264,94 @@ public class WarplyManagerHelper {
+ "&refresh_token=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("refresh_token")
+ "&client_id=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_id")
+ "&client_secret=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_secret")
+ "&session_id=" + sessionId;
+ "&Session_ID=" + ccmsItem.getSessionId()
+ "&businessService="
+ "&offerName=" + ccmsItem.getOfferName()
+ "&productType=" + ccmsItem.getProductType()
+ "&provDuration=" + ccmsItem.getProvDuration()
+ "&noOfRecurrance=" + ccmsItem.getNoOfRecurrance()
+ "&price=" + ccmsItem.getPrice()
+ "&discount=" + ccmsItem.getDiscount()
+ "&voiceCategory=" + ccmsItem.getVoiceCategory()
+ "&dataCategory=" + ccmsItem.getDataCategory()
+ "&minsValue=" + ccmsItem.getMinsValue()
+ "&dataValue=" + ccmsItem.getDataValue()
+ "&provStepValueMins=" + ccmsItem.getProvStepValueMins()
+ "&UACIOfferTrackingCode="
+ "&MSISDN="
+ "&OFFERCODE1="
+ "&SCORE="
+ "&ZONE="
+ "&WAVE="
+ "&VALIDITY="
+ "&TREATMENT_CODE="
+ "&GUID="
+ "&OfferAudienceLevel=";
// if (mConsumer != null)
// url = url + "&auth_token=" + (mConsumer.getUuid());
// else
// url = url + "&auth_token=";
return url;
}
/**
* Open CCMS campaign
*/
public static String constructCcmsUrl(LoyaltyContextualOfferModel item, String sessionId) {
String url = "";
if (item != null) {
if (mUniqueCampaignList != null && mUniqueCampaignList.get("gifts_for_you") != null && mUniqueCampaignList.get("gifts_for_you").size() > 0) {
for (Campaign camp : mUniqueCampaignList.get("gifts_for_you")) {
try {
String key = WarpJSONParser.getJSONFromString(camp.getExtraFields()).keys().next();
if (!TextUtils.isEmpty(key) && key.equals("loyaltyCampaignId")) {
String keyValue = WarpJSONParser.getJSONFromString(camp.getExtraFields()).optString(key);
if (keyValue.equals(item.getLoyaltyCampaignId())) {
Log.v("CCMS_PRESSED", item.getId() + " " + item.getOfferName());
url = camp.getIndexUrl()
+ "?web_id=" + WarpUtils.getWebId(Warply.getWarplyContext())
+ "&app_uuid=" + WarplyProperty.getAppUuid(Warply.getWarplyContext())
+ "&api_key=" + WarpUtils.getApiKey(Warply.getWarplyContext())
+ "&session_uuid=" + camp.getSessionUUID()
+ "&access_token=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("access_token")
+ "&refresh_token=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("refresh_token")
+ "&client_id=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_id")
+ "&client_secret=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_secret")
+ "&Session_ID=" + sessionId //item.getSessionId()
+ "&businessService="
+ "&offerName=" + item.getOfferName()
+ "&productType=" + item.getProductType()
+ "&provDuration=" + item.getProvDuration()
+ "&noOfRecurrance=" + item.getNoOfRecurrance()
+ "&price=" + item.getPrice()
+ "&discount=" + item.getDiscount()
+ "&voiceCategory=" + item.getVoiceCategory()
+ "&dataCategory=" + item.getDataCategory()
+ "&minsValue=" + item.getMinsValue()
+ "&dataValue=" + item.getDataValue()
+ "&provStepValueMins=" + item.getProvStepValueMins()
+ "&UACIOfferTrackingCode="
+ "&MSISDN="
+ "&OFFERCODE1="
+ "&SCORE="
+ "&ZONE="
+ "&WAVE="
+ "&VALIDITY="
+ "&TREATMENT_CODE="
+ "&GUID="
+ "&OfferAudienceLevel=";
break;
}
}
} catch (Exception exception) {
Log.v("WarplyManagerHelper_CCMS_Error", exception.toString());
}
}
}
}
// if (mConsumer != null)
// url = url + "&auth_token=" + (mConsumer.getUuid());
......@@ -427,15 +516,17 @@ public class WarplyManagerHelper {
public static void setUniqueCampaignList(CampaignList campaignList) {
mCampaignList = campaignList;
for (Campaign campaign : campaignList) {
if (mUniqueCampaignList.containsKey(campaign.getOfferCategory().trim())) {
CampaignList tempCampaignList = (CampaignList) mUniqueCampaignList.get(campaign.getOfferCategory().trim());
tempCampaignList.add(campaign);
mUniqueCampaignList.put(campaign.getOfferCategory().trim(), tempCampaignList);
} else {
CampaignList tempCampaignList = new CampaignList();
tempCampaignList.add(campaign);
mUniqueCampaignList.put(campaign.getOfferCategory().trim(), tempCampaignList);
if (campaignList != null) {
for (Campaign campaign : campaignList) {
if (mUniqueCampaignList.containsKey(campaign.getOfferCategory().trim())) {
CampaignList tempCampaignList = (CampaignList) mUniqueCampaignList.get(campaign.getOfferCategory().trim());
tempCampaignList.add(campaign);
mUniqueCampaignList.put(campaign.getOfferCategory().trim(), tempCampaignList);
} else {
CampaignList tempCampaignList = new CampaignList();
tempCampaignList.add(campaign);
mUniqueCampaignList.put(campaign.getOfferCategory().trim(), tempCampaignList);
}
}
}
}
......@@ -468,7 +559,7 @@ public class WarplyManagerHelper {
badge.setCouponCount(couponCount);
badge.setValue(couponValue);
mLoyaltyBadge = badge;
mCouponList = couponList;
mCouponList = cpnlist;
}
public static LoyaltyBadgeModel getLoyaltyBadge() {
......@@ -483,6 +574,14 @@ public class WarplyManagerHelper {
mCouponsetsList = couponsets;
}
public static float getDealsCouponsSum() {
return mDealsSum;
}
public static void setDealsCouponsSum(float sum) {
mDealsSum = sum;
}
// ===========================================================
// Inner and Anonymous Classes
// ===========================================================
......
......@@ -37,6 +37,7 @@ import android.net.http.SslError;
import android.os.Build;
import androidx.core.content.ContextCompat;
import androidx.work.WorkManager;
import android.text.TextUtils;
import android.util.AttributeSet;
......@@ -66,6 +67,7 @@ import ly.warp.sdk.io.models.CouponEventModel;
import ly.warp.sdk.io.models.QuestionnaireEventModel;
import ly.warp.sdk.io.models.WarplyPacingCardEventModel;
import ly.warp.sdk.io.models.WarplyPacingCardServiceEnabledModel;
import ly.warp.sdk.services.UpdateUserLocationService;
import ly.warp.sdk.utils.WarpUtils;
import ly.warp.sdk.utils.WarplyProperty;
import ly.warp.sdk.utils.WarplyUrlHandler;
......@@ -385,9 +387,10 @@ public class WarpView extends WebView {
questionnaireEvent.setParameter(parts[2]);
WarpUtils.setUserTag(Warply.getWarplyContext(), parts[2]);
EventBus.getDefault().post(new WarplyEventBusManager(questionnaireEvent));
} else if (parts[1].equals("event:couponRetrieved")) {
EventBus.getDefault().post(new WarplyEventBusManager(new CouponEventModel()));
} else if (parts[1].equals("couponRetrieved")) {
// EventBus.getDefault().post(new WarplyEventBusManager(new CouponEventModel()));
} else if (parts[2].equals("serviceDisabled")) {
// WorkManager.getInstance(Warply.getWarplyContext()).cancelAllWorkByTag(UpdateUserLocationService.TAG);
WarplyPacingCardServiceEnabledModel pacingService = new WarplyPacingCardServiceEnabledModel();
pacingService.setEnabled(false);
EventBus.getDefault().post(new WarplyEventBusManager(pacingService));
......@@ -404,7 +407,9 @@ public class WarpView extends WebView {
pacingVisible.setVisible(false);
EventBus.getDefault().post(new WarplyEventBusManager(pacingVisible));
} else if (parts[1].equals("request") || parts[1].equals("response")) {
WarpUtils.log("**************** WARPLY Webview Log START *****************");
WarpUtils.verbose(parts[2]);
WarpUtils.log("**************** WARPLY Webview Log END *****************");
}
}
}
......
......@@ -85,8 +85,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:layout_marginHorizontal="40dp"
android:gravity="center"
android:text="@string/cos_popup_gifts_subtitle"
android:textColor="@android:color/white"
android:textSize="16sp" />
......
......@@ -98,7 +98,7 @@
android:id="@+id/iv_profile_photo"
android:layout_width="70dp"
android:layout_height="70dp"
android:src="@drawable/profile_photo"
android:src="@drawable/ic_default_photo"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
......
......@@ -85,8 +85,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:layout_marginHorizontal="40dp"
android:gravity="center"
android:text="@string/cos_popup_more_subtitle"
android:textColor="@android:color/white"
android:textSize="16sp" />
......