@capgo/inappbrowser 1.0.7 → 1.0.11
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/android/build.gradle
CHANGED
|
@@ -55,7 +55,7 @@ dependencies {
|
|
|
55
55
|
testImplementation "junit:junit:$junitVersion"
|
|
56
56
|
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
57
57
|
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
58
|
-
implementation 'androidx.browser:browser:1.
|
|
58
|
+
implementation 'androidx.browser:browser:1.6.0'
|
|
59
59
|
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
|
60
60
|
implementation 'com.google.android.material:material:1.0.0'
|
|
61
61
|
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.2.0'
|
|
@@ -8,6 +8,7 @@ import android.net.Uri;
|
|
|
8
8
|
import android.os.Bundle;
|
|
9
9
|
import android.text.TextUtils;
|
|
10
10
|
import android.util.Log;
|
|
11
|
+
import android.webkit.CookieManager;
|
|
11
12
|
import android.webkit.WebStorage;
|
|
12
13
|
import androidx.browser.customtabs.CustomTabsCallback;
|
|
13
14
|
import androidx.browser.customtabs.CustomTabsClient;
|
|
@@ -28,6 +29,7 @@ public class InAppBrowserPlugin extends Plugin {
|
|
|
28
29
|
private CustomTabsClient customTabsClient;
|
|
29
30
|
private CustomTabsSession currentSession;
|
|
30
31
|
private WebViewDialog webViewDialog = null;
|
|
32
|
+
private String currentUrl = "";
|
|
31
33
|
|
|
32
34
|
CustomTabsServiceConnection connection = new CustomTabsServiceConnection() {
|
|
33
35
|
@Override
|
|
@@ -49,6 +51,7 @@ public class InAppBrowserPlugin extends Plugin {
|
|
|
49
51
|
if (url == null || TextUtils.isEmpty(url)) {
|
|
50
52
|
call.reject("Invalid URL");
|
|
51
53
|
}
|
|
54
|
+
currentUrl = url;
|
|
52
55
|
this.getActivity()
|
|
53
56
|
.runOnUiThread(
|
|
54
57
|
new Runnable() {
|
|
@@ -71,6 +74,7 @@ public class InAppBrowserPlugin extends Plugin {
|
|
|
71
74
|
if (url == null || TextUtils.isEmpty(url)) {
|
|
72
75
|
call.reject("Invalid URL");
|
|
73
76
|
}
|
|
77
|
+
currentUrl = url;
|
|
74
78
|
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(
|
|
75
79
|
getCustomTabsSession()
|
|
76
80
|
);
|
|
@@ -112,8 +116,28 @@ public class InAppBrowserPlugin extends Plugin {
|
|
|
112
116
|
|
|
113
117
|
@PluginMethod
|
|
114
118
|
public void clearCookies(PluginCall call) {
|
|
115
|
-
|
|
116
|
-
|
|
119
|
+
if (webViewDialog == null) {
|
|
120
|
+
call.reject("WebView is not open");
|
|
121
|
+
} else {
|
|
122
|
+
String url = currentUrl;
|
|
123
|
+
if (url == null || TextUtils.isEmpty(url)) {
|
|
124
|
+
call.reject("Invalid URL");
|
|
125
|
+
} else {
|
|
126
|
+
CookieManager cookieManager = CookieManager.getInstance();
|
|
127
|
+
String cookie = cookieManager.getCookie(url);
|
|
128
|
+
if (cookie != null) {
|
|
129
|
+
String[] cookies = cookie.split(";");
|
|
130
|
+
for (String c : cookies) {
|
|
131
|
+
String cookieName = c.substring(0, c.indexOf("="));
|
|
132
|
+
cookieManager.setCookie(
|
|
133
|
+
url,
|
|
134
|
+
cookieName + "=; Expires=Thu, 01 Jan 1970 00:00:01 GMT"
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
call.resolve();
|
|
139
|
+
}
|
|
140
|
+
}
|
|
117
141
|
}
|
|
118
142
|
|
|
119
143
|
@PluginMethod
|
|
@@ -122,6 +146,7 @@ public class InAppBrowserPlugin extends Plugin {
|
|
|
122
146
|
if (url == null || TextUtils.isEmpty(url)) {
|
|
123
147
|
call.reject("Invalid URL");
|
|
124
148
|
}
|
|
149
|
+
currentUrl = url;
|
|
125
150
|
final Options options = new Options();
|
|
126
151
|
options.setUrl(url);
|
|
127
152
|
options.setHeaders(call.getObject("headers"));
|