Panagiotis Triantafyllou

new fixes

......@@ -5,13 +5,17 @@ import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.text.Html;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.core.content.ContextCompat;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.google.zxing.BarcodeFormat;
......@@ -41,10 +45,12 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener
// ===========================================================
private ImageView mIvBack, mIvCouponPhoto, mIvBarcode;
private TextView mTvTerms, mTvCouponCode, mTvCouponTitle, mTvCouponSubtitle, mTvCouponDate;
private LinearLayout mLlGiftIt, mLlShops;
private TextView mTvTerms, mTvCouponCode, mTvCouponTitle, mTvCouponSubtitle, mTvCouponDate,
mTvTermsValue;
private LinearLayout mLlGiftIt, mLlShops, mLlBarcodeShown, mLlBarcodeContainer, mLlTerms;
private Coupon mCoupon;
private Couponset mCouponset;
private boolean mIsBarcodeShown = false, mIsTermsShown = false;
// ===========================================================
// Methods for/from SuperClass/Interfaces
......@@ -67,6 +73,10 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener
mIvCouponPhoto = findViewById(R.id.imageView6);
mIvBarcode = findViewById(R.id.iv_barcode);
mLlShops = findViewById(R.id.ll_shops);
mLlBarcodeShown = findViewById(R.id.ll_show_barcode);
mLlBarcodeContainer = findViewById(R.id.ll_barcode_container_items);
mLlTerms = findViewById(R.id.ll_terms_inner);
mTvTermsValue = findViewById(R.id.tv_terms_value);
initViews();
}
......@@ -92,6 +102,38 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener
Intent intent = new Intent(CouponInfoActivity.this, ShopsActivity.class);
intent.putExtra("couponset", (Serializable) mCouponset);
startActivity(intent);
return;
}
if (view.getId() == R.id.ll_show_barcode) {
if (mIsBarcodeShown) {
mLlBarcodeContainer.setVisibility(View.GONE);
TextView barcodeButtonTitle = mLlBarcodeShown.findViewById(R.id.tv_barcode);
ImageView barcodeButtonArrow = mLlBarcodeShown.findViewById(R.id.iv_barcode_arrow);
barcodeButtonTitle.setText(getString(R.string.cos_show_barcode));
barcodeButtonArrow.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_arrow_down_dark));
mIsBarcodeShown = false;
} else {
mLlBarcodeContainer.setVisibility(View.VISIBLE);
TextView barcodeButtonTitle = mLlBarcodeShown.findViewById(R.id.tv_barcode);
ImageView barcodeButtonArrow = mLlBarcodeShown.findViewById(R.id.iv_barcode_arrow);
barcodeButtonTitle.setText(getString(R.string.cos_hide_barcode));
barcodeButtonArrow.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_arrow_up_dark));
mIsBarcodeShown = true;
}
return;
}
if (view.getId() == R.id.ll_terms_inner) {
if (mIsTermsShown) {
mTvTermsValue.setVisibility(View.GONE);
ImageView termsButtonArrow = mLlTerms.findViewById(R.id.iv_terms_arrow);
termsButtonArrow.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_arrow_down_dark));
mIsTermsShown = false;
} else {
mTvTermsValue.setVisibility(View.VISIBLE);
ImageView termsButtonArrow = mLlTerms.findViewById(R.id.iv_terms_arrow);
termsButtonArrow.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_arrow_up_dark));
mIsTermsShown = true;
}
}
}
......@@ -118,6 +160,14 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener
}
}
if (mCouponset != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
mTvTermsValue.setText(Html.fromHtml(mCouponset.getTerms(), Html.FROM_HTML_MODE_COMPACT));
} else {
mTvTermsValue.setText(Html.fromHtml(mCouponset.getTerms()));
}
}
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm");
Date newDate = new Date();
try {
......@@ -146,6 +196,8 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener
// mTvTerms.setPaintFlags(mTvTerms.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
mLlGiftIt.setOnClickListener(this);
mLlShops.setOnClickListener(this);
mLlBarcodeShown.setOnClickListener(this);
mLlTerms.setOnClickListener(this);
String tempCoupon = mCoupon.getCoupon();
for (int i = 0; i < (12 - mCoupon.getCoupon().length()); i++) {
......
......@@ -67,6 +67,7 @@ public class ShopsActivity extends FragmentActivity implements View.OnClickListe
mIvBack = findViewById(R.id.iv_shops_back);
mMapView = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.mv_shops);
mMapView.getMapAsync(this);
mIvBack.setOnClickListener(this);
}
@Override
......
......@@ -60,6 +60,7 @@ public class Coupon implements Parcelable, Serializable {
private static final String TRANSACTION_UUID = "transaction_uuid";
private static final String CHANGES_DATES = "changes_dates";
private static final String COUPONSET_UUID = "couponset_uuid";
private static final String MERCHANT_UUID = "merchant_uuid";
/* Member variables of the Campaign object */
......@@ -77,6 +78,7 @@ public class Coupon implements Parcelable, Serializable {
private String transactionUuid = "";
private JSONObject changesDates = new JSONObject();
private String couponsetUuid = "";
private String merchantUuid = "";
/**
* Basic constructor used to create an object from a String, representing a
......@@ -110,6 +112,7 @@ public class Coupon implements Parcelable, Serializable {
this.transactionUuid = json.optString(TRANSACTION_UUID);
this.changesDates = json.optJSONObject(CHANGES_DATES);
this.couponsetUuid = json.optString(COUPONSET_UUID);
this.merchantUuid = json.optString(MERCHANT_UUID);
}
}
......@@ -127,6 +130,7 @@ public class Coupon implements Parcelable, Serializable {
this.transactionDate = source.readString();
this.transactionUuid = source.readString();
this.couponsetUuid = source.readString();
this.merchantUuid = source.readString();
}
@Override
......@@ -144,6 +148,7 @@ public class Coupon implements Parcelable, Serializable {
dest.writeString(this.transactionDate);
dest.writeString(this.transactionUuid);
dest.writeString(this.couponsetUuid);
dest.writeString(this.merchantUuid);
}
/**
......@@ -168,6 +173,7 @@ public class Coupon implements Parcelable, Serializable {
jObj.putOpt(TRANSACTION_UUID, this.transactionUuid);
jObj.putOpt(CHANGES_DATES, this.changesDates);
jObj.putOpt(COUPONSET_UUID, this.couponsetUuid);
jObj.putOpt(MERCHANT_UUID, this.merchantUuid);
} catch (JSONException e) {
if (WarpConstants.DEBUG) {
e.printStackTrace();
......@@ -319,6 +325,14 @@ public class Coupon implements Parcelable, Serializable {
this.couponsetUuid = couponsetUuid;
}
public String getMerchantUuid() {
return merchantUuid;
}
public void setMerchantUuid(String merchantUuid) {
this.merchantUuid = merchantUuid;
}
@Override
public int describeContents() {
return 0;
......
......@@ -136,6 +136,50 @@ public class Merchant implements Parcelable, Serializable, ClusterItem {
private JSONObject product = new JSONObject();
private LatLng coordinates;
public Merchant() {
this.address = "";
this.id = "";
this.store_id = "";
this.name = "";
this.logo = "";
this.website = "";
this.email = "";
this.telephone = "";
this.category = "";
this.description = "";
this.short_description = "";
this.region = "";
this.latitude = 0.0;
this.longitude = 0.0;
this.image = "";
this.extra_fields = new JSONObject();
this.active = true;
this.city = "";
this.country = "";
this.postal_code = "";
this.vat = "";
this.uuid = "";
this.category_uuid = "";
this.created = "";
this.parent = "";
this.img = new JSONArray();
this.img_preview = "";
this.admin_name = "";
this.sorting = 0;
this.body = "";
this.owner_name = "";
this.preview = "";
this.merchant_metadata = new JSONObject();
this.promoted = false;
this.distance = 0;
this.default_shown = true;
this.hidden = false;
this.working_hours = new JSONObject();
this.tags = new JSONArray();
this.product = new JSONObject();
coordinates = new LatLng(this.latitude, this.longitude);
}
/**
* Basic constructor used to create an object from a String, representing a
* JSON Object
......
......@@ -61,6 +61,7 @@ import ly.warp.sdk.io.models.CustomerStateModel;
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.request.CosmoteRetrieveSharingRequest;
import ly.warp.sdk.io.request.CosmoteSharingRequest;
import ly.warp.sdk.io.request.WarplyIntegrationRequest;
......@@ -96,6 +97,7 @@ public class WarplyManagerHelper {
mAlertDialogReturnSharing, mAlertDialogErrorSharing;
private static LoyaltyBadgeModel mLoyaltyBadge = new LoyaltyBadgeModel();
private static float mDealsSum = 0.0f;
private static MerchantList mMerchantList = new MerchantList();
// ===========================================================
// Methods for/from SuperClass/Interfaces
......@@ -908,6 +910,14 @@ public class WarplyManagerHelper {
mCouponsetsList = couponsets;
}
public static void setMerchantList(MerchantList merchantList) {
mMerchantList = merchantList;
}
public static MerchantList getMerchantList() {
return mMerchantList;
}
public static float getDealsCouponsSum() {
return mDealsSum;
}
......
......@@ -25,6 +25,10 @@
package ly.warp.sdk.utils.managers;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
......@@ -2163,65 +2167,80 @@ public class WarplyManager {
WarpUtils.log("[WARP Trace] WARPLY User Coupons Request is active");
WarpUtils.log("**************************************************");
getCouponsets(new WarplyGetCouponsetsRequest()
.setLanguage(WarplyProperty.getLanguage(Warply.getWarplyContext())), new CallbackReceiver<CouponsetsList>() {
@Override
public void onSuccess(CouponsetsList result) {
Warply.postReceiveMicroappData(WarpConstants.MICROAPP_COUPONS, true, "context", request.toJson(), new CouponsHook(new CallbackReceiver<CouponList>() {
WarplyManager.getMerchantsMultilingual(new WarplyMerchantsRequest()
.setIsMultilingual(true)
, new CallbackReceiver<MerchantList>() {
@Override
public void onSuccess(CouponList response) {
CouponList mCouponList = new CouponList();
for (Coupon coupon : response) {
for (Couponset couponset : result) {
if (coupon.getCouponsetUuid().equals(couponset.getUuid())) {
coupon.setDescription(couponset.getShortDescription());
coupon.setImage(couponset.getImgPreview());
coupon.setName(couponset.getName());
mCouponList.add(coupon);
}
}
}
WarplyManagerHelper.setCouponList(mCouponList);
public void onSuccess(MerchantList result) {
WarplyManagerHelper.setMerchantList(result);
CouponList mActiveCouponList = new CouponList();
for (Coupon coupon : mCouponList) {
if (coupon.getStatus() == 1)
mActiveCouponList.add(coupon);
}
getCouponsets(new WarplyGetCouponsetsRequest()
.setLanguage(WarplyProperty.getLanguage(Warply.getWarplyContext())), new CallbackReceiver<CouponsetsList>() {
@Override
public void onSuccess(CouponsetsList result) {
Warply.postReceiveMicroappData(WarpConstants.MICROAPP_COUPONS, true, "context", request.toJson(), new CouponsHook(new CallbackReceiver<CouponList>() {
@Override
public void onSuccess(CouponList response) {
CouponList mCouponList = new CouponList();
for (Coupon coupon : response) {
for (Couponset couponset : result) {
if (coupon.getCouponsetUuid().equals(couponset.getUuid())) {
coupon.setDescription(couponset.getShortDescription());
coupon.setImage(couponset.getImgPreview());
coupon.setName(couponset.getName());
coupon.setMerchantUuid(couponset.getMerchantUuid());
mCouponList.add(coupon);
}
}
}
WarplyManagerHelper.setCouponList(mCouponList);
CouponList mActiveCouponList = new CouponList();
for (Coupon coupon : mCouponList) {
if (coupon.getStatus() == 1)
mActiveCouponList.add(coupon);
}
receiver.onSuccess(mActiveCouponList);
}
@Override
public void onFailure(int errorCode) {
if (errorCode == 401) {
refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() {
@Override
public void onSuccess(JSONObject result) {
int status = result.optInt("status", 2);
if (status == 1)
getUserCoupons(request, receiver);
else
receiver.onFailure(status);
}
@Override
public void onFailure(int errorCode) {
receiver.onFailure(errorCode);
}
});
} else
receiver.onFailure(errorCode);
}
},
request.getSignature()));
}
receiver.onSuccess(mActiveCouponList);
@Override
public void onFailure(int errorCode) {
receiver.onFailure(errorCode);
}
});
}
@Override
public void onFailure(int errorCode) {
if (errorCode == 401) {
refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() {
@Override
public void onSuccess(JSONObject result) {
int status = result.optInt("status", 2);
if (status == 1)
getUserCoupons(request, receiver);
else
receiver.onFailure(status);
}
@Override
public void onFailure(int errorCode) {
receiver.onFailure(errorCode);
}
});
} else
receiver.onFailure(errorCode);
}
},
request.getSignature()));
}
@Override
public void onFailure(int errorCode) {
receiver.onFailure(errorCode);
}
});
});
}
public static void getCosmoteUser(WarplyCosmoteUserRequest request, final CallbackReceiver<JSONObject> receiver) {
......
......@@ -24,6 +24,8 @@ import io.reactivex.subjects.PublishSubject;
import ly.warp.sdk.R;
import ly.warp.sdk.io.models.Coupon;
import ly.warp.sdk.io.models.CouponList;
import ly.warp.sdk.io.models.Merchant;
import ly.warp.sdk.utils.WarplyManagerHelper;
public class ActiveCouponAdapter extends RecyclerView.Adapter<ActiveCouponAdapter.ActiveCouponViewHolder> {
......@@ -92,30 +94,61 @@ public class ActiveCouponAdapter extends RecyclerView.Adapter<ActiveCouponAdapte
@Override
public void onBindViewHolder(final ActiveCouponViewHolder holder, int position) {
Coupon couponItem = mCoupons.get(position);
Merchant merchant = new Merchant();
if (mIsPast)
holder.ivCouponBackground.setColorFilter(ContextCompat.getColor(mContext, R.color.grey_light3), android.graphics.PorterDuff.Mode.MULTIPLY);
if (couponItem != null) {
if (!TextUtils.isEmpty(couponItem.getImage())) {
Glide.with(mContext)
if (WarplyManagerHelper.getMerchantList() != null && WarplyManagerHelper.getMerchantList().size() > 0) {
for (Merchant mer : WarplyManagerHelper.getMerchantList()) {
if (mer.getUuid().equals(couponItem.getMerchantUuid())) {
merchant = mer;
break;
}
}
}
if (merchant == null) {
if (!TextUtils.isEmpty(couponItem.getImage())) {
Glide.with(mContext)
// .setDefaultRequestOptions(
// RequestOptions
// .placeholderOf(R.drawable.ic_default_contact_photo)
// .error(R.drawable.ic_default_contact_photo))
.load(couponItem.getImage())
.diskCacheStrategy(DiskCacheStrategy.DATA)
.into(holder.ivCouponLogo);
.load(couponItem.getImage())
.diskCacheStrategy(DiskCacheStrategy.DATA)
.into(holder.ivCouponLogo);
} else {
Glide.with(mContext)
.load(R.drawable.ic_cosmote_logo_horizontal_grey)
.into(holder.ivCouponLogo);
}
holder.tvCouponTitle.setText(couponItem.getName());
if (!mIsPast)
holder.tvCouponDescription.setText(couponItem.getDescription());
} else {
Glide.with(mContext)
.load(R.drawable.ic_cosmote_logo_horizontal_grey)
.into(holder.ivCouponLogo);
if (!TextUtils.isEmpty(merchant.getImage())) {
Glide.with(mContext)
// .setDefaultRequestOptions(
// RequestOptions
// .placeholderOf(R.drawable.ic_default_contact_photo)
// .error(R.drawable.ic_default_contact_photo))
.load(merchant.getImage())
.diskCacheStrategy(DiskCacheStrategy.DATA)
.into(holder.ivCouponLogo);
} else {
Glide.with(mContext)
.load(R.drawable.ic_cosmote_logo_horizontal_grey)
.into(holder.ivCouponLogo);
}
holder.tvCouponTitle.setText(merchant.getAdminName());
if (!mIsPast)
holder.tvCouponDescription.setText(merchant.getShortDescription());
}
holder.tvCouponTitle.setText(couponItem.getName());
if (!mIsPast)
holder.tvCouponDescription.setText(couponItem.getDescription());
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm");
Date newDate = new Date();
try {
......
......@@ -121,6 +121,8 @@
<string name="cos_wallet_text4">&#160;σε προσφορές από&#160;</string>
<string name="cos_wallet_text5">&#160;κουπόνια!</string>
<string name="cos_value2">%1$s</string>
<string name="cos_show_barcode">Εμφάνιση barcode</string>
<string name="cos_hide_barcode">Απόκρυψη barcode</string>
<string-array name="coupons_array">
<item>Κουπόνια</item>
......