@capacitor/android 3.5.0 → 3.7.0
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/CHANGELOG.md +31 -0
- package/capacitor/src/main/java/com/getcapacitor/AppUUID.java +65 -0
- package/capacitor/src/main/java/com/getcapacitor/Bridge.java +4 -1
- package/capacitor/src/main/java/com/getcapacitor/CapConfig.java +14 -0
- package/capacitor/src/main/java/com/getcapacitor/ProcessedRoute.java +28 -0
- package/capacitor/src/main/java/com/getcapacitor/RouteProcessor.java +1 -1
- package/capacitor/src/main/java/com/getcapacitor/WebViewLocalServer.java +11 -4
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,37 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [3.7.0](https://github.com/ionic-team/capacitor/compare/3.6.0...3.7.0) (2022-08-01)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @capacitor/android
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [3.6.0](https://github.com/ionic-team/capacitor/compare/3.5.1...3.6.0) (2022-06-17)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* **android:** update support for Portals for Capacitor to include Live Updates ([#5660](https://github.com/ionic-team/capacitor/issues/5660)) ([62f0a5e](https://github.com/ionic-team/capacitor/commit/62f0a5eaa40776aad79dbf8f8c0900037d3cc97e))
|
|
20
|
+
* **iOS, Android:** add AppUUID Lib for plugins ([#5690](https://github.com/ionic-team/capacitor/issues/5690)) ([05e76cf](https://github.com/ionic-team/capacitor/commit/05e76cf526a44e07fa75f9482fa2223a13918638))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
## [3.5.1](https://github.com/ionic-team/capacitor/compare/3.5.0...3.5.1) (2022-05-04)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### Bug Fixes
|
|
30
|
+
|
|
31
|
+
* **android:** move initialFocus on webview into config ([#5579](https://github.com/ionic-team/capacitor/issues/5579)) ([8b4e861](https://github.com/ionic-team/capacitor/commit/8b4e861514b0fbe08e9296f49c280234f54742e1))
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
6
37
|
# [3.5.0](https://github.com/ionic-team/capacitor/compare/3.4.3...3.5.0) (2022-04-22)
|
|
7
38
|
|
|
8
39
|
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
package com.getcapacitor;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.content.SharedPreferences;
|
|
5
|
+
import androidx.appcompat.app.AppCompatActivity;
|
|
6
|
+
import java.nio.charset.StandardCharsets;
|
|
7
|
+
import java.security.MessageDigest;
|
|
8
|
+
import java.security.NoSuchAlgorithmException;
|
|
9
|
+
import java.util.Objects;
|
|
10
|
+
import java.util.UUID;
|
|
11
|
+
|
|
12
|
+
public final class AppUUID {
|
|
13
|
+
|
|
14
|
+
private static final String KEY = "CapacitorAppUUID";
|
|
15
|
+
|
|
16
|
+
public static String getAppUUID(AppCompatActivity activity) throws Exception {
|
|
17
|
+
assertAppUUID(activity);
|
|
18
|
+
return readUUID(activity);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public static void regenerateAppUUID(AppCompatActivity activity) throws Exception {
|
|
22
|
+
try {
|
|
23
|
+
String uuid = generateUUID();
|
|
24
|
+
writeUUID(activity, uuid);
|
|
25
|
+
} catch (NoSuchAlgorithmException ex) {
|
|
26
|
+
throw new Exception("Capacitor App UUID could not be generated.");
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
private static void assertAppUUID(AppCompatActivity activity) throws Exception {
|
|
31
|
+
String uuid = readUUID(activity);
|
|
32
|
+
if (uuid.equals("")) {
|
|
33
|
+
regenerateAppUUID(activity);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
private static String generateUUID() throws NoSuchAlgorithmException {
|
|
38
|
+
MessageDigest salt = MessageDigest.getInstance("SHA-256");
|
|
39
|
+
salt.update(UUID.randomUUID().toString().getBytes(StandardCharsets.UTF_8));
|
|
40
|
+
return bytesToHex(salt.digest());
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
private static String readUUID(AppCompatActivity activity) {
|
|
44
|
+
SharedPreferences sharedPref = activity.getPreferences(Context.MODE_PRIVATE);
|
|
45
|
+
return sharedPref.getString(KEY, "");
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
private static void writeUUID(AppCompatActivity activity, String uuid) {
|
|
49
|
+
SharedPreferences sharedPref = activity.getPreferences(Context.MODE_PRIVATE);
|
|
50
|
+
SharedPreferences.Editor editor = sharedPref.edit();
|
|
51
|
+
editor.putString(KEY, uuid);
|
|
52
|
+
editor.apply();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
private static String bytesToHex(byte[] bytes) {
|
|
56
|
+
byte[] HEX_ARRAY = "0123456789ABCDEF".getBytes(StandardCharsets.US_ASCII);
|
|
57
|
+
byte[] hexChars = new byte[bytes.length * 2];
|
|
58
|
+
for (int j = 0; j < bytes.length; j++) {
|
|
59
|
+
int v = bytes[j] & 0xFF;
|
|
60
|
+
hexChars[j * 2] = HEX_ARRAY[v >>> 4];
|
|
61
|
+
hexChars[j * 2 + 1] = HEX_ARRAY[v & 0x0F];
|
|
62
|
+
}
|
|
63
|
+
return new String(hexChars, StandardCharsets.UTF_8);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -447,7 +447,10 @@ public class Bridge {
|
|
|
447
447
|
Logger.debug("WebView background color not applied");
|
|
448
448
|
}
|
|
449
449
|
|
|
450
|
-
|
|
450
|
+
if (config.isInitialFocus()) {
|
|
451
|
+
webView.requestFocusFromTouch();
|
|
452
|
+
}
|
|
453
|
+
|
|
451
454
|
WebView.setWebContentsDebuggingEnabled(this.config.isWebContentsDebuggingEnabled());
|
|
452
455
|
}
|
|
453
456
|
|
|
@@ -40,6 +40,7 @@ public class CapConfig {
|
|
|
40
40
|
private boolean captureInput = false;
|
|
41
41
|
private boolean webContentsDebuggingEnabled = false;
|
|
42
42
|
private boolean loggingEnabled = true;
|
|
43
|
+
private boolean initialFocus = true;
|
|
43
44
|
|
|
44
45
|
// Embedded
|
|
45
46
|
private String startPath;
|
|
@@ -116,6 +117,7 @@ public class CapConfig {
|
|
|
116
117
|
this.captureInput = builder.captureInput;
|
|
117
118
|
this.webContentsDebuggingEnabled = builder.webContentsDebuggingEnabled;
|
|
118
119
|
this.loggingEnabled = builder.loggingEnabled;
|
|
120
|
+
this.initialFocus = builder.initialFocus;
|
|
119
121
|
|
|
120
122
|
// Embedded
|
|
121
123
|
this.startPath = builder.startPath;
|
|
@@ -187,6 +189,8 @@ public class CapConfig {
|
|
|
187
189
|
loggingEnabled = isDebug;
|
|
188
190
|
}
|
|
189
191
|
|
|
192
|
+
initialFocus = JSONUtils.getBoolean(configJSON, "android.initialFocus", initialFocus);
|
|
193
|
+
|
|
190
194
|
// Plugins
|
|
191
195
|
pluginsConfiguration = deserializePluginsConfig(JSONUtils.getObject(configJSON, "plugins"));
|
|
192
196
|
}
|
|
@@ -243,6 +247,10 @@ public class CapConfig {
|
|
|
243
247
|
return loggingEnabled;
|
|
244
248
|
}
|
|
245
249
|
|
|
250
|
+
public boolean isInitialFocus() {
|
|
251
|
+
return initialFocus;
|
|
252
|
+
}
|
|
253
|
+
|
|
246
254
|
public PluginConfig getPluginConfiguration(String pluginId) {
|
|
247
255
|
PluginConfig pluginConfig = pluginsConfiguration.get(pluginId);
|
|
248
256
|
if (pluginConfig == null) {
|
|
@@ -398,6 +406,7 @@ public class CapConfig {
|
|
|
398
406
|
private boolean captureInput = false;
|
|
399
407
|
private Boolean webContentsDebuggingEnabled = null;
|
|
400
408
|
private boolean loggingEnabled = true;
|
|
409
|
+
private boolean initialFocus = false;
|
|
401
410
|
|
|
402
411
|
// Embedded
|
|
403
412
|
private String startPath = null;
|
|
@@ -496,5 +505,10 @@ public class CapConfig {
|
|
|
496
505
|
this.loggingEnabled = enabled;
|
|
497
506
|
return this;
|
|
498
507
|
}
|
|
508
|
+
|
|
509
|
+
public Builder setInitialFocus(boolean focus) {
|
|
510
|
+
this.initialFocus = focus;
|
|
511
|
+
return this;
|
|
512
|
+
}
|
|
499
513
|
}
|
|
500
514
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
package com.getcapacitor;
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* An data class used in conjunction with RouteProcessor.
|
|
5
|
+
*
|
|
6
|
+
* @see com.getcapacitor.RouteProcessor
|
|
7
|
+
*/
|
|
8
|
+
public class ProcessedRoute {
|
|
9
|
+
|
|
10
|
+
private String path;
|
|
11
|
+
private boolean isAsset;
|
|
12
|
+
|
|
13
|
+
public String getPath() {
|
|
14
|
+
return path;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public void setPath(String path) {
|
|
18
|
+
this.path = path;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public boolean isAsset() {
|
|
22
|
+
return isAsset;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
public void setAsset(boolean asset) {
|
|
26
|
+
isAsset = asset;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -256,7 +256,9 @@ public class WebViewLocalServer {
|
|
|
256
256
|
try {
|
|
257
257
|
String startPath = this.basePath + "/index.html";
|
|
258
258
|
if (bridge.getRouteProcessor() != null) {
|
|
259
|
-
|
|
259
|
+
ProcessedRoute processedRoute = bridge.getRouteProcessor().process(this.basePath, "/index.html");
|
|
260
|
+
startPath = processedRoute.getPath();
|
|
261
|
+
isAsset = processedRoute.isAsset();
|
|
260
262
|
}
|
|
261
263
|
|
|
262
264
|
if (isAsset) {
|
|
@@ -474,16 +476,21 @@ public class WebViewLocalServer {
|
|
|
474
476
|
// Pass path to routeProcessor if present
|
|
475
477
|
RouteProcessor routeProcessor = bridge.getRouteProcessor();
|
|
476
478
|
if (routeProcessor != null) {
|
|
477
|
-
|
|
479
|
+
ProcessedRoute processedRoute = bridge.getRouteProcessor().process("", path);
|
|
480
|
+
path = processedRoute.getPath();
|
|
481
|
+
isAsset = processedRoute.isAsset();
|
|
478
482
|
}
|
|
479
483
|
|
|
480
484
|
try {
|
|
481
485
|
if (path.startsWith(capacitorContentStart)) {
|
|
482
486
|
stream = protocolHandler.openContentUrl(url);
|
|
483
|
-
} else if (path.startsWith(capacitorFileStart)
|
|
484
|
-
|
|
487
|
+
} else if (path.startsWith(capacitorFileStart)) {
|
|
488
|
+
stream = protocolHandler.openFile(path);
|
|
489
|
+
} else if (!isAsset) {
|
|
490
|
+
if (routeProcessor == null) {
|
|
485
491
|
path = basePath + url.getPath();
|
|
486
492
|
}
|
|
493
|
+
|
|
487
494
|
stream = protocolHandler.openFile(path);
|
|
488
495
|
} else {
|
|
489
496
|
stream = protocolHandler.openAsset(assetPath + path);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capacitor/android",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.7.0",
|
|
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)",
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
"verify": "./gradlew clean lint build test -b capacitor/build.gradle"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"@capacitor/core": "^3.
|
|
25
|
+
"@capacitor/core": "^3.7.0"
|
|
26
26
|
},
|
|
27
27
|
"publishConfig": {
|
|
28
28
|
"access": "public"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "84ec6619623510e345b2637e33febe94b10cc736"
|
|
31
31
|
}
|