Skip to content

Commit a5718a8

Browse files
committed
Merge branch 'active_manual_coupons'
2 parents ab13595 + adbda9b commit a5718a8

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

core/src/main/java/io/snabble/sdk/ShoppingCart.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,14 @@ public ItemType getType() {
672672
return null;
673673
}
674674

675+
public boolean isManualCouponApplied() {
676+
if (lineItem != null) {
677+
return lineItem.priceModifiers.size() > 0; // TODO that is not correct
678+
}
679+
680+
return false;
681+
}
682+
675683
public boolean isEditable() {
676684
if (coupon != null) {
677685
return false;

ui/src/main/java/io/snabble/sdk/ui/cart/ShoppingCartView.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
import android.app.Activity;
55
import android.app.Application;
66
import android.content.Context;
7+
import android.content.res.ColorStateList;
78
import android.content.res.Resources;
9+
import android.graphics.Color;
10+
import android.graphics.ColorMatrix;
11+
import android.graphics.ColorMatrixColorFilter;
812
import android.text.Editable;
913
import android.text.InputFilter;
1014
import android.text.TextWatcher;
@@ -21,6 +25,7 @@
2125

2226
import androidx.annotation.DrawableRes;
2327
import androidx.appcompat.app.AlertDialog;
28+
import androidx.core.widget.TextViewCompat;
2429
import androidx.fragment.app.FragmentActivity;
2530
import androidx.recyclerview.widget.DefaultItemAnimator;
2631
import androidx.recyclerview.widget.DiffUtil;
@@ -619,13 +624,19 @@ public void bindTo(final ProductRow row, boolean hasAnyImages) {
619624
boolean hasCoupon = row.item.getCoupon() != null;
620625
boolean isAgeRestricted = false;
621626

627+
redLabel.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#ff0000")));
628+
622629
if (row.item.getProduct() != null) {
623630
isAgeRestricted = row.item.getProduct().getSaleRestriction().isAgeRestriction();
624631
}
625632

626633
redLabel.setVisibility(hasCoupon || isAgeRestricted ? View.VISIBLE : View.GONE);
627634

628635
if (hasCoupon) {
636+
if (!row.item.isManualCouponApplied()) {
637+
redLabel.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#999999")));
638+
}
639+
629640
redLabel.setText("%");
630641
} else {
631642
long age = row.item.getProduct().getSaleRestriction().getValue();

0 commit comments

Comments
 (0)