@capgo/inappbrowser 0.3.1 → 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CapgoInappbrowser.podspec +1 -1
- package/README.md +4 -4
- package/android/build.gradle +9 -9
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/InAppBrowserPlugin.java +59 -52
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/Options.java +1 -0
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/WebViewCallbacks.java +2 -0
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/WebViewDialog.java +96 -91
- package/android/src/main/res/layout/activity_browser.xml +1 -1
- package/android/src/main/res/values/browser_theme.xml +3 -0
- package/android/src/main/res/values/styles.xml +2 -10
- package/dist/docs.json +4 -4
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +1 -3
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +1 -3
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/Enums.swift +4 -3
- package/ios/Plugin/InAppBrowserPlugin.swift +34 -34
- package/ios/Plugin/WKWebViewController.swift +152 -152
- package/package.json +19 -14
|
@@ -11,7 +11,7 @@ Pod::Spec.new do |s|
|
|
|
11
11
|
s.author = package['author']
|
|
12
12
|
s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
|
|
13
13
|
s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
14
|
-
s.ios.deployment_target = '
|
|
14
|
+
s.ios.deployment_target = '13.0'
|
|
15
15
|
s.dependency 'Capacitor'
|
|
16
16
|
s.swift_version = '5.1'
|
|
17
17
|
end
|
package/README.md
CHANGED
|
@@ -207,10 +207,10 @@ Will be triggered when user clicks on confirm button when disclaimer is required
|
|
|
207
207
|
|
|
208
208
|
| Members | Value |
|
|
209
209
|
| ---------------- | ------------------------- |
|
|
210
|
-
| **`ACTIVITY`** | <code>
|
|
211
|
-
| **`NAVIGATION`** | <code>
|
|
212
|
-
| **`BLANK`** | <code>
|
|
213
|
-
| **`DEFAULT`** | <code>
|
|
210
|
+
| **`ACTIVITY`** | <code>'activity'</code> |
|
|
211
|
+
| **`NAVIGATION`** | <code>'navigation'</code> |
|
|
212
|
+
| **`BLANK`** | <code>'blank'</code> |
|
|
213
|
+
| **`DEFAULT`** | <code>''</code> |
|
|
214
214
|
|
|
215
215
|
|
|
216
216
|
#### BackgroundColor
|
package/android/build.gradle
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
ext {
|
|
2
|
-
junitVersion =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
|
|
3
|
+
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.3'
|
|
4
|
+
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.4.0'
|
|
5
|
+
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.4.2'
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
buildscript {
|
|
9
9
|
repositories {
|
|
10
|
+
mavenCentral()
|
|
10
11
|
google()
|
|
11
|
-
jcenter()
|
|
12
12
|
}
|
|
13
13
|
dependencies {
|
|
14
|
-
classpath 'com.android.tools.build:gradle:
|
|
14
|
+
classpath 'com.android.tools.build:gradle:7.3.1'
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
apply plugin: 'com.android.library'
|
|
19
19
|
|
|
20
20
|
android {
|
|
21
|
-
compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion :
|
|
21
|
+
compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 32
|
|
22
22
|
defaultConfig {
|
|
23
|
-
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion :
|
|
24
|
-
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion :
|
|
23
|
+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
|
|
24
|
+
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 32
|
|
25
25
|
versionCode 1
|
|
26
26
|
versionName "1.0"
|
|
27
27
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
@@ -6,24 +6,22 @@ import android.net.Uri;
|
|
|
6
6
|
import android.os.Bundle;
|
|
7
7
|
import android.text.TextUtils;
|
|
8
8
|
import android.util.Log;
|
|
9
|
-
|
|
10
9
|
import androidx.browser.customtabs.CustomTabsCallback;
|
|
11
10
|
import androidx.browser.customtabs.CustomTabsClient;
|
|
12
11
|
import androidx.browser.customtabs.CustomTabsIntent;
|
|
13
12
|
import androidx.browser.customtabs.CustomTabsServiceConnection;
|
|
14
13
|
import androidx.browser.customtabs.CustomTabsSession;
|
|
15
|
-
|
|
16
14
|
import com.getcapacitor.JSObject;
|
|
17
15
|
import com.getcapacitor.Plugin;
|
|
18
16
|
import com.getcapacitor.PluginCall;
|
|
19
17
|
import com.getcapacitor.PluginMethod;
|
|
20
18
|
import com.getcapacitor.annotation.CapacitorPlugin;
|
|
21
|
-
|
|
22
19
|
import java.util.Iterator;
|
|
23
20
|
|
|
24
21
|
@CapacitorPlugin(name = "InAppBrowser")
|
|
25
22
|
public class InAppBrowserPlugin extends Plugin {
|
|
26
|
-
|
|
23
|
+
|
|
24
|
+
public static final String CUSTOM_TAB_PACKAGE_NAME = "com.android.chrome"; // Change when in stable
|
|
27
25
|
private CustomTabsClient customTabsClient;
|
|
28
26
|
private CustomTabsSession currentSession;
|
|
29
27
|
private WebViewDialog webViewDialog = null;
|
|
@@ -36,45 +34,46 @@ public class InAppBrowserPlugin extends Plugin {
|
|
|
36
34
|
}
|
|
37
35
|
|
|
38
36
|
@Override
|
|
39
|
-
public void onServiceDisconnected(ComponentName name) {
|
|
40
|
-
}
|
|
37
|
+
public void onServiceDisconnected(ComponentName name) {}
|
|
41
38
|
};
|
|
42
39
|
|
|
43
|
-
@PluginMethod
|
|
40
|
+
@PluginMethod
|
|
44
41
|
public void setUrl(PluginCall call) {
|
|
45
42
|
String url = call.getString("url");
|
|
46
|
-
if(url == null || TextUtils.isEmpty(url)) {
|
|
43
|
+
if (url == null || TextUtils.isEmpty(url)) {
|
|
47
44
|
call.reject("Invalid URL");
|
|
48
45
|
}
|
|
49
|
-
getActivity()
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
46
|
+
getActivity()
|
|
47
|
+
.runOnUiThread(
|
|
48
|
+
new Runnable() {
|
|
49
|
+
@Override
|
|
50
|
+
public void run() {
|
|
51
|
+
webViewDialog.setUrl(url);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
);
|
|
55
55
|
call.resolve();
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
@PluginMethod
|
|
58
|
+
@PluginMethod
|
|
59
59
|
public void open(PluginCall call) {
|
|
60
60
|
String url = call.getString("url");
|
|
61
|
-
if(url == null || TextUtils.isEmpty(url)) {
|
|
61
|
+
if (url == null || TextUtils.isEmpty(url)) {
|
|
62
62
|
call.reject("Invalid URL");
|
|
63
63
|
}
|
|
64
64
|
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(getCustomTabsSession());
|
|
65
65
|
CustomTabsIntent tabsIntent = builder.build();
|
|
66
|
-
tabsIntent.intent.putExtra(Intent.EXTRA_REFERRER,
|
|
67
|
-
Uri.parse(Intent.URI_ANDROID_APP_SCHEME + "//" + getContext().getPackageName()));
|
|
66
|
+
tabsIntent.intent.putExtra(Intent.EXTRA_REFERRER, Uri.parse(Intent.URI_ANDROID_APP_SCHEME + "//" + getContext().getPackageName()));
|
|
68
67
|
tabsIntent.intent.putExtra(android.provider.Browser.EXTRA_HEADERS, this.getHeaders(call));
|
|
69
68
|
tabsIntent.launchUrl(getContext(), Uri.parse(url));
|
|
70
69
|
|
|
71
70
|
call.resolve();
|
|
72
71
|
}
|
|
73
72
|
|
|
74
|
-
@PluginMethod
|
|
73
|
+
@PluginMethod
|
|
75
74
|
public void openWebView(PluginCall call) {
|
|
76
75
|
String url = call.getString("url");
|
|
77
|
-
if(url == null || TextUtils.isEmpty(url)) {
|
|
76
|
+
if (url == null || TextUtils.isEmpty(url)) {
|
|
78
77
|
call.reject("Invalid URL");
|
|
79
78
|
}
|
|
80
79
|
final Options options = new Options();
|
|
@@ -86,32 +85,37 @@ public class InAppBrowserPlugin extends Plugin {
|
|
|
86
85
|
options.setToolbarType(call.getString("toolbarType", ""));
|
|
87
86
|
options.setPresentAfterPageLoad(call.getBoolean("isPresentAfterPageLoad", false));
|
|
88
87
|
options.setPluginCall(call);
|
|
89
|
-
options.setCallbacks(
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
88
|
+
options.setCallbacks(
|
|
89
|
+
new WebViewCallbacks() {
|
|
90
|
+
@Override
|
|
91
|
+
public void urlChangeEvent(String url) {
|
|
92
|
+
notifyListeners("urlChangeEvent", new JSObject().put("url", url));
|
|
93
|
+
}
|
|
94
94
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
95
|
+
@Override
|
|
96
|
+
public void pageLoaded() {
|
|
97
|
+
notifyListeners("browserPageLoaded", new JSObject());
|
|
98
|
+
}
|
|
99
99
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
});
|
|
105
|
-
getActivity().runOnUiThread(new Runnable() {
|
|
106
|
-
@Override
|
|
107
|
-
public void run() {
|
|
108
|
-
webViewDialog = new WebViewDialog(getContext(), android.R.style.Theme_NoTitleBar, options);
|
|
109
|
-
webViewDialog.presentWebView();
|
|
100
|
+
@Override
|
|
101
|
+
public void pageLoadError() {
|
|
102
|
+
notifyListeners("pageLoadError", new JSObject());
|
|
103
|
+
}
|
|
110
104
|
}
|
|
111
|
-
|
|
105
|
+
);
|
|
106
|
+
getActivity()
|
|
107
|
+
.runOnUiThread(
|
|
108
|
+
new Runnable() {
|
|
109
|
+
@Override
|
|
110
|
+
public void run() {
|
|
111
|
+
webViewDialog = new WebViewDialog(getContext(), android.R.style.Theme_NoTitleBar, options);
|
|
112
|
+
webViewDialog.presentWebView();
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
);
|
|
112
116
|
}
|
|
113
117
|
|
|
114
|
-
@PluginMethod
|
|
118
|
+
@PluginMethod
|
|
115
119
|
public void close(PluginCall call) {
|
|
116
120
|
if (webViewDialog != null) {
|
|
117
121
|
webViewDialog.dismiss();
|
|
@@ -127,9 +131,9 @@ public class InAppBrowserPlugin extends Plugin {
|
|
|
127
131
|
private Bundle getHeaders(PluginCall pluginCall) {
|
|
128
132
|
JSObject headersProvided = pluginCall.getObject("headers");
|
|
129
133
|
Bundle headers = new Bundle();
|
|
130
|
-
if(headersProvided != null) {
|
|
134
|
+
if (headersProvided != null) {
|
|
131
135
|
Iterator<String> keys = headersProvided.keys();
|
|
132
|
-
while(keys.hasNext()) {
|
|
136
|
+
while (keys.hasNext()) {
|
|
133
137
|
String key = keys.next();
|
|
134
138
|
headers.putString(key, headersProvided.getString(key));
|
|
135
139
|
}
|
|
@@ -154,16 +158,19 @@ public class InAppBrowserPlugin extends Plugin {
|
|
|
154
158
|
}
|
|
155
159
|
|
|
156
160
|
if (currentSession == null) {
|
|
157
|
-
currentSession =
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
161
|
+
currentSession =
|
|
162
|
+
customTabsClient.newSession(
|
|
163
|
+
new CustomTabsCallback() {
|
|
164
|
+
@Override
|
|
165
|
+
public void onNavigationEvent(int navigationEvent, Bundle extras) {
|
|
166
|
+
switch (navigationEvent) {
|
|
167
|
+
case NAVIGATION_FINISHED:
|
|
168
|
+
notifyListeners("browserPageLoaded", new JSObject());
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
164
172
|
}
|
|
165
|
-
|
|
166
|
-
});
|
|
173
|
+
);
|
|
167
174
|
}
|
|
168
175
|
return currentSession;
|
|
169
176
|
}
|
|
@@ -14,7 +14,6 @@ import android.webkit.WebViewClient;
|
|
|
14
14
|
import android.widget.ImageButton;
|
|
15
15
|
import android.widget.TextView;
|
|
16
16
|
import androidx.appcompat.widget.Toolbar;
|
|
17
|
-
|
|
18
17
|
import java.net.URI;
|
|
19
18
|
import java.net.URISyntaxException;
|
|
20
19
|
import java.util.HashMap;
|
|
@@ -22,6 +21,7 @@ import java.util.Iterator;
|
|
|
22
21
|
import java.util.Map;
|
|
23
22
|
|
|
24
23
|
public class WebViewDialog extends Dialog {
|
|
24
|
+
|
|
25
25
|
private WebView _webView;
|
|
26
26
|
private Toolbar _toolbar;
|
|
27
27
|
private Options _options;
|
|
@@ -51,11 +51,11 @@ public class WebViewDialog extends Dialog {
|
|
|
51
51
|
_webView.getSettings().setUseWideViewPort(true);
|
|
52
52
|
|
|
53
53
|
Map<String, String> requestHeaders = new HashMap<>();
|
|
54
|
-
if(_options.getHeaders() != null) {
|
|
54
|
+
if (_options.getHeaders() != null) {
|
|
55
55
|
Iterator<String> keys = _options.getHeaders().keys();
|
|
56
|
-
while(keys.hasNext()) {
|
|
56
|
+
while (keys.hasNext()) {
|
|
57
57
|
String key = keys.next();
|
|
58
|
-
if(TextUtils.equals(key, "User-Agent")) {
|
|
58
|
+
if (TextUtils.equals(key, "User-Agent")) {
|
|
59
59
|
_webView.getSettings().setUserAgentString(_options.getHeaders().getString(key));
|
|
60
60
|
} else {
|
|
61
61
|
requestHeaders.put(key, _options.getHeaders().getString(key));
|
|
@@ -70,7 +70,7 @@ public class WebViewDialog extends Dialog {
|
|
|
70
70
|
setupToolbar();
|
|
71
71
|
setWebViewClient();
|
|
72
72
|
|
|
73
|
-
if(!this._options.isPresentAfterPageLoad()) {
|
|
73
|
+
if (!this._options.isPresentAfterPageLoad()) {
|
|
74
74
|
show();
|
|
75
75
|
_options.getPluginCall().success();
|
|
76
76
|
}
|
|
@@ -78,15 +78,15 @@ public class WebViewDialog extends Dialog {
|
|
|
78
78
|
|
|
79
79
|
public void setUrl(String url) {
|
|
80
80
|
Map<String, String> requestHeaders = new HashMap<>();
|
|
81
|
-
if(_options.getHeaders() != null) {
|
|
81
|
+
if (_options.getHeaders() != null) {
|
|
82
82
|
Iterator<String> keys = _options.getHeaders().keys();
|
|
83
|
-
while(keys.hasNext()) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
83
|
+
while (keys.hasNext()) {
|
|
84
|
+
String key = keys.next();
|
|
85
|
+
if (TextUtils.equals(key, "User-Agent")) {
|
|
86
|
+
_webView.getSettings().setUserAgentString(_options.getHeaders().getString(key));
|
|
87
|
+
} else {
|
|
88
|
+
requestHeaders.put(key, _options.getHeaders().getString(key));
|
|
89
|
+
}
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
_webView.loadUrl(url, requestHeaders);
|
|
@@ -99,7 +99,7 @@ public class WebViewDialog extends Dialog {
|
|
|
99
99
|
|
|
100
100
|
private void setupToolbar() {
|
|
101
101
|
_toolbar = this.findViewById(R.id.tool_bar);
|
|
102
|
-
if(!TextUtils.isEmpty(_options.getTitle())) {
|
|
102
|
+
if (!TextUtils.isEmpty(_options.getTitle())) {
|
|
103
103
|
this.setTitle(_options.getTitle());
|
|
104
104
|
} else {
|
|
105
105
|
try {
|
|
@@ -111,40 +111,46 @@ public class WebViewDialog extends Dialog {
|
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
View backButton = _toolbar.findViewById(R.id.backButton);
|
|
114
|
-
backButton.setOnClickListener(
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
_webView.
|
|
114
|
+
backButton.setOnClickListener(
|
|
115
|
+
new View.OnClickListener() {
|
|
116
|
+
@Override
|
|
117
|
+
public void onClick(View view) {
|
|
118
|
+
if (_webView.canGoBack()) {
|
|
119
|
+
_webView.goBack();
|
|
120
|
+
}
|
|
119
121
|
}
|
|
120
122
|
}
|
|
121
|
-
|
|
123
|
+
);
|
|
122
124
|
|
|
123
125
|
View forwardButton = _toolbar.findViewById(R.id.forwardButton);
|
|
124
|
-
forwardButton.setOnClickListener(
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
_webView.
|
|
126
|
+
forwardButton.setOnClickListener(
|
|
127
|
+
new View.OnClickListener() {
|
|
128
|
+
@Override
|
|
129
|
+
public void onClick(View view) {
|
|
130
|
+
if (_webView.canGoForward()) {
|
|
131
|
+
_webView.goForward();
|
|
132
|
+
}
|
|
129
133
|
}
|
|
130
134
|
}
|
|
131
|
-
|
|
135
|
+
);
|
|
132
136
|
|
|
133
137
|
View closeButton = _toolbar.findViewById(R.id.closeButton);
|
|
134
|
-
closeButton.setOnClickListener(
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
+
closeButton.setOnClickListener(
|
|
139
|
+
new View.OnClickListener() {
|
|
140
|
+
@Override
|
|
141
|
+
public void onClick(View view) {
|
|
142
|
+
dismiss();
|
|
143
|
+
}
|
|
138
144
|
}
|
|
139
|
-
|
|
145
|
+
);
|
|
140
146
|
|
|
141
|
-
if(TextUtils.equals(_options.getToolbarType(), "activity")) {
|
|
147
|
+
if (TextUtils.equals(_options.getToolbarType(), "activity")) {
|
|
142
148
|
_toolbar.findViewById(R.id.forwardButton).setVisibility(View.GONE);
|
|
143
149
|
_toolbar.findViewById(R.id.backButton).setVisibility(View.GONE);
|
|
144
150
|
//TODO: Add share button functionality
|
|
145
|
-
} else if(TextUtils.equals(_options.getToolbarType(), "navigation")) {
|
|
151
|
+
} else if (TextUtils.equals(_options.getToolbarType(), "navigation")) {
|
|
146
152
|
//TODO: Remove share button when implemented
|
|
147
|
-
} else if(TextUtils.equals(_options.getToolbarType(), "blank")){
|
|
153
|
+
} else if (TextUtils.equals(_options.getToolbarType(), "blank")) {
|
|
148
154
|
_toolbar.setVisibility(View.GONE);
|
|
149
155
|
} else {
|
|
150
156
|
_toolbar.findViewById(R.id.forwardButton).setVisibility(View.GONE);
|
|
@@ -153,77 +159,76 @@ public class WebViewDialog extends Dialog {
|
|
|
153
159
|
}
|
|
154
160
|
|
|
155
161
|
private void setWebViewClient() {
|
|
156
|
-
_webView.setWebViewClient(
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
@Override
|
|
164
|
-
public void onLoadResource(WebView view, String url) {
|
|
165
|
-
super.onLoadResource(view, url);
|
|
166
|
-
}
|
|
162
|
+
_webView.setWebViewClient(
|
|
163
|
+
new WebViewClient() {
|
|
164
|
+
@Override
|
|
165
|
+
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
167
168
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
try {
|
|
172
|
-
URI uri = new URI(url);
|
|
173
|
-
setTitle(uri.getHost());
|
|
174
|
-
} catch (URISyntaxException e) {
|
|
175
|
-
// Do nothing
|
|
169
|
+
@Override
|
|
170
|
+
public void onLoadResource(WebView view, String url) {
|
|
171
|
+
super.onLoadResource(view, url);
|
|
176
172
|
}
|
|
177
|
-
_options.getCallbacks().urlChangeEvent(url);
|
|
178
|
-
}
|
|
179
173
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
show();
|
|
189
|
-
_options.getPluginCall().success();
|
|
174
|
+
@Override
|
|
175
|
+
public void onPageStarted(WebView view, String url, Bitmap favicon) {
|
|
176
|
+
super.onPageStarted(view, url, favicon);
|
|
177
|
+
try {
|
|
178
|
+
URI uri = new URI(url);
|
|
179
|
+
setTitle(uri.getHost());
|
|
180
|
+
} catch (URISyntaxException e) {
|
|
181
|
+
// Do nothing
|
|
190
182
|
}
|
|
183
|
+
_options.getCallbacks().urlChangeEvent(url);
|
|
191
184
|
}
|
|
192
185
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
186
|
+
@Override
|
|
187
|
+
public void onPageFinished(WebView view, String url) {
|
|
188
|
+
super.onPageFinished(view, url);
|
|
189
|
+
_options.getCallbacks().pageLoaded();
|
|
190
|
+
if (!isInitialized) {
|
|
191
|
+
isInitialized = true;
|
|
192
|
+
_webView.clearHistory();
|
|
193
|
+
if (_options.isPresentAfterPageLoad()) {
|
|
194
|
+
show();
|
|
195
|
+
_options.getPluginCall().success();
|
|
196
|
+
}
|
|
197
|
+
}
|
|
201
198
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
199
|
+
ImageButton backButton = _toolbar.findViewById(R.id.backButton);
|
|
200
|
+
if (_webView.canGoBack()) {
|
|
201
|
+
backButton.setImageResource(R.drawable.arrow_back_enabled);
|
|
202
|
+
backButton.setEnabled(true);
|
|
203
|
+
} else {
|
|
204
|
+
backButton.setImageResource(R.drawable.arrow_back_disabled);
|
|
205
|
+
backButton.setEnabled(false);
|
|
206
|
+
}
|
|
210
207
|
|
|
211
|
-
|
|
212
|
-
|
|
208
|
+
ImageButton forwardButton = _toolbar.findViewById(R.id.forwardButton);
|
|
209
|
+
if (_webView.canGoForward()) {
|
|
210
|
+
forwardButton.setImageResource(R.drawable.arrow_forward_enabled);
|
|
211
|
+
forwardButton.setEnabled(true);
|
|
212
|
+
} else {
|
|
213
|
+
forwardButton.setImageResource(R.drawable.arrow_forward_disabled);
|
|
214
|
+
forwardButton.setEnabled(false);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
_options.getCallbacks().pageLoaded();
|
|
218
|
+
}
|
|
213
219
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
220
|
+
@Override
|
|
221
|
+
public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
|
|
222
|
+
super.onReceivedError(view, request, error);
|
|
223
|
+
_options.getCallbacks().pageLoadError();
|
|
224
|
+
}
|
|
218
225
|
}
|
|
219
|
-
|
|
226
|
+
);
|
|
220
227
|
}
|
|
221
228
|
|
|
222
|
-
|
|
223
|
-
|
|
224
229
|
@Override
|
|
225
230
|
public void onBackPressed() {
|
|
226
|
-
if(_webView.canGoBack() && TextUtils.equals(_options.getToolbarType(), "navigation")) {
|
|
231
|
+
if (_webView.canGoBack() && TextUtils.equals(_options.getToolbarType(), "navigation")) {
|
|
227
232
|
_webView.goBack();
|
|
228
233
|
} else {
|
|
229
234
|
super.onBackPressed();
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
<com.google.android.material.appbar.AppBarLayout
|
|
10
10
|
android:layout_width="match_parent"
|
|
11
11
|
android:layout_height="wrap_content"
|
|
12
|
-
android:theme="@style/
|
|
12
|
+
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
|
|
13
13
|
|
|
14
14
|
<include
|
|
15
15
|
android:id="@+id/tool_bar"
|
|
@@ -1,12 +1,4 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
1
2
|
<resources>
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
<style name="AppTheme.NoActionBar">
|
|
5
|
-
<item name="windowActionBar">false</item>
|
|
6
|
-
<item name="windowNoTitle">true</item>
|
|
7
|
-
</style>
|
|
8
|
-
|
|
9
|
-
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
|
|
10
|
-
|
|
11
|
-
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
|
|
12
|
-
</resources>
|
|
4
|
+
</resources>
|
package/dist/docs.json
CHANGED
|
@@ -345,25 +345,25 @@
|
|
|
345
345
|
"members": [
|
|
346
346
|
{
|
|
347
347
|
"name": "ACTIVITY",
|
|
348
|
-
"value": "
|
|
348
|
+
"value": "'activity'",
|
|
349
349
|
"tags": [],
|
|
350
350
|
"docs": ""
|
|
351
351
|
},
|
|
352
352
|
{
|
|
353
353
|
"name": "NAVIGATION",
|
|
354
|
-
"value": "
|
|
354
|
+
"value": "'navigation'",
|
|
355
355
|
"tags": [],
|
|
356
356
|
"docs": ""
|
|
357
357
|
},
|
|
358
358
|
{
|
|
359
359
|
"name": "BLANK",
|
|
360
|
-
"value": "
|
|
360
|
+
"value": "'blank'",
|
|
361
361
|
"tags": [],
|
|
362
362
|
"docs": ""
|
|
363
363
|
},
|
|
364
364
|
{
|
|
365
365
|
"name": "DEFAULT",
|
|
366
|
-
"value": "
|
|
366
|
+
"value": "''",
|
|
367
367
|
"tags": [],
|
|
368
368
|
"docs": ""
|
|
369
369
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAsBA,MAAM,CAAN,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,kCAAe,CAAA;IACf,kCAAe,CAAA;AACjB,CAAC,EAHW,eAAe,KAAf,eAAe,QAG1B;AACD,MAAM,CAAN,IAAY,WAKX;AALD,WAAY,WAAW;IACrB,oCAAqB,CAAA;IACrB,wCAAyB,CAAA;IACzB,8BAAe,CAAA;IACf,2BAAY,CAAA;AACd,CAAC,EALW,WAAW,KAAX,WAAW,QAKtB","sourcesContent":["import type { PluginListenerHandle } from '@capacitor/core';\n\nexport interface UrlEvent {\n /**\n * Emit when the url changes\n *\n * @since 0.0.1\n */\n url: string;\n}\nexport interface BtnEvent {\n /**\n * Emit when a button is clicked.\n *\n * @since 0.0.1\n */\n url: string;\n}\n\nexport type UrlChangeListener = (state: UrlEvent) => void;\nexport type ConfirmBtnListener = (state: BtnEvent) => void;\n\nexport enum BackgroundColor
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAsBA,MAAM,CAAN,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,kCAAe,CAAA;IACf,kCAAe,CAAA;AACjB,CAAC,EAHW,eAAe,KAAf,eAAe,QAG1B;AACD,MAAM,CAAN,IAAY,WAKX;AALD,WAAY,WAAW;IACrB,oCAAqB,CAAA;IACrB,wCAAyB,CAAA;IACzB,8BAAe,CAAA;IACf,2BAAY,CAAA;AACd,CAAC,EALW,WAAW,KAAX,WAAW,QAKtB","sourcesContent":["import type { PluginListenerHandle } from '@capacitor/core';\n\nexport interface UrlEvent {\n /**\n * Emit when the url changes\n *\n * @since 0.0.1\n */\n url: string;\n}\nexport interface BtnEvent {\n /**\n * Emit when a button is clicked.\n *\n * @since 0.0.1\n */\n url: string;\n}\n\nexport type UrlChangeListener = (state: UrlEvent) => void;\nexport type ConfirmBtnListener = (state: BtnEvent) => void;\n\nexport enum BackgroundColor {\n WHITE = 'white',\n BLACK = 'black',\n}\nexport enum ToolBarType {\n ACTIVITY = 'activity',\n NAVIGATION = 'navigation',\n BLANK = 'blank',\n DEFAULT = '',\n}\n\nexport interface Headers {\n [key: string]: string;\n}\n\nexport interface OpenOptions {\n url: string;\n headers?: Headers;\n isPresentAfterPageLoad?: boolean;\n}\n\nexport interface DisclaimerOptions {\n title: string;\n message: string;\n confirmBtn: string;\n cancelBtn: string;\n}\n\nexport interface OpenWebViewOptions {\n url: string;\n headers?: Headers;\n shareDisclaimer?: DisclaimerOptions;\n toolbarType?: ToolBarType;\n shareSubject?: string;\n title: string;\n backgroundColor?: BackgroundColor;\n isPresentAfterPageLoad?: boolean;\n}\n\n// CapBrowser.addListener(\"urlChangeEvent\", (info: any) => {\n// console.log(info.url)\n// })\n\n// CapBrowser.addListener(\"confirmBtnClicked\", (info: any) => {\n// // will be triggered when user clicks on confirm button when disclaimer is required, works only on iOS\n// console.log(info.url)\n// })\nexport interface InAppBrowserPlugin {\n open(options: OpenOptions): Promise<any>;\n close(): Promise<any>;\n openWebView(options: OpenWebViewOptions): Promise<any>;\n setUrl(options: { url: string }): Promise<any>;\n /**\n * Listen for url change\n *\n * @since 0.0.1\n */\n addListener(\n eventName: 'urlChangeEvent',\n listenerFunc: UrlChangeListener\n ): Promise<PluginListenerHandle> & PluginListenerHandle;\n /**\n * Will be triggered when user clicks on confirm button when disclaimer is required, works only on iOS\n *\n * @since 0.0.1\n */\n addListener(\n eventName: 'confirmBtnClicked',\n listenerFunc: ConfirmBtnListener\n ): Promise<PluginListenerHandle> & PluginListenerHandle;\n}\n"]}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { registerPlugin } from '@capacitor/core';
|
|
2
2
|
const InAppBrowser = registerPlugin('InAppBrowser', {
|
|
3
|
-
web: () => import('./web').then(m => new m.InAppBrowserWeb()),
|
|
3
|
+
web: () => import('./web').then((m) => new m.InAppBrowserWeb()),
|
|
4
4
|
});
|
|
5
5
|
export * from './definitions';
|
|
6
6
|
export { InAppBrowser };
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,YAAY,GAAG,cAAc,CAAqB,cAAc,EAAE;IACtE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,YAAY,GAAG,cAAc,CAAqB,cAAc,EAAE;IACtE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;CAChE,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { InAppBrowserPlugin } from './definitions';\n\nconst InAppBrowser = registerPlugin<InAppBrowserPlugin>('InAppBrowser', {\n web: () => import('./web').then((m) => new m.InAppBrowserWeb()),\n});\n\nexport * from './definitions';\nexport { InAppBrowser };\n"]}
|
package/dist/esm/web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,eAAgB,SAAQ,SAAS;IAC5C,KAAK,CAAC,IAAI,CAAC,OAAoB;QAC7B,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC7B,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,KAAK,CAAC,WAAW,CAAC,OAA2B;QAC3C,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;QACpC,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,KAAK,CAAC,KAAK;QACT,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACrB,OAAO;IACT,CAAC;IACD,KAAK,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,eAAgB,SAAQ,SAAS;IAC5C,KAAK,CAAC,IAAI,CAAC,OAAoB;QAC7B,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC7B,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,KAAK,CAAC,WAAW,CAAC,OAA2B;QAC3C,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;QACpC,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,KAAK,CAAC,KAAK;QACT,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACrB,OAAO;IACT,CAAC;IACD,KAAK,CAAC,MAAM,CAAC,OAAwB;QACnC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;QACnC,OAAO;IACT,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { InAppBrowserPlugin, OpenWebViewOptions, OpenOptions } from './definitions';\n\nexport class InAppBrowserWeb extends WebPlugin implements InAppBrowserPlugin {\n async open(options: OpenOptions): Promise<any> {\n console.log('open', options);\n return options;\n }\n async openWebView(options: OpenWebViewOptions): Promise<any> {\n console.log('openWebView', options);\n return options;\n }\n async close(): Promise<any> {\n console.log('close');\n return;\n }\n async setUrl(options: { url: string }): Promise<any> {\n console.log('setUrl', options.url);\n return;\n }\n}\n"]}
|