@capacitor/android 3.6.0 → 4.0.0-beta.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,27 @@
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.0.0-beta.0](https://github.com/ionic-team/capacitor/compare/3.6.0...4.0.0-beta.0) (2022-06-17)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **android:** make removeAllListeners return a promise ([#5527](https://github.com/ionic-team/capacitor/issues/5527)) ([6f4d858](https://github.com/ionic-team/capacitor/commit/6f4d858ea879d97109c0c7da2d664d04806adc2a))
12
+ * **android:** prevent app from loading if server.url is invalid ([d4a0dea](https://github.com/ionic-team/capacitor/commit/d4a0deaa37eda4476f0be030e266c2c1260fc6e8))
13
+
14
+
15
+ ### Features
16
+
17
+ * **android:** don't allow server.androidScheme to be set to schemes handled by WebView ([01285ba](https://github.com/ionic-team/capacitor/commit/01285ba253d602b08a41240ad2ccf370730d51a3))
18
+ * **android:** set default targetSDK to 31 ([#5442](https://github.com/ionic-team/capacitor/issues/5442)) ([4442459](https://github.com/ionic-team/capacitor/commit/4442459b24cdbac25cb1e4de11583d22c21452b3))
19
+ * **android:** set default targetSDK to 32 ([#5611](https://github.com/ionic-team/capacitor/issues/5611)) ([416b966](https://github.com/ionic-team/capacitor/commit/416b9662fbf6233d23216c0c0441862603c3a723))
20
+ * **android:** Upgrade gradle to 7.4 ([#5445](https://github.com/ionic-team/capacitor/issues/5445)) ([28eaf18](https://github.com/ionic-team/capacitor/commit/28eaf1851fa7a912917dbb40c68fb4dd583d08ad))
21
+ * **android:** Use java 11 ([#5552](https://github.com/ionic-team/capacitor/issues/5552)) ([e47959f](https://github.com/ionic-team/capacitor/commit/e47959fcbd6a89b97b1275a5814fdb4e7ce30672))
22
+
23
+
24
+
25
+
26
+
6
27
  # [3.6.0](https://github.com/ionic-team/capacitor/compare/3.5.1...3.6.0) (2022-06-17)
7
28
 
8
29
 
@@ -13,6 +34,23 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
13
34
 
14
35
 
15
36
 
37
+ # [4.0.0-alpha.2](https://github.com/ionic-team/capacitor/compare/3.4.1...4.0.0-alpha.2) (2022-05-12)
38
+
39
+
40
+ ### Bug Fixes
41
+
42
+ * **android:** make removeAllListeners return a promise ([#5527](https://github.com/ionic-team/capacitor/issues/5527)) ([6f4d858](https://github.com/ionic-team/capacitor/commit/6f4d858ea879d97109c0c7da2d664d04806adc2a))
43
+ * **android:** prevent app from loading if server.url is invalid ([d4a0dea](https://github.com/ionic-team/capacitor/commit/d4a0deaa37eda4476f0be030e266c2c1260fc6e8))
44
+
45
+
46
+ ### Features
47
+
48
+ * **android:** don't allow server.androidScheme to be set to schemes handled by WebView ([01285ba](https://github.com/ionic-team/capacitor/commit/01285ba253d602b08a41240ad2ccf370730d51a3))
49
+ * **android:** set default targetSDK to 31 ([#5442](https://github.com/ionic-team/capacitor/issues/5442)) ([4442459](https://github.com/ionic-team/capacitor/commit/4442459b24cdbac25cb1e4de11583d22c21452b3))
50
+ * **android:** Upgrade gradle to 7.4 ([#5445](https://github.com/ionic-team/capacitor/issues/5445)) ([28eaf18](https://github.com/ionic-team/capacitor/commit/28eaf1851fa7a912917dbb40c68fb4dd583d08ad))
51
+ * **android:** Use java 11 ([#5552](https://github.com/ionic-team/capacitor/issues/5552)) ([e47959f](https://github.com/ionic-team/capacitor/commit/e47959fcbd6a89b97b1275a5814fdb4e7ce30672))
52
+
53
+
16
54
 
17
55
 
18
56
  ## [3.5.1](https://github.com/ionic-team/capacitor/compare/3.5.0...3.5.1) (2022-05-04)
@@ -35,6 +73,14 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
35
73
 
36
74
 
37
75
 
76
+ # [4.0.0-alpha.1](https://github.com/ionic-team/capacitor/compare/3.4.1...4.0.0-alpha.1) (2022-03-25)
77
+
78
+
79
+ ### Features
80
+
81
+ * **android:** set default targetSDK to 31 ([#5442](https://github.com/ionic-team/capacitor/issues/5442)) ([4442459](https://github.com/ionic-team/capacitor/commit/4442459b24cdbac25cb1e4de11583d22c21452b3))
82
+ * **android:** Upgrade gradle to 7.4 ([#5445](https://github.com/ionic-team/capacitor/issues/5445)) ([28eaf18](https://github.com/ionic-team/capacitor/commit/28eaf1851fa7a912917dbb40c68fb4dd583d08ad))
83
+
38
84
 
39
85
 
40
86
  ## [3.4.3](https://github.com/ionic-team/capacitor/compare/3.4.2...3.4.3) (2022-03-04)
@@ -51,8 +97,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
51
97
 
52
98
 
53
99
 
54
-
55
-
56
100
  ## [3.4.1](https://github.com/ionic-team/capacitor/compare/3.4.0...3.4.1) (2022-02-09)
57
101
 
58
102
  **Note:** Version bump only for package @capacitor/android
@@ -1,13 +1,13 @@
1
1
  ext {
2
- androidxActivityVersion = project.hasProperty('androidxActivityVersion') ? rootProject.ext.androidxActivityVersion : '1.2.0'
3
- androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.2.0'
4
- androidxCoordinatorLayoutVersion = project.hasProperty('androidxCoordinatorLayoutVersion') ? rootProject.ext.androidxCoordinatorLayoutVersion : '1.1.0'
5
- androidxCoreVersion = project.hasProperty('androidxCoreVersion') ? rootProject.ext.androidxCoreVersion : '1.3.2'
6
- androidxFragmentVersion = project.hasProperty('androidxFragmentVersion') ? rootProject.ext.androidxFragmentVersion : '1.3.0'
7
- junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.1'
8
- androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.2'
9
- androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.3.0'
10
- cordovaAndroidVersion = project.hasProperty('cordovaAndroidVersion') ? rootProject.ext.cordovaAndroidVersion : '7.0.0'
2
+ androidxActivityVersion = project.hasProperty('androidxActivityVersion') ? rootProject.ext.androidxActivityVersion : '1.4.0'
3
+ androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.4.2'
4
+ androidxCoordinatorLayoutVersion = project.hasProperty('androidxCoordinatorLayoutVersion') ? rootProject.ext.androidxCoordinatorLayoutVersion : '1.2.0'
5
+ androidxCoreVersion = project.hasProperty('androidxCoreVersion') ? rootProject.ext.androidxCoreVersion : '1.8.0'
6
+ androidxFragmentVersion = project.hasProperty('androidxFragmentVersion') ? rootProject.ext.androidxFragmentVersion : '1.4.1'
7
+ junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
8
+ androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.3'
9
+ androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.4.0'
10
+ cordovaAndroidVersion = project.hasProperty('cordovaAndroidVersion') ? rootProject.ext.cordovaAndroidVersion : '10.1.1'
11
11
  }
12
12
 
13
13
 
@@ -17,7 +17,7 @@ buildscript {
17
17
  mavenCentral()
18
18
  }
19
19
  dependencies {
20
- classpath 'com.android.tools.build:gradle:4.2.1'
20
+ classpath 'com.android.tools.build:gradle:7.2.1'
21
21
  }
22
22
  }
23
23
 
@@ -26,10 +26,10 @@ tasks.withType(Javadoc).all { enabled = false }
26
26
  apply plugin: 'com.android.library'
27
27
 
28
28
  android {
29
- compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 30
29
+ compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 32
30
30
  defaultConfig {
31
- minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 21
32
- targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 30
31
+ minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
32
+ targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 32
33
33
  versionCode 1
34
34
  versionName "1.0"
35
35
  consumerProguardFiles 'proguard-rules.pro'
@@ -47,15 +47,14 @@ android {
47
47
  warningsAsErrors true
48
48
  }
49
49
  compileOptions {
50
- sourceCompatibility JavaVersion.VERSION_1_8
51
- targetCompatibility JavaVersion.VERSION_1_8
50
+ sourceCompatibility JavaVersion.VERSION_11
51
+ targetCompatibility JavaVersion.VERSION_11
52
52
  }
53
53
  }
54
54
 
55
55
  repositories {
56
56
  google()
57
57
  mavenCentral()
58
- jcenter()
59
58
  }
60
59
 
61
60
  dependencies {
@@ -22,6 +22,7 @@ import androidx.activity.result.contract.ActivityResultContract;
22
22
  import androidx.annotation.NonNull;
23
23
  import androidx.appcompat.app.AppCompatActivity;
24
24
  import androidx.core.app.ActivityCompat;
25
+ import androidx.core.content.pm.PackageInfoCompat;
25
26
  import androidx.fragment.app.Fragment;
26
27
  import com.getcapacitor.android.R;
27
28
  import com.getcapacitor.annotation.CapacitorPlugin;
@@ -218,7 +219,10 @@ public class Bridge {
218
219
  try {
219
220
  URL appUrlObject = new URL(appUrlConfig);
220
221
  authorities.add(appUrlObject.getAuthority());
221
- } catch (Exception ex) {}
222
+ } catch (Exception ex) {
223
+ Logger.error("Provided server url is invalid: " + ex.getMessage());
224
+ return;
225
+ }
222
226
  localUrl = appUrlConfig;
223
227
  appUrl = appUrlConfig;
224
228
  } else {
@@ -293,7 +297,7 @@ public class Bridge {
293
297
 
294
298
  try {
295
299
  PackageInfo pInfo = getContext().getPackageManager().getPackageInfo(getContext().getPackageName(), 0);
296
- versionCode = Integer.toString(pInfo.versionCode);
300
+ versionCode = Integer.toString((int) PackageInfoCompat.getLongVersionCode(pInfo));
297
301
  versionName = pInfo.versionName;
298
302
  } catch (Exception ex) {
299
303
  Logger.error("Unable to get package info", ex);
@@ -421,7 +425,6 @@ public class Bridge {
421
425
  settings.setDomStorageEnabled(true);
422
426
  settings.setGeolocationEnabled(true);
423
427
  settings.setDatabaseEnabled(true);
424
- settings.setAppCacheEnabled(true);
425
428
  settings.setMediaPlaybackRequiresUserGesture(false);
426
429
  settings.setJavaScriptCanOpenWindowsAutomatically(true);
427
430
  if (this.config.isMixedContentAllowed()) {
@@ -475,6 +478,17 @@ public class Bridge {
475
478
  }
476
479
  }
477
480
 
481
+ @SuppressWarnings("deprecation")
482
+ private String getLegacyPluginName(Class<? extends Plugin> pluginClass) {
483
+ NativePlugin legacyPluginAnnotation = pluginClass.getAnnotation(NativePlugin.class);
484
+ if (legacyPluginAnnotation == null) {
485
+ Logger.error("Plugin doesn't have the @CapacitorPlugin annotation. Please add it");
486
+ return null;
487
+ }
488
+
489
+ return legacyPluginAnnotation.name();
490
+ }
491
+
478
492
  /**
479
493
  * Register a plugin class
480
494
  * @param pluginClass a class inheriting from Plugin
@@ -484,14 +498,10 @@ public class Bridge {
484
498
 
485
499
  CapacitorPlugin pluginAnnotation = pluginClass.getAnnotation(CapacitorPlugin.class);
486
500
  if (pluginAnnotation == null) {
487
- NativePlugin legacyPluginAnnotation = pluginClass.getAnnotation(NativePlugin.class);
488
-
489
- if (legacyPluginAnnotation == null) {
490
- Logger.error("Plugin doesn't have the @CapacitorPlugin annotation. Please add it");
501
+ pluginName = this.getLegacyPluginName(pluginClass);
502
+ if (pluginName == null) {
491
503
  return;
492
504
  }
493
-
494
- pluginName = legacyPluginAnnotation.name();
495
505
  } else {
496
506
  pluginName = pluginAnnotation.name();
497
507
  }
@@ -530,6 +540,7 @@ public class Bridge {
530
540
  * @return
531
541
  */
532
542
  @Deprecated
543
+ @SuppressWarnings("deprecation")
533
544
  public PluginHandle getPluginWithRequestCode(int requestCode) {
534
545
  for (PluginHandle handle : this.plugins.values()) {
535
546
  int[] requestCodes;
@@ -845,6 +856,7 @@ public class Bridge {
845
856
  }
846
857
 
847
858
  @Deprecated
859
+ @SuppressWarnings("deprecation")
848
860
  public void startActivityForPluginWithResult(PluginCall call, Intent intent, int requestCode) {
849
861
  Logger.debug("Starting activity for result");
850
862
 
@@ -862,6 +874,7 @@ public class Bridge {
862
874
  * @param grantResults the set of granted/denied permissions
863
875
  * @return true if permission code was handled by a plugin explicitly, false if not
864
876
  */
877
+ @SuppressWarnings("deprecation")
865
878
  boolean onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
866
879
  PluginHandle plugin = getPluginWithRequestCode(requestCode);
867
880
 
@@ -1001,6 +1014,7 @@ public class Bridge {
1001
1014
  * @param resultCode
1002
1015
  * @param data
1003
1016
  */
1017
+ @SuppressWarnings("deprecation")
1004
1018
  boolean onActivityResult(int requestCode, int resultCode, Intent data) {
1005
1019
  PluginHandle plugin = getPluginWithRequestCode(requestCode);
1006
1020
 
@@ -26,43 +26,14 @@ public class BridgeActivity extends AppCompatActivity {
26
26
  setTheme(getResources().getIdentifier("AppTheme_NoActionBar", "style", getPackageName()));
27
27
  setTheme(R.style.AppTheme_NoActionBar);
28
28
  setContentView(R.layout.bridge_layout_main);
29
- }
30
-
31
- /**
32
- * Initializes the Capacitor Bridge with the Activity.
33
- * @deprecated It is preferred not to call this method. If it is not called, the bridge is
34
- * initialized automatically. If you need to add additional plugins during initialization,
35
- * use {@link #registerPlugin(Class)} or {@link #registerPlugins(List)}.
36
- *
37
- * @param plugins A list of plugins to initialize with Capacitor
38
- */
39
- @Deprecated
40
- protected void init(Bundle savedInstanceState, List<Class<? extends Plugin>> plugins) {
41
- this.init(savedInstanceState, plugins, null);
42
- }
43
-
44
- /**
45
- * Initializes the Capacitor Bridge with the Activity.
46
- * @deprecated It is preferred not to call this method. If it is not called, the bridge is
47
- * initialized automatically. If you need to add additional plugins during initialization,
48
- * use {@link #registerPlugin(Class)} or {@link #registerPlugins(List)}.
49
- *
50
- * @param plugins A list of plugins to initialize with Capacitor
51
- * @param config An instance of a Capacitor Configuration to use. If null, will load from file
52
- */
53
- @Deprecated
54
- protected void init(Bundle savedInstanceState, List<Class<? extends Plugin>> plugins, CapConfig config) {
55
- this.initialPlugins = plugins;
56
- this.config = config;
29
+ PluginManager loader = new PluginManager(getAssets());
57
30
 
58
- this.load();
59
- }
31
+ try {
32
+ bridgeBuilder.addPlugins(loader.loadPluginClasses());
33
+ } catch (PluginLoadException ex) {
34
+ Logger.error("Error loading plugins.", ex);
35
+ }
60
36
 
61
- /**
62
- * @deprecated This method should not be called manually.
63
- */
64
- @Deprecated
65
- protected void load(Bundle savedInstanceState) {
66
37
  this.load();
67
38
  }
68
39
 
@@ -96,20 +67,6 @@ public class BridgeActivity extends AppCompatActivity {
96
67
  @Override
97
68
  public void onStart() {
98
69
  super.onStart();
99
-
100
- // Preferred behavior: init() was not called, so we construct the bridge with auto-loaded plugins.
101
- if (bridge == null) {
102
- PluginManager loader = new PluginManager(getAssets());
103
-
104
- try {
105
- bridgeBuilder.addPlugins(loader.loadPluginClasses());
106
- } catch (PluginLoadException ex) {
107
- Logger.error("Error loading plugins.", ex);
108
- }
109
-
110
- this.load();
111
- }
112
-
113
70
  activityDepth++;
114
71
  this.bridge.onStart();
115
72
  Logger.debug("App started");
@@ -147,7 +147,6 @@ public class BridgeWebChromeClient extends WebChromeClient {
147
147
  AlertDialog.Builder builder = new AlertDialog.Builder(view.getContext());
148
148
  builder
149
149
  .setMessage(message)
150
- .setTitle("Alert")
151
150
  .setPositiveButton(
152
151
  "OK",
153
152
  (dialog, buttonIndex) -> {
@@ -187,7 +186,6 @@ public class BridgeWebChromeClient extends WebChromeClient {
187
186
 
188
187
  builder
189
188
  .setMessage(message)
190
- .setTitle("Confirm")
191
189
  .setPositiveButton(
192
190
  "OK",
193
191
  (dialog, buttonIndex) -> {
@@ -236,7 +234,6 @@ public class BridgeWebChromeClient extends WebChromeClient {
236
234
 
237
235
  builder
238
236
  .setMessage(message)
239
- .setTitle("Prompt")
240
237
  .setView(input)
241
238
  .setPositiveButton(
242
239
  "OK",
@@ -286,8 +283,10 @@ public class BridgeWebChromeClient extends WebChromeClient {
286
283
  callback.invoke(origin, true, false);
287
284
  } else {
288
285
  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)) {
286
+ if (
287
+ Build.VERSION.SDK_INT >= Build.VERSION_CODES.S &&
288
+ PermissionHelper.hasPermissions(bridge.getContext(), coarsePermission)
289
+ ) {
291
290
  callback.invoke(origin, true, false);
292
291
  } else {
293
292
  callback.invoke(origin, false, false);
@@ -28,6 +28,7 @@ public class BridgeWebViewClient extends WebViewClient {
28
28
  return bridge.launchIntent(url);
29
29
  }
30
30
 
31
+ @Deprecated
31
32
  @Override
32
33
  public boolean shouldOverrideUrlLoading(WebView view, String url) {
33
34
  return bridge.launchIntent(Uri.parse(url));
@@ -9,8 +9,10 @@ import android.content.res.AssetManager;
9
9
  import androidx.annotation.Nullable;
10
10
  import com.getcapacitor.util.JSONUtils;
11
11
  import java.io.IOException;
12
+ import java.util.Arrays;
12
13
  import java.util.HashMap;
13
14
  import java.util.Iterator;
15
+ import java.util.List;
14
16
  import java.util.Locale;
15
17
  import java.util.Map;
16
18
  import org.json.JSONException;
@@ -106,7 +108,11 @@ public class CapConfig {
106
108
  this.html5mode = builder.html5mode;
107
109
  this.serverUrl = builder.serverUrl;
108
110
  this.hostname = builder.hostname;
109
- this.androidScheme = builder.androidScheme;
111
+
112
+ if (this.validateScheme(builder.androidScheme)) {
113
+ this.androidScheme = builder.androidScheme;
114
+ }
115
+
110
116
  this.allowNavigation = builder.allowNavigation;
111
117
 
112
118
  // Android Config
@@ -150,7 +156,12 @@ public class CapConfig {
150
156
  html5mode = JSONUtils.getBoolean(configJSON, "server.html5mode", html5mode);
151
157
  serverUrl = JSONUtils.getString(configJSON, "server.url", null);
152
158
  hostname = JSONUtils.getString(configJSON, "server.hostname", hostname);
153
- androidScheme = JSONUtils.getString(configJSON, "server.androidScheme", androidScheme);
159
+
160
+ String configSchema = JSONUtils.getString(configJSON, "server.androidScheme", androidScheme);
161
+ if (this.validateScheme(configSchema)) {
162
+ androidScheme = configSchema;
163
+ }
164
+
154
165
  allowNavigation = JSONUtils.getArray(configJSON, "server.allowNavigation", null);
155
166
 
156
167
  // Android
@@ -195,6 +206,16 @@ public class CapConfig {
195
206
  pluginsConfiguration = deserializePluginsConfig(JSONUtils.getObject(configJSON, "plugins"));
196
207
  }
197
208
 
209
+ private boolean validateScheme(String scheme) {
210
+ List<String> invalidSchemes = Arrays.asList("file", "ftp", "ftps", "ws", "wss", "about", "blob", "data");
211
+ if (invalidSchemes.contains(scheme)) {
212
+ Logger.warn(scheme + " is not an allowed scheme. Defaulting to http.");
213
+ return false;
214
+ }
215
+
216
+ return true;
217
+ }
218
+
198
219
  public boolean isHTML5Mode() {
199
220
  return html5mode;
200
221
  }
@@ -30,6 +30,7 @@ public class CapacitorWebView extends WebView {
30
30
  }
31
31
 
32
32
  @Override
33
+ @SuppressWarnings("deprecation")
33
34
  public boolean dispatchKeyEvent(KeyEvent event) {
34
35
  if (event.getAction() == KeyEvent.ACTION_MULTIPLE) {
35
36
  evaluateJavascript("document.activeElement.value = document.activeElement.value + '" + event.getCharacters() + "';", null);
@@ -77,7 +77,7 @@ public class FileUtils {
77
77
  final String type = split[0];
78
78
 
79
79
  if ("primary".equalsIgnoreCase(type)) {
80
- return Environment.getExternalStorageDirectory() + "/" + split[1];
80
+ return legacyPrimaryPath(split[1]);
81
81
  } else {
82
82
  final int splitIndex = docId.indexOf(':', 1);
83
83
  final String tag = docId.substring(0, splitIndex);
@@ -136,6 +136,11 @@ public class FileUtils {
136
136
  return null;
137
137
  }
138
138
 
139
+ @SuppressWarnings("deprecation")
140
+ private static String legacyPrimaryPath(String pathPart) {
141
+ return Environment.getExternalStorageDirectory() + "/" + pathPart;
142
+ }
143
+
139
144
  /**
140
145
  * Read a plaintext file.
141
146
  *
@@ -94,7 +94,7 @@ public class JSExport {
94
94
  return readFile(context.getAssets(), path);
95
95
  }
96
96
  } catch (IOException ex) {
97
- Logger.error("Unable to read file at path " + path);
97
+ Logger.warn("Unable to read file at path " + path);
98
98
  }
99
99
  return builder.toString();
100
100
  }
@@ -745,9 +745,10 @@ public class Plugin {
745
745
  * @param call
746
746
  */
747
747
  @SuppressWarnings("unused")
748
- @PluginMethod(returnType = PluginMethod.RETURN_NONE)
748
+ @PluginMethod(returnType = PluginMethod.RETURN_PROMISE)
749
749
  public void removeAllListeners(PluginCall call) {
750
750
  eventListeners.clear();
751
+ call.resolve();
751
752
  }
752
753
 
753
754
  /**
@@ -788,15 +789,7 @@ public class Plugin {
788
789
  public void requestPermissions(PluginCall call) {
789
790
  CapacitorPlugin annotation = handle.getPluginAnnotation();
790
791
  if (annotation == null) {
791
- // handle permission requests for plugins defined with @NativePlugin (prior to 3.0.0)
792
- NativePlugin legacyAnnotation = this.handle.getLegacyPluginAnnotation();
793
- String[] perms = legacyAnnotation.permissions();
794
- if (perms.length > 0) {
795
- saveCall(call);
796
- pluginRequestPermissions(perms, legacyAnnotation.permissionRequestCode());
797
- } else {
798
- call.resolve();
799
- }
792
+ handleLegacyPermission(call);
800
793
  } else {
801
794
  // handle permission requests for plugins defined with @CapacitorPlugin (since 3.0.0)
802
795
  String[] permAliases = null;
@@ -862,6 +855,19 @@ public class Plugin {
862
855
  }
863
856
  }
864
857
 
858
+ @SuppressWarnings("deprecation")
859
+ private void handleLegacyPermission(PluginCall call) {
860
+ // handle permission requests for plugins defined with @NativePlugin (prior to 3.0.0)
861
+ NativePlugin legacyAnnotation = this.handle.getLegacyPluginAnnotation();
862
+ String[] perms = legacyAnnotation.permissions();
863
+ if (perms.length > 0) {
864
+ saveCall(call);
865
+ pluginRequestPermissions(perms, legacyAnnotation.permissionRequestCode());
866
+ } else {
867
+ call.resolve();
868
+ }
869
+ }
870
+
865
871
  /**
866
872
  * Handle request permissions result. A plugin using the deprecated {@link NativePlugin}
867
873
  * should override this to handle the result, or this method will handle the result
@@ -20,11 +20,14 @@ public class PluginHandle {
20
20
 
21
21
  private final String pluginId;
22
22
 
23
+ @SuppressWarnings("deprecation")
23
24
  private NativePlugin legacyPluginAnnotation;
25
+
24
26
  private CapacitorPlugin pluginAnnotation;
25
27
 
26
28
  private Plugin instance;
27
29
 
30
+ @SuppressWarnings("deprecation")
28
31
  public PluginHandle(Bridge bridge, Class<? extends Plugin> pluginClass) throws InvalidPluginException, PluginLoadException {
29
32
  this.bridge = bridge;
30
33
  this.pluginClass = pluginClass;
@@ -67,6 +70,7 @@ public class PluginHandle {
67
70
  return this.pluginId;
68
71
  }
69
72
 
73
+ @SuppressWarnings("deprecation")
70
74
  public NativePlugin getLegacyPluginAnnotation() {
71
75
  return this.legacyPluginAnnotation;
72
76
  }
@@ -12,7 +12,6 @@ class CapacitorCordovaCookieManager implements ICordovaCookieManager {
12
12
  public CapacitorCordovaCookieManager(WebView webview) {
13
13
  webView = webview;
14
14
  cookieManager = CookieManager.getInstance();
15
- CookieManager.setAcceptFileSchemeCookies(true);
16
15
  cookieManager.setAcceptThirdPartyCookies(webView, true);
17
16
  }
18
17
 
@@ -33,7 +32,7 @@ class CapacitorCordovaCookieManager implements ICordovaCookieManager {
33
32
 
34
33
  @Override
35
34
  public void clearCookies() {
36
- cookieManager.removeAllCookie();
35
+ cookieManager.removeAllCookies(null);
37
36
  }
38
37
 
39
38
  @Override
@@ -112,6 +112,7 @@ public class MockCordovaWebViewImpl implements CordovaWebView {
112
112
  @Override
113
113
  public void clearCache() {}
114
114
 
115
+ @Deprecated
115
116
  @Override
116
117
  public void clearCache(boolean b) {}
117
118
 
@@ -181,6 +182,7 @@ public class MockCordovaWebViewImpl implements CordovaWebView {
181
182
  this.pluginManager.onDestroy();
182
183
  }
183
184
 
185
+ @Deprecated
184
186
  @Override
185
187
  public void sendJavascript(String statememt) {
186
188
  nativeToJsMessageQueue.addJavaScript(statememt);
@@ -198,14 +200,17 @@ public class MockCordovaWebViewImpl implements CordovaWebView {
198
200
  @Override
199
201
  public void showWebPage(String url, boolean openExternal, boolean clearHistory, Map<String, Object> params) {}
200
202
 
203
+ @Deprecated
201
204
  @Override
202
205
  public boolean isCustomViewShowing() {
203
206
  return false;
204
207
  }
205
208
 
209
+ @Deprecated
206
210
  @Override
207
211
  public void showCustomView(View view, WebChromeClient.CustomViewCallback callback) {}
208
212
 
213
+ @Deprecated
209
214
  @Override
210
215
  public void hideCustomView() {}
211
216
 
@@ -1,6 +1,6 @@
1
1
  <?xml version="1.0" encoding="utf-8"?>
2
- <resources>
3
- <color name="colorPrimary">#3F51B5</color>
4
- <color name="colorPrimaryDark">#303F9F</color>
5
- <color name="colorAccent">#FF4081</color>
2
+ <resources xmlns:tools="http://schemas.android.com/tools">
3
+ <color tools:ignore="UnusedResources" name="colorPrimary">#3F51B5</color>
4
+ <color tools:ignore="UnusedResources" name="colorPrimaryDark">#303F9F</color>
5
+ <color tools:ignore="UnusedResources" name="colorAccent">#FF4081</color>
6
6
  </resources>
@@ -1,7 +1,2 @@
1
1
  <resources>
2
- <string name="app_name">CapacitorAndroid</string>
3
- <string name="ok">OK</string>
4
- <string name="picture">Picture</string>
5
- <string name="request_permission">Allow this app to take pictures</string>
6
- <string name="camera_error">Unable to use camera</string>
7
2
  </resources>
@@ -1,13 +1,4 @@
1
1
  <resources>
2
-
3
- <!-- Base application theme. -->
4
- <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
5
- <!-- Customize your theme here. -->
6
- <item name="colorPrimary">@color/colorPrimary</item>
7
- <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
8
- <item name="colorAccent">@color/colorAccent</item>
9
- </style>
10
-
11
2
  <style name="AppTheme.NoActionBar" parent="Theme.AppCompat.NoActionBar">
12
3
  <item name="windowActionBar">false</item>
13
4
  <item name="windowNoTitle">true</item>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor/android",
3
- "version": "3.6.0",
3
+ "version": "4.0.0-beta.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)",
@@ -27,5 +27,5 @@
27
27
  "publishConfig": {
28
28
  "access": "public"
29
29
  },
30
- "gitHead": "1e06a199a44bb5321f0fb48b5fbca961cc1dbb50"
30
+ "gitHead": "d9e553f76fac74df6ab0f2bf5c3da18e51b2282b"
31
31
  }
@@ -1,12 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <vector xmlns:android="http://schemas.android.com/apk/res/android"
3
- android:width="16dp"
4
- android:height="16dp"
5
- android:viewportHeight="108"
6
- android:viewportWidth="108">
7
-
8
- <path
9
- android:width="1dp"
10
- android:color="@android:color/transparent" />
11
-
12
- </vector>