@capacitor/android 3.2.2 → 3.3.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,57 @@
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.3.0](https://github.com/ionic-team/capacitor/compare/3.2.5...3.3.0) (2021-11-03)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **core:** avoid crash on logging circular objects ([#5186](https://github.com/ionic-team/capacitor/issues/5186)) ([1451ec8](https://github.com/ionic-team/capacitor/commit/1451ec850a9ef73267a032638e73f1fc440647b9))
12
+
13
+
14
+ ### Features
15
+
16
+ * **android:** ability to reload the webview ([#5184](https://github.com/ionic-team/capacitor/issues/5184)) ([c495bed](https://github.com/ionic-team/capacitor/commit/c495bed216ddf05450f185d2d3f09b4052b281a8))
17
+
18
+
19
+
20
+
21
+
22
+ ## [3.2.5](https://github.com/ionic-team/capacitor/compare/3.2.4...3.2.5) (2021-10-13)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * **android:** Avoid ConcurrentModificationException on notifyListeners ([#5125](https://github.com/ionic-team/capacitor/issues/5125)) ([b82bfe0](https://github.com/ionic-team/capacitor/commit/b82bfe0db2e38fa286eb18391b1d5e2f86a1b35c))
28
+ * **android:** Support cordova-android 10 ([#5103](https://github.com/ionic-team/capacitor/issues/5103)) ([e238233](https://github.com/ionic-team/capacitor/commit/e238233dcf34a183af4861176789d1feb1eb51fa))
29
+
30
+
31
+
32
+
33
+
34
+ ## [3.2.4](https://github.com/ionic-team/capacitor/compare/3.2.3...3.2.4) (2021-09-27)
35
+
36
+
37
+ ### Bug Fixes
38
+
39
+ * **ios:** show correct line number on console logs ([#5073](https://github.com/ionic-team/capacitor/issues/5073)) ([ec41e74](https://github.com/ionic-team/capacitor/commit/ec41e743aa4ba81e791ad446fac461b7f43b46ed))
40
+
41
+
42
+
43
+
44
+
45
+ ## [3.2.3](https://github.com/ionic-team/capacitor/compare/3.2.2...3.2.3) (2021-09-15)
46
+
47
+
48
+ ### Bug Fixes
49
+
50
+ * **android:** proguard rules ([#5048](https://github.com/ionic-team/capacitor/issues/5048)) ([cf15c0f](https://github.com/ionic-team/capacitor/commit/cf15c0fb3bd67315011865fedb4157d5076965fd))
51
+ * **android:** save activity result launcher calls ([#5004](https://github.com/ionic-team/capacitor/issues/5004)) ([2c1eb60](https://github.com/ionic-team/capacitor/commit/2c1eb603c79b94f6fcc74f0cbef523590b656a1e))
52
+
53
+
54
+
55
+
56
+
6
57
  ## [3.2.2](https://github.com/ionic-team/capacitor/compare/3.2.1...3.2.2) (2021-09-02)
7
58
 
8
59
  **Note:** Version bump only for package @capacitor/android
@@ -32,6 +32,7 @@ android {
32
32
  targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 30
33
33
  versionCode 1
34
34
  versionName "1.0"
35
+ consumerProguardFiles 'proguard-rules.pro'
35
36
  testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
36
37
  }
37
38
  buildTypes {
@@ -167,21 +167,6 @@ const nativeBridge = (function (exports) {
167
167
  win.Capacitor = cap;
168
168
  win.Ionic.WebView = IonicWebView;
169
169
  };
170
- const safeStringify = (value) => {
171
- const seen = new Set();
172
- return JSON.stringify(value, (_k, v) => {
173
- if (seen.has(v)) {
174
- if (v === null)
175
- return null;
176
- else
177
- return '...';
178
- }
179
- if (typeof v === 'object') {
180
- seen.add(v);
181
- }
182
- return v;
183
- });
184
- };
185
170
  const initLogger = (win, cap) => {
186
171
  const BRIDGED_CONSOLE_METHODS = [
187
172
  'debug',
@@ -248,7 +233,7 @@ const nativeBridge = (function (exports) {
248
233
  const serializeConsoleMessage = (msg) => {
249
234
  if (typeof msg === 'object') {
250
235
  try {
251
- msg = safeStringify(msg);
236
+ msg = JSON.stringify(msg);
252
237
  }
253
238
  catch (e) {
254
239
  // ignore
@@ -258,24 +243,21 @@ const nativeBridge = (function (exports) {
258
243
  };
259
244
  // patch window.console on iOS and store original console fns
260
245
  const isIos = getPlatformId(win) === 'ios';
261
- const originalConsole = Object.assign({}, win.console);
262
246
  if (win.console && isIos) {
263
- for (const logfn of BRIDGED_CONSOLE_METHODS) {
264
- win.console[logfn] = (...args) => {
265
- const msgs = [...args];
266
- originalConsole[logfn](...msgs);
267
- try {
247
+ Object.defineProperties(win.console, BRIDGED_CONSOLE_METHODS.reduce((props, method) => {
248
+ const consoleMethod = win.console[method].bind(win.console);
249
+ props[method] = {
250
+ value: (...args) => {
251
+ const msgs = [...args];
268
252
  cap.toNative('Console', 'log', {
269
- level: logfn,
253
+ level: method,
270
254
  message: msgs.map(serializeConsoleMessage).join(' '),
271
255
  });
272
- }
273
- catch (e) {
274
- // error converting/posting console messages
275
- originalConsole.error(e);
276
- }
256
+ return consoleMethod(...args);
257
+ },
277
258
  };
278
- }
259
+ return props;
260
+ }, {}));
279
261
  }
280
262
  cap.logJs = (msg, level) => {
281
263
  switch (level) {
@@ -320,7 +302,7 @@ const nativeBridge = (function (exports) {
320
302
  postToNative = data => {
321
303
  var _a;
322
304
  try {
323
- win.androidBridge.postMessage(safeStringify(data));
305
+ win.androidBridge.postMessage(JSON.stringify(data));
324
306
  }
325
307
  catch (e) {
326
308
  (_a = win === null || win === void 0 ? void 0 : win.console) === null || _a === void 0 ? void 0 : _a.error(e);
@@ -351,7 +333,7 @@ const nativeBridge = (function (exports) {
351
333
  url: url,
352
334
  line: lineNo,
353
335
  col: columnNo,
354
- errorObject: safeStringify(err),
336
+ errorObject: JSON.stringify(err),
355
337
  },
356
338
  };
357
339
  if (err !== null) {
@@ -501,4 +483,4 @@ const nativeBridge = (function (exports) {
501
483
 
502
484
  return exports;
503
485
 
504
- }({}));
486
+ })({});
@@ -690,6 +690,10 @@ public class Bridge {
690
690
  return pluginCallForLastActivity;
691
691
  }
692
692
 
693
+ void setPluginCallForLastActivity(PluginCall pluginCallForLastActivity) {
694
+ this.pluginCallForLastActivity = pluginCallForLastActivity;
695
+ }
696
+
693
697
  /**
694
698
  * Release a retained call
695
699
  * @param call a call to release
@@ -1144,6 +1148,13 @@ public class Bridge {
1144
1148
  webView.post(() -> webView.loadUrl(appUrl));
1145
1149
  }
1146
1150
 
1151
+ /**
1152
+ * Reload the WebView
1153
+ */
1154
+ public void reload() {
1155
+ webView.post(() -> webView.loadUrl(appUrl));
1156
+ }
1157
+
1147
1158
  public String getLocalUrl() {
1148
1159
  return localUrl;
1149
1160
  }
@@ -146,7 +146,7 @@ public class FileUtils {
146
146
  */
147
147
  static String readFile(AssetManager assetManager, String fileName) throws IOException {
148
148
  try (BufferedReader reader = new BufferedReader(new InputStreamReader(assetManager.open(fileName)))) {
149
- StringBuffer buffer = new StringBuffer();
149
+ StringBuilder buffer = new StringBuilder();
150
150
  String line;
151
151
  while ((line = reader.readLine()) != null) {
152
152
  buffer.append(line + "\n");
@@ -29,6 +29,7 @@ import java.util.List;
29
29
  import java.util.Locale;
30
30
  import java.util.Map;
31
31
  import java.util.Set;
32
+ import java.util.concurrent.CopyOnWriteArrayList;
32
33
  import org.json.JSONException;
33
34
 
34
35
  /**
@@ -175,7 +176,7 @@ public class Plugin {
175
176
  // return when null since call was rejected in getLauncherOrReject
176
177
  return;
177
178
  }
178
-
179
+ bridge.setPluginCallForLastActivity(call);
179
180
  lastPluginCallId = call.getCallbackId();
180
181
  bridge.saveCall(call);
181
182
  activityResultLauncher.launch(intent);
@@ -668,7 +669,8 @@ public class Plugin {
668
669
  return;
669
670
  }
670
671
 
671
- for (PluginCall call : listeners) {
672
+ CopyOnWriteArrayList<PluginCall> listenersCopy = new CopyOnWriteArrayList(listeners);
673
+ for (PluginCall call : listenersCopy) {
672
674
  call.resolve(data);
673
675
  }
674
676
  }
@@ -894,7 +896,7 @@ public class Plugin {
894
896
  * @return a new {@link Bundle} with fields set from the options of the last saved {@link PluginCall}
895
897
  */
896
898
  protected Bundle saveInstanceState() {
897
- PluginCall savedCall = getSavedCall();
899
+ PluginCall savedCall = bridge.getSavedCall(lastPluginCallId);
898
900
 
899
901
  if (savedCall == null) {
900
902
  return null;
@@ -1,7 +1,7 @@
1
1
  package com.getcapacitor.cordova;
2
2
 
3
- import android.app.Activity;
4
3
  import android.util.Pair;
4
+ import androidx.appcompat.app.AppCompatActivity;
5
5
  import java.util.concurrent.Executors;
6
6
  import org.apache.cordova.CordovaInterfaceImpl;
7
7
  import org.apache.cordova.CordovaPlugin;
@@ -9,7 +9,7 @@ import org.json.JSONException;
9
9
 
10
10
  public class MockCordovaInterfaceImpl extends CordovaInterfaceImpl {
11
11
 
12
- public MockCordovaInterfaceImpl(Activity activity) {
12
+ public MockCordovaInterfaceImpl(AppCompatActivity activity) {
13
13
  super(activity, Executors.newCachedThreadPool());
14
14
  }
15
15
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor/android",
3
- "version": "3.2.2",
3
+ "version": "3.3.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.2.0"
25
+ "@capacitor/core": "^3.3.0"
26
26
  },
27
27
  "publishConfig": {
28
28
  "access": "public"
29
29
  },
30
- "gitHead": "a02716096b1492b4337f41369ebe951cae331694"
30
+ "gitHead": "cb7eacd3c69512cf85c03cb06ef9ebf44d32e425"
31
31
  }