Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(android): incorrect keyboard height #2924

Merged
merged 3 commits into from
Jun 10, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import android.view.Display;
import android.view.View;
import android.view.ViewTreeObserver;
import android.view.WindowInsets;
import android.view.inputmethod.InputMethodManager;

import com.getcapacitor.JSObject;
Expand Down Expand Up @@ -54,18 +55,19 @@ 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 - stableInsetBottom;
jcesarmobile marked this conversation as resolved.
Show resolved Hide resolved
} 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 = getActivity().getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
screenHeight = size.y;
} else {
screenHeight = rootViewHeight;
}

int heightDiff = screenHeight - resultBottom;
Expand Down