1111
1212public class IonicKeyboard extends CordovaPlugin {
1313
14- public void initialize (CordovaInterface cordova , CordovaWebView webView ) {
14+ public void initialize (CordovaInterface cordova , CordovaWebView webView ) {
1515 super .initialize (cordova , webView );
1616
1717 //calculate density-independent pixels (dp)
@@ -25,7 +25,7 @@ public void initialize(CordovaInterface cordova, CordovaWebView webView) {
2525 //http://stackoverflow.com/a/4737265/1091751 detect if keyboard is showing
2626 final View rootView = cordova .getActivity ().getWindow ().getDecorView ().findViewById (android .R .id .content ).getRootView ();
2727 OnGlobalLayoutListener list = new OnGlobalLayoutListener () {
28- int previousHeightDiff = 0 ;
28+ int previousHeightDiff = 0 ;
2929 @ Override
3030 public void onGlobalLayout () {
3131 Rect r = new Rect ();
@@ -34,13 +34,13 @@ public void onGlobalLayout() {
3434
3535 int heightDiff = rootView .getRootView ().getHeight () - (r .bottom - r .top );
3636 if (heightDiff > 200 && heightDiff != previousHeightDiff ) { // if more than 200 pixels, its probably a keyboard...
37- int keyboardHeight = (int )(heightDiff / density );
38- appView .sendJavascript ("cordova.plugins.Keyboard.isVisible = true" );
39- appView .sendJavascript ("cordova.fireWindowEvent('native.showkeyboard', { 'keyboardHeight':" + Integer .toString (keyboardHeight )+"});" );
37+ int keyboardHeight = (int )(heightDiff / density );
38+ appView .sendJavascript ("cordova.plugins.Keyboard.isVisible = true" );
39+ appView .sendJavascript ("cordova.fireWindowEvent('native.showkeyboard', { 'keyboardHeight':" + Integer .toString (keyboardHeight )+"});" );
4040 }
41- else if (heightDiff != previousHeightDiff && (previousHeightDiff - heightDiff ) > 200 ){
42- appView .sendJavascript ("cordova.plugins.Keyboard.isVisible = false" );
43- appView .sendJavascript ("cordova.fireWindowEvent('native.hidekeyboard')" );
41+ else if ( heightDiff != previousHeightDiff && ( previousHeightDiff - heightDiff ) > 200 ){
42+ appView .sendJavascript ("cordova.plugins.Keyboard.isVisible = false" );
43+ appView .sendJavascript ("cordova.fireWindowEvent('native.hidekeyboard')" );
4444 }
4545 previousHeightDiff = heightDiff ;
4646 }
0 commit comments