aboutsummaryrefslogtreecommitdiffstats
path: root/Android
diff options
context:
space:
mode:
Diffstat (limited to 'Android')
-rw-r--r--Android/AndroidManifest.xml2
-rwxr-xr-xAndroid/res/xml/config.xml3
-rw-r--r--Android/src/org/apache/cordova/plugins/SoftKeyBoard.java46
3 files changed, 50 insertions, 1 deletions
diff --git a/Android/AndroidManifest.xml b/Android/AndroidManifest.xml
index 26d2a92..3daeee7 100644
--- a/Android/AndroidManifest.xml
+++ b/Android/AndroidManifest.xml
@@ -32,7 +32,7 @@
<activity
android:name=".AndroidActivity"
android:label="@string/title_activity_main"
- android:screenOrientation="portrait" android:windowSoftInputMode="adjustPan">
+ android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
diff --git a/Android/res/xml/config.xml b/Android/res/xml/config.xml
index beecbbe..cca1357 100755
--- a/Android/res/xml/config.xml
+++ b/Android/res/xml/config.xml
@@ -106,6 +106,9 @@
<feature name="InAppBrowser">
<param name="android-package" value="org.apache.cordova.InAppBrowser"/>
</feature>
+ <feature name="SoftKeyBoard">
+ <param name="android-package" value="org.apache.cordova.plugins.SoftKeyBoard"/>
+ </feature>
<!-- Deprecated plugins element. Remove in 3.0 -->
<plugins>
</plugins>
diff --git a/Android/src/org/apache/cordova/plugins/SoftKeyBoard.java b/Android/src/org/apache/cordova/plugins/SoftKeyBoard.java
new file mode 100644
index 0000000..18940e1
--- /dev/null
+++ b/Android/src/org/apache/cordova/plugins/SoftKeyBoard.java
@@ -0,0 +1,46 @@
+package org.apache.cordova.plugins;
+
+import org.json.JSONArray;
+import android.content.Context;
+import android.view.inputmethod.InputMethodManager;
+import org.apache.cordova.api.CordovaPlugin;
+import org.apache.cordova.api.CallbackContext;
+
+public class SoftKeyBoard extends CordovaPlugin {
+public SoftKeyBoard () { }
+
+public void showKeyBoard () {
+ InputMethodManager mgr = (InputMethodManager) cordova.getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
+ mgr.showSoftInput(webView, InputMethodManager.SHOW_IMPLICIT);
+ ((InputMethodManager) cordova.getActivity().getSystemService(Context.INPUT_METHOD_SERVICE)).showSoftInput(webView, 0);
+}
+
+public void hideKeyBoard() {
+ InputMethodManager mgr = (InputMethodManager) cordova.getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
+ mgr.hideSoftInputFromWindow(webView.getWindowToken(), 0);
+}
+
+public boolean isKeyBoardShowing() {
+ // if more than 100 pixels, its probably a keyboard...
+ int heightDiff = webView.getRootView().getHeight() - webView.getHeight();
+ return (100 < heightDiff);
+}
+
+@Override
+public boolean execute(String action, JSONArray args, CallbackContext callbackContext) {
+ if (action.equals("show")) {
+ this.showKeyBoard();
+ callbackContext.success("done");
+ return true;
+ } else if (action.equals("hide")) {
+ this.hideKeyBoard();
+ callbackContext.success();
+ return true;
+ } else if (action.equals("isShowing")) {
+ callbackContext.success(Boolean.toString(this.isKeyBoardShowing()));
+ return true;
+ } else {
+ return false;
+ }
+}
+}