11package io .snabble .sdk .ui .checkout ;
22
33import android .content .Context ;
4+ import android .content .res .Resources ;
45import android .support .annotation .NonNull ;
56import android .util .AttributeSet ;
67import android .view .View ;
@@ -28,6 +29,7 @@ class CheckoutEncodedCodesView extends FrameLayout implements View.OnLayoutChang
2829 private View scrollContainer ;
2930 private ScrollView scrollView ;
3031 private TextView explanationText ;
32+ private TextView explanationText2 ;
3133 private SnabbleSdk sdkInstance ;
3234 private int codeCount ;
3335
@@ -75,10 +77,11 @@ public void onClick(View v) {
7577 textView .setText (getContext ().getString (R .string .Snabble_PaymentSelection_title ) + " " + formattedAmount );
7678
7779 explanationText = findViewById (R .id .explanation1 );
80+ explanationText2 = findViewById (R .id .explanation2 );
7881 }
7982
80- private void updateExplanationText (int codeCount ){
81- if (codeCount > 1 ) {
83+ private void updateExplanationText (int codeCount ) {
84+ if (codeCount > 1 ) {
8285 explanationText .setText (R .string .Snabble_QRCode_showTheseCodes );
8386 } else {
8487 explanationText .setText (R .string .Snabble_QRCode_showThisCode );
@@ -102,14 +105,22 @@ protected void onDetachedFromWindow() {
102105 @ Override
103106 public void onLayoutChange (View v , int left , int top , int right , int bottom ,
104107 int oldLeft , int oldTop , int oldRight , int oldBottom ) {
105- if (left != oldLeft || top != oldTop || right != oldRight || bottom != oldBottom ) {
106- if (scrollContainer .getWidth () > 0 && scrollContainer .getHeight () > 0 ) {
108+ if (left != oldLeft || top != oldTop || right != oldRight || bottom != oldBottom ) {
109+ if (scrollContainer .getWidth () > 0 && scrollContainer .getHeight () > 0 ) {
107110 scrollView .removeAllViews ();
108111 CodeListView codeListView = new CodeListView (getContext ());
109112 scrollView .addView (codeListView , new ViewGroup .LayoutParams (
110113 ViewGroup .LayoutParams .MATCH_PARENT ,
111114 ViewGroup .LayoutParams .WRAP_CONTENT ));
112115 }
116+
117+ Resources resources = getResources ();
118+
119+ int h = Math .round (scrollContainer .getHeight () * resources .getDisplayMetrics ().density );
120+ if (h < 160 ) {
121+ explanationText .setVisibility (View .GONE );
122+ explanationText2 .setVisibility (View .GONE );
123+ }
113124 }
114125 }
115126
@@ -129,7 +140,7 @@ public CodeListView(@NonNull Context context) {
129140
130141 addCodes ();
131142
132- if (getChildCount () == 0 ){
143+ if (getChildCount () == 0 ) {
133144 barcodeHeight = h ;
134145 }
135146
@@ -147,16 +158,16 @@ private void addCodes() {
147158
148159 for (int i = 0 ; i < shoppingCart .size (); i ++) {
149160 Product product = shoppingCart .getProduct (i );
150- if (product .getType () == Product .Type .UserWeighed ){
161+ if (product .getType () == Product .Type .UserWeighed ) {
151162 //encoding weight in ean
152163 String [] weighItemIds = product .getWeighedItemIds ();
153- if (weighItemIds != null && weighItemIds .length > 0 ){
164+ if (weighItemIds != null && weighItemIds .length > 0 ) {
154165 StringBuilder code = new StringBuilder (weighItemIds [0 ]);
155- if (code .length () == 13 ){
166+ if (code .length () == 13 ) {
156167 StringBuilder embeddedWeight = new StringBuilder ();
157168 String quantity = String .valueOf (shoppingCart .getQuantity (i ));
158169 int leadingZeros = 5 - quantity .length ();
159- for (int j = 0 ; j < leadingZeros ; j ++){
170+ for (int j = 0 ; j < leadingZeros ; j ++) {
160171 embeddedWeight .append ('0' );
161172 }
162173 embeddedWeight .append (quantity );
@@ -201,7 +212,7 @@ private void addScannableCode(String scannableCode) {
201212 generateView ();
202213 }
203214
204- if (stringBuilder .length () == 0 ){
215+ if (stringBuilder .length () == 0 ) {
205216 stringBuilder .append (sdkInstance .getEncodedCodesPrefix ());
206217 } else {
207218 stringBuilder .append (sdkInstance .getEncodedCodesSeperator ());
0 commit comments