Skip to content

Commit 149c937

Browse files
Merge pull request #3 from hogangnono/feature/HGNN-1001
[HGNN-1001] triggerback 옵션 추가
2 parents 29cb0b7 + e44b9cc commit 149c937

File tree

4 files changed

+32
-3
lines changed

4 files changed

+32
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cordova-plugin-inappbrowser",
3-
"version": "5.0.7-hogangnono",
3+
"version": "5.0.9-hogangnono",
44
"description": "Cordova InAppBrowser Plugin",
55
"types": "./types/index.d.ts",
66
"cordova": {

plugin.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
2222
id="cordova-plugin-inappbrowser"
23-
version="5.0.7-hogangnono">
23+
version="5.0.9-hogangnono">
2424

2525
<name>InAppBrowser</name>
2626
<description>Cordova InAppBrowser Plugin</description>

src/android/InAppBrowser.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ public class InAppBrowser extends CordovaPlugin {
105105
private static final String CLEAR_ALL_CACHE = "clearcache";
106106
private static final String CLEAR_SESSION_CACHE = "clearsessioncache";
107107
private static final String HARDWARE_BACK_BUTTON = "hardwareback";
108+
private static final String TRIGGER_BACK_BUTTON = "triggerback";
108109
private static final String MEDIA_PLAYBACK_REQUIRES_USER_ACTION = "mediaPlaybackRequiresUserAction";
109110
private static final String INTENT_PROTOCOL_START = "intent:";
110111
private static final String INTENT_PROTOCOL_INTENT = "#Intent;";
@@ -113,6 +114,7 @@ public class InAppBrowser extends CordovaPlugin {
113114
private static final String HOGANGNONO_SCHEME = "hogangnono://";
114115
private static final String SHOULD_PAUSE = "shouldPauseOnSuspend";
115116
private static final Boolean DEFAULT_HARDWARE_BACK = true;
117+
private static final Boolean DEFAULT_TRIGGER_BACK = false;
116118
private static final String USER_WIDE_VIEW_PORT = "useWideViewPort";
117119
private static final String TOOLBAR_COLOR = "toolbarcolor";
118120
private static final String CLOSE_BUTTON_CAPTION = "closebuttoncaption";
@@ -140,6 +142,7 @@ public class InAppBrowser extends CordovaPlugin {
140142
private boolean clearAllCache = false;
141143
private boolean clearSessionCache = false;
142144
private boolean hadwareBackButton = true;
145+
private boolean triggerBackButton = false;
143146
private boolean mediaPlaybackRequiresUserGesture = false;
144147
private boolean shouldPauseInAppBrowser = false;
145148
private boolean useWideViewPort = true;
@@ -589,6 +592,21 @@ public boolean hardwareBack() {
589592
return hadwareBackButton;
590593
}
591594

595+
/**
596+
* Hogangnono - Has the user set the trigger back button to go back
597+
* @return boolean
598+
*/
599+
public boolean isTriggerBack() {
600+
return triggerBackButton;
601+
}
602+
603+
/**
604+
* Hogangnono - Execute javaScript for triggering back button
605+
*/
606+
public void triggerBackButton() {
607+
this.inAppWebView.loadUrl("javascript:window.backbutton && window.backbutton()");
608+
}
609+
592610
/**
593611
* Checks to see if it is possible to go forward one page in history, then does so.
594612
*/
@@ -667,6 +685,12 @@ public String showWebPage(final String url, HashMap<String, String> features) {
667685
} else {
668686
hadwareBackButton = DEFAULT_HARDWARE_BACK;
669687
}
688+
String triggerBack = features.get(TRIGGER_BACK_BUTTON);
689+
if (triggerBack != null) {
690+
triggerBackButton = triggerBack.equals("yes") ? true : false;
691+
} else {
692+
triggerBackButton = DEFAULT_TRIGGER_BACK;
693+
}
670694
String mediaPlayback = features.get(MEDIA_PLAYBACK_REQUIRES_USER_ACTION);
671695
if (mediaPlayback != null) {
672696
mediaPlaybackRequiresUserGesture = mediaPlayback.equals("yes") ? true : false;

src/android/InAppBrowserDialog.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,12 @@ public void onBackPressed () {
5050
if (this.inAppBrowser.hardwareBack() && this.inAppBrowser.canGoBack()) {
5151
this.inAppBrowser.goBack();
5252
} else {
53-
this.inAppBrowser.closeDialog();
53+
// Hogangnono - triggerback 옵션이 설정되어 있으면, 웹뷰를 닫지 않고 웹으로 backbutton 함수를 실행시킨다
54+
if (this.inAppBrowser.isTriggerBack()) {
55+
this.inAppBrowser.triggerBackButton();
56+
} else {
57+
this.inAppBrowser.closeDialog();
58+
}
5459
}
5560
}
5661
}

0 commit comments

Comments
 (0)