@capgo/inappbrowser 6.6.5 → 6.6.6
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/README.md
CHANGED
|
@@ -28,7 +28,9 @@ Web platform is not supported. Use `window.open` instead.
|
|
|
28
28
|
Add the following to your `AndroidManifest.xml` file:
|
|
29
29
|
|
|
30
30
|
```xml
|
|
31
|
-
<uses-permission android:name="android.permission.CAMERA" />
|
|
31
|
+
<uses-permission android:name="android.permission.CAMERA" />
|
|
32
|
+
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
|
|
33
|
+
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
|
|
32
34
|
```
|
|
33
35
|
|
|
34
36
|
Then the permission will be asked when the camera is used.
|
|
@@ -9,14 +9,10 @@ import android.content.pm.ResolveInfo;
|
|
|
9
9
|
import android.net.Uri;
|
|
10
10
|
import android.os.Bundle;
|
|
11
11
|
import android.text.TextUtils;
|
|
12
|
-
import android.util.ArrayMap;
|
|
13
12
|
import android.util.Log;
|
|
14
|
-
import android.view.View;
|
|
15
|
-
import android.view.View;
|
|
16
13
|
import android.webkit.CookieManager;
|
|
17
14
|
import android.webkit.PermissionRequest;
|
|
18
|
-
import
|
|
19
|
-
import android.webkit.WebResourceResponse;
|
|
15
|
+
import androidx.annotation.NonNull;
|
|
20
16
|
import androidx.browser.customtabs.CustomTabsCallback;
|
|
21
17
|
import androidx.browser.customtabs.CustomTabsClient;
|
|
22
18
|
import androidx.browser.customtabs.CustomTabsIntent;
|
|
@@ -32,11 +28,6 @@ import com.getcapacitor.annotation.Permission;
|
|
|
32
28
|
import com.getcapacitor.annotation.PermissionCallback;
|
|
33
29
|
import java.util.ArrayList;
|
|
34
30
|
import java.util.Iterator;
|
|
35
|
-
import java.util.List;
|
|
36
|
-
import java.util.Objects;
|
|
37
|
-
import java.util.Optional;
|
|
38
|
-
import java.util.UUID;
|
|
39
|
-
import java.util.concurrent.Semaphore;
|
|
40
31
|
import org.json.JSONException;
|
|
41
32
|
import org.json.JSONObject;
|
|
42
33
|
|
|
@@ -94,33 +85,27 @@ public class InAppBrowserPlugin
|
|
|
94
85
|
}
|
|
95
86
|
|
|
96
87
|
@PermissionCallback
|
|
97
|
-
private void microphonePermissionCallback() {
|
|
88
|
+
private void microphonePermissionCallback(PluginCall call) {
|
|
98
89
|
if (getPermissionState("microphone") == PermissionState.GRANTED) {
|
|
99
|
-
|
|
90
|
+
grantCameraAndMicrophonePermission();
|
|
100
91
|
} else {
|
|
101
92
|
if (currentPermissionRequest != null) {
|
|
102
93
|
currentPermissionRequest.deny();
|
|
103
94
|
currentPermissionRequest = null;
|
|
104
95
|
}
|
|
105
|
-
|
|
96
|
+
call.reject("Microphone permission is required");
|
|
106
97
|
}
|
|
107
98
|
}
|
|
108
99
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
);
|
|
119
|
-
webViewDialog.currentPermissionRequest = null;
|
|
120
|
-
}
|
|
121
|
-
call.resolve();
|
|
122
|
-
} else {
|
|
123
|
-
call.reject("Camera permission is required");
|
|
100
|
+
private void grantCameraAndMicrophonePermission() {
|
|
101
|
+
if (currentPermissionRequest != null) {
|
|
102
|
+
currentPermissionRequest.grant(
|
|
103
|
+
new String[] {
|
|
104
|
+
PermissionRequest.RESOURCE_VIDEO_CAPTURE,
|
|
105
|
+
PermissionRequest.RESOURCE_AUDIO_CAPTURE,
|
|
106
|
+
}
|
|
107
|
+
);
|
|
108
|
+
currentPermissionRequest = null;
|
|
124
109
|
}
|
|
125
110
|
}
|
|
126
111
|
|
|
@@ -128,8 +113,14 @@ public class InAppBrowserPlugin
|
|
|
128
113
|
this.currentPermissionRequest = request;
|
|
129
114
|
if (getPermissionState("camera") != PermissionState.GRANTED) {
|
|
130
115
|
requestPermissionForAlias("camera", null, "cameraPermissionCallback");
|
|
116
|
+
} else if (getPermissionState("microphone") != PermissionState.GRANTED) {
|
|
117
|
+
requestPermissionForAlias(
|
|
118
|
+
"microphone",
|
|
119
|
+
null,
|
|
120
|
+
"microphonePermissionCallback"
|
|
121
|
+
);
|
|
131
122
|
} else {
|
|
132
|
-
|
|
123
|
+
grantCameraAndMicrophonePermission();
|
|
133
124
|
}
|
|
134
125
|
}
|
|
135
126
|
|
|
@@ -188,17 +179,20 @@ public class InAppBrowserPlugin
|
|
|
188
179
|
@PermissionCallback
|
|
189
180
|
private void cameraPermissionCallback(PluginCall call) {
|
|
190
181
|
if (getPermissionState("camera") == PermissionState.GRANTED) {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
new String[] { PermissionRequest.RESOURCE_VIDEO_CAPTURE }
|
|
182
|
+
if (getPermissionState("microphone") != PermissionState.GRANTED) {
|
|
183
|
+
requestPermissionForAlias(
|
|
184
|
+
"microphone",
|
|
185
|
+
null,
|
|
186
|
+
"microphonePermissionCallback"
|
|
197
187
|
);
|
|
198
|
-
|
|
188
|
+
} else {
|
|
189
|
+
grantCameraAndMicrophonePermission();
|
|
199
190
|
}
|
|
200
|
-
call.resolve();
|
|
201
191
|
} else {
|
|
192
|
+
if (currentPermissionRequest != null) {
|
|
193
|
+
currentPermissionRequest.deny();
|
|
194
|
+
currentPermissionRequest = null;
|
|
195
|
+
}
|
|
202
196
|
call.reject("Camera permission is required");
|
|
203
197
|
}
|
|
204
198
|
}
|
|
@@ -215,7 +209,7 @@ public class InAppBrowserPlugin
|
|
|
215
209
|
CustomTabsServiceConnection connection = new CustomTabsServiceConnection() {
|
|
216
210
|
@Override
|
|
217
211
|
public void onCustomTabsServiceConnected(
|
|
218
|
-
ComponentName name,
|
|
212
|
+
@NonNull ComponentName name,
|
|
219
213
|
CustomTabsClient client
|
|
220
214
|
) {
|
|
221
215
|
customTabsClient = client;
|
|
@@ -339,8 +333,6 @@ public class InAppBrowserPlugin
|
|
|
339
333
|
String cookieString = cookieManager.getCookie(url);
|
|
340
334
|
ArrayList<String> cookiesToRemove = new ArrayList<>();
|
|
341
335
|
|
|
342
|
-
cookiesToRemove.clear();
|
|
343
|
-
|
|
344
336
|
if (cookieString != null) {
|
|
345
337
|
String[] cookies = cookieString.split("; ");
|
|
346
338
|
|
|
@@ -417,8 +409,12 @@ public class InAppBrowserPlugin
|
|
|
417
409
|
options.setUrl(url);
|
|
418
410
|
options.setHeaders(call.getObject("headers"));
|
|
419
411
|
options.setCredentials(call.getObject("credentials"));
|
|
420
|
-
options.setShowReloadButton(
|
|
421
|
-
|
|
412
|
+
options.setShowReloadButton(
|
|
413
|
+
Boolean.TRUE.equals(call.getBoolean("showReloadButton", false))
|
|
414
|
+
);
|
|
415
|
+
options.setVisibleTitle(
|
|
416
|
+
Boolean.TRUE.equals(call.getBoolean("visibleTitle", true))
|
|
417
|
+
);
|
|
422
418
|
if (Boolean.TRUE.equals(options.getVisibleTitle())) {
|
|
423
419
|
options.setTitle(call.getString("title", "New Window"));
|
|
424
420
|
} else {
|
|
@@ -434,15 +430,19 @@ public class InAppBrowserPlugin
|
|
|
434
430
|
options.setShareSubject(call.getString("shareSubject", null));
|
|
435
431
|
options.setToolbarType(call.getString("toolbarType", ""));
|
|
436
432
|
options.setActiveNativeNavigationForWebview(
|
|
437
|
-
|
|
433
|
+
Boolean.TRUE.equals(
|
|
434
|
+
call.getBoolean("activeNativeNavigationForWebview", false)
|
|
435
|
+
)
|
|
438
436
|
);
|
|
439
437
|
options.setDisableGoBackOnNativeApplication(
|
|
440
|
-
|
|
438
|
+
Boolean.TRUE.equals(
|
|
439
|
+
call.getBoolean("disableGoBackOnNativeApplication", false)
|
|
440
|
+
)
|
|
441
441
|
);
|
|
442
442
|
options.setPresentAfterPageLoad(
|
|
443
|
-
call.getBoolean("isPresentAfterPageLoad", false)
|
|
443
|
+
Boolean.TRUE.equals(call.getBoolean("isPresentAfterPageLoad", false))
|
|
444
444
|
);
|
|
445
|
-
if (call.getBoolean("closeModal", false)) {
|
|
445
|
+
if (Boolean.TRUE.equals(call.getBoolean("closeModal", false))) {
|
|
446
446
|
options.setCloseModal(true);
|
|
447
447
|
options.setCloseModalTitle(call.getString("closeModalTitle", "Close"));
|
|
448
448
|
options.setCloseModalDescription(
|
|
@@ -541,11 +541,11 @@ public class InAppBrowserPlugin
|
|
|
541
541
|
}
|
|
542
542
|
JSObject eventData = call.getObject("detail");
|
|
543
543
|
// Log event data
|
|
544
|
-
Log.d("InAppBrowserPlugin", "Event data: " + eventData.toString());
|
|
545
544
|
if (eventData == null) {
|
|
546
545
|
call.reject("No event data provided");
|
|
547
546
|
return;
|
|
548
547
|
}
|
|
548
|
+
Log.d("InAppBrowserPlugin", "Event data: " + eventData.toString());
|
|
549
549
|
this.getActivity()
|
|
550
550
|
.runOnUiThread(
|
|
551
551
|
new Runnable() {
|
|
@@ -14,7 +14,6 @@ import android.net.Uri;
|
|
|
14
14
|
import android.net.http.SslError;
|
|
15
15
|
import android.text.TextUtils;
|
|
16
16
|
import android.util.Log;
|
|
17
|
-
import android.view.KeyEvent;
|
|
18
17
|
import android.view.View;
|
|
19
18
|
import android.view.Window;
|
|
20
19
|
import android.view.WindowManager;
|
|
@@ -26,17 +25,16 @@ import android.webkit.ValueCallback;
|
|
|
26
25
|
import android.webkit.WebChromeClient;
|
|
27
26
|
import android.webkit.WebResourceError;
|
|
28
27
|
import android.webkit.WebResourceRequest;
|
|
29
|
-
import android.webkit.WebResourceResponse;
|
|
30
28
|
import android.webkit.WebView;
|
|
31
29
|
import android.webkit.WebViewClient;
|
|
32
30
|
import android.widget.ImageButton;
|
|
33
31
|
import android.widget.TextView;
|
|
34
32
|
import android.widget.Toast;
|
|
35
33
|
import android.widget.Toolbar;
|
|
36
|
-
import androidx.annotation.Nullable;
|
|
37
34
|
import com.getcapacitor.JSObject;
|
|
38
35
|
import java.net.URI;
|
|
39
36
|
import java.net.URISyntaxException;
|
|
37
|
+
import java.util.Arrays;
|
|
40
38
|
import java.util.HashMap;
|
|
41
39
|
import java.util.Iterator;
|
|
42
40
|
import java.util.Map;
|
|
@@ -45,7 +43,6 @@ import java.util.concurrent.ExecutorService;
|
|
|
45
43
|
import java.util.concurrent.Executors;
|
|
46
44
|
import java.util.concurrent.Semaphore;
|
|
47
45
|
import java.util.concurrent.TimeUnit;
|
|
48
|
-
import org.json.JSONArray;
|
|
49
46
|
import org.json.JSONObject;
|
|
50
47
|
|
|
51
48
|
public class WebViewDialog extends Dialog {
|
|
@@ -116,14 +113,14 @@ public class WebViewDialog extends Dialog {
|
|
|
116
113
|
}
|
|
117
114
|
}
|
|
118
115
|
|
|
116
|
+
@SuppressLint("SetJavaScriptEnabled")
|
|
119
117
|
public void presentWebView() {
|
|
120
118
|
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
|
121
119
|
setCancelable(true);
|
|
122
|
-
getWindow()
|
|
123
|
-
.
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
);
|
|
120
|
+
Objects.requireNonNull(getWindow()).setFlags(
|
|
121
|
+
WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
|
122
|
+
WindowManager.LayoutParams.FLAG_FULLSCREEN
|
|
123
|
+
);
|
|
127
124
|
setContentView(R.layout.activity_browser);
|
|
128
125
|
getWindow()
|
|
129
126
|
.setLayout(
|
|
@@ -178,7 +175,7 @@ public class WebViewDialog extends Dialog {
|
|
|
178
175
|
public void onPermissionRequest(final PermissionRequest request) {
|
|
179
176
|
Log.i(
|
|
180
177
|
"INAPPBROWSER",
|
|
181
|
-
"onPermissionRequest " + request.getResources()
|
|
178
|
+
"onPermissionRequest " + Arrays.toString(request.getResources())
|
|
182
179
|
);
|
|
183
180
|
final String[] requestedResources = request.getResources();
|
|
184
181
|
for (String r : requestedResources) {
|
|
@@ -191,7 +188,7 @@ public class WebViewDialog extends Dialog {
|
|
|
191
188
|
if (permissionHandler != null) {
|
|
192
189
|
permissionHandler.handleCameraPermissionRequest(request);
|
|
193
190
|
}
|
|
194
|
-
|
|
191
|
+
return; // Return here to avoid denying the request
|
|
195
192
|
} else if (r.equals(PermissionRequest.RESOURCE_AUDIO_CAPTURE)) {
|
|
196
193
|
Log.i("INAPPBROWSER", "RESOURCE_AUDIO_CAPTURE req");
|
|
197
194
|
// Store the permission request
|
|
@@ -200,9 +197,11 @@ public class WebViewDialog extends Dialog {
|
|
|
200
197
|
if (permissionHandler != null) {
|
|
201
198
|
permissionHandler.handleMicrophonePermissionRequest(request);
|
|
202
199
|
}
|
|
203
|
-
|
|
200
|
+
return; // Return here to avoid denying the request
|
|
204
201
|
}
|
|
205
202
|
}
|
|
203
|
+
// If no matching permission is found, deny the request
|
|
204
|
+
request.deny();
|
|
206
205
|
}
|
|
207
206
|
|
|
208
207
|
@Override
|