Panagiotis Triantafyllou

new unified coupons screen with basket part1

......@@ -7,8 +7,10 @@ import android.os.Handler;
import android.os.Looper;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
......@@ -30,6 +32,7 @@ import ly.warp.sdk.utils.WarplyManagerHelper;
import ly.warp.sdk.utils.managers.WarplyAnalyticsManager;
import ly.warp.sdk.utils.managers.WarplyEventBusManager;
import ly.warp.sdk.utils.managers.WarplyManager;
import ly.warp.sdk.views.adapters.ActiveCouponAdapter;
import ly.warp.sdk.views.adapters.MarketCouponAdapter;
......@@ -43,11 +46,16 @@ public class ActiveUnifiedCouponsActivity extends Activity implements View.OnCli
// Fields
// ===========================================================
private ImageView mIvBack;
private RecyclerView mRecyclerUnifiedCoupons;
private ImageView mIvBack, mIvInfo, mIvInfoClose, mIvChooseAll;
private RecyclerView mRecyclerUnifiedCoupons, mRvActiveUnifiedCoupons;
private MarketCouponAdapter mAdapterUnifiedCoupons;
private TextView mTvEmptyUnifiedCoupons, mFontHeader;
private boolean mUnifiedPressed = false;
private TextView mTvEmptyUnifiedCoupons, mFontHeader, mTvInnerTitle,
mTvInnerSubtitle, mTvInnerClose, mTvUnifieCouponsTitle, mTvActiveUnifiedCouponsTitle,
mTvChooseAll;
private boolean mUnifiedPressed = false, mActiveUnifiedPressed = false;
private ConstraintLayout mClInfoView, mClActiveCouponsHeader;
private RelativeLayout mRlUnifiedCoupons, mRlActiveUnifiedCoupons;
private ActiveCouponAdapter mAdapterCoupons;
// ===========================================================
// Methods for/from SuperClass/Interfaces
......@@ -62,8 +70,26 @@ public class ActiveUnifiedCouponsActivity extends Activity implements View.OnCli
mTvEmptyUnifiedCoupons = findViewById(R.id.tv_no_unified_coupons);
mRecyclerUnifiedCoupons = findViewById(R.id.rv_active_unified_coupons);
mFontHeader = findViewById(R.id.textView3);
WarpUtils.renderCustomFont(this, R.font.bt_cosmo_bold, mFontHeader);
WarpUtils.renderCustomFont(this, R.font.peridot_regular, mTvEmptyUnifiedCoupons);
mIvInfo = findViewById(R.id.iv_coupons_info);
mClInfoView = findViewById(R.id.cl_info_view);
mTvInnerTitle = mClInfoView.findViewById(R.id.tv_inner_title);
mTvInnerSubtitle = mClInfoView.findViewById(R.id.tv_inner_subtitle);
mIvInfoClose = mClInfoView.findViewById(R.id.iv_loyalty_history_close);
mTvInnerClose = mClInfoView.findViewById(R.id.tv_inner_close);
mRlUnifiedCoupons = findViewById(R.id.rl_unified_coupons);
mRecyclerUnifiedCoupons = mRlUnifiedCoupons.findViewById(R.id.rv_active_unified_coupons);
mTvUnifieCouponsTitle = mRlUnifiedCoupons.findViewById(R.id.tv_sm_coupons_title);
mRlActiveUnifiedCoupons = findViewById(R.id.rl_active_unified_coupons);
mRvActiveUnifiedCoupons = mRlActiveUnifiedCoupons.findViewById(R.id.rv_active_single_unified_coupons);
mClActiveCouponsHeader = findViewById(R.id.cl_active_sm_coupons_title);
mTvActiveUnifiedCouponsTitle = mClActiveCouponsHeader.findViewById(R.id.tv_active_sm_coupons_title);
mTvChooseAll = mClActiveCouponsHeader.findViewById(R.id.tv_choose_all);
mIvChooseAll = mClActiveCouponsHeader.findViewById(R.id.iv_choose_all);
WarpUtils.renderCustomFont(this, R.font.bt_cosmo_bold, mFontHeader, mTvInnerTitle,
mTvUnifieCouponsTitle, mTvActiveUnifiedCouponsTitle);
WarpUtils.renderCustomFont(this, R.font.peridot_regular, mTvEmptyUnifiedCoupons, mTvInnerSubtitle);
WarpUtils.renderCustomFont(this, R.font.peridot_bold, mTvInnerClose);
WarpUtils.renderCustomFont(this, R.font.peridot_semi_bold, mTvChooseAll);
initViews();
}
......@@ -73,6 +99,7 @@ public class ActiveUnifiedCouponsActivity extends Activity implements View.OnCli
super.onResume();
WarplyAnalyticsManager.logTrackersEvent(this, "screen", "ActiveUnifiedCouponsScreen");
mUnifiedPressed = false;
mActiveUnifiedPressed = false;
filterItems();
}
......@@ -106,6 +133,18 @@ public class ActiveUnifiedCouponsActivity extends Activity implements View.OnCli
public void onClick(View view) {
if (view.getId() == R.id.iv_coupons_close) {
onBackPressed();
return;
}
if (view.getId() == R.id.iv_coupons_info) {
mClInfoView.setVisibility(View.VISIBLE);
return;
}
if (view.getId() == R.id.iv_loyalty_history_close || view.getId() == R.id.tv_inner_close) {
mClInfoView.setVisibility(View.GONE);
return;
}
if (view.getId() == R.id.iv_choose_all) {
}
}
......@@ -115,10 +154,20 @@ public class ActiveUnifiedCouponsActivity extends Activity implements View.OnCli
private void initViews() {
mIvBack.setOnClickListener(this);
mIvInfo.setOnClickListener(this);
mIvInfoClose.setOnClickListener(this);
mTvInnerClose.setOnClickListener(this);
mIvChooseAll.setOnClickListener(this);
}
private void filterItems() {
if (WarplyManagerHelper.getMarketCouponsList() != null && WarplyManagerHelper.getMarketCouponsList().size() > 0) {
if (WarplyManagerHelper.getMarketCouponsList() != null && WarplyManagerHelper.getMarketCouponsList().isEmpty()
&& WarplyManagerHelper.getSmCouponsList() != null && WarplyManagerHelper.getSmCouponsList().isEmpty()) {
mTvEmptyUnifiedCoupons.setVisibility(View.VISIBLE);
}
if (WarplyManagerHelper.getMarketCouponsList() != null && !WarplyManagerHelper.getMarketCouponsList().isEmpty()) {
ArrayList<UnifiedCoupon> unilist = new ArrayList<UnifiedCoupon>();
for (UnifiedCoupon unicpn : WarplyManagerHelper.getMarketCouponsList()) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
......@@ -151,9 +200,38 @@ public class ActiveUnifiedCouponsActivity extends Activity implements View.OnCli
.doOnError(error -> {
})
.subscribe();
mRlUnifiedCoupons.setVisibility(View.VISIBLE);
} else {
mRecyclerUnifiedCoupons.setVisibility(View.GONE);
mTvEmptyUnifiedCoupons.setVisibility(View.VISIBLE);
mRlUnifiedCoupons.setVisibility(View.GONE);
}
if (WarplyManagerHelper.getSmCouponsList() != null && !WarplyManagerHelper.getSmCouponsList().isEmpty()) {
Collections.sort(WarplyManagerHelper.getSmCouponsList(), (coupon1, coupon2) -> coupon2.getExpirationDate().compareTo(coupon1.getExpirationDate()));
mRvActiveUnifiedCoupons.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
mAdapterCoupons = new ActiveCouponAdapter(this, WarplyManagerHelper.getSmCouponsList(), false, false, true);
mRvActiveUnifiedCoupons.setAdapter(mAdapterCoupons);
mAdapterCoupons.getPositionClicks()
.doOnNext(coupon -> {
if (!mActiveUnifiedPressed) {
mActiveUnifiedPressed = true;
WarplyAnalyticsManager.logTrackersEvent(this, "click", ("MarketCoupon").concat(":").concat(coupon.getName()));
Intent intent = new Intent(ActiveUnifiedCouponsActivity.this, CouponInfoActivity.class);
intent.putExtra("coupon", coupon.getCoupon());
intent.putExtra("isFromWallet", true);
// intent.putExtra("isUnified", true);
// intent.putExtra("unifiedCoupon", coupon.getBarcode());
startActivity(intent);
}
})
.doOnError(error -> {
})
.subscribe();
mRlActiveUnifiedCoupons.setVisibility(View.VISIBLE);
} else {
mRlActiveUnifiedCoupons.setVisibility(View.GONE);
}
}
......
......@@ -21,6 +21,8 @@ import com.bumptech.glide.load.engine.DiskCacheStrategy;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import io.reactivex.Observable;
......@@ -36,7 +38,8 @@ public class ActiveCouponAdapter extends RecyclerView.Adapter<ActiveCouponAdapte
private Context mContext;
private CouponList mCoupons;
private final PublishSubject<Coupon> onClickSubject = PublishSubject.create();
private boolean mIsPast = false, mIsCustom = false;
private boolean mIsPast = false, mIsCustom = false, mIsActiveSM = false;
private Set<Coupon> mSelectedItems = new HashSet<>();
public ActiveCouponAdapter(Context mContext, CouponList campaignList) {
this.mContext = mContext;
......@@ -57,11 +60,19 @@ public class ActiveCouponAdapter extends RecyclerView.Adapter<ActiveCouponAdapte
this.mIsCustom = custom;
}
public ActiveCouponAdapter(Context mContext, CouponList campaignList, boolean past, boolean custom, boolean isActiveSM) {
this.mContext = mContext;
this.mCoupons = campaignList;
this.mIsPast = past;
this.mIsCustom = custom;
this.mIsActiveSM = isActiveSM;
}
public class ActiveCouponViewHolder extends RecyclerView.ViewHolder {
private ImageView ivCouponLogo, ivCouponBackground;
private ImageView ivCouponLogo, ivCouponBackground, ivChooseCoupon;
private TextView tvCouponTitle, tvCouponValue, tvCouponDate, tvDateLimit,
tvCouponDescription, tvCouponDateExpired, tvDateLimitTitle;
private ConstraintLayout clCustomLayout;
private ConstraintLayout clCustomLayout, clActiveCustomLayout;
private LinearLayout lLDateLimit;
public ActiveCouponViewHolder(View view) {
......@@ -73,10 +84,12 @@ public class ActiveCouponAdapter extends RecyclerView.Adapter<ActiveCouponAdapte
tvCouponDate = view.findViewById(R.id.tv_active_coupons_date);
tvCouponDescription = view.findViewById(R.id.tv_active_coupons_description);
clCustomLayout = view.findViewById(R.id.cl_custom_layout);
clActiveCustomLayout = view.findViewById(R.id.cl_active_custom_layout);
tvCouponDateExpired = view.findViewById(R.id.tv_active_coupons_date_expired);
tvDateLimit = view.findViewById(R.id.tv_active_coupons_date_limit);
tvDateLimitTitle = view.findViewById(R.id.tv_active_coupons_date_limit_title);
lLDateLimit = view.findViewById(R.id.ll_date_limit);
ivChooseCoupon = view.findViewById(R.id.iv_choose_coupon);
WarpUtils.renderCustomFont(mContext, R.font.bt_cosmo_bold, tvCouponTitle, tvCouponValue);
WarpUtils.renderCustomFont(mContext, R.font.peridot_regular, tvCouponDescription, tvCouponDate);
......@@ -111,6 +124,8 @@ public class ActiveCouponAdapter extends RecyclerView.Adapter<ActiveCouponAdapte
itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.past_coupon_layout, parent, false);
else if (mIsCustom)
itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.custom_coupon_layout, parent, false);
else if (mIsActiveSM)
itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.custom_active_coupon_layout, parent, false);
else
itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.active_coupon_layout, parent, false);
return new ActiveCouponViewHolder(itemView);
......@@ -120,6 +135,7 @@ public class ActiveCouponAdapter extends RecyclerView.Adapter<ActiveCouponAdapte
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) {
......@@ -218,6 +234,28 @@ public class ActiveCouponAdapter extends RecyclerView.Adapter<ActiveCouponAdapte
return;
}
if (mIsActiveSM) {
if (mSelectedItems.contains(couponItem)) {
holder.ivChooseCoupon.setBackgroundResource(R.drawable.ic_circle_checked_skyblue);
holder.clActiveCustomLayout.setBackgroundResource(R.drawable.ic_coupon_background_new3_border_skyblue);
} else {
holder.ivChooseCoupon.setBackgroundResource(R.drawable.ic_circle_gray);
holder.clActiveCustomLayout.setBackgroundResource(R.drawable.ic_coupon_background_new3);
}
holder.ivChooseCoupon.setOnClickListener(v -> {
if (mSelectedItems.contains(couponItem)) {
mSelectedItems.remove(couponItem);
holder.ivChooseCoupon.setBackgroundResource(R.drawable.ic_circle_gray);
holder.clActiveCustomLayout.setBackgroundResource(R.drawable.ic_coupon_background_new3);
} else {
mSelectedItems.add(couponItem);
holder.ivChooseCoupon.setBackgroundResource(R.drawable.ic_circle_checked_skyblue);
holder.clActiveCustomLayout.setBackgroundResource(R.drawable.ic_coupon_background_new3_border_skyblue);
}
});
}
if (!TextUtils.isEmpty(couponItem.getMerchantDetails().getImgPreview())) {
Glide.with(mContext)
// .setDefaultRequestOptions(
......@@ -285,6 +323,10 @@ public class ActiveCouponAdapter extends RecyclerView.Adapter<ActiveCouponAdapte
}
}
public Set<Coupon> getSelectedCoupons() {
return mSelectedItems;
}
private long getDaysBetweenDates(String start, String end) {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
Date startDate, endDate;
......
<?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Shadow layer -->
<!-- <item>-->
<!-- <shape android:shape="rectangle">-->
<!-- <solid android:color="#00000000" /> &lt;!&ndash; Transparent color &ndash;&gt;-->
<!-- <corners android:radius="20dp" />-->
<!-- <padding/>-->
<!-- <size android:width="0dp" android:height="0dp"/>-->
<!-- <gradient-->
<!-- android:startColor="#00000091"-->
<!-- android:endColor="#00000000"-->
<!-- android:angle="270"/>-->
<!-- </shape>-->
<!-- </item>-->
<!-- Background layer -->
<item>
<shape android:shape="rectangle">
<solid android:color="@color/cos_grey2" /> <!-- Background color -->
<corners android:radius="14dp" /> <!-- Rounded corners -->
</shape>
</item>
</layer-list>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:custom="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="145dp"
android:layout_marginHorizontal="6dp"
android:layout_marginBottom="3dp"
android:id="@+id/cl_active_custom_layout"
android:background="@drawable/ic_coupon_background_new3">
<androidx.constraintlayout.widget.Guideline
android:id="@+id/gl_vertical_72_percent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.72" />
<ImageView
android:id="@+id/iv_active_coupon"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_marginStart="24dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:src="@drawable/ic_gifts_for_you" />
<ly.warp.sdk.views.DividerView
android:id="@+id/v_separator"
android:layout_width="1dp"
android:layout_height="0dp"
android:layout_marginVertical="16dp"
android:layout_marginStart="16dp"
android:layerType="software"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/iv_active_coupon"
app:layout_constraintTop_toTopOf="parent"
custom:color="@color/cos_gray"
custom:dashGap="10dp"
custom:dashLength="10dp"
custom:dashThickness="1dp"
custom:orientation="vertical" />
<LinearLayout
android:id="@+id/ll_coupon_info"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/v_separator"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="@+id/tv_active_coupons_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:textColor="@color/cos_light_black"
android:textSize="16sp"
tools:text="Εκπτωτικο κουπονι 10$ για αγορες στα ΙΚΕΑ" />
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.constraintlayout.widget.Guideline
android:id="@+id/gl_vertical_62_percent_inner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.62" />
<TextView
android:id="@+id/tv_active_coupons_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/cos_light_black"
android:textSize="42sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="10$" />
<TextView
android:id="@+id/tv_active_coupons_description"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="3"
android:textColor="@color/cos_light_black"
android:textSize="12sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toEndOf="@+id/gl_vertical_62_percent_inner"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.545"
tools:text="Εκπτωση με ελάχιστες αγορές 100€" />
</androidx.constraintlayout.widget.ConstraintLayout>
<TextView
android:id="@+id/tv_active_coupons_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/cos_light_black"
android:textSize="12sp"
tools:text="@string/cos_active_coupon_date" />
</LinearLayout>
<ImageView
android:id="@+id/iv_choose_coupon"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:src="@drawable/ic_circle_gray" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
......@@ -75,6 +75,9 @@
<string name="cos_no_active_rewards">Δεν υπάρχουν δώρα</string>
<string name="cos_past_all_coupons">Παλαιότερα κουπόνια</string>
<string name="cos_coupon_expired_date">Εξαργυρώθηκε την %1$s</string>
<string name="cos_coupon_unified_title">Ενιαία κουπόνια</string>
<string name="cos_coupon_active_unified_title">Κουπόνια</string>
<string name="cos_coupon_active_unified_choose_all_title">Επιλογή όλων</string>
<string name="cos_popup_gifts_title">COSMOTE GIFTS FOR YOU</string>
<string name="cos_popup_gifts_subtitle">Σε αυτή την ενότητα βρίσκεις τα διαθέσιμα δώρα και επιβραβεύσεις αποκλειστικά για σένα!</string>
<string name="cos_mycoupon_date">Το κουπόνι ισχύει έως %1$s</string>
......@@ -165,6 +168,8 @@
<string name="cos_dlg_no_shops_positive">Δες το eshop</string>
<string name="cos_profile_preferences_placeholder">Οι προτιμήσεις μου</string>
<string name="cos_market_title">SUPERMARKET DEALS</string>
<string name="cos_market_subtitle">Δημιούργησε το δικό σου ενιαίο κουπόνι προσφορών, και εξαργύρωσέ το στα supermarket της επιλογής σου γρήγορα και εύκολα με ένα μόνο κωδικό κουπονιού!</string>
<string name="cos_market_close">Τέλος</string>
<string name="cos_rewards_title2">COSMOTE Επιβράβευση</string>
<string name="cos_market_item_title">COSMOTE\nSUPERMARKET\nDEALS</string>
<string name="cos_market_active_coupons">έχεις %1$s ενεργά κουπόνια αξίας %2$s€</string>
......