apache / apache/cordova-plugin-inappbrowser
Prevent closing InAppBrowser
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 2.2k
- PR merge metrics
- No merged PRs in 30d
Description
I have an simple app that onDeviceReady starts the InAppBrowser and shows a web application with some cordova features on it.
When the user press hardwareback the application goes back, but when there are no page in the history the InAppBrowser is closed.
## Motivation Behind Feature
Since the appplication is a native shell and the main part is the InAppBrowser, it must't be closed using the hardwareback.
## Feature Description
Currenlty I'm changing the InAppBrowserDialog.java code in the onBackPressed event handler like:
```
public void onBackPressed () {
if (this.inAppBrowser == null) {
this.dismiss();
} else {
// better to go through the in inAppBrowser
// because it does a clean up
if (this.inAppBrowser.hardwareBack() && this.inAppBrowser.canGoBack()) {
this.inAppBrowser.goBack();
} else {
// this.inAppBrowser.closeDialog();
}
}
}
```
but is the typical change to a plugin that will be a future pain.
I'm thinking about an InAppBrowser open attribute like hardwareBackClose=no, that avoid the browser close if harware back is pressed and there is no browser history.
## Alternatives or Workarounds
Aside the code changes I can't find any alternatives.
Contributor guide
Research direction
Start with InAppBrowserDialog.java and trace the onBackPressed path described in the issue, including how hardwareBack() and closeDialog() interact. Define the open attribute's behavior and verify that pressing hardware back still navigates when history exists but does not close the InAppBrowser when history is exhausted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java, javascript
- Domain
- mobile-dev
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100