Skip to content

Commit 6cf8678

Browse files
authored
Merge pull request #19 from snabble/accessibility_improvements
APPS-159 Support dynamic typing
2 parents ceaa1f1 + b0b8eda commit 6cf8678

File tree

41 files changed

+145
-124
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+145
-124
lines changed

java-sample/src/main/res/layout/activity_main.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
android:layout_gravity="center"
1717
android:gravity="center"
1818
android:visibility="gone"
19+
android:textAppearance="?attr/textAppearanceBodyLarge"
1920
android:id="@+id/sdk_error" />
2021

2122
<FrameLayout

java-sample/src/main/res/layout/item_dropdown.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
33
android:layout_width="match_parent" android:layout_height="wrap_content"
44
android:padding="8dp"
5-
android:textSize="16sp"/>
5+
android:textAppearance="?attr/textAppearanceBodyLarge"/>

kotlin-sample/src/main/res/layout/activity_loading.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
android:layout_width="wrap_content"
1010
android:layout_height="wrap_content"
1111
android:layout_gravity="center"
12+
android:textAppearance="?attr/textAppearanceBodyLarge"
1213
android:text="Loading" />
1314

1415
</FrameLayout>

kotlin-sample/src/main/res/layout/fragment_home.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
android:layout_marginTop="8dp"
1717
android:layout_marginEnd="8dp"
1818
android:textAlignment="center"
19-
android:textSize="20sp"
19+
android:textAppearance="?attr/textAppearanceBodyLarge"
2020
android:text="Welcome to the snabble SDK Sample!" />
2121

2222
<Button
@@ -27,5 +27,6 @@
2727
android:layout_marginTop="8dp"
2828
android:layout_marginEnd="8dp"
2929
android:textAlignment="center"
30+
android:textAppearance="?attr/textAppearanceBodyLarge"
3031
android:text="Show payment credentials"/>
3132
</LinearLayout>

kotlin-sample/src/main/res/layout/fragment_success.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
android:layout_marginEnd="8dp"
1616
android:textAlignment="center"
1717
android:layout_gravity="center"
18-
android:text="Custom success screen"
19-
android:textSize="20sp" />
18+
android:textAppearance="?attr/textAppearanceBodyLarge"
19+
android:text="Custom success screen" />
2020
</FrameLayout>

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

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
import android.webkit.WebChromeClient;
1414
import android.webkit.WebView;
1515
import android.webkit.WebViewClient;
16-
import android.widget.FrameLayout;
1716
import android.widget.ProgressBar;
17+
import android.widget.RelativeLayout;
1818
import android.widget.TextView;
1919
import android.widget.Toast;
2020

@@ -52,7 +52,7 @@
5252
import okhttp3.RequestBody;
5353
import okhttp3.Response;
5454

55-
public class CreditCardInputView extends FrameLayout {
55+
public class CreditCardInputView extends RelativeLayout {
5656
public static final String ARG_PROJECT_ID = "projectId";
5757
public static final String ARG_PAYMENT_TYPE = "paymentType";
5858

@@ -69,6 +69,7 @@ public class CreditCardInputView extends FrameLayout {
6969
private String projectId;
7070
private Project lastProject;
7171
private TextView threeDHint;
72+
private boolean isLoaded;
7273

7374
public CreditCardInputView(Context context) {
7475
super(context);
@@ -130,9 +131,36 @@ public void onProgressChanged(WebView view, final int newProgress) {
130131
threeDHint = findViewById(R.id.threed_secure_hint);
131132
threeDHint.setVisibility(View.GONE);
132133

134+
watchForBigSizeChanges();
133135
requestHash();
134136
}
135137

138+
public void watchForBigSizeChanges() {
139+
addOnLayoutChangeListener(new OnLayoutChangeListener() {
140+
int highestHeight = 0;
141+
142+
@Override
143+
public void onLayoutChange(View v, int left, int top, int right, int bottom,
144+
int oldLeft, int oldTop, int oldRight, int oldBottom) {
145+
int height = bottom - top;
146+
highestHeight = Math.max(highestHeight, height);
147+
if (height < highestHeight) {
148+
threeDHint.setVisibility(View.GONE);
149+
150+
// for some reason the WebView bounds do not update itself on layout changes
151+
webView.setLeft(getLeft());
152+
webView.setTop(getTop());
153+
webView.setRight(getRight());
154+
webView.setBottom(getBottom());
155+
} else {
156+
if (isLoaded) {
157+
threeDHint.setVisibility(View.VISIBLE);
158+
}
159+
}
160+
}
161+
});
162+
}
163+
136164
public void load(String projectId, PaymentMethod paymentType) {
137165
this.projectId = projectId;
138166
this.paymentType = paymentType;
@@ -232,7 +260,12 @@ private void loadForm(HashResponse hashResponse) {
232260
NumberFormat numberFormat = NumberFormat.getCurrencyInstance(project.getCurrencyLocale());
233261
BigDecimal chargeTotal = new BigDecimal(hashResponse.chargeTotal);
234262
threeDHint.setVisibility(View.VISIBLE);
235-
threeDHint.setText(resources.getString(R.string.Snabble_CC_3dsecureHint_retailerWithPrice, numberFormat.format(chargeTotal), companyName));
263+
threeDHint.setText(
264+
resources.getString(R.string.Snabble_CC_3dsecureHint_retailerWithPrice,
265+
numberFormat.format(chargeTotal),
266+
companyName)
267+
);
268+
isLoaded = true;
236269
} catch (IOException e) {
237270
Logger.e(e.getMessage());
238271
threeDHint.setVisibility(View.GONE);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
android:layout_height="wrap_content"
3535
android:layout_gravity="center_horizontal"
3636
android:gravity="center"
37-
android:textSize="15sp"
37+
android:textAppearance="?attr/textAppearanceBodyMedium"
3838
android:layout_marginBottom="16dp"
3939
android:text="@string/Snabble.Scanner.BundleDialog.headline" />
4040

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

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
android:layout_below="@+id/close"
2929
android:layout_centerHorizontal="true"
3030
android:layout_marginBottom="4dp"
31-
android:textSize="14sp"
31+
android:textAppearance="?attr/textAppearanceBodyMedium"
3232
tools:text="Wiha" />
3333

3434
<TextView
@@ -43,7 +43,7 @@
4343
android:layout_marginEnd="8dp"
4444
android:layout_marginRight="8dp"
4545
android:gravity="center"
46-
android:textSize="16sp"
46+
android:textAppearance="?attr/textAppearanceBodyLarge"
4747
tools:text="Schraubendreher Top G 8,0x1,2" />
4848

4949
<TextView
@@ -53,7 +53,7 @@
5353
android:layout_below="@+id/name"
5454
android:layout_centerHorizontal="true"
5555
android:gravity="center"
56-
android:textSize="15sp"
56+
android:textAppearance="?attr/textAppearanceBodyMedium"
5757
android:alpha="0.6"
5858
android:layout_marginBottom="4dp"
5959
tools:text="1,29 €" />
@@ -65,7 +65,7 @@
6565
android:layout_below="@+id/originalPrice"
6666
android:layout_centerHorizontal="true"
6767
android:gravity="center"
68-
android:textSize="20sp"
68+
android:textAppearance="?attr/textAppearanceTitleLarge"
6969
tools:text="2 × 1,00 € = 2,00 €" />
7070

7171
<TextView
@@ -75,7 +75,7 @@
7575
android:layout_below="@+id/price"
7676
android:layout_centerHorizontal="true"
7777
android:layout_marginTop="4dp"
78-
android:textSize="12sp"
78+
android:textAppearance="?attr/textAppearanceBodySmall"
7979
tools:text="+ 0,45 € deposit" />
8080

8181
<com.google.android.material.button.MaterialButton
@@ -86,7 +86,7 @@
8686
android:layout_below="@+id/depositPrice"
8787
android:layout_centerHorizontal="true"
8888
android:layout_marginBottom="-16dp"
89-
android:textSize="14sp"
89+
android:textAppearance="?attr/textAppearanceBodyMedium"
9090
tools:text="Reduzierten Preis eingeben"
9191
tools:textColor="#c40000" />
9292

@@ -138,7 +138,7 @@
138138
android:focusableInTouchMode="true"
139139
android:gravity="center"
140140
android:inputType="number"
141-
android:textSize="16sp"
141+
android:textAppearance="?attr/textAppearanceBodyLarge"
142142
android:text="1" />
143143

144144
</com.google.android.material.textfield.TextInputLayout>
@@ -178,7 +178,7 @@
178178
android:layout_marginStart="4dp"
179179
android:layout_toEndOf="@+id/quantity_text_input"
180180
android:layout_toRightOf="@+id/quantity_text_input"
181-
android:textSize="17sp"
181+
android:textAppearance="?attr/textAppearanceBodyLarge"
182182
android:visibility="gone"
183183
tools:text="g" />
184184

@@ -192,10 +192,7 @@
192192
android:layout_marginLeft="16dp"
193193
android:layout_marginTop="16dp"
194194
android:layout_marginRight="16dp"
195-
android:text="@string/Snabble.Scanner.addToCart"
196-
app:autoSizeMaxTextSize="16sp"
197-
app:autoSizeMinTextSize="8sp"
198-
app:autoSizeTextType="uniform" />
195+
android:text="@string/Snabble.Scanner.addToCart" />
199196

200197

201198
<!-- invisible view as a margin, marginBottom does not work on API 16-18 -->

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@
2727
android:layout_width="wrap_content"
2828
android:layout_height="wrap_content"
2929
android:gravity="center"
30-
android:textSize="17sp"
31-
android:textStyle="bold"
30+
android:textAppearance="?attr/textAppearanceTitleMedium"
3231
android:text="@string/Snabble.SEPA.mandate"/>
3332

3433
<ScrollView
@@ -40,7 +39,7 @@
4039
android:layout_width="wrap_content"
4140
android:layout_height="wrap_content"
4241
android:gravity="center"
43-
android:textSize="13sp"
42+
android:textAppearance="?attr/textAppearanceBodySmall"
4443
tools:text="Ich ermächtige Lebensmittelmärkte snabble GmbH, einmalig eine Zahlung von meinem Konto mittels Lastschrift einzuziehen."/>
4544
</ScrollView>
4645
</LinearLayout>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
android:layout_height="wrap_content"
99
android:layout_gravity="center"
1010
android:visibility="gone"
11+
android:textAppearance="?attr/textAppearanceBodyLarge"
1112
android:text="The snabble SDK is not initialized."/>
1213

1314
<FrameLayout

0 commit comments

Comments
 (0)