Skip to content

Commit

Permalink
Apply fix from ionic-team/capacitor#2924
Browse files Browse the repository at this point in the history
  • Loading branch information
Tony Zappia committed Jun 2, 2021
1 parent 0408e72 commit 72d38ad
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/android/CDVIonicKeyboard.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import android.view.View;
import android.view.ViewTreeObserver;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.view.WindowInsets;
import android.view.inputmethod.InputMethodManager;

// import additionally required classes for calculating screen height
Expand Down Expand Up @@ -90,18 +91,20 @@ public void onGlobalLayout() {
// cache properties for later use
int rootViewHeight = rootView.getRootView().getHeight();
int resultBottom = r.bottom;

// calculate screen height differently for android versions >= 21: Lollipop 5.x, Marshmallow 6.x
//http://stackoverflow.com/a/29257533/3642890 beware of nexus 5
int screenHeight;

if (Build.VERSION.SDK_INT >= 21) {
if (Build.VERSION.SDK_INT >= 23) {
WindowInsets windowInsets = rootView.getRootWindowInsets();
int stableInsetBottom = windowInsets.getStableInsetBottom();
screenHeight = rootViewHeight;
resultBottom = resultBottom + stableInsetBottom;
} else {
// calculate screen height differently for android versions <23: Lollipop 5.x, Marshmallow 6.x
//http://stackoverflow.com/a/29257533/3642890 beware of nexus 5
Display display = cordova.getActivity().getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
screenHeight = size.y;
} else {
screenHeight = rootViewHeight;
}

int heightDiff = screenHeight - resultBottom;
Expand Down

0 comments on commit 72d38ad

Please sign in to comment.