Skip to content

Commit 9f3a0da

Browse files
committed
- improved checkout status layout
- now using android:listDivider attribute for dividers
1 parent c13c9e8 commit 9f3a0da

File tree

10 files changed

+47
-239
lines changed

10 files changed

+47
-239
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# Changelog
22
All notable changes to this project will be documented in this file.
33

4+
## [0.12.2]
5+
6+
### Changed
7+
- Improved layout of checkout status screen
8+
- List dividers are now using the style attribute android:listDivider
9+
- The color snabble_dividerColor is removed
10+
411
## [0.12.1]
512

613
### Fixed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ allprojects {
2323
}
2424

2525
project.ext {
26-
sdkVersion='0.12.1'
26+
sdkVersion='0.12.2'
2727
versionCode=1
2828

2929
compileSdkVersion=28

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,6 @@ private void inflateView(Context context, AttributeSet attrs) {
127127

128128
DividerItemDecoration itemDecoration = new DividerItemDecoration(recyclerView.getContext(),
129129
layoutManager.getOrientation());
130-
int dividerColor = ResourcesCompat.getColor(getResources(), R.color.snabble_dividerColor, null);
131-
itemDecoration.setDrawable(new ColorDrawable(dividerColor));
132130
recyclerView.addItemDecoration(itemDecoration);
133131

134132
coordinatorLayout = findViewById(R.id.coordinator_layout);

ui/src/main/java/io/snabble/sdk/ui/checkout/CheckoutStatusView.java

Lines changed: 1 addition & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,9 @@
2424
import io.snabble.sdk.ui.telemetry.Telemetry;
2525

2626
class CheckoutStatusView extends FrameLayout implements Checkout.OnCheckoutStateChangedListener {
27-
private ViewGroup[] steps;
28-
private int currentStep;
2927
private Checkout checkout;
3028
private BarcodeView checkoutIdCode;
3129

32-
private Handler handler = new Handler(Looper.getMainLooper());
33-
3430
public CheckoutStatusView(Context context) {
3531
super(context);
3632
inflateView();
@@ -48,12 +44,6 @@ public CheckoutStatusView(Context context, AttributeSet attrs, int defStyleAttr)
4844

4945
private void inflateView() {
5046
inflate(getContext(), R.layout.view_checkout_status, this);
51-
currentStep = 0;
52-
53-
steps = new ViewGroup[3];
54-
steps[0] = findViewById(R.id.step1);
55-
steps[1] = findViewById(R.id.step2);
56-
steps[2] = findViewById(R.id.step3);
5747

5848
checkoutIdCode = findViewById(R.id.checkout_id_code);
5949

@@ -71,68 +61,14 @@ public void onClick(View v) {
7161
}
7262
});
7363

74-
for(View v : steps) {
75-
ImageView imageView = v.findViewWithTag("image");
76-
ProgressBar progressBar = v.findViewWithTag("progress");
77-
78-
int color = 0x1d1f2440;
79-
progressBar.getIndeterminateDrawable().setColorFilter(color, PorterDuff.Mode.SRC_IN);
80-
progressBar.getProgressDrawable().setColorFilter(color, PorterDuff.Mode.SRC_IN);
81-
progressBar.setIndeterminate(false);
82-
progressBar.setProgress(0);
83-
84-
// tinting the white backgrounded images with the background color
85-
// so they appear seamless
86-
ImageViewCompat.setImageTintMode(imageView, PorterDuff.Mode.MULTIPLY);
87-
TypedValue a = new TypedValue();
88-
getContext().getTheme().resolveAttribute(android.R.attr.windowBackground, a, true);
89-
if (a.type >= TypedValue.TYPE_FIRST_COLOR_INT && a.type <= TypedValue.TYPE_LAST_COLOR_INT) {
90-
ImageViewCompat.setImageTintList(imageView, ColorStateList.valueOf(a.data));
91-
}
92-
}
93-
9464
if (SnabbleUI.getActionBar() != null) {
95-
SnabbleUI.getActionBar().setTitle(R.string.Snabble_Checkout_verifying);
65+
SnabbleUI.getActionBar().setTitle(R.string.Snabble_Payment_confirm);
9666
}
9767

9868
checkout = SnabbleUI.getProject().getCheckout();
9969
onStateChanged(checkout.getState());
10070
}
10171

102-
private void setStep(int step) {
103-
currentStep = step;
104-
105-
if (currentStep < steps.length) {
106-
crossFade(steps[currentStep]);
107-
108-
int nextStep = currentStep + 1;
109-
if (nextStep < steps.length) {
110-
ProgressBar progressBar = steps[nextStep].findViewWithTag("progress");
111-
progressBar.setIndeterminate(true);
112-
}
113-
}
114-
}
115-
116-
private void crossFade(final ViewGroup vg) {
117-
ImageView imageView = vg.findViewWithTag("image");
118-
ImageView imageView2 = vg.findViewWithTag("image_ok");
119-
ProgressBar progressBar = vg.findViewWithTag("progress");
120-
121-
imageView.animate()
122-
.alpha(0f)
123-
.setInterpolator(new AccelerateDecelerateInterpolator())
124-
.setDuration(500)
125-
.start();
126-
127-
imageView2.animate()
128-
.alpha(1f)
129-
.setInterpolator(new AccelerateDecelerateInterpolator())
130-
.setDuration(500)
131-
.start();
132-
133-
progressBar.setVisibility(View.INVISIBLE);
134-
}
135-
13672
@Override
13773
protected void onAttachedToWindow() {
13874
super.onAttachedToWindow();
@@ -159,17 +95,6 @@ public void onStateChanged(Checkout.State state) {
15995
if (id != null) {
16096
checkoutIdCode.setText(id);
16197
}
162-
setStep(0);
163-
break;
164-
case PAYMENT_APPROVED:
165-
setStep(1);
166-
Telemetry.event(Telemetry.Event.CheckoutSuccessful);
167-
handler.postDelayed(new Runnable() {
168-
@Override
169-
public void run() {
170-
setStep(2);
171-
}
172-
}, 1000);
17398
break;
17499
case DENIED_BY_PAYMENT_PROVIDER:
175100
Telemetry.event(Telemetry.Event.CheckoutDeniedByPaymentProvider);

ui/src/main/java/io/snabble/sdk/ui/payment/PaymentCredentialsListView.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ private void inflateView() {
6363
recyclerView.setItemAnimator(null);
6464

6565
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL);
66-
int dividerColor = ResourcesCompat.getColor(getResources(), R.color.snabble_dividerColor, null);
67-
dividerItemDecoration.setDrawable(new ColorDrawable(dividerColor));
6866
recyclerView.addItemDecoration(dividerItemDecoration);
6967

7068
View fab = findViewById(R.id.fab);

ui/src/main/java/io/snabble/sdk/ui/payment/PaymentCredentialsSelectView.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,6 @@ public void click() {
6969
recyclerView.setItemAnimator(null);
7070

7171
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL);
72-
int dividerColor = ResourcesCompat.getColor(getResources(), R.color.snabble_dividerColor, null);
73-
dividerItemDecoration.setDrawable(new ColorDrawable(dividerColor));
7472
recyclerView.addItemDecoration(dividerItemDecoration);
7573
}
7674

ui/src/main/res/layout/item_bundle_select.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<View
1313
android:layout_width="match_parent"
1414
android:layout_height="1px"
15-
android:background="@color/snabble_dividerColor" />
15+
android:background="?android:attr/listDivider" />
1616

1717
<TextView
1818
android:layout_width="wrap_content"

ui/src/main/res/layout/view_checkout_status.xml

Lines changed: 34 additions & 154 deletions
Original file line numberDiff line numberDiff line change
@@ -5,177 +5,57 @@
55
android:layout_width="match_parent"
66
android:layout_height="wrap_content">
77

8-
<com.google.android.flexbox.FlexboxLayout
8+
<LinearLayout
99
android:layout_width="match_parent"
1010
android:layout_height="match_parent"
11-
android:layout_above="@+id/bottom_container"
12-
android:paddingTop="8dp"
13-
android:paddingBottom="8dp"
14-
app:flexDirection="column"
15-
app:justifyContent="center"
16-
app:flexWrap="nowrap">
17-
<FrameLayout
18-
android:id="@+id/step1"
11+
android:orientation="vertical"
12+
android:gravity="center">
13+
<io.snabble.sdk.ui.scanner.BarcodeView
14+
android:id="@+id/checkout_id_code"
1915
android:layout_width="match_parent"
20-
android:layout_height="wrap_content"
21-
android:layout_gravity="center_horizontal"
22-
app:layout_maxHeight="80dp"
23-
app:layout_flexGrow="1">
24-
25-
<ProgressBar
26-
style="?android:attr/progressBarStyleHorizontal"
27-
android:layout_width="match_parent"
28-
android:layout_height="wrap_content"
29-
android:layout_gravity="bottom"
30-
android:layout_marginBottom="4dp"
31-
android:tag="progress" />
32-
33-
<androidx.appcompat.widget.AppCompatImageView
34-
android:layout_width="60dp"
35-
android:layout_height="60dp"
36-
android:adjustViewBounds="true"
37-
android:layout_gravity="bottom|center_horizontal"
38-
android:scaleType="centerInside"
39-
android:src="@drawable/ic_verify_1"
40-
android:tag="image" />
41-
42-
<androidx.appcompat.widget.AppCompatImageView
43-
android:layout_width="60dp"
44-
android:layout_height="60dp"
45-
android:adjustViewBounds="true"
46-
android:layout_gravity="bottom|center_horizontal"
47-
android:alpha="0"
48-
android:scaleType="centerInside"
49-
android:src="@drawable/ic_verify_ok"
50-
android:tag="image_ok" />
51-
</FrameLayout>
16+
android:layout_height="168dp"
17+
android:background="?android:attr/windowBackground"
18+
app:format="DATA_MATRIX"
19+
tools:ignore="RtlHardcoded" />
5220

5321
<TextView
54-
android:layout_width="wrap_content"
55-
android:layout_height="wrap_content"
56-
android:layout_gravity="center_horizontal"
57-
app:layout_maxHeight="48dp"
58-
app:layout_flexGrow="0.5"
59-
android:gravity="center"
60-
android:text="@string/Snabble.PaymentStatus.step1"
61-
android:textSize="15sp" />
62-
63-
<FrameLayout
64-
android:id="@+id/step2"
22+
android:id="@+id/message"
6523
android:layout_width="match_parent"
6624
android:layout_height="wrap_content"
67-
android:layout_gravity="center_horizontal"
68-
app:layout_maxHeight="80dp"
69-
app:layout_flexGrow="1">
70-
71-
<ProgressBar
72-
style="?android:attr/progressBarStyleHorizontal"
73-
android:layout_width="match_parent"
74-
android:layout_height="wrap_content"
75-
android:layout_gravity="bottom"
76-
android:layout_marginBottom="4dp"
77-
android:tag="progress" />
78-
79-
<androidx.appcompat.widget.AppCompatImageView
80-
android:layout_width="60dp"
81-
android:layout_height="60dp"
82-
android:adjustViewBounds="true"
83-
android:layout_gravity="bottom|center_horizontal"
84-
android:scaleType="centerInside"
85-
android:src="@drawable/ic_verify_2"
86-
android:tag="image" />
87-
88-
<androidx.appcompat.widget.AppCompatImageView
89-
android:layout_width="60dp"
90-
android:layout_height="60dp"
91-
android:adjustViewBounds="true"
92-
android:layout_gravity="bottom|center_horizontal"
93-
android:alpha="0"
94-
android:scaleType="centerInside"
95-
android:src="@drawable/ic_verify_ok"
96-
android:tag="image_ok" />
97-
</FrameLayout>
98-
99-
<TextView
100-
android:layout_width="wrap_content"
101-
android:layout_height="wrap_content"
102-
android:layout_gravity="center_horizontal"
103-
app:layout_maxHeight="48dp"
104-
app:layout_flexGrow="0.5"
25+
android:layout_gravity="center"
10526
android:gravity="center"
106-
android:text="@string/Snabble.PaymentStatus.step2"
107-
android:textSize="15sp" />
108-
109-
<FrameLayout
110-
android:id="@+id/step3"
111-
android:layout_width="match_parent"
112-
android:layout_height="wrap_content"
113-
android:layout_gravity="center_horizontal"
114-
app:layout_maxHeight="80dp"
115-
app:layout_flexGrow="1">
116-
117-
<ProgressBar
118-
style="?android:attr/progressBarStyleHorizontal"
119-
android:layout_width="match_parent"
120-
android:layout_height="wrap_content"
121-
android:layout_gravity="bottom"
122-
android:layout_marginBottom="4dp"
123-
android:tag="progress" />
124-
125-
<androidx.appcompat.widget.AppCompatImageView
126-
android:layout_width="60dp"
127-
android:layout_height="60dp"
128-
android:adjustViewBounds="true"
129-
android:layout_gravity="bottom|center_horizontal"
130-
android:scaleType="centerInside"
131-
android:src="@drawable/ic_verify_3"
132-
android:tag="image" />
133-
134-
<androidx.appcompat.widget.AppCompatImageView
135-
android:layout_width="60dp"
136-
android:layout_height="60dp"
137-
android:layout_gravity="bottom|center_horizontal"
138-
android:alpha="0"
139-
android:scaleType="centerInside"
140-
android:src="@drawable/ic_verify_ok"
141-
android:tag="image_ok" />
142-
</FrameLayout>
27+
android:padding="16dp"
28+
android:text="@string/Snabble.Payment.presentCode"
29+
android:textSize="17sp" />
14330

144-
<TextView
31+
<ProgressBar
14532
android:layout_width="wrap_content"
14633
android:layout_height="wrap_content"
147-
android:layout_gravity="center_horizontal"
148-
app:layout_maxHeight="48dp"
149-
app:layout_flexGrow="0.5"
150-
android:gravity="center"
151-
android:text="@string/Snabble.PaymentStatus.step3"
152-
android:textSize="15sp" />
153-
</com.google.android.flexbox.FlexboxLayout>
154-
155-
<FrameLayout
156-
android:id="@+id/bottom_container"
157-
android:layout_width="match_parent"
158-
android:layout_height="wrap_content"
159-
android:layout_alignParentBottom="true">
34+
android:layout_marginTop="16dp"
35+
android:indeterminate="true"/>
16036

16137
<TextView
162-
android:id="@+id/cancel"
38+
android:id="@+id/waiting"
16339
android:layout_width="match_parent"
16440
android:layout_height="wrap_content"
16541
android:layout_gravity="center"
16642
android:gravity="center"
167-
android:padding="16dp"
168-
android:text="@string/Snabble.Cancel"
169-
android:textColor="@color/snabble_primaryColor"
43+
android:paddingTop="4dp"
44+
android:paddingLeft="16dp"
45+
android:paddingRight="16dp"
46+
android:text="@string/Snabble.Payment.waiting"
17047
android:textSize="17sp" />
48+
</LinearLayout>
17149

172-
<io.snabble.sdk.ui.scanner.BarcodeView
173-
android:id="@+id/checkout_id_code"
174-
android:layout_width="80dp"
175-
android:layout_height="80dp"
176-
android:layout_gravity="right"
177-
android:padding="8dp"
178-
app:format="DATA_MATRIX"
179-
tools:ignore="RtlHardcoded" />
180-
</FrameLayout>
50+
<TextView
51+
android:id="@+id/cancel"
52+
android:layout_width="match_parent"
53+
android:layout_height="wrap_content"
54+
android:layout_gravity="center"
55+
android:layout_alignParentBottom="true"
56+
android:gravity="center"
57+
android:padding="16dp"
58+
android:text="@string/Snabble.Cancel"
59+
android:textColor="@color/snabble_primaryColor"
60+
android:textSize="17sp" />
18161
</RelativeLayout>

ui/src/main/res/values/colors.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
<color name="snabble_textColorDark">#1D1F24</color>
1414
<color name="snabble_textColorAction">@color/snabble_primaryColor</color>
1515
<color name="snabble_textColorError">#ff0000</color>
16-
<color name="snabble_dividerColor">#D8D8D8</color>
1716
<color name="snabble_backgroundColorDark">#0d0d0d</color>
1817
<color name="snabble_black">#1D1F24</color>
1918
</resources>

0 commit comments

Comments
 (0)