1313import android .webkit .WebChromeClient ;
1414import android .webkit .WebView ;
1515import android .webkit .WebViewClient ;
16- import android .widget .FrameLayout ;
1716import android .widget .ProgressBar ;
17+ import android .widget .RelativeLayout ;
1818import android .widget .TextView ;
1919import android .widget .Toast ;
2020
5252import okhttp3 .RequestBody ;
5353import 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 );
0 commit comments