Skip to content

Commit a285023

Browse files
authored
Update InAppBrowserDialog.java
1 parent b496e03 commit a285023

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

src/android/InAppBrowserDialog.java

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,40 @@ public void setInAppBroswer(InAppBrowser browser) {
4141
this.inAppBrowser = browser;
4242
}
4343

44-
public void onBackPressed () {
44+
public void onBackPressed() {
4545
if (this.inAppBrowser == null) {
4646
this.dismiss();
4747
} else {
4848
// better to go through the in inAppBrowser
4949
// because it does a clean up
50-
if (this.inAppBrowser.hardwareBack() && this.inAppBrowser.canGoBack()) {
50+
if (this.inAppBrowser.canGoBack()) {
5151
this.inAppBrowser.goBack();
52-
} else {
53-
this.inAppBrowser.closeDialog();
52+
} else {
53+
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context)
54+
.setTitle("Exit")
55+
.setMessage("You are about to exit, are you sure?")
56+
.setPositiveButton("Exit", new DialogInterface.OnClickListener() {
57+
public void onClick(DialogInterface dialog, int which) {
58+
if (inAppBrowser == null) {
59+
dismiss();
60+
} else {
61+
// better to go through the in inAppBrowser
62+
// because it does a clean up
63+
if (inAppBrowser.hardwareBack() && inAppBrowser.canGoBack()) {
64+
inAppBrowser.goBack();
65+
} else {
66+
inAppBrowser.closeDialog();
67+
}
68+
}
69+
}
70+
})
71+
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
72+
public void onClick(DialogInterface dialog, int which) {
73+
dialog.cancel();
74+
}
75+
});
76+
alertDialogBuilder.create();
77+
alertDialogBuilder.show();
5478
}
5579
}
5680
}

0 commit comments

Comments
 (0)