@capacitor/android 9.0.0-alpha.3 → 9.0.0-alpha.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/capacitor/build.gradle +3 -4
- package/capacitor/src/main/java/com/getcapacitor/Bridge.java +10 -56
- package/capacitor/src/main/java/com/getcapacitor/BridgeWebChromeClient.java +2 -2
- package/capacitor/src/main/java/com/getcapacitor/FileUtils.java +1 -1
- package/capacitor/src/main/java/com/getcapacitor/WebViewLocalServer.java +6 -6
- package/capacitor/src/main/java/com/getcapacitor/plugin/CapacitorCookieManager.java +3 -3
- package/capacitor/src/main/java/com/getcapacitor/plugin/util/CapacitorHttpUrlConnection.java +2 -11
- package/capacitor/src/main/java/com/getcapacitor/plugin/util/HttpRequestHandler.java +2 -2
- package/capacitor-cordova/build.gradle +3 -4
- package/package.json +3 -3
package/capacitor/build.gradle
CHANGED
|
@@ -20,7 +20,7 @@ buildscript {
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
dependencies {
|
|
23
|
-
classpath 'com.android.tools.build:gradle:
|
|
23
|
+
classpath 'com.android.tools.build:gradle:9.2.1'
|
|
24
24
|
|
|
25
25
|
if (System.getenv("CAP_PUBLISH") == "true") {
|
|
26
26
|
classpath 'io.github.gradle-nexus:publish-plugin:1.3.0'
|
|
@@ -40,10 +40,9 @@ if (System.getenv("CAP_PUBLISH") == "true") {
|
|
|
40
40
|
|
|
41
41
|
android {
|
|
42
42
|
namespace = "com.getcapacitor.android"
|
|
43
|
-
compileSdk = project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion :
|
|
43
|
+
compileSdk = project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 37
|
|
44
44
|
defaultConfig {
|
|
45
|
-
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion :
|
|
46
|
-
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 36
|
|
45
|
+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 26
|
|
47
46
|
versionCode 1
|
|
48
47
|
versionName "1.0"
|
|
49
48
|
consumerProguardFiles 'proguard-rules.pro'
|
|
@@ -11,7 +11,6 @@ import android.content.pm.PackageInfo;
|
|
|
11
11
|
import android.content.pm.PackageManager;
|
|
12
12
|
import android.content.res.Configuration;
|
|
13
13
|
import android.net.Uri;
|
|
14
|
-
import android.os.Build;
|
|
15
14
|
import android.os.Bundle;
|
|
16
15
|
import android.os.Handler;
|
|
17
16
|
import android.os.HandlerThread;
|
|
@@ -51,7 +50,6 @@ import java.util.LinkedList;
|
|
|
51
50
|
import java.util.List;
|
|
52
51
|
import java.util.Map;
|
|
53
52
|
import java.util.Set;
|
|
54
|
-
import java.util.function.Function;
|
|
55
53
|
import java.util.regex.Matcher;
|
|
56
54
|
import java.util.regex.Pattern;
|
|
57
55
|
import org.json.JSONException;
|
|
@@ -294,63 +292,19 @@ public class Bridge {
|
|
|
294
292
|
|
|
295
293
|
@SuppressLint("WebViewApiAvailability")
|
|
296
294
|
public boolean isMinimumWebViewInstalled() {
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
if (
|
|
301
|
-
|
|
302
|
-
Pattern pattern = Pattern.compile("(\\d+)");
|
|
303
|
-
Matcher matcher = pattern.matcher(info.versionName);
|
|
304
|
-
if (matcher.find()) {
|
|
305
|
-
String majorVersionStr = matcher.group(0);
|
|
306
|
-
int majorVersion = Integer.parseInt(majorVersionStr);
|
|
307
|
-
if (info.packageName.equals("com.huawei.webview")) {
|
|
308
|
-
return majorVersion >= config.getMinHuaweiWebViewVersion();
|
|
309
|
-
}
|
|
310
|
-
return majorVersion >= config.getMinWebViewVersion();
|
|
311
|
-
} else {
|
|
312
|
-
return false;
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
// Otherwise manually check WebView versions
|
|
317
|
-
try {
|
|
318
|
-
PackageInfo info = InternalUtils.getPackageInfo(pm, "com.android.chrome");
|
|
319
|
-
String majorVersionStr = info.versionName.split("\\.")[0];
|
|
320
|
-
int majorVersion = Integer.parseInt(majorVersionStr);
|
|
321
|
-
return majorVersion >= config.getMinWebViewVersion();
|
|
322
|
-
} catch (Exception ex) {
|
|
323
|
-
Logger.warn("Unable to get package info for 'com.google.android.webview'" + ex.toString());
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
try {
|
|
327
|
-
PackageInfo info = InternalUtils.getPackageInfo(pm, "com.android.webview");
|
|
328
|
-
String majorVersionStr = info.versionName.split("\\.")[0];
|
|
295
|
+
PackageInfo info = WebView.getCurrentWebViewPackage();
|
|
296
|
+
Pattern pattern = Pattern.compile("(\\d+)");
|
|
297
|
+
Matcher matcher = pattern.matcher(info.versionName);
|
|
298
|
+
if (matcher.find()) {
|
|
299
|
+
String majorVersionStr = matcher.group(0);
|
|
329
300
|
int majorVersion = Integer.parseInt(majorVersionStr);
|
|
301
|
+
if (info.packageName.equals("com.huawei.webview")) {
|
|
302
|
+
return majorVersion >= config.getMinHuaweiWebViewVersion();
|
|
303
|
+
}
|
|
330
304
|
return majorVersion >= config.getMinWebViewVersion();
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
final int amazonFireMajorWebViewVersion = extractWebViewMajorVersion(pm, "com.amazon.webview.chromium");
|
|
336
|
-
if (amazonFireMajorWebViewVersion >= config.getMinWebViewVersion()) {
|
|
337
|
-
return true;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
// Could not detect any webview, return false
|
|
341
|
-
return false;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
private int extractWebViewMajorVersion(final PackageManager pm, final String webViewPackageName) {
|
|
345
|
-
try {
|
|
346
|
-
final PackageInfo info = InternalUtils.getPackageInfo(pm, webViewPackageName);
|
|
347
|
-
final String majorVersionStr = info.versionName.split("\\.")[0];
|
|
348
|
-
final int majorVersion = Integer.parseInt(majorVersionStr);
|
|
349
|
-
return majorVersion;
|
|
350
|
-
} catch (Exception ex) {
|
|
351
|
-
Logger.warn(String.format("Unable to get package info for '%s' with err '%s'", webViewPackageName, ex));
|
|
305
|
+
} else {
|
|
306
|
+
return false;
|
|
352
307
|
}
|
|
353
|
-
return 0;
|
|
354
308
|
}
|
|
355
309
|
|
|
356
310
|
public boolean launchIntent(Uri url) {
|
|
@@ -282,7 +282,7 @@ public class BridgeWebChromeClient extends WebChromeClient {
|
|
|
282
282
|
boolean captureEnabled = fileChooserParams.isCaptureEnabled();
|
|
283
283
|
boolean capturePhoto = captureEnabled && acceptTypes.contains("image/*");
|
|
284
284
|
final boolean captureVideo = captureEnabled && acceptTypes.contains("video/*");
|
|
285
|
-
if (
|
|
285
|
+
if (capturePhoto || captureVideo) {
|
|
286
286
|
if (isMediaCaptureSupported()) {
|
|
287
287
|
showMediaCaptureOrFilePicker(filePathCallback, fileChooserParams, captureVideo);
|
|
288
288
|
} else {
|
|
@@ -447,7 +447,7 @@ public class BridgeWebChromeClient extends WebChromeClient {
|
|
|
447
447
|
}
|
|
448
448
|
|
|
449
449
|
public boolean isValidMsg(String msg) {
|
|
450
|
-
return !(msg.contains("%cresult %c") ||
|
|
450
|
+
return !(msg.contains("%cresult %c") || msg.contains("%cnative %c") || msg.equalsIgnoreCase("console.groupEnd"));
|
|
451
451
|
}
|
|
452
452
|
|
|
453
453
|
private Uri createImageFileUri() throws IOException {
|
|
@@ -218,7 +218,7 @@ public class FileUtils {
|
|
|
218
218
|
Cursor cursor = context.getContentResolver().query(uri, null, null, null, null);
|
|
219
219
|
int nameIndex = cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME);
|
|
220
220
|
cursor.moveToFirst();
|
|
221
|
-
String name =
|
|
221
|
+
String name = cursor.getString(nameIndex);
|
|
222
222
|
String fileName = sanitizeFilename(name);
|
|
223
223
|
File file = new File(context.getFilesDir(), fileName);
|
|
224
224
|
try {
|
|
@@ -208,7 +208,7 @@ public class WebViewLocalServer {
|
|
|
208
208
|
}
|
|
209
209
|
|
|
210
210
|
private boolean isMainUrl(Uri loadingUrl) {
|
|
211
|
-
return
|
|
211
|
+
return bridge.getServerUrl() == null && loadingUrl.getHost().equalsIgnoreCase(bridge.getHost());
|
|
212
212
|
}
|
|
213
213
|
|
|
214
214
|
private boolean isAllowedUrl(Uri loadingUrl) {
|
|
@@ -709,31 +709,31 @@ public class WebViewLocalServer {
|
|
|
709
709
|
@Override
|
|
710
710
|
public int available() throws IOException {
|
|
711
711
|
InputStream is = getInputStream();
|
|
712
|
-
return
|
|
712
|
+
return is != null ? is.available() : -1;
|
|
713
713
|
}
|
|
714
714
|
|
|
715
715
|
@Override
|
|
716
716
|
public int read() throws IOException {
|
|
717
717
|
InputStream is = getInputStream();
|
|
718
|
-
return
|
|
718
|
+
return is != null ? is.read() : -1;
|
|
719
719
|
}
|
|
720
720
|
|
|
721
721
|
@Override
|
|
722
722
|
public int read(byte[] b) throws IOException {
|
|
723
723
|
InputStream is = getInputStream();
|
|
724
|
-
return
|
|
724
|
+
return is != null ? is.read(b) : -1;
|
|
725
725
|
}
|
|
726
726
|
|
|
727
727
|
@Override
|
|
728
728
|
public int read(byte[] b, int off, int len) throws IOException {
|
|
729
729
|
InputStream is = getInputStream();
|
|
730
|
-
return
|
|
730
|
+
return is != null ? is.read(b, off, len) : -1;
|
|
731
731
|
}
|
|
732
732
|
|
|
733
733
|
@Override
|
|
734
734
|
public long skip(long n) throws IOException {
|
|
735
735
|
InputStream is = getInputStream();
|
|
736
|
-
return
|
|
736
|
+
return is != null ? is.skip(n) : 0;
|
|
737
737
|
}
|
|
738
738
|
}
|
|
739
739
|
|
|
@@ -192,12 +192,12 @@ public class CapacitorCookieManager extends CookieManager {
|
|
|
192
192
|
@Override
|
|
193
193
|
public void put(URI uri, Map<String, List<String>> responseHeaders) {
|
|
194
194
|
// make sure our args are valid
|
|
195
|
-
if (
|
|
195
|
+
if (uri == null || responseHeaders == null) return;
|
|
196
196
|
|
|
197
197
|
// go over the headers
|
|
198
198
|
for (String headerKey : responseHeaders.keySet()) {
|
|
199
199
|
// ignore headers which aren't cookie related
|
|
200
|
-
if (
|
|
200
|
+
if (headerKey == null || !(headerKey.equalsIgnoreCase("Set-Cookie2") || headerKey.equalsIgnoreCase("Set-Cookie"))) continue;
|
|
201
201
|
|
|
202
202
|
// process each of the headers
|
|
203
203
|
for (String headerValue : Objects.requireNonNull(responseHeaders.get(headerKey))) {
|
|
@@ -215,7 +215,7 @@ public class CapacitorCookieManager extends CookieManager {
|
|
|
215
215
|
@Override
|
|
216
216
|
public Map<String, List<String>> get(URI uri, Map<String, List<String>> requestHeaders) {
|
|
217
217
|
// make sure our args are valid
|
|
218
|
-
if (
|
|
218
|
+
if (uri == null || requestHeaders == null) throw new IllegalArgumentException("Argument is null");
|
|
219
219
|
|
|
220
220
|
// save our url once
|
|
221
221
|
String url = uri.toString();
|
package/capacitor/src/main/java/com/getcapacitor/plugin/util/CapacitorHttpUrlConnection.java
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
package com.getcapacitor.plugin.util;
|
|
2
2
|
|
|
3
|
-
import android.os.Build;
|
|
4
3
|
import android.os.LocaleList;
|
|
5
4
|
import android.text.TextUtils;
|
|
6
5
|
import com.getcapacitor.Bridge;
|
|
@@ -211,9 +210,7 @@ public class CapacitorHttpUrlConnection implements ICapacitorHttpUrlConnection {
|
|
|
211
210
|
this.writeRequestBody(dataString != null ? dataString : "");
|
|
212
211
|
} else if (bodyType != null && bodyType.equals("file")) {
|
|
213
212
|
try (DataOutputStream os = new DataOutputStream(connection.getOutputStream())) {
|
|
214
|
-
|
|
215
|
-
os.write(Base64.getDecoder().decode(body.toString()));
|
|
216
|
-
}
|
|
213
|
+
os.write(Base64.getDecoder().decode(body.toString()));
|
|
217
214
|
os.flush();
|
|
218
215
|
}
|
|
219
216
|
} else if (contentType.contains("application/x-www-form-urlencoded")) {
|
|
@@ -295,13 +292,7 @@ public class CapacitorHttpUrlConnection implements ICapacitorHttpUrlConnection {
|
|
|
295
292
|
os.writeBytes("Content-Type: " + fileContentType + lineEnd);
|
|
296
293
|
os.writeBytes("Content-Transfer-Encoding: binary" + lineEnd);
|
|
297
294
|
os.writeBytes(lineEnd);
|
|
298
|
-
|
|
299
|
-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
300
|
-
os.write(Base64.getDecoder().decode(value));
|
|
301
|
-
} else {
|
|
302
|
-
os.write(android.util.Base64.decode(value, android.util.Base64.DEFAULT));
|
|
303
|
-
}
|
|
304
|
-
|
|
295
|
+
os.write(Base64.getDecoder().decode(value));
|
|
305
296
|
os.writeBytes(lineEnd);
|
|
306
297
|
}
|
|
307
298
|
}
|
|
@@ -168,8 +168,8 @@ public class HttpRequestHandler {
|
|
|
168
168
|
"://" +
|
|
169
169
|
uri.getAuthority() +
|
|
170
170
|
uri.getPath() +
|
|
171
|
-
(
|
|
172
|
-
(
|
|
171
|
+
(!urlQuery.equals("") ? "?" + urlQuery : "") +
|
|
172
|
+
(uri.getFragment() != null ? uri.getFragment() : "");
|
|
173
173
|
this.url = new URL(unEncodedUrlString);
|
|
174
174
|
|
|
175
175
|
return this;
|
|
@@ -9,7 +9,7 @@ buildscript {
|
|
|
9
9
|
mavenCentral()
|
|
10
10
|
}
|
|
11
11
|
dependencies {
|
|
12
|
-
classpath 'com.android.tools.build:gradle:
|
|
12
|
+
classpath 'com.android.tools.build:gradle:9.2.1'
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
|
|
@@ -17,10 +17,9 @@ apply plugin: 'com.android.library'
|
|
|
17
17
|
|
|
18
18
|
android {
|
|
19
19
|
namespace = "com.getcapacitor.cordova"
|
|
20
|
-
compileSdk = project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion :
|
|
20
|
+
compileSdk = project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 37
|
|
21
21
|
defaultConfig {
|
|
22
|
-
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion :
|
|
23
|
-
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 36
|
|
22
|
+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 26
|
|
24
23
|
versionCode 1
|
|
25
24
|
versionName "1.0"
|
|
26
25
|
consumerProguardFiles 'proguard-rules.pro'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capacitor/android",
|
|
3
|
-
"version": "9.0.0-alpha.
|
|
3
|
+
"version": "9.0.0-alpha.5",
|
|
4
4
|
"description": "Capacitor: Cross-platform apps with JavaScript and the web",
|
|
5
5
|
"homepage": "https://capacitorjs.com",
|
|
6
6
|
"author": "Ionic Team <hi@ionic.io> (https://ionic.io)",
|
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
"capacitor-cordova/src/main/"
|
|
24
24
|
],
|
|
25
25
|
"scripts": {
|
|
26
|
-
"verify": "./gradlew clean lint build test
|
|
26
|
+
"verify": "./gradlew :capacitor-android:clean :capacitor-android:lint :capacitor-android:build :capacitor-android:test"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
|
-
"@capacitor/core": "^9.0.0-alpha.
|
|
29
|
+
"@capacitor/core": "^9.0.0-alpha.5"
|
|
30
30
|
},
|
|
31
31
|
"publishConfig": {
|
|
32
32
|
"access": "public"
|