@capacitor/android 4.7.2 → 4.8.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 CHANGED
@@ -3,6 +3,31 @@
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
+ # [4.8.0](https://github.com/ionic-team/capacitor/compare/4.7.3...4.8.0) (2023-04-26)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **android:** launching intents without host ([#6493](https://github.com/ionic-team/capacitor/issues/6493)) ([6028ff4](https://github.com/ionic-team/capacitor/commit/6028ff482b489c150e348a3b536387c321b39b80))
12
+ * **cookies:** check isEnabled before setting cookieHandler ([24a28cb](https://github.com/ionic-team/capacitor/commit/24a28cb0a391dcd7f305000c4973b4c2c9a79359))
13
+ * **cookies:** init cookie manager after server url is set ([4000b02](https://github.com/ionic-team/capacitor/commit/4000b0259223fcd505bbd5393e2458f0abd3b156))
14
+ * **http:** copy native response url to fetch response ([42d2eb3](https://github.com/ionic-team/capacitor/commit/42d2eb3c3c04e087b88df7252cd2c323b00a3f95))
15
+
16
+
17
+
18
+
19
+
20
+ ## [4.7.3](https://github.com/ionic-team/capacitor/compare/4.7.2...4.7.3) (2023-03-31)
21
+
22
+
23
+ ### Bug Fixes
24
+
25
+ * **android:** remove stored references to bridge that holds it in memory ([#6448](https://github.com/ionic-team/capacitor/issues/6448)) ([#6455](https://github.com/ionic-team/capacitor/issues/6455)) ([8fa2d1c](https://github.com/ionic-team/capacitor/commit/8fa2d1c560321d9eb91edb1c81bf64f802289604))
26
+
27
+
28
+
29
+
30
+
6
31
  ## [4.7.2](https://github.com/ionic-team/capacitor/compare/4.7.1...4.7.2) (2023-03-31)
7
32
 
8
33
 
@@ -392,6 +392,14 @@ var nativeBridge = (function (exports) {
392
392
  headers: nativeResponse.headers,
393
393
  status: nativeResponse.status,
394
394
  });
395
+ /*
396
+ * copy url to response, `cordova-plugin-ionic` uses this url from the response
397
+ * we need `Object.defineProperty` because url is an inherited getter on the Response
398
+ * see: https://stackoverflow.com/a/57382543
399
+ * */
400
+ Object.defineProperty(response, 'url', {
401
+ value: nativeResponse.url,
402
+ });
395
403
  console.timeEnd(tag);
396
404
  return response;
397
405
  }
@@ -371,7 +371,7 @@ public class Bridge {
371
371
 
372
372
  Uri appUri = Uri.parse(appUrl);
373
373
  if (
374
- !(url.getHost().equals(appUri.getHost()) && url.getScheme().equals(appUri.getScheme())) &&
374
+ !(appUri.getHost().equals(url.getHost()) && url.getScheme().equals(appUri.getScheme())) &&
375
375
  !appAllowNavigationMask.matches(url.getHost())
376
376
  ) {
377
377
  try {
@@ -17,7 +17,10 @@ import java.util.Objects;
17
17
  public class CapacitorCookieManager extends CookieManager {
18
18
 
19
19
  private final android.webkit.CookieManager webkitCookieManager;
20
- private final Bridge bridge;
20
+
21
+ private final String localUrl;
22
+
23
+ private final String serverUrl;
21
24
 
22
25
  /**
23
26
  * Create a new cookie manager with the default cookie store and policy
@@ -36,18 +39,19 @@ public class CapacitorCookieManager extends CookieManager {
36
39
  public CapacitorCookieManager(CookieStore store, CookiePolicy policy, Bridge bridge) {
37
40
  super(store, policy);
38
41
  webkitCookieManager = android.webkit.CookieManager.getInstance();
39
- this.bridge = bridge;
42
+ this.localUrl = bridge.getLocalUrl();
43
+ this.serverUrl = bridge.getServerUrl();
40
44
  }
41
45
 
42
46
  public String getSanitizedDomain(String url) {
43
47
  if (url == null || url.isEmpty()) {
44
- url = this.bridge.getLocalUrl();
48
+ url = this.localUrl;
45
49
  }
46
50
 
47
51
  try {
48
52
  new URI(url);
49
53
  } catch (Exception ex) {
50
- return this.bridge.getServerUrl();
54
+ return this.serverUrl;
51
55
  }
52
56
 
53
57
  return url;
@@ -20,15 +20,18 @@ public class CapacitorCookies extends Plugin {
20
20
  @Override
21
21
  public void load() {
22
22
  this.bridge.getWebView().addJavascriptInterface(this, "CapacitorCookiesAndroidInterface");
23
- this.cookieManager = new CapacitorCookieManager(null, java.net.CookiePolicy.ACCEPT_ALL, this.bridge);
24
- CookieHandler.setDefault(cookieManager);
25
23
  super.load();
26
24
  }
27
25
 
28
26
  @JavascriptInterface
29
27
  public boolean isEnabled() {
30
28
  PluginConfig pluginConfig = getBridge().getConfig().getPluginConfiguration("CapacitorCookies");
31
- return pluginConfig.getBoolean("enabled", false);
29
+ boolean isEnabled = pluginConfig.getBoolean("enabled", false);
30
+ if (isEnabled) {
31
+ this.cookieManager = new CapacitorCookieManager(null, java.net.CookiePolicy.ACCEPT_ALL, this.bridge);
32
+ CookieHandler.setDefault(cookieManager);
33
+ }
34
+ return isEnabled;
32
35
  }
33
36
 
34
37
  /**
@@ -31,8 +31,7 @@ public class CapacitorHttp extends Plugin {
31
31
  @Override
32
32
  public void run() {
33
33
  try {
34
- HttpRequestHandler.bridge = bridge;
35
- JSObject response = HttpRequestHandler.request(call, httpMethod);
34
+ JSObject response = HttpRequestHandler.request(call, httpMethod, getBridge());
36
35
  call.resolve(response);
37
36
  } catch (Exception e) {
38
37
  call.reject(e.getLocalizedMessage(), e.getClass().getSimpleName(), e);
@@ -27,8 +27,6 @@ import org.json.JSONObject;
27
27
 
28
28
  public class HttpRequestHandler {
29
29
 
30
- public static Bridge bridge = null;
31
-
32
30
  /**
33
31
  * An enum specifying conventional HTTP Response Types
34
32
  * See https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseType
@@ -367,7 +365,8 @@ public class HttpRequestHandler {
367
365
  * @throws URISyntaxException thrown when the URI is malformed
368
366
  * @throws JSONException thrown when the incoming JSON is malformed
369
367
  */
370
- public static JSObject request(PluginCall call, String httpMethod) throws IOException, URISyntaxException, JSONException {
368
+ public static JSObject request(PluginCall call, String httpMethod, Bridge bridge)
369
+ throws IOException, URISyntaxException, JSONException {
371
370
  String urlString = call.getString("url", "");
372
371
  JSObject headers = call.getObject("headers");
373
372
  JSObject params = call.getObject("params");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor/android",
3
- "version": "4.7.2",
3
+ "version": "4.8.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)",
@@ -28,5 +28,5 @@
28
28
  "publishConfig": {
29
29
  "access": "public"
30
30
  },
31
- "gitHead": "f17e5827ea115250c17c289c3db5432b67df6907"
31
+ "gitHead": "b43c69d9d6530fa1a0cc461d6db14859865ed995"
32
32
  }