From 893ecec55e575a2be50a370f5235bded8ce934b1 Mon Sep 17 00:00:00 2001 From: Joe Bowser Date: Fri, 27 Jul 2012 10:33:38 -0700 Subject: [PATCH 1/3] Minor fix to deal with weird keyboard focus issues and the back button. CB-1146 --- .../src/org/apache/cordova/CordovaWebView.java | 8 +++++++- framework/src/org/apache/cordova/DroidGap.java | 15 +++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/framework/src/org/apache/cordova/CordovaWebView.java b/framework/src/org/apache/cordova/CordovaWebView.java index 234ff65c..30b65b37 100755 --- a/framework/src/org/apache/cordova/CordovaWebView.java +++ b/framework/src/org/apache/cordova/CordovaWebView.java @@ -81,6 +81,8 @@ public class CordovaWebView extends WebView { private boolean volumeupBound; + private boolean handleButton = false; + /** * Constructor. * @@ -749,7 +751,6 @@ public class CordovaWebView extends WebView { return super.onKeyUp(keyCode, event); } - Log.d(TAG, "KeyUp has been triggered on the view"); return false; } @@ -788,6 +789,7 @@ public class CordovaWebView extends WebView { public void handlePause(boolean keepRunning) { + LOG.d(TAG, "Handle the pause"); // Send pause event to JavaScript this.loadUrl("javascript:try{cordova.fireDocumentEvent('pause');}catch(e){console.log('exception firing pause event from native');};"); @@ -843,4 +845,8 @@ public class CordovaWebView extends WebView { this.pluginManager.onNewIntent(intent); } } + + public boolean hadKeyEvent() { + return handleButton; + } } diff --git a/framework/src/org/apache/cordova/DroidGap.java b/framework/src/org/apache/cordova/DroidGap.java index 4d6df528..a42f16cd 100755 --- a/framework/src/org/apache/cordova/DroidGap.java +++ b/framework/src/org/apache/cordova/DroidGap.java @@ -1032,5 +1032,20 @@ public class DroidGap extends Activity implements CordovaInterface { } return null; } + + /* + * (non-Javadoc) + * @see android.app.Activity#onKeyUp(int, android.view.KeyEvent) + */ + + @Override + public boolean onKeyUp(int keyCode, KeyEvent event) + { + if (appView.backHistory() || keyCode != KeyEvent.KEYCODE_BACK) + return appView.onKeyUp(keyCode, event); + else + return super.onKeyUp(keyCode, event); + } + } From f2afa4dd5093e3a9def488c15a3e3bff6ee50c5a Mon Sep 17 00:00:00 2001 From: Joe Bowser Date: Fri, 27 Jul 2012 13:31:25 -0700 Subject: [PATCH 2/3] Tweaking the Android Manfest to cope with new target changes: CB-1147 --- bin/templates/project/AndroidManifest.xml | 6 +++--- framework/AndroidManifest.xml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/templates/project/AndroidManifest.xml b/bin/templates/project/AndroidManifest.xml index 0cff488c..9e9abcdf 100644 --- a/bin/templates/project/AndroidManifest.xml +++ b/bin/templates/project/AndroidManifest.xml @@ -48,8 +48,8 @@ - + @@ -57,5 +57,5 @@ - + diff --git a/framework/AndroidManifest.xml b/framework/AndroidManifest.xml index a2676834..92f66f44 100755 --- a/framework/AndroidManifest.xml +++ b/framework/AndroidManifest.xml @@ -51,7 +51,7 @@ + android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale"> From 3d53b9244d84cac9bdee445b7c07ffeb41a550bf Mon Sep 17 00:00:00 2001 From: Andrew Grieve Date: Mon, 16 Jul 2012 13:26:40 -0400 Subject: [PATCH 3/3] Adds FileTransfer support for upload headers. -Support previously existed via options.params.headers. This CL deprecates this (undocumented) way of adding headers and adds support for options.headers. -This also adds support for multiple headers via: options.headers = {"Name": ["Value1", "Value2"]}. --- .../src/org/apache/cordova/FileTransfer.java | 39 ++++++++++++------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/framework/src/org/apache/cordova/FileTransfer.java b/framework/src/org/apache/cordova/FileTransfer.java index 2b2620ba..4adace5b 100644 --- a/framework/src/org/apache/cordova/FileTransfer.java +++ b/framework/src/org/apache/cordova/FileTransfer.java @@ -115,6 +115,11 @@ public class FileTransfer extends Plugin { if (params == null) params = new JSONObject(); boolean trustEveryone = args.optBoolean(6); boolean chunkedMode = args.optBoolean(7) || args.isNull(7); //Always use chunked mode unless set to false as per API + JSONObject headers = args.optJSONObject(8); + // Look for headers on the params map for backwards compatibility with older Cordova versions. + if (headers == null && params != null) { + headers = params.optJSONObject("headers"); + } Log.d(LOG_TAG, "fileKey: " + fileKey); Log.d(LOG_TAG, "fileName: " + fileName); @@ -122,6 +127,7 @@ public class FileTransfer extends Plugin { Log.d(LOG_TAG, "params: " + params); Log.d(LOG_TAG, "trustEveryone: " + trustEveryone); Log.d(LOG_TAG, "chunkedMode: " + chunkedMode); + Log.d(LOG_TAG, "headers: " + headers); // Create return object FileUploadResult result = new FileUploadResult(); @@ -177,25 +183,32 @@ public class FileTransfer extends Plugin { conn.setRequestMethod("POST"); conn.setRequestProperty("Connection", "Keep-Alive"); conn.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + BOUNDARY); - - // Handle the other headers - try { - JSONObject headers = params.getJSONObject("headers"); - for (Iterator iter = headers.keys(); iter.hasNext();) - { - String headerKey = iter.next().toString(); - conn.setRequestProperty(headerKey, headers.getString(headerKey)); - } - } catch (JSONException e1) { - // No headers to be manipulated! - } - + // Set the cookies on the response String cookie = CookieManager.getInstance().getCookie(target); if (cookie != null) { conn.setRequestProperty("Cookie", cookie); } + // Handle the other headers + if (headers != null) { + try { + for (Iterator iter = headers.keys(); iter.hasNext(); ) { + String headerKey = iter.next().toString(); + JSONArray headerValues = headers.optJSONArray(headerKey); + if (headerValues == null) { + headerValues = new JSONArray(); + headerValues.put(headers.getString(headerKey)); + } + conn.setRequestProperty(headerKey, headerValues.getString(0)); + for (int i = 1; i < headerValues.length(); ++i) { + conn.addRequestProperty(headerKey, headerValues.getString(i)); + } + } + } catch (JSONException e1) { + // No headers to be manipulated! + } + } /* * Store the non-file portions of the multipart data as a string, so that we can add it