@capacitor-plus/android 8.3.12 → 8.5.1

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.
@@ -353,7 +353,7 @@ public class BridgeWebChromeClient extends WebChromeClient {
353
353
  boolean captureEnabled = fileChooserParams.isCaptureEnabled();
354
354
  boolean capturePhoto = captureEnabled && acceptTypes.contains("image/*");
355
355
  final boolean captureVideo = captureEnabled && acceptTypes.contains("video/*");
356
- if ((capturePhoto || captureVideo)) {
356
+ if (capturePhoto || captureVideo) {
357
357
  if (isMediaCaptureSupported()) {
358
358
  showMediaCaptureOrFilePicker(filePathCallback, fileChooserParams, captureVideo);
359
359
  } else {
@@ -411,6 +411,7 @@ public class BridgeWebChromeClient extends WebChromeClient {
411
411
  return false;
412
412
  }
413
413
  takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, imageFileUri);
414
+ takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION);
414
415
 
415
416
  // Store in static variables to survive activity recreation
416
417
  pendingFilePathCallback = filePathCallback;
@@ -539,7 +540,7 @@ public class BridgeWebChromeClient extends WebChromeClient {
539
540
  }
540
541
 
541
542
  public boolean isValidMsg(String msg) {
542
- return !(msg.contains("%cresult %c") || (msg.contains("%cnative %c")) || msg.equalsIgnoreCase("console.groupEnd"));
543
+ return !(msg.contains("%cresult %c") || msg.contains("%cnative %c") || msg.equalsIgnoreCase("console.groupEnd"));
543
544
  }
544
545
 
545
546
  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 = (cursor.getString(nameIndex));
221
+ String name = cursor.getString(nameIndex);
222
222
  String fileName = sanitizeFilename(name);
223
223
  File file = new File(context.getFilesDir(), fileName);
224
224
  try {
@@ -65,6 +65,17 @@ public class PluginConfig {
65
65
  return JSONUtils.getInt(config, configKey, defaultValue);
66
66
  }
67
67
 
68
+ /**
69
+ * Get a double value for a plugin in the Capacitor config.
70
+ *
71
+ * @param configKey The key of the value to retrieve
72
+ * @param defaultValue A default value to return if the key does not exist in the config
73
+ * @return The value from the config, if key exists. Default value returned if not
74
+ */
75
+ public double getDouble(String configKey, double defaultValue) {
76
+ return JSONUtils.getDouble(config, configKey, defaultValue);
77
+ }
78
+
68
79
  /**
69
80
  * Get a string array value for a plugin in the Capacitor config.
70
81
  *
@@ -221,7 +221,7 @@ public class WebViewLocalServer {
221
221
  }
222
222
 
223
223
  private boolean isMainUrl(Uri loadingUrl) {
224
- return (bridge.getServerUrl() == null && loadingUrl.getHost().equalsIgnoreCase(bridge.getHost()));
224
+ return bridge.getServerUrl() == null && loadingUrl.getHost().equalsIgnoreCase(bridge.getHost());
225
225
  }
226
226
 
227
227
  private boolean isAllowedUrl(Uri loadingUrl) {
@@ -728,31 +728,31 @@ public class WebViewLocalServer {
728
728
  @Override
729
729
  public int available() throws IOException {
730
730
  InputStream is = getInputStream();
731
- return (is != null) ? is.available() : -1;
731
+ return is != null ? is.available() : -1;
732
732
  }
733
733
 
734
734
  @Override
735
735
  public int read() throws IOException {
736
736
  InputStream is = getInputStream();
737
- return (is != null) ? is.read() : -1;
737
+ return is != null ? is.read() : -1;
738
738
  }
739
739
 
740
740
  @Override
741
741
  public int read(byte[] b) throws IOException {
742
742
  InputStream is = getInputStream();
743
- return (is != null) ? is.read(b) : -1;
743
+ return is != null ? is.read(b) : -1;
744
744
  }
745
745
 
746
746
  @Override
747
747
  public int read(byte[] b, int off, int len) throws IOException {
748
748
  InputStream is = getInputStream();
749
- return (is != null) ? is.read(b, off, len) : -1;
749
+ return is != null ? is.read(b, off, len) : -1;
750
750
  }
751
751
 
752
752
  @Override
753
753
  public long skip(long n) throws IOException {
754
754
  InputStream is = getInputStream();
755
- return (is != null) ? is.skip(n) : 0;
755
+ return is != null ? is.skip(n) : 0;
756
756
  }
757
757
  }
758
758
 
@@ -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 ((uri == null) || (responseHeaders == null)) return;
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 ((headerKey == null) || !(headerKey.equalsIgnoreCase("Set-Cookie2") || headerKey.equalsIgnoreCase("Set-Cookie"))) continue;
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 ((uri == null) || (requestHeaders == null)) throw new IllegalArgumentException("Argument is null");
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();
@@ -196,7 +196,8 @@ public class SystemBars extends Plugin {
196
196
  getActivity().runOnUiThread(() -> {
197
197
  this.bridge.getWebView().evaluateJavascript(viewportMetaJSFunction, (res) -> {
198
198
  hasViewportCover = res.equals("true");
199
- ViewCompat.requestApplyInsets((View) getBridge().getWebView().getParent());
199
+
200
+ getBridge().getWebView().requestApplyInsets();
200
201
  });
201
202
  });
202
203
  }
@@ -235,8 +236,15 @@ public class SystemBars extends Plugin {
235
236
 
236
237
  private void initSafeAreaCSSVariables() {
237
238
  if (INSETS_HANDLING_CSS.equals(insetsHandling)) {
238
- View v = (View) this.getBridge().getWebView().getParent();
239
- WindowInsetsCompat insets = ViewCompat.getRootWindowInsets(v);
239
+ WindowInsetsCompat insets;
240
+
241
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) {
242
+ View v = (View) this.getBridge().getWebView().getParent();
243
+ insets = ViewCompat.getRootWindowInsets(v);
244
+ } else {
245
+ insets = WindowInsetsCompat.CONSUMED;
246
+ }
247
+
240
248
  if (insets != null) {
241
249
  Insets safeAreaInsets = calcSafeAreaInsets(insets);
242
250
  injectSafeAreaCSS(safeAreaInsets.top, safeAreaInsets.right, safeAreaInsets.bottom, safeAreaInsets.left);
@@ -264,10 +272,8 @@ public class SystemBars extends Plugin {
264
272
  // We need to correct for a possible shown IME
265
273
  v.setPadding(0, 0, 0, keyboardVisible ? imeInsets.bottom : 0);
266
274
 
267
- if (hasViewportCover && INSETS_HANDLING_CSS.equals(insetsHandling)) {
268
- Insets safeAreaInsets = calcSafeAreaInsets(safeAreaSource);
269
- injectSafeAreaCSS(safeAreaInsets.top, safeAreaInsets.right, safeAreaInsets.bottom, safeAreaInsets.left);
270
- }
275
+ Insets safeAreaInsets = calcSafeAreaInsets(safeAreaSource);
276
+ injectSafeAreaCSS(safeAreaInsets.top, safeAreaInsets.right, safeAreaInsets.bottom, safeAreaInsets.left);
271
277
 
272
278
  return new WindowInsetsCompat.Builder(insets)
273
279
  .setInsets(
@@ -291,10 +297,8 @@ public class SystemBars extends Plugin {
291
297
  .setInsets(WindowInsetsCompat.Type.systemBars() | WindowInsetsCompat.Type.displayCutout(), Insets.of(0, 0, 0, 0))
292
298
  .build();
293
299
 
294
- if (INSETS_HANDLING_CSS.equals(insetsHandling)) {
295
- Insets safeAreaInsets = calcSafeAreaInsets(safeAreaSource);
296
- injectSafeAreaCSS(safeAreaInsets.top, safeAreaInsets.right, safeAreaInsets.bottom, safeAreaInsets.left);
297
- }
300
+ Insets safeAreaInsets = calcSafeAreaInsets(safeAreaSource);
301
+ injectSafeAreaCSS(safeAreaInsets.top, safeAreaInsets.right, safeAreaInsets.bottom, safeAreaInsets.left);
298
302
 
299
303
  return newInsets;
300
304
  });
@@ -168,8 +168,8 @@ public class HttpRequestHandler {
168
168
  "://" +
169
169
  uri.getAuthority() +
170
170
  uri.getPath() +
171
- ((!urlQuery.equals("")) ? "?" + urlQuery : "") +
172
- ((uri.getFragment() != null) ? uri.getFragment() : "");
171
+ (!urlQuery.equals("") ? "?" + urlQuery : "") +
172
+ (uri.getFragment() != null ? uri.getFragment() : "");
173
173
  this.url = new URL(unEncodedUrlString);
174
174
 
175
175
  return this;
@@ -75,6 +75,26 @@ public class JSONUtils {
75
75
  return defaultValue;
76
76
  }
77
77
 
78
+ /**
79
+ * Get a double value from the given JSON object.
80
+ *
81
+ * @param jsonObject A JSON object to search
82
+ * @param key A key to fetch from the JSON object
83
+ * @param defaultValue A default value to return if the key cannot be found
84
+ * @return The value at the given key in the JSON object, or the default value
85
+ */
86
+ public static double getDouble(JSONObject jsonObject, String key, double defaultValue) {
87
+ String k = getDeepestKey(key);
88
+ try {
89
+ JSONObject o = getDeepestObject(jsonObject, key);
90
+ return o.getDouble(k);
91
+ } catch (JSONException ignore) {
92
+ // value was not found
93
+ }
94
+
95
+ return defaultValue;
96
+ }
97
+
78
98
  /**
79
99
  * Get a JSON object value from the given JSON object.
80
100
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor-plus/android",
3
- "version": "8.3.12",
3
+ "version": "8.5.1",
4
4
  "description": "Capacitor+: Enhanced Capacitor with automated upstream sync - Cross-platform apps with JavaScript and the web",
5
5
  "homepage": "https://capgo.app/docs/plugins/capacitor-plus/",
6
6
  "author": "Capgo Team <support@capgo.app> (https://capgo.app)",
@@ -23,8 +23,8 @@
23
23
  "verify": "./gradlew clean lint build test -b capacitor/build.gradle"
24
24
  },
25
25
  "peerDependencies": {
26
- "@capacitor-plus/core": "^8.3.0",
27
- "@capacitor/core": "^8.3.0"
26
+ "@capacitor-plus/core": "^8.5.0",
27
+ "@capacitor/core": "^8.5.0"
28
28
  },
29
29
  "publishConfig": {
30
30
  "access": "public"