Skip to content

Commit 5dd2ccb

Browse files
committed
Bugfixes for qr code checkout
1 parent bc8b421 commit 5dd2ccb

File tree

5 files changed

+61
-10
lines changed

5 files changed

+61
-10
lines changed

CHANGELOG.md

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

4+
## [0.12.3]
5+
6+
### Fixed
7+
- Added missing Checkout-ID to QRCodePOS checkout types
8+
- Fixed hiding of explanation text on small displays (QVGA or smaller)
9+
- Checkout screen with QRCodePOS type now also sets the ActionBar title if an ActionBar is
10+
set with SnabbleUI.registerActionBar
11+
412
## [0.12.2]
513

614
### Changed

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.2'
26+
sdkVersion='0.12.3'
2727
versionCode=1
2828

2929
compileSdkVersion=28

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
package io.snabble.sdk.ui.checkout;
22

33
import android.content.Context;
4-
import android.content.res.Resources;
54
import android.os.Handler;
65
import android.os.Looper;
76
import androidx.annotation.NonNull;
8-
import android.util.AttributeSet;
7+
import android.util.DisplayMetrics;
98
import android.view.View;
109
import android.view.ViewGroup;
1110
import android.widget.Button;
@@ -141,10 +140,9 @@ public void run() {
141140
ViewGroup.LayoutParams.WRAP_CONTENT));
142141
}
143142

144-
Resources resources = getResources();
145-
146-
int h = Math.round(scrollContainer.getHeight() * resources.getDisplayMetrics().density);
147-
if (h < 160) {
143+
DisplayMetrics dm = getResources().getDisplayMetrics();
144+
int dpHeight = Math.round(scrollContainer.getHeight() / dm.density);
145+
if (dpHeight < 220) {
148146
explanationText.setVisibility(View.GONE);
149147
explanationText2.setVisibility(View.GONE);
150148
}

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
package io.snabble.sdk.ui.checkout;
22

33
import android.content.Context;
4+
import android.content.res.Resources;
5+
import android.os.Handler;
6+
import android.os.Looper;
47
import android.util.AttributeSet;
8+
import android.util.DisplayMetrics;
59
import android.view.View;
10+
import android.view.ViewGroup;
611
import android.widget.FrameLayout;
712
import android.widget.TextView;
813

@@ -58,6 +63,32 @@ public void onClick(View v) {
5863
payAmount.setVisibility(View.GONE);
5964
findViewById(R.id.explanation2).setVisibility(View.GONE);
6065
}
66+
67+
if (SnabbleUI.getActionBar() != null) {
68+
findViewById(R.id.explanation1).setVisibility(View.GONE);
69+
SnabbleUI.getActionBar().setTitle(R.string.Snabble_QRCode_showThisCode);
70+
}
71+
72+
TextView checkoutId = findViewById(R.id.checkout_id);
73+
String id = project.getCheckout().getId();
74+
if (id != null && id.length() >= 4) {
75+
String text = getResources().getString(R.string.Snabble_Checkout_ID);
76+
checkoutId.setText(String.format("%s: %s", text, id.substring(id.length() - 4)));
77+
} else {
78+
checkoutId.setVisibility(View.GONE);
79+
}
80+
}
81+
82+
@Override
83+
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
84+
super.onSizeChanged(w, h, oldw, oldh);
85+
86+
DisplayMetrics dm = getResources().getDisplayMetrics();
87+
int dpHeight = Math.round(h / dm.density);
88+
if (dpHeight < 400) {
89+
findViewById(R.id.explanation1).setVisibility(View.GONE);
90+
findViewById(R.id.explanation2).setVisibility(View.GONE);
91+
}
6192
}
6293

6394
public void setQRCodeText(String text) {

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

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,31 @@
44
android:layout_width="match_parent"
55
android:layout_height="match_parent"
66
android:background="#ffffff">
7+
<TextView
8+
android:id="@+id/checkout_id"
9+
android:layout_width="wrap_content"
10+
android:layout_height="wrap_content"
11+
android:gravity="center"
12+
android:layout_centerHorizontal="true"
13+
android:layout_alignParentTop="true"
14+
tools:text="Checkout-ID: a64b"
15+
android:textColor="@color/snabble_textColorDark"
16+
android:layout_marginTop="16dp"
17+
android:layout_marginLeft="24dp"
18+
android:layout_marginRight="24dp"
19+
android:textStyle="bold"
20+
android:textSize="17sp" />
721

822
<TextView
923
android:id="@+id/explanation1"
1024
android:layout_width="wrap_content"
1125
android:layout_height="wrap_content"
1226
android:gravity="center"
1327
android:layout_centerHorizontal="true"
14-
android:layout_alignParentTop="true"
28+
android:layout_below="@+id/checkout_id"
1529
android:text="@string/Snabble.QRCode.showThisCode"
1630
android:textColor="@color/snabble_textColorDark"
17-
android:layout_marginTop="16dp"
31+
android:layout_marginTop="8dp"
1832
android:layout_marginLeft="24dp"
1933
android:layout_marginRight="24dp"
2034
android:textSize="17sp" />
@@ -24,7 +38,7 @@
2438
android:layout_width="match_parent"
2539
android:layout_height="match_parent"
2640
android:padding="12dp"
27-
android:layout_above="@+id/explanation2"
41+
android:layout_above="@+id/pay_amount"
2842
android:layout_below="@+id/explanation1"
2943
tools:format="QR_CODE"
3044
tools:text="357294723482348234283472834732748327493473274832749347327483274947327483274838;" />

0 commit comments

Comments
 (0)