Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4471D105FF for ; Wed, 4 Mar 2015 08:35:17 +0000 (UTC) Received: (qmail 96999 invoked by uid 500); 4 Mar 2015 08:35:17 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 96874 invoked by uid 500); 4 Mar 2015 08:35:17 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 96834 invoked by uid 99); 4 Mar 2015 08:35:17 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Mar 2015 08:35:17 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 9C2B4E0F58; Wed, 4 Mar 2015 08:35:16 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: purplecabbage@apache.org To: commits@cordova.apache.org Date: Wed, 04 Mar 2015 08:35:16 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [1/4] cordova-plugin-inappbrowser git commit: Add a hardwareback option to allow for the hardware back button to go back. Repository: cordova-plugin-inappbrowser Updated Branches: refs/heads/master f4879e9e5 -> a45dbc80b Add a hardwareback option to allow for the hardware back button to go back. 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/392a73c2 Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/tree/392a73c2 Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/diff/392a73c2 Branch: refs/heads/master Commit: 392a73c2cdcfc643622832cb6d2ac218f4da082a Parents: a5dedae Author: Kris Erickson Authored: Sun Mar 9 11:33:24 2014 -0700 Committer: Kris Erickson Committed: Sun Mar 9 11:33:24 2014 -0700 ---------------------------------------------------------------------- src/android/InAppBrowser.java | 24 +++++++++++++++++++++++- src/android/InAppBrowserDialog.java | 6 +++++- 2 files changed, 28 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/blob/392a73c2/src/android/InAppBrowser.java ---------------------------------------------------------------------- diff --git a/src/android/InAppBrowser.java b/src/android/InAppBrowser.java index 796036f..ab8c4fb 100644 --- a/src/android/InAppBrowser.java +++ b/src/android/InAppBrowser.java @@ -78,6 +78,7 @@ public class InAppBrowser extends CordovaPlugin { private static final String CLOSE_BUTTON_CAPTION = "closebuttoncaption"; private static final String CLEAR_ALL_CACHE = "clearcache"; private static final String CLEAR_SESSION_CACHE = "clearsessioncache"; + private static final String HARDWARE_BACK_BUTTON = "hardwareback"; private InAppBrowserDialog dialog; private WebView inAppWebView; @@ -88,6 +89,7 @@ public class InAppBrowser extends CordovaPlugin { private String buttonLabel = "Done"; private boolean clearAllCache= false; private boolean clearSessionCache=false; + private boolean hadwareBackButton=false; /** * Executes the request and returns PluginResult. @@ -363,13 +365,29 @@ public class InAppBrowser extends CordovaPlugin { /** * Checks to see if it is possible to go back one page in history, then does so. */ - private void goBack() { + public void goBack() { if (this.inAppWebView.canGoBack()) { this.inAppWebView.goBack(); } } /** + * Can the web browser go back? + * @return boolean + */ + public boolean canGoBack() { + return this.inAppWebView.canGoBack(); + } + + /** + * Has the user set the hardware back button to go back + * @return boolean + */ + public boolean hardwareBack() { + return hadwareBackButton; + } + + /** * Checks to see if it is possible to go forward one page in history, then does so. */ private void goForward() { @@ -428,6 +446,10 @@ public class InAppBrowser extends CordovaPlugin { if (hidden != null) { openWindowHidden = hidden.booleanValue(); } + Boolean hardwareBack = features.get(HARDWARE_BACK_BUTTON); + if (hardwareBack != null) { + hadwareBackButton = hardwareBack.booleanValue(); + } Boolean cache = features.get(CLEAR_ALL_CACHE); if (cache != null) { clearAllCache = cache.booleanValue(); http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/blob/392a73c2/src/android/InAppBrowserDialog.java ---------------------------------------------------------------------- diff --git a/src/android/InAppBrowserDialog.java b/src/android/InAppBrowserDialog.java index 124e211..d701720 100644 --- a/src/android/InAppBrowserDialog.java +++ b/src/android/InAppBrowserDialog.java @@ -48,7 +48,11 @@ public class InAppBrowserDialog extends Dialog { } else { // better to go through the in inAppBrowser // because it does a clean up - this.inAppBrowser.closeDialog(); + if (this.inAppBrowser.hardwareBack() && this.inAppBrowser.canGoBack()) { + this.inAppBrowser.goBack(); + } else { + this.inAppBrowser.closeDialog(); + } } } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org For additional commands, e-mail: commits-help@cordova.apache.org