aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Android/AndroidManifest.xml2
-rwxr-xr-xAndroid/res/xml/config.xml3
-rw-r--r--Android/src/org/apache/cordova/plugins/SoftKeyBoard.java46
-rw-r--r--src/css/fms.css2
-rw-r--r--src/index.html1
-rw-r--r--src/js/app.js2
-rw-r--r--src/js/map-OpenLayers.js8
-rw-r--r--src/js/softkeyboard.js35
-rw-r--r--src/js/views/fms.js6
9 files changed, 96 insertions, 9 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;
+ }
+}
+}
diff --git a/src/css/fms.css b/src/css/fms.css
index f7c55a3..abcb6bb 100644
--- a/src/css/fms.css
+++ b/src/css/fms.css
@@ -415,7 +415,7 @@
#map_box{
background-color: rgba(0,0,0,0);
position: fixed;
- top: 45px, left: 0, right: 0, bottom: 0;
+ top: 0px, left: 0, right: 0, bottom: 0;
padding: 0px;
display:block;
height: 100%;
diff --git a/src/index.html b/src/index.html
index 3d8162b..8805c76 100644
--- a/src/index.html
+++ b/src/index.html
@@ -22,6 +22,7 @@
<script type="text/javascript" src="jslib/jquery.mobile-1.3.1.min.js"></script>
<script type="text/javascript" src="jslib/moment-2.0.0.min.js"></script>
<script type="text/javascript" src="../cordova.js"></script>
+ <script type="text/javascript" src="js/softkeyboard.js"></script>
<script type="text/javascript" src="jslib/lodash.min.js"></script>
<script type="text/javascript" src="jslib/backbone-min.js"></script>
diff --git a/src/js/app.js b/src/js/app.js
index 757507b..1818b6e 100644
--- a/src/js/app.js
+++ b/src/js/app.js
@@ -260,6 +260,8 @@ var tpl = {
FMS.currentUser = new FMS.User({id: 1});
}
+ FMS.windowHeight = $(window).height();
+
if ( localStorage.usedBefore ) {
FMS.usedBefore = 1;
}
diff --git a/src/js/map-OpenLayers.js b/src/js/map-OpenLayers.js
index 53d324e..f120391 100644
--- a/src/js/map-OpenLayers.js
+++ b/src/js/map-OpenLayers.js
@@ -202,14 +202,10 @@ OpenLayers.Map.prototype.getCurrentSize = function() {
function show_map(event) {
if (typeof fixmystreet !== 'undefined' && fixmystreet.page == 'around') {
// Immediately go full screen map if on around page
- var screen = $(window).height(),
- header = $('[data-role=header]').height(),
- footer = $('[data-role=footer]').height(),
- content = screen - header - footer;
$('#map_box').css({
position: 'fixed',
- top: 45, left: 0, right: 0, bottom: 0,
- height: content,
+ top: 0, left: 0, right: 0, bottom: 0,
+ height: $(window).height(),
margin: 0
});
} else {
diff --git a/src/js/softkeyboard.js b/src/js/softkeyboard.js
new file mode 100644
index 0000000..adffc2f
--- /dev/null
+++ b/src/js/softkeyboard.js
@@ -0,0 +1,35 @@
+(function( cordova ) {
+
+ function SoftKeyBoard() {}
+
+ SoftKeyBoard.prototype.show = function(win, fail) {
+ return cordova.exec(
+ function (args) { if(win !== undefined) { win(args); } },
+ function (args) { if(fail !== undefined) { fail(args); } },
+ "SoftKeyBoard", "show", []);
+ };
+
+ SoftKeyBoard.prototype.hide = function(win, fail) {
+ console.log('hiding keyboard');
+ return cordova.exec(
+ function (args) { if(win !== undefined) { win(args); } },
+ function (args) { if(fail !== undefined) { fail(args); } },
+ "SoftKeyBoard", "hide", []);
+ };
+
+ SoftKeyBoard.prototype.isShowing = function(win, fail) {
+ return cordova.exec(
+ function (args) { if(win !== undefined) { win(args); } },
+ function (args) { if(fail !== undefined) { fail(args); } },
+ "SoftKeyBoard", "isShowing", []);
+ };
+
+ if(!window.plugins) {
+ window.plugins = {};
+ }
+
+ if (!window.plugins.SoftKeyBoard) {
+ window.plugins.SoftKeyBoard = new SoftKeyBoard();
+ }
+
+})( window.cordova );
diff --git a/src/js/views/fms.js b/src/js/views/fms.js
index be4c84a..a6019c2 100644
--- a/src/js/views/fms.js
+++ b/src/js/views/fms.js
@@ -48,7 +48,7 @@
content = this.$(this.contentSelector),
top = content.position().top,
viewHeight = $(window).height(),
- contentHeight = viewHeight - header.outerHeight() - this.bottomMargin;
+ contentHeight = FMS.windowHeight - header.outerHeight() - this.bottomMargin;
this.setHeight( content, contentHeight - top );
},
@@ -66,6 +66,10 @@
afterDisplay: function() {},
navigate: function( route, reverse ) {
+ if ( FMS.isAndroid ) {
+ var softkeyboard = window.plugins.SoftKeyBoard;
+ softkeyboard.hide();
+ }
if ( reverse ) {
FMS.router.reverseTransition();
}