@capacitor/android 3.3.1 → 3.4.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,55 @@
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.4.0](https://github.com/ionic-team/capacitor/compare/3.3.4...3.4.0) (2022-01-19)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **android:** prevent input file crash if accept has . ([#5363](https://github.com/ionic-team/capacitor/issues/5363)) ([bdacb30](https://github.com/ionic-team/capacitor/commit/bdacb300bb6391dc4b84bb2bab075df993a15cba))
12
+
13
+
14
+ ### Features
15
+
16
+ * **android:** Add getLong helper on PluginCall ([#5235](https://github.com/ionic-team/capacitor/issues/5235)) ([26261fb](https://github.com/ionic-team/capacitor/commit/26261fb49211330c4db72c259359565da7d7bc4b))
17
+
18
+
19
+
20
+
21
+
22
+ ## [3.3.4](https://github.com/ionic-team/capacitor/compare/3.3.3...3.3.4) (2022-01-05)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * **android:** Prevent crash if activity killed on input file ([#5328](https://github.com/ionic-team/capacitor/issues/5328)) ([a206841](https://github.com/ionic-team/capacitor/commit/a20684180a9b6fd50547ae578f21531faa116da5))
28
+
29
+
30
+
31
+
32
+
33
+ ## [3.3.3](https://github.com/ionic-team/capacitor/compare/3.3.2...3.3.3) (2021-12-08)
34
+
35
+
36
+ ### Bug Fixes
37
+
38
+ * **android:** Prevent crash in restoreInstanceState if bundleData is null ([#5289](https://github.com/ionic-team/capacitor/issues/5289)) ([622d62f](https://github.com/ionic-team/capacitor/commit/622d62fc0d7cd79558bf6f11331bd7d6690aa4f9))
39
+
40
+
41
+
42
+
43
+
44
+ ## [3.3.2](https://github.com/ionic-team/capacitor/compare/3.3.1...3.3.2) (2021-11-17)
45
+
46
+
47
+ ### Bug Fixes
48
+
49
+ * **android:** Allow web geolocation if only COARSE_LOCATION is granted ([#5236](https://github.com/ionic-team/capacitor/issues/5236)) ([bc7b24e](https://github.com/ionic-team/capacitor/commit/bc7b24e9b58b194b32b750c5816c8d8ef180834a))
50
+
51
+
52
+
53
+
54
+
6
55
  ## [3.3.1](https://github.com/ionic-team/capacitor/compare/3.3.0...3.3.1) (2021-11-05)
7
56
 
8
57
  **Note:** Version bump only for package @capacitor/android
@@ -54,8 +54,8 @@ android {
54
54
 
55
55
  repositories {
56
56
  google()
57
- jcenter()
58
57
  mavenCentral()
58
+ jcenter()
59
59
  }
60
60
 
61
61
  dependencies {
@@ -807,8 +807,10 @@ public class Bridge {
807
807
  // Let the plugin restore any state it needs
808
808
  Bundle bundleData = savedInstanceState.getBundle(BUNDLE_PLUGIN_CALL_BUNDLE_KEY);
809
809
  PluginHandle lastPlugin = getPlugin(lastPluginId);
810
- if (lastPlugin != null) {
810
+ if (bundleData != null && lastPlugin != null) {
811
811
  lastPlugin.getInstance().restoreState(bundleData);
812
+ } else {
813
+ Logger.error("Unable to restore last plugin call");
812
814
  }
813
815
  }
814
816
  }
@@ -823,10 +825,15 @@ public class Bridge {
823
825
  PluginHandle handle = getPlugin(call.getPluginId());
824
826
 
825
827
  if (handle != null) {
826
- outState.putString(BUNDLE_LAST_PLUGIN_ID_KEY, call.getPluginId());
827
- outState.putString(BUNDLE_LAST_PLUGIN_CALL_METHOD_NAME_KEY, call.getMethodName());
828
- outState.putString(BUNDLE_PLUGIN_CALL_OPTIONS_SAVED_KEY, call.getData().toString());
829
- outState.putBundle(BUNDLE_PLUGIN_CALL_BUNDLE_KEY, handle.getInstance().saveInstanceState());
828
+ Bundle bundle = handle.getInstance().saveInstanceState();
829
+ if (bundle != null) {
830
+ outState.putString(BUNDLE_LAST_PLUGIN_ID_KEY, call.getPluginId());
831
+ outState.putString(BUNDLE_LAST_PLUGIN_CALL_METHOD_NAME_KEY, call.getMethodName());
832
+ outState.putString(BUNDLE_PLUGIN_CALL_OPTIONS_SAVED_KEY, call.getData().toString());
833
+ outState.putBundle(BUNDLE_PLUGIN_CALL_BUNDLE_KEY, bundle);
834
+ } else {
835
+ Logger.error("Couldn't save last " + call.getPluginId() + "'s Plugin " + call.getMethodName() + " call");
836
+ }
830
837
  }
831
838
  }
832
839
  }
@@ -7,6 +7,7 @@ import android.app.AlertDialog;
7
7
  import android.content.ActivityNotFoundException;
8
8
  import android.content.Intent;
9
9
  import android.net.Uri;
10
+ import android.os.Build;
10
11
  import android.os.Environment;
11
12
  import android.provider.MediaStore;
12
13
  import android.view.View;
@@ -69,7 +70,11 @@ public class BridgeWebChromeClient extends WebChromeClient {
69
70
  activityLauncher =
70
71
  bridge.registerForActivityResult(
71
72
  new ActivityResultContracts.StartActivityForResult(),
72
- result -> activityListener.onActivityResult(result)
73
+ result -> {
74
+ if (activityListener != null) {
75
+ activityListener.onActivityResult(result);
76
+ }
77
+ }
73
78
  );
74
79
  }
75
80
 
@@ -280,7 +285,13 @@ public class BridgeWebChromeClient extends WebChromeClient {
280
285
  if (isGranted) {
281
286
  callback.invoke(origin, true, false);
282
287
  } else {
283
- callback.invoke(origin, false, false);
288
+ final String[] coarsePermission = { Manifest.permission.ACCESS_COARSE_LOCATION };
289
+ // TODO replace with Build.VERSION_CODES.S once we target SDK 31
290
+ if (Build.VERSION.SDK_INT >= 31 && PermissionHelper.hasPermissions(bridge.getContext(), coarsePermission)) {
291
+ callback.invoke(origin, true, false);
292
+ } else {
293
+ callback.invoke(origin, false, false);
294
+ }
284
295
  }
285
296
  };
286
297
  permissionLauncher.launch(geoPermissions);
@@ -403,7 +414,7 @@ public class BridgeWebChromeClient extends WebChromeClient {
403
414
  if (fileChooserParams.getMode() == FileChooserParams.MODE_OPEN_MULTIPLE) {
404
415
  intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
405
416
  }
406
- if (fileChooserParams.getAcceptTypes().length > 1) {
417
+ if (fileChooserParams.getAcceptTypes().length > 1 || intent.getType().startsWith(".")) {
407
418
  String[] validTypes = getValidTypes(fileChooserParams.getAcceptTypes());
408
419
  intent.putExtra(Intent.EXTRA_MIME_TYPES, validTypes);
409
420
  if (intent.getType().startsWith(".")) {
@@ -214,6 +214,24 @@ public class PluginCall {
214
214
  return defaultValue;
215
215
  }
216
216
 
217
+ @Nullable
218
+ public Long getLong(String name) {
219
+ return this.getLong(name, null);
220
+ }
221
+
222
+ @Nullable
223
+ public Long getLong(String name, @Nullable Long defaultValue) {
224
+ Object value = this.data.opt(name);
225
+ if (value == null) {
226
+ return defaultValue;
227
+ }
228
+
229
+ if (value instanceof Long) {
230
+ return (Long) value;
231
+ }
232
+ return defaultValue;
233
+ }
234
+
217
235
  @Nullable
218
236
  public Float getFloat(String name) {
219
237
  return this.getFloat(name, null);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor/android",
3
- "version": "3.3.1",
3
+ "version": "3.4.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.3.0"
25
+ "@capacitor/core": "^3.4.0"
26
26
  },
27
27
  "publishConfig": {
28
28
  "access": "public"
29
29
  },
30
- "gitHead": "8ff7434e9b775e6acb05efae23771ee1b18e26c9"
30
+ "gitHead": "4e84c04251167ea8212969fead84b6a1d694b561"
31
31
  }