You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2013/10/10 18:13:18 UTC
git commit: CB-3747 Fix back button having different dismiss logic
from the close button.
Updated Branches:
refs/heads/dev 8cd786b60 -> 8df4b7d03
CB-3747 Fix back button having different dismiss logic from the close button.
Also made the IAB close when the owner page is navigated (implemented
onReset).
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/commit/8df4b7d0
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/tree/8df4b7d0
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/diff/8df4b7d0
Branch: refs/heads/dev
Commit: 8df4b7d03b3766cce03e26f996dfa3b54e417f04
Parents: 8cd786b
Author: Andrew Grieve <ag...@chromium.org>
Authored: Thu Oct 10 11:49:00 2013 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Thu Oct 10 11:51:58 2013 -0400
----------------------------------------------------------------------
src/android/InAppBrowser.java | 71 +++++++++++++++++++++-----------------
1 file changed, 40 insertions(+), 31 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/blob/8df4b7d0/src/android/InAppBrowser.java
----------------------------------------------------------------------
diff --git a/src/android/InAppBrowser.java b/src/android/InAppBrowser.java
index dfe1a50..940a409 100644
--- a/src/android/InAppBrowser.java
+++ b/src/android/InAppBrowser.java
@@ -18,20 +18,6 @@
*/
package org.apache.cordova.inappbrowser;
-import java.util.HashMap;
-import java.util.StringTokenizer;
-
-
-import org.apache.cordova.Config;
-import org.apache.cordova.CordovaWebView;
-import org.apache.cordova.CallbackContext;
-import org.apache.cordova.CordovaPlugin;
-import org.apache.cordova.LOG;
-import org.apache.cordova.PluginResult;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
import android.annotation.SuppressLint;
import android.app.Dialog;
import android.content.Context;
@@ -52,11 +38,7 @@ import android.view.WindowManager.LayoutParams;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.webkit.CookieManager;
-import android.webkit.WebChromeClient;
-import android.webkit.GeolocationPermissions.Callback;
-import android.webkit.JsPromptResult;
import android.webkit.WebSettings;
-import android.webkit.WebStorage;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;
@@ -64,6 +46,19 @@ import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
+import org.apache.cordova.CallbackContext;
+import org.apache.cordova.Config;
+import org.apache.cordova.CordovaPlugin;
+import org.apache.cordova.CordovaWebView;
+import org.apache.cordova.LOG;
+import org.apache.cordova.PluginResult;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.HashMap;
+import java.util.StringTokenizer;
+
@SuppressLint("SetJavaScriptEnabled")
public class InAppBrowser extends CordovaPlugin {
@@ -157,7 +152,6 @@ public class InAppBrowser extends CordovaPlugin {
}
else if (action.equals("close")) {
closeDialog();
- this.callbackContext.success();
}
else if (action.equals("injectScriptCode")) {
String jsWrapper = null;
@@ -215,6 +209,22 @@ public class InAppBrowser extends CordovaPlugin {
}
/**
+ * Called when the view navigates.
+ */
+ @Override
+ public void onReset() {
+ closeDialog();
+ }
+
+ /**
+ * Called by AccelBroker when listener is to be shut down.
+ * Stop listener.
+ */
+ public void onDestroy() {
+ closeDialog();
+ }
+
+ /**
* Inject an object (script or style) into the InAppBrowser WebView.
*
* This is a helper method for the inject{Script|Style}{Code|File} API calls, which
@@ -442,14 +452,7 @@ public class InAppBrowser extends CordovaPlugin {
dialog.setCancelable(true);
dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
public void onDismiss(DialogInterface dialog) {
- try {
- JSONObject obj = new JSONObject();
- obj.put("type", EXIT_EVENT);
-
- sendUpdate(obj, false);
- } catch (JSONException e) {
- Log.d(LOG_TAG, "Should never happen");
- }
+ closeDialog();
}
});
@@ -624,10 +627,16 @@ public class InAppBrowser extends CordovaPlugin {
*
* @param obj a JSONObject contain event payload information
* @param status the status code to return to the JavaScript environment
- */ private void sendUpdate(JSONObject obj, boolean keepCallback, PluginResult.Status status) {
- PluginResult result = new PluginResult(status, obj);
- result.setKeepCallback(keepCallback);
- this.callbackContext.sendPluginResult(result);
+ */
+ private void sendUpdate(JSONObject obj, boolean keepCallback, PluginResult.Status status) {
+ if (callbackContext != null) {
+ PluginResult result = new PluginResult(status, obj);
+ result.setKeepCallback(keepCallback);
+ callbackContext.sendPluginResult(result);
+ if (!keepCallback) {
+ callbackContext = null;
+ }
+ }
}