Skip to content
This repository was archived by the owner on Apr 2, 2018. It is now read-only.

Commit 77ab8f6

Browse files
committed
calculate dp's not device px
1 parent 07d1015 commit 77ab8f6

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/android/IonicKeyboard.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@ public void onGlobalLayout() {
3333
rootView.getWindowVisibleDisplayFrame(r);
3434

3535
int heightDiff = rootView.getRootView().getHeight() - (r.bottom - r.top);
36-
if (heightDiff > 200 && heightDiff != previousHeightDiff) { // if more than 200 pixels, its probably a keyboard...
37-
int keyboardHeight = (int)(heightDiff / density);
36+
int pixelHeightDiff = (int)(heightDiff / density);
37+
if (pixelHeightDiff > 100 && pixelHeightDiff != previousHeightDiff) { // if more than 100 pixels, its probably a keyboard...
3838
appView.sendJavascript("cordova.plugins.Keyboard.isVisible = true");
39-
appView.sendJavascript("cordova.fireWindowEvent('native.showkeyboard', { 'keyboardHeight':" + Integer.toString(keyboardHeight)+"});");
39+
appView.sendJavascript("cordova.fireWindowEvent('native.showkeyboard', { 'keyboardHeight':" + Integer.toString(pixelHeightDiff)+"});");
4040
}
41-
else if ( heightDiff != previousHeightDiff && ( previousHeightDiff - heightDiff ) > 200 ){
41+
else if ( pixelHeightDiff != previousHeightDiff && ( previousHeightDiff - pixelHeightDiff ) > 100 ){
4242
appView.sendJavascript("cordova.plugins.Keyboard.isVisible = false");
4343
appView.sendJavascript("cordova.fireWindowEvent('native.hidekeyboard')");
4444
}
45-
previousHeightDiff = heightDiff;
45+
previousHeightDiff = pixelHeightDiff;
4646
}
4747
};
4848

0 commit comments

Comments
 (0)