Skip to content

Commit

Permalink
Adding a method toggleHardwareBack to toggle the hardware back butt…
Browse files Browse the repository at this point in the history
…on functionality.
  • Loading branch information
sagrawal31 committed Mar 15, 2019
1 parent 652e47f commit 810b924
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Difference with the original repository
There are few difference/changes as compared to the original version

1. Clearing & closing the WebView after exiting the OverAppBrowser to prevent memory link in Android
2. Not closing the OverAppBrowser from Android back button
2. A method to toggle the hardware back button `toggleHardwareBack`
3. Changed id of the plugin

Installation
Expand Down
2 changes: 2 additions & 0 deletions src/android/OverAppBrowser.java
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ else if (SYSTEM.equals(target)) {
PluginResult pluginResult = new PluginResult(PluginResult.Status.OK);
pluginResult.setKeepCallback(true);
this.callbackContext.sendPluginResult(pluginResult);
} else if (action.equals("toggleHardwareBack")) {
this.hadwareBackButton = args.getBoolean(1)
} else {
return false;
}
Expand Down
17 changes: 7 additions & 10 deletions src/android/OverAppBrowserDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,8 @@ Licensed to the Apache Software Foundation (ASF) under one
*/
package com.lesfrancschatons.cordova.plugins.overappbrowser;

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.util.Log;

import org.json.JSONException;
import org.json.JSONObject;

/**
* Created by Oliver on 22/11/2013.
Expand All @@ -42,17 +37,19 @@ public void setOverAppBroswer(OverAppBrowser browser) {
this.overAppBrowser = browser;
}

/*public void onBackPressed () {
public void onBackPressed () {
if (!this.overAppBrowser.hardwareBack()) {
return;
}

if (this.overAppBrowser == null) {
this.dismiss();
} else {
// better to go through the in overAppBrowser
// because it does a clean up
if (this.overAppBrowser.hardwareBack() && this.overAppBrowser.canGoBack()) {
if (this.overAppBrowser.canGoBack()) {
this.overAppBrowser.goBack();
} else {
this.overAppBrowser.closeDialog();
}
}
}*/
}
}
3 changes: 3 additions & 0 deletions www/ios/OverAppBrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ OverAppBrowser.prototype = {
resize: function (originX, originY, width, height) {
exec(null, null, "OverAppBrowser", "resize", [originX, originY, width, height]);
},
toggleHardwareBack: function (enable) {
exec(null, null, "OverAppBrowser", "toggleHardwareBack", [enable]);
},
addEventListener: function (eventname,f) {
if (eventname in this.channels) {
this.channels[eventname].subscribe(f);
Expand Down

0 comments on commit 810b924

Please sign in to comment.