@capacitor/android 6.2.0 → 7.0.0-alpha.2

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.
@@ -1,13 +1,13 @@
1
1
  ext {
2
- androidxActivityVersion = project.hasProperty('androidxActivityVersion') ? rootProject.ext.androidxActivityVersion : '1.8.0'
3
- androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.6.1'
2
+ androidxActivityVersion = project.hasProperty('androidxActivityVersion') ? rootProject.ext.androidxActivityVersion : '1.9.2'
3
+ androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.7.0'
4
4
  androidxCoordinatorLayoutVersion = project.hasProperty('androidxCoordinatorLayoutVersion') ? rootProject.ext.androidxCoordinatorLayoutVersion : '1.2.0'
5
- androidxCoreVersion = project.hasProperty('androidxCoreVersion') ? rootProject.ext.androidxCoreVersion : '1.12.0'
6
- androidxFragmentVersion = project.hasProperty('androidxFragmentVersion') ? rootProject.ext.androidxFragmentVersion : '1.6.2'
7
- androidxWebkitVersion = project.hasProperty('androidxWebkitVersion') ? rootProject.ext.androidxWebkitVersion : '1.9.0'
5
+ androidxCoreVersion = project.hasProperty('androidxCoreVersion') ? rootProject.ext.androidxCoreVersion : '1.15.0'
6
+ androidxFragmentVersion = project.hasProperty('androidxFragmentVersion') ? rootProject.ext.androidxFragmentVersion : '1.8.4'
7
+ androidxWebkitVersion = project.hasProperty('androidxWebkitVersion') ? rootProject.ext.androidxWebkitVersion : '1.12.1'
8
8
  junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
9
- androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.5'
10
- androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.5.1'
9
+ androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.2.1'
10
+ androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.6.1'
11
11
  cordovaAndroidVersion = project.hasProperty('cordovaAndroidVersion') ? rootProject.ext.cordovaAndroidVersion : '10.1.1'
12
12
  }
13
13
 
@@ -22,7 +22,7 @@ buildscript {
22
22
  }
23
23
  }
24
24
  dependencies {
25
- classpath 'com.android.tools.build:gradle:8.2.1'
25
+ classpath 'com.android.tools.build:gradle:8.7.0'
26
26
 
27
27
  if (System.getenv("CAP_PUBLISH") == "true") {
28
28
  classpath 'io.github.gradle-nexus:publish-plugin:1.3.0'
@@ -42,10 +42,10 @@ if (System.getenv("CAP_PUBLISH") == "true") {
42
42
 
43
43
  android {
44
44
  namespace "com.getcapacitor.android"
45
- compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 34
45
+ compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 35
46
46
  defaultConfig {
47
- minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
48
- targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 34
47
+ minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 23
48
+ targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 35
49
49
  versionCode 1
50
50
  versionName "1.0"
51
51
  consumerProguardFiles 'proguard-rules.pro'
@@ -90,7 +90,7 @@ dependencies {
90
90
  androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
91
91
  androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
92
92
  implementation "org.apache.cordova:framework:$cordovaAndroidVersion"
93
- testImplementation 'org.json:json:20231013'
94
- testImplementation 'org.mockito:mockito-inline:5.2.0'
93
+ testImplementation 'org.json:json:20240303'
94
+ testImplementation 'org.mockito:mockito-core:5.14.1'
95
95
  }
96
96
 
@@ -142,9 +142,7 @@ var nativeBridge = (function (exports) {
142
142
  const CAPACITOR_HTTP_INTERCEPTOR = '/_capacitor_http_interceptor_';
143
143
  const CAPACITOR_HTTP_INTERCEPTOR_URL_PARAM = 'u';
144
144
  // TODO: export as Cap function
145
- const isRelativeOrProxyUrl = (url) => !url ||
146
- !(url.startsWith('http:') || url.startsWith('https:')) ||
147
- url.indexOf(CAPACITOR_HTTP_INTERCEPTOR) > -1;
145
+ const isRelativeOrProxyUrl = (url) => !url || !(url.startsWith('http:') || url.startsWith('https:')) || url.indexOf(CAPACITOR_HTTP_INTERCEPTOR) > -1;
148
146
  // TODO: export as Cap function
149
147
  const createProxyUrl = (url, win) => {
150
148
  var _a, _b;
@@ -174,11 +172,10 @@ var nativeBridge = (function (exports) {
174
172
  return webviewServerUrl + '/_capacitor_file_' + filePath;
175
173
  }
176
174
  else if (filePath.startsWith('file://')) {
177
- return (webviewServerUrl + filePath.replace('file://', '/_capacitor_file_'));
175
+ return webviewServerUrl + filePath.replace('file://', '/_capacitor_file_');
178
176
  }
179
177
  else if (filePath.startsWith('content://')) {
180
- return (webviewServerUrl +
181
- filePath.replace('content:/', '/_capacitor_content_'));
178
+ return webviewServerUrl + filePath.replace('content:/', '/_capacitor_content_');
182
179
  }
183
180
  }
184
181
  return filePath;
@@ -289,9 +286,6 @@ var nativeBridge = (function (exports) {
289
286
  return docAddEventListener.apply(doc, args);
290
287
  };
291
288
  }
292
- // deprecated in v3, remove from v4
293
- cap.platform = cap.getPlatform();
294
- cap.isNative = cap.isNativePlatform();
295
289
  win.Capacitor = cap;
296
290
  };
297
291
  const initVendor = (win, cap) => {
@@ -321,27 +315,14 @@ var nativeBridge = (function (exports) {
321
315
  win.Ionic.WebView = IonicWebView;
322
316
  };
323
317
  const initLogger = (win, cap) => {
324
- const BRIDGED_CONSOLE_METHODS = [
325
- 'debug',
326
- 'error',
327
- 'info',
328
- 'log',
329
- 'trace',
330
- 'warn',
331
- ];
318
+ const BRIDGED_CONSOLE_METHODS = ['debug', 'error', 'info', 'log', 'trace', 'warn'];
332
319
  const createLogFromNative = (c) => (result) => {
333
320
  if (isFullConsole(c)) {
334
321
  const success = result.success === true;
335
322
  const tagStyles = success
336
323
  ? 'font-style: italic; font-weight: lighter; color: gray'
337
324
  : 'font-style: italic; font-weight: lighter; color: red';
338
- c.groupCollapsed('%cresult %c' +
339
- result.pluginId +
340
- '.' +
341
- result.methodName +
342
- ' (#' +
343
- result.callbackId +
344
- ')', tagStyles, 'font-style: italic; font-weight: bold; color: #444');
325
+ c.groupCollapsed('%cresult %c' + result.pluginId + '.' + result.methodName + ' (#' + result.callbackId + ')', tagStyles, 'font-style: italic; font-weight: bold; color: #444');
345
326
  if (result.success === false) {
346
327
  c.error(result.error);
347
328
  }
@@ -361,13 +342,7 @@ var nativeBridge = (function (exports) {
361
342
  };
362
343
  const createLogToNative = (c) => (call) => {
363
344
  if (isFullConsole(c)) {
364
- c.groupCollapsed('%cnative %c' +
365
- call.pluginId +
366
- '.' +
367
- call.methodName +
368
- ' (#' +
369
- call.callbackId +
370
- ')', 'font-weight: lighter; color: gray', 'font-weight: bold; color: #000');
345
+ c.groupCollapsed('%cnative %c' + call.pluginId + '.' + call.methodName + ' (#' + call.callbackId + ')', 'font-weight: lighter; color: gray', 'font-weight: bold; color: #000');
371
346
  c.dir(call);
372
347
  c.groupEnd();
373
348
  }
@@ -379,9 +354,7 @@ var nativeBridge = (function (exports) {
379
354
  if (!c) {
380
355
  return false;
381
356
  }
382
- return (typeof c.groupCollapsed === 'function' ||
383
- typeof c.groupEnd === 'function' ||
384
- typeof c.dir === 'function');
357
+ return typeof c.groupCollapsed === 'function' || typeof c.groupEnd === 'function' || typeof c.dir === 'function';
385
358
  };
386
359
  const serializeConsoleMessage = (msg) => {
387
360
  try {
@@ -440,9 +413,7 @@ var nativeBridge = (function (exports) {
440
413
  set: function (val) {
441
414
  const cookiePairs = val.split(';');
442
415
  const domainSection = val.toLowerCase().split('domain=')[1];
443
- const domain = cookiePairs.length > 1 &&
444
- domainSection != null &&
445
- domainSection.length > 0
416
+ const domain = cookiePairs.length > 1 && domainSection != null && domainSection.length > 0
446
417
  ? domainSection.split(';')[0].trim()
447
418
  : '';
448
419
  if (platform === 'ios') {
@@ -527,8 +498,7 @@ var nativeBridge = (function (exports) {
527
498
  dataType: type,
528
499
  headers: Object.assign(Object.assign({}, headers), optionHeaders),
529
500
  });
530
- const contentType = nativeResponse.headers['Content-Type'] ||
531
- nativeResponse.headers['content-type'];
501
+ const contentType = nativeResponse.headers['Content-Type'] || nativeResponse.headers['content-type'];
532
502
  let data = (contentType === null || contentType === void 0 ? void 0 : contentType.startsWith('application/json'))
533
503
  ? JSON.stringify(nativeResponse.data)
534
504
  : nativeResponse.data;
@@ -570,8 +540,7 @@ var nativeBridge = (function (exports) {
570
540
  },
571
541
  });
572
542
  const prototype = win.CapacitorWebXMLHttpRequest.prototype;
573
- const isProgressEventAvailable = () => typeof ProgressEvent !== 'undefined' &&
574
- ProgressEvent.prototype instanceof Event;
543
+ const isProgressEventAvailable = () => typeof ProgressEvent !== 'undefined' && ProgressEvent.prototype instanceof Event;
575
544
  // XHR patch abort
576
545
  prototype.abort = function () {
577
546
  if (isRelativeOrProxyUrl(this._url)) {
@@ -652,9 +621,7 @@ var nativeBridge = (function (exports) {
652
621
  },
653
622
  });
654
623
  convertBody(body).then(({ data, type, headers }) => {
655
- const otherHeaders = this._headers != null && Object.keys(this._headers).length > 0
656
- ? this._headers
657
- : undefined;
624
+ const otherHeaders = this._headers != null && Object.keys(this._headers).length > 0 ? this._headers : undefined;
658
625
  // intercept request & pass to the bridge
659
626
  cap
660
627
  .nativePromise('CapacitorHttp', 'request', {
@@ -678,8 +645,7 @@ var nativeBridge = (function (exports) {
678
645
  }
679
646
  this._headers = nativeResponse.headers;
680
647
  this.status = nativeResponse.status;
681
- if (this.responseType === '' ||
682
- this.responseType === 'text') {
648
+ if (this.responseType === '' || this.responseType === 'text') {
683
649
  this.response =
684
650
  typeof nativeResponse.data !== 'string'
685
651
  ? JSON.stringify(nativeResponse.data)
@@ -688,8 +654,7 @@ var nativeBridge = (function (exports) {
688
654
  else {
689
655
  this.response = nativeResponse.data;
690
656
  }
691
- this.responseText = ((_a = (nativeResponse.headers['Content-Type'] ||
692
- nativeResponse.headers['content-type'])) === null || _a === void 0 ? void 0 : _a.startsWith('application/json'))
657
+ this.responseText = ((_a = (nativeResponse.headers['Content-Type'] || nativeResponse.headers['content-type'])) === null || _a === void 0 ? void 0 : _a.startsWith('application/json'))
693
658
  ? JSON.stringify(nativeResponse.data)
694
659
  : nativeResponse.data;
695
660
  this.responseURL = nativeResponse.url;
@@ -805,7 +770,7 @@ var nativeBridge = (function (exports) {
805
770
  };
806
771
  cap.logToNative = createLogToNative(win.console);
807
772
  cap.logFromNative = createLogFromNative(win.console);
808
- cap.handleError = err => win.console.error(err);
773
+ cap.handleError = (err) => win.console.error(err);
809
774
  win.Capacitor = cap;
810
775
  };
811
776
  function initNativeBridge(win) {
@@ -814,7 +779,7 @@ var nativeBridge = (function (exports) {
814
779
  const callbacks = new Map();
815
780
  const webviewServerUrl = typeof win.WEBVIEW_SERVER_URL === 'string' ? win.WEBVIEW_SERVER_URL : '';
816
781
  cap.getServerUrl = () => webviewServerUrl;
817
- cap.convertFileSrc = filePath => convertFileSrcServerUrl(webviewServerUrl, filePath);
782
+ cap.convertFileSrc = (filePath) => convertFileSrcServerUrl(webviewServerUrl, filePath);
818
783
  // Counter of callback ids, randomized to avoid
819
784
  // any issues during reloads if a call comes back with
820
785
  // an existing callback id from an old session
@@ -823,12 +788,12 @@ var nativeBridge = (function (exports) {
823
788
  const isNativePlatform = () => true;
824
789
  const getPlatform = () => getPlatformId(win);
825
790
  cap.getPlatform = getPlatform;
826
- cap.isPluginAvailable = name => Object.prototype.hasOwnProperty.call(cap.Plugins, name);
791
+ cap.isPluginAvailable = (name) => Object.prototype.hasOwnProperty.call(cap.Plugins, name);
827
792
  cap.isNativePlatform = isNativePlatform;
828
793
  // create the postToNative() fn if needed
829
794
  if (getPlatformId(win) === 'android') {
830
795
  // android platform
831
- postToNative = data => {
796
+ postToNative = (data) => {
832
797
  var _a;
833
798
  try {
834
799
  win.androidBridge.postMessage(JSON.stringify(data));
@@ -840,7 +805,7 @@ var nativeBridge = (function (exports) {
840
805
  }
841
806
  else if (getPlatformId(win) === 'ios') {
842
807
  // ios platform
843
- postToNative = data => {
808
+ postToNative = (data) => {
844
809
  var _a;
845
810
  try {
846
811
  data.type = data.type ? data.type : 'message';
@@ -885,8 +850,7 @@ var nativeBridge = (function (exports) {
885
850
  if (typeof postToNative === 'function') {
886
851
  let callbackId = '-1';
887
852
  if (storedCallback &&
888
- (typeof storedCallback.callback === 'function' ||
889
- typeof storedCallback.resolve === 'function')) {
853
+ (typeof storedCallback.callback === 'function' || typeof storedCallback.resolve === 'function')) {
890
854
  // store the call for later lookup
891
855
  callbackId = String(++callbackIdCount);
892
856
  callbacks.set(callbackId, storedCallback);
@@ -921,7 +885,7 @@ var nativeBridge = (function (exports) {
921
885
  /**
922
886
  * Process a response from the native layer.
923
887
  */
924
- cap.fromNative = result => {
888
+ cap.fromNative = (result) => {
925
889
  returnResult(result);
926
890
  };
927
891
  const returnResult = (result) => {
@@ -75,7 +75,6 @@ import org.json.JSONException;
75
75
  */
76
76
  public class Bridge {
77
77
 
78
- private static final String PREFS_NAME = "CapacitorSettings";
79
78
  private static final String PERMISSION_PREFS_NAME = "PluginPermStates";
80
79
  private static final String BUNDLE_LAST_PLUGIN_ID_KEY = "capacitorLastActivityPluginId";
81
80
  private static final String BUNDLE_LAST_PLUGIN_CALL_METHOD_NAME_KEY = "capacitorLastActivityPluginMethod";
@@ -563,7 +562,6 @@ public class Bridge {
563
562
  settings.setJavaScriptEnabled(true);
564
563
  settings.setDomStorageEnabled(true);
565
564
  settings.setGeolocationEnabled(true);
566
- settings.setDatabaseEnabled(true);
567
565
  settings.setMediaPlaybackRequiresUserGesture(false);
568
566
  settings.setJavaScriptCanOpenWindowsAutomatically(true);
569
567
  if (this.config.isMixedContentAllowed()) {
@@ -1026,8 +1024,13 @@ public class Bridge {
1026
1024
  try {
1027
1025
  JSObject options = new JSObject(lastOptionsJson);
1028
1026
 
1029
- pluginCallForLastActivity =
1030
- new PluginCall(msgHandler, lastPluginId, PluginCall.CALLBACK_ID_DANGLING, lastPluginCallMethod, options);
1027
+ pluginCallForLastActivity = new PluginCall(
1028
+ msgHandler,
1029
+ lastPluginId,
1030
+ PluginCall.CALLBACK_ID_DANGLING,
1031
+ lastPluginCallMethod,
1032
+ options
1033
+ );
1031
1034
  } catch (JSONException ex) {
1032
1035
  Logger.error("Unable to restore plugin call, unable to parse persisted JSON object", ex);
1033
1036
  }
@@ -77,13 +77,12 @@ public class BridgeFragment extends Fragment {
77
77
  startDir = getArguments().getString(ARG_START_DIR);
78
78
  }
79
79
 
80
- bridge =
81
- new Bridge.Builder(this)
82
- .setInstanceState(savedInstanceState)
83
- .setPlugins(initialPlugins)
84
- .setConfig(config)
85
- .addWebViewListeners(webViewListeners)
86
- .create();
80
+ bridge = new Bridge.Builder(this)
81
+ .setInstanceState(savedInstanceState)
82
+ .setPlugins(initialPlugins)
83
+ .setConfig(config)
84
+ .addWebViewListeners(webViewListeners)
85
+ .create();
87
86
 
88
87
  if (startDir != null) {
89
88
  bridge.setServerAssetPath(startDir);
@@ -67,15 +67,11 @@ public class BridgeWebChromeClient extends WebChromeClient {
67
67
  };
68
68
 
69
69
  permissionLauncher = bridge.registerForActivityResult(new ActivityResultContracts.RequestMultiplePermissions(), permissionCallback);
70
- activityLauncher =
71
- bridge.registerForActivityResult(
72
- new ActivityResultContracts.StartActivityForResult(),
73
- result -> {
74
- if (activityListener != null) {
75
- activityListener.onActivityResult(result);
76
- }
77
- }
78
- );
70
+ activityLauncher = bridge.registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
71
+ if (activityListener != null) {
72
+ activityListener.onActivityResult(result);
73
+ }
74
+ });
79
75
  }
80
76
 
81
77
  /**
@@ -104,8 +100,6 @@ public class BridgeWebChromeClient extends WebChromeClient {
104
100
 
105
101
  @Override
106
102
  public void onPermissionRequest(final PermissionRequest request) {
107
- boolean isRequestPermissionRequired = android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M;
108
-
109
103
  List<String> permissionList = new ArrayList<>();
110
104
  if (Arrays.asList(request.getResources()).contains("android.webkit.resource.VIDEO_CAPTURE")) {
111
105
  permissionList.add(Manifest.permission.CAMERA);
@@ -114,16 +108,15 @@ public class BridgeWebChromeClient extends WebChromeClient {
114
108
  permissionList.add(Manifest.permission.MODIFY_AUDIO_SETTINGS);
115
109
  permissionList.add(Manifest.permission.RECORD_AUDIO);
116
110
  }
117
- if (!permissionList.isEmpty() && isRequestPermissionRequired) {
111
+ if (!permissionList.isEmpty()) {
118
112
  String[] permissions = permissionList.toArray(new String[0]);
119
- permissionListener =
120
- isGranted -> {
121
- if (isGranted) {
122
- request.grant(request.getResources());
123
- } else {
124
- request.deny();
125
- }
126
- };
113
+ permissionListener = isGranted -> {
114
+ if (isGranted) {
115
+ request.grant(request.getResources());
116
+ } else {
117
+ request.deny();
118
+ }
119
+ };
127
120
  permissionLauncher.launch(permissions);
128
121
  } else {
129
122
  request.grant(request.getResources());
@@ -147,19 +140,14 @@ public class BridgeWebChromeClient extends WebChromeClient {
147
140
  AlertDialog.Builder builder = new AlertDialog.Builder(view.getContext());
148
141
  builder
149
142
  .setMessage(message)
150
- .setPositiveButton(
151
- "OK",
152
- (dialog, buttonIndex) -> {
153
- dialog.dismiss();
154
- result.confirm();
155
- }
156
- )
157
- .setOnCancelListener(
158
- dialog -> {
159
- dialog.dismiss();
160
- result.cancel();
161
- }
162
- );
143
+ .setPositiveButton("OK", (dialog, buttonIndex) -> {
144
+ dialog.dismiss();
145
+ result.confirm();
146
+ })
147
+ .setOnCancelListener(dialog -> {
148
+ dialog.dismiss();
149
+ result.cancel();
150
+ });
163
151
 
164
152
  AlertDialog dialog = builder.create();
165
153
 
@@ -186,26 +174,18 @@ public class BridgeWebChromeClient extends WebChromeClient {
186
174
 
187
175
  builder
188
176
  .setMessage(message)
189
- .setPositiveButton(
190
- "OK",
191
- (dialog, buttonIndex) -> {
192
- dialog.dismiss();
193
- result.confirm();
194
- }
195
- )
196
- .setNegativeButton(
197
- "Cancel",
198
- (dialog, buttonIndex) -> {
199
- dialog.dismiss();
200
- result.cancel();
201
- }
202
- )
203
- .setOnCancelListener(
204
- dialog -> {
205
- dialog.dismiss();
206
- result.cancel();
207
- }
208
- );
177
+ .setPositiveButton("OK", (dialog, buttonIndex) -> {
178
+ dialog.dismiss();
179
+ result.confirm();
180
+ })
181
+ .setNegativeButton("Cancel", (dialog, buttonIndex) -> {
182
+ dialog.dismiss();
183
+ result.cancel();
184
+ })
185
+ .setOnCancelListener(dialog -> {
186
+ dialog.dismiss();
187
+ result.cancel();
188
+ });
209
189
 
210
190
  AlertDialog dialog = builder.create();
211
191
 
@@ -235,28 +215,20 @@ public class BridgeWebChromeClient extends WebChromeClient {
235
215
  builder
236
216
  .setMessage(message)
237
217
  .setView(input)
238
- .setPositiveButton(
239
- "OK",
240
- (dialog, buttonIndex) -> {
241
- dialog.dismiss();
242
-
243
- String inputText1 = input.getText().toString().trim();
244
- result.confirm(inputText1);
245
- }
246
- )
247
- .setNegativeButton(
248
- "Cancel",
249
- (dialog, buttonIndex) -> {
250
- dialog.dismiss();
251
- result.cancel();
252
- }
253
- )
254
- .setOnCancelListener(
255
- dialog -> {
256
- dialog.dismiss();
257
- result.cancel();
258
- }
259
- );
218
+ .setPositiveButton("OK", (dialog, buttonIndex) -> {
219
+ dialog.dismiss();
220
+
221
+ String inputText1 = input.getText().toString().trim();
222
+ result.confirm(inputText1);
223
+ })
224
+ .setNegativeButton("Cancel", (dialog, buttonIndex) -> {
225
+ dialog.dismiss();
226
+ result.cancel();
227
+ })
228
+ .setOnCancelListener(dialog -> {
229
+ dialog.dismiss();
230
+ result.cancel();
231
+ });
260
232
 
261
233
  AlertDialog dialog = builder.create();
262
234
 
@@ -277,22 +249,21 @@ public class BridgeWebChromeClient extends WebChromeClient {
277
249
  final String[] geoPermissions = { Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION };
278
250
 
279
251
  if (!PermissionHelper.hasPermissions(bridge.getContext(), geoPermissions)) {
280
- permissionListener =
281
- isGranted -> {
282
- if (isGranted) {
252
+ permissionListener = isGranted -> {
253
+ if (isGranted) {
254
+ callback.invoke(origin, true, false);
255
+ } else {
256
+ final String[] coarsePermission = { Manifest.permission.ACCESS_COARSE_LOCATION };
257
+ if (
258
+ Build.VERSION.SDK_INT >= Build.VERSION_CODES.S &&
259
+ PermissionHelper.hasPermissions(bridge.getContext(), coarsePermission)
260
+ ) {
283
261
  callback.invoke(origin, true, false);
284
262
  } else {
285
- final String[] coarsePermission = { Manifest.permission.ACCESS_COARSE_LOCATION };
286
- if (
287
- Build.VERSION.SDK_INT >= Build.VERSION_CODES.S &&
288
- PermissionHelper.hasPermissions(bridge.getContext(), coarsePermission)
289
- ) {
290
- callback.invoke(origin, true, false);
291
- } else {
292
- callback.invoke(origin, false, false);
293
- }
263
+ callback.invoke(origin, false, false);
294
264
  }
295
- };
265
+ }
266
+ };
296
267
  permissionLauncher.launch(geoPermissions);
297
268
  } else {
298
269
  // permission is already granted
@@ -315,15 +286,14 @@ public class BridgeWebChromeClient extends WebChromeClient {
315
286
  if (isMediaCaptureSupported()) {
316
287
  showMediaCaptureOrFilePicker(filePathCallback, fileChooserParams, captureVideo);
317
288
  } else {
318
- permissionListener =
319
- isGranted -> {
320
- if (isGranted) {
321
- showMediaCaptureOrFilePicker(filePathCallback, fileChooserParams, captureVideo);
322
- } else {
323
- Logger.warn(Logger.tags("FileChooser"), "Camera permission not granted");
324
- filePathCallback.onReceiveValue(null);
325
- }
326
- };
289
+ permissionListener = isGranted -> {
290
+ if (isGranted) {
291
+ showMediaCaptureOrFilePicker(filePathCallback, fileChooserParams, captureVideo);
292
+ } else {
293
+ Logger.warn(Logger.tags("FileChooser"), "Camera permission not granted");
294
+ filePathCallback.onReceiveValue(null);
295
+ }
296
+ };
327
297
  final String[] camPermission = { Manifest.permission.CAMERA };
328
298
  permissionLauncher.launch(camPermission);
329
299
  }
@@ -375,14 +345,13 @@ public class BridgeWebChromeClient extends WebChromeClient {
375
345
  return false;
376
346
  }
377
347
  takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, imageFileUri);
378
- activityListener =
379
- activityResult -> {
380
- Uri[] result = null;
381
- if (activityResult.getResultCode() == Activity.RESULT_OK) {
382
- result = new Uri[] { imageFileUri };
383
- }
384
- filePathCallback.onReceiveValue(result);
385
- };
348
+ activityListener = activityResult -> {
349
+ Uri[] result = null;
350
+ if (activityResult.getResultCode() == Activity.RESULT_OK) {
351
+ result = new Uri[] { imageFileUri };
352
+ }
353
+ filePathCallback.onReceiveValue(result);
354
+ };
386
355
  activityLauncher.launch(takePictureIntent);
387
356
 
388
357
  return true;
@@ -395,14 +364,13 @@ public class BridgeWebChromeClient extends WebChromeClient {
395
364
  return false;
396
365
  }
397
366
 
398
- activityListener =
399
- activityResult -> {
400
- Uri[] result = null;
401
- if (activityResult.getResultCode() == Activity.RESULT_OK) {
402
- result = new Uri[] { activityResult.getData().getData() };
403
- }
404
- filePathCallback.onReceiveValue(result);
405
- };
367
+ activityListener = activityResult -> {
368
+ Uri[] result = null;
369
+ if (activityResult.getResultCode() == Activity.RESULT_OK) {
370
+ result = new Uri[] { activityResult.getData().getData() };
371
+ }
372
+ filePathCallback.onReceiveValue(result);
373
+ };
406
374
  activityLauncher.launch(takeVideoIntent);
407
375
 
408
376
  return true;
@@ -421,21 +389,20 @@ public class BridgeWebChromeClient extends WebChromeClient {
421
389
  }
422
390
  }
423
391
  try {
424
- activityListener =
425
- activityResult -> {
426
- Uri[] result;
427
- Intent resultIntent = activityResult.getData();
428
- if (activityResult.getResultCode() == Activity.RESULT_OK && resultIntent.getClipData() != null) {
429
- final int numFiles = resultIntent.getClipData().getItemCount();
430
- result = new Uri[numFiles];
431
- for (int i = 0; i < numFiles; i++) {
432
- result[i] = resultIntent.getClipData().getItemAt(i).getUri();
433
- }
434
- } else {
435
- result = WebChromeClient.FileChooserParams.parseResult(activityResult.getResultCode(), resultIntent);
392
+ activityListener = activityResult -> {
393
+ Uri[] result;
394
+ Intent resultIntent = activityResult.getData();
395
+ if (activityResult.getResultCode() == Activity.RESULT_OK && resultIntent.getClipData() != null) {
396
+ final int numFiles = resultIntent.getClipData().getItemCount();
397
+ result = new Uri[numFiles];
398
+ for (int i = 0; i < numFiles; i++) {
399
+ result[i] = resultIntent.getClipData().getItemAt(i).getUri();
436
400
  }
437
- filePathCallback.onReceiveValue(result);
438
- };
401
+ } else {
402
+ result = WebChromeClient.FileChooserParams.parseResult(activityResult.getResultCode(), resultIntent);
403
+ }
404
+ filePathCallback.onReceiveValue(result);
405
+ };
439
406
  activityLauncher.launch(intent);
440
407
  } catch (ActivityNotFoundException e) {
441
408
  filePathCallback.onReceiveValue(null);
@@ -256,18 +256,26 @@ public class CapConfig {
256
256
  allowNavigation = JSONUtils.getArray(configJSON, "server.allowNavigation", null);
257
257
 
258
258
  // Android
259
- overriddenUserAgentString =
260
- JSONUtils.getString(configJSON, "android.overrideUserAgent", JSONUtils.getString(configJSON, "overrideUserAgent", null));
261
- appendedUserAgentString =
262
- JSONUtils.getString(configJSON, "android.appendUserAgent", JSONUtils.getString(configJSON, "appendUserAgent", null));
263
- backgroundColor =
264
- JSONUtils.getString(configJSON, "android.backgroundColor", JSONUtils.getString(configJSON, "backgroundColor", null));
265
- allowMixedContent =
266
- JSONUtils.getBoolean(
267
- configJSON,
268
- "android.allowMixedContent",
269
- JSONUtils.getBoolean(configJSON, "allowMixedContent", allowMixedContent)
270
- );
259
+ overriddenUserAgentString = JSONUtils.getString(
260
+ configJSON,
261
+ "android.overrideUserAgent",
262
+ JSONUtils.getString(configJSON, "overrideUserAgent", null)
263
+ );
264
+ appendedUserAgentString = JSONUtils.getString(
265
+ configJSON,
266
+ "android.appendUserAgent",
267
+ JSONUtils.getString(configJSON, "appendUserAgent", null)
268
+ );
269
+ backgroundColor = JSONUtils.getString(
270
+ configJSON,
271
+ "android.backgroundColor",
272
+ JSONUtils.getString(configJSON, "backgroundColor", null)
273
+ );
274
+ allowMixedContent = JSONUtils.getBoolean(
275
+ configJSON,
276
+ "android.allowMixedContent",
277
+ JSONUtils.getBoolean(configJSON, "allowMixedContent", allowMixedContent)
278
+ );
271
279
  minWebViewVersion = JSONUtils.getInt(configJSON, "android.minWebViewVersion", DEFAULT_ANDROID_WEBVIEW_VERSION);
272
280
  minHuaweiWebViewVersion = JSONUtils.getInt(configJSON, "android.minHuaweiWebViewVersion", DEFAULT_HUAWEI_WEBVIEW_VERSION);
273
281
  captureInput = JSONUtils.getBoolean(configJSON, "android.captureInput", captureInput);
@@ -150,10 +150,8 @@ public class MessageHandler {
150
150
  }
151
151
 
152
152
  private void callCordovaPluginMethod(String callbackId, String service, String action, String actionArgs) {
153
- bridge.execute(
154
- () -> {
155
- cordovaPluginManager.exec(service, action, callbackId, actionArgs);
156
- }
157
- );
153
+ bridge.execute(() -> {
154
+ cordovaPluginManager.exec(service, action, callbackId, actionArgs);
155
+ });
158
156
  }
159
157
  }
@@ -50,25 +50,6 @@ public class PluginCall {
50
50
  this.msgHandler.sendResponseMessage(this, successResult, null);
51
51
  }
52
52
 
53
- /**
54
- * @deprecated
55
- * Use {@link #resolve(JSObject data)}
56
- */
57
- @Deprecated
58
- public void success(JSObject data) {
59
- PluginResult result = new PluginResult(data);
60
- this.msgHandler.sendResponseMessage(this, result, null);
61
- }
62
-
63
- /**
64
- * @deprecated
65
- * Use {@link #resolve()}
66
- */
67
- @Deprecated
68
- public void success() {
69
- this.resolve(new JSObject());
70
- }
71
-
72
53
  public void resolve(JSObject data) {
73
54
  PluginResult result = new PluginResult(data);
74
55
  this.msgHandler.sendResponseMessage(this, result, null);
@@ -90,33 +71,6 @@ public class PluginCall {
90
71
  this.msgHandler.sendResponseMessage(this, null, errorResult);
91
72
  }
92
73
 
93
- /**
94
- * @deprecated
95
- * Use {@link #reject(String msg, Exception ex)}
96
- */
97
- @Deprecated
98
- public void error(String msg, Exception ex) {
99
- reject(msg, ex);
100
- }
101
-
102
- /**
103
- * @deprecated
104
- * Use {@link #reject(String msg, String code, Exception ex)}
105
- */
106
- @Deprecated
107
- public void error(String msg, String code, Exception ex) {
108
- reject(msg, code, ex);
109
- }
110
-
111
- /**
112
- * @deprecated
113
- * Use {@link #reject(String msg)}
114
- */
115
- @Deprecated
116
- public void error(String msg) {
117
- reject(msg);
118
- }
119
-
120
74
  public void reject(String msg, String code, Exception ex, JSObject data) {
121
75
  PluginResult errorResult = new PluginResult();
122
76
 
@@ -77,7 +77,9 @@ public class UriMatcher {
77
77
  UriMatcher node = this;
78
78
  for (int i = -2; i < numTokens; i++) {
79
79
  String token;
80
- if (i == -2) token = scheme; else if (i == -1) token = authority; else token = tokens[i];
80
+ if (i == -2) token = scheme;
81
+ else if (i == -1) token = authority;
82
+ else token = tokens[i];
81
83
  ArrayList<UriMatcher> children = node.mChildren;
82
84
  int numChildren = children.size();
83
85
  UriMatcher child;
@@ -130,7 +132,9 @@ public class UriMatcher {
130
132
 
131
133
  for (int i = -2; i < li; i++) {
132
134
  String u;
133
- if (i == -2) u = uri.getScheme(); else if (i == -1) u = uri.getAuthority(); else u = pathSegments.get(i);
135
+ if (i == -2) u = uri.getScheme();
136
+ else if (i == -1) u = uri.getAuthority();
137
+ else u = pathSegments.get(i);
134
138
  ArrayList<UriMatcher> list = node.mChildren;
135
139
  if (list == null) {
136
140
  break;
@@ -139,7 +143,7 @@ public class UriMatcher {
139
143
  int lj = list.size();
140
144
  for (int j = 0; j < lj; j++) {
141
145
  UriMatcher n = list.get(j);
142
- which_switch:switch (n.mWhich) {
146
+ which_switch: switch (n.mWhich) {
143
147
  case MASK:
144
148
  if (HostMask.Parser.parse(n.mText).matches(u)) {
145
149
  node = n;
@@ -72,14 +72,12 @@ public class MockCordovaWebViewImpl implements CordovaWebView {
72
72
  public void onNativeToJsMessageAvailable(final NativeToJsMessageQueue queue) {
73
73
  cordova
74
74
  .getActivity()
75
- .runOnUiThread(
76
- () -> {
77
- String js = queue.popAndEncodeAsJs();
78
- if (js != null) {
79
- webView.evaluateJavascript(js, null);
80
- }
75
+ .runOnUiThread(() -> {
76
+ String js = queue.popAndEncodeAsJs();
77
+ if (js != null) {
78
+ webView.evaluateJavascript(js, null);
81
79
  }
82
- );
80
+ });
83
81
  }
84
82
  }
85
83
 
@@ -46,34 +46,31 @@ public class CapacitorCookies extends Plugin {
46
46
 
47
47
  @PluginMethod
48
48
  public void getCookies(PluginCall call) {
49
- this.bridge.eval(
50
- "document.cookie",
51
- value -> {
52
- String cookies = value.substring(1, value.length() - 1);
53
- String[] cookieArray = cookies.split(";");
54
-
55
- JSObject cookieMap = new JSObject();
56
-
57
- for (String cookie : cookieArray) {
58
- if (cookie.length() > 0) {
59
- String[] keyValue = cookie.split("=", 2);
60
-
61
- if (keyValue.length == 2) {
62
- String key = keyValue[0].trim();
63
- String val = keyValue[1].trim();
64
- try {
65
- key = URLDecoder.decode(keyValue[0].trim(), StandardCharsets.UTF_8.name());
66
- val = URLDecoder.decode(keyValue[1].trim(), StandardCharsets.UTF_8.name());
67
- } catch (UnsupportedEncodingException ignored) {}
68
-
69
- cookieMap.put(key, val);
70
- }
49
+ this.bridge.eval("document.cookie", value -> {
50
+ String cookies = value.substring(1, value.length() - 1);
51
+ String[] cookieArray = cookies.split(";");
52
+
53
+ JSObject cookieMap = new JSObject();
54
+
55
+ for (String cookie : cookieArray) {
56
+ if (cookie.length() > 0) {
57
+ String[] keyValue = cookie.split("=", 2);
58
+
59
+ if (keyValue.length == 2) {
60
+ String key = keyValue[0].trim();
61
+ String val = keyValue[1].trim();
62
+ try {
63
+ key = URLDecoder.decode(keyValue[0].trim(), StandardCharsets.UTF_8.name());
64
+ val = URLDecoder.decode(keyValue[1].trim(), StandardCharsets.UTF_8.name());
65
+ } catch (UnsupportedEncodingException ignored) {}
66
+
67
+ cookieMap.put(key, val);
71
68
  }
72
69
  }
73
-
74
- call.resolve(cookieMap);
75
70
  }
76
- );
71
+
72
+ call.resolve(cookieMap);
73
+ });
77
74
  }
78
75
 
79
76
  @PluginMethod
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor/android",
3
- "version": "6.2.0",
3
+ "version": "7.0.0-alpha.2",
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)",
@@ -23,7 +23,7 @@
23
23
  "verify": "./gradlew clean lint build test -b capacitor/build.gradle"
24
24
  },
25
25
  "peerDependencies": {
26
- "@capacitor/core": "^6.2.0"
26
+ "@capacitor/core": "^7.0.0-alpha.2"
27
27
  },
28
28
  "publishConfig": {
29
29
  "access": "public"