mirror of
https://github.com/shuto-cn/cordova-plugin-inappbrowser.git
synced 2025-02-24 02:52:57 +08:00
Merge branch 'master' of https://github.com/shuto-cn/cordova-plugin-inappbrowser
This commit is contained in:
commit
2fe3ef9096
@ -125,6 +125,7 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
private static final String COLOR = "color";
|
||||
private static final String BACKGROUND = "background";
|
||||
private static final String BACKBUTTON = "backbutton";
|
||||
private static final String CANHARDWAREBACK = "canhardwareback";
|
||||
|
||||
private static final List customizableOptions = Arrays.asList(CLOSE_BUTTON_CAPTION, TOOLBAR_COLOR, NAVIGATION_COLOR, CLOSE_BUTTON_COLOR, FOOTER_COLOR,BACKGROUND,COLOR);
|
||||
|
||||
@ -160,6 +161,8 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
private boolean statusbar = true;
|
||||
// 标题栏
|
||||
private boolean titlebar = false;
|
||||
// 物理返回键是否生效
|
||||
private boolean canhardwareback = true;
|
||||
private String color = "";
|
||||
private String background = "";
|
||||
private boolean backbutton = true;
|
||||
@ -757,6 +760,10 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
if (backbuttonSet != null) {
|
||||
backbutton = backbuttonSet.equals("yes");
|
||||
}
|
||||
String canhardwarebackSet = features.get(CANHARDWAREBACK);
|
||||
if (canhardwarebackSet != null) {
|
||||
canhardwareback = canhardwarebackSet.equals("yes");
|
||||
}
|
||||
if (features.get(COLOR) != null) {
|
||||
color = features.get(COLOR);
|
||||
}
|
||||
@ -841,7 +848,7 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
};
|
||||
|
||||
// Let's create the main dialog
|
||||
dialog = new InAppBrowserDialog(cordova.getActivity(),fullscreen ? android.R.style.Theme_NoTitleBar : android.R.style.Theme_Black);
|
||||
dialog = new InAppBrowserDialog(cordova.getActivity(),fullscreen ? android.R.style.Theme_NoTitleBar : android.R.style.Theme_Black, canhardwareback);
|
||||
dialog.getWindow().getAttributes().windowAnimations = android.R.style.Animation_Dialog;
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
if (fullscreen) {
|
||||
|
@ -31,10 +31,12 @@ import org.json.JSONObject;
|
||||
public class InAppBrowserDialog extends Dialog {
|
||||
Context context;
|
||||
InAppBrowser inAppBrowser = null;
|
||||
boolean canHardwareBack = true;
|
||||
|
||||
public InAppBrowserDialog(Context context, int theme) {
|
||||
public InAppBrowserDialog(Context context, int theme, boolean canHardwareBack) {
|
||||
super(context, theme);
|
||||
this.context = context;
|
||||
this.canHardwareBack = canHardwareBack;
|
||||
}
|
||||
|
||||
public void setInAppBroswer(InAppBrowser browser) {
|
||||
@ -42,16 +44,19 @@ public class InAppBrowserDialog extends Dialog {
|
||||
}
|
||||
|
||||
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();
|
||||
if (canHardwareBack){
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user