@@ -1074,36 +1074,29 @@ public void postMessage(String data) {
10741074 webViewLayout .addView (footer );
10751075 }
10761076
1077- WindowManager .LayoutParams lp = new WindowManager .LayoutParams ();
1078- lp .copyFrom (dialog .getWindow ().getAttributes ());
1079- lp .width = WindowManager .LayoutParams .MATCH_PARENT ;
1080-
1077+ int windowHeight = WindowManager .LayoutParams .MATCH_PARENT ;
1078+
10811079 if (bottomReduceHeightBy != 0 ) {
10821080 // Resize the window if it has to be reduced to less than the available screen height
10831081 DisplayMetrics displayMetrics = new DisplayMetrics ();
10841082 cordova .getActivity ().getWindowManager ().getDefaultDisplay ().getMetrics (displayMetrics );
10851083
10861084 // Make sure to convert height to density independent pixels (dip)
1087- // The height is reduced by 1 pixel to correct 1 pixel dip error on high resolution/density devices
1088- int reducedHeightDip = (int ) ((float ) bottomReduceHeightBy * displayMetrics .density ) - 1 ;
1085+ int reducedHeightDip = (int ) ((float ) bottomReduceHeightBy * displayMetrics .density );
10891086
1090- // Calculate visible display size
1091- // Note that the visible display height differs from the device height by the status bar height if the device does not have a notch
1092- // In devices with a notch, they are the same
1087+ // Calculate status bar height
10931088 Rect rectangle = new Rect ();
10941089 cordova .getActivity ().getWindow ().getDecorView ().getWindowVisibleDisplayFrame (rectangle );
1090+ int statusBarHeightDip = rectangle .top ;
10951091
1096- // Note that device height - visible display height is zero in devices with a notch, non zero on other devices
1097- lp .height = rectangle .height () - reducedHeightDip ;
1098-
1099- // Make sure the dialog is aligned to the bottom of the status bar as it is centered by default
1100- lp .gravity = Gravity .TOP ;
1092+ windowHeight = rectangle .height () + statusBarHeightDip - reducedHeightDip ;
11011093 }
11021094
11031095 if (dialog != null ) {
11041096 dialog .setContentView (main );
11051097 dialog .show ();
1106- dialog .getWindow ().setAttributes (lp );
1098+ dialog .getWindow ().setGravity (Gravity .TOP );
1099+ dialog .getWindow ().setLayout (WindowManager .LayoutParams .MATCH_PARENT , windowHeight );
11071100
11081101 if (bottomReduceHeightBy != 0 ) {
11091102 // Ensure the parent window respond to clicks when the web view is displayed on top of it
0 commit comments