@capacitor/android 3.8.0 → 3.9.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,17 @@
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.9.0](https://github.com/ionic-team/capacitor/compare/3.8.0...3.9.0) (2022-10-21)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **android:** added ServerPath object and building options for setting initial load from portals ([#6005](https://github.com/ionic-team/capacitor/issues/6005)) ([a408213](https://github.com/ionic-team/capacitor/commit/a4082136ef0588d89575ba022baf83520ca4956b))
12
+
13
+
14
+
15
+
16
+
6
17
  # [3.8.0](https://github.com/ionic-team/capacitor/compare/3.7.0...3.8.0) (2022-09-08)
7
18
 
8
19
  **Note:** Version bump only for package @capacitor/android
@@ -1,5 +1,6 @@
1
1
  package com.getcapacitor;
2
2
 
3
+ import android.annotation.SuppressLint;
3
4
  import android.app.Activity;
4
5
  import android.content.ActivityNotFoundException;
5
6
  import android.content.Context;
@@ -133,6 +134,9 @@ public class Bridge {
133
134
  // An interface to manipulate route resolving
134
135
  private RouteProcessor routeProcessor;
135
136
 
137
+ // A pre-determined path to load the bridge
138
+ private ServerPath serverPath;
139
+
136
140
  /**
137
141
  * Create the Bridge with a reference to the main {@link Activity} for the
138
142
  * app, and a reference to the {@link WebView} our app will use.
@@ -150,11 +154,12 @@ public class Bridge {
150
154
  CordovaPreferences preferences,
151
155
  CapConfig config
152
156
  ) {
153
- this(context, null, webView, initialPlugins, cordovaInterface, pluginManager, preferences, config);
157
+ this(context, null, null, webView, initialPlugins, cordovaInterface, pluginManager, preferences, config);
154
158
  }
155
159
 
156
160
  private Bridge(
157
161
  AppCompatActivity context,
162
+ ServerPath serverPath,
158
163
  Fragment fragment,
159
164
  WebView webView,
160
165
  List<Class<? extends Plugin>> initialPlugins,
@@ -164,6 +169,7 @@ public class Bridge {
164
169
  CapConfig config
165
170
  ) {
166
171
  this.app = new App();
172
+ this.serverPath = serverPath;
167
173
  this.context = context;
168
174
  this.fragment = fragment;
169
175
  this.webView = webView;
@@ -253,8 +259,17 @@ public class Bridge {
253
259
  setServerBasePath(path);
254
260
  }
255
261
  }
256
- // Get to work
257
- webView.loadUrl(appUrl);
262
+
263
+ // If serverPath configured, start server based on provided path
264
+ if (serverPath != null) {
265
+ if (serverPath.getType() == ServerPath.PathType.ASSET_PATH) {
266
+ setServerAssetPath(serverPath.getPath());
267
+ } else {
268
+ setServerBasePath(serverPath.getPath());
269
+ }
270
+ } else {
271
+ webView.loadUrl(appUrl);
272
+ }
258
273
  }
259
274
 
260
275
  public boolean launchIntent(Uri url) {
@@ -415,6 +430,7 @@ public class Bridge {
415
430
  /**
416
431
  * Initialize the WebView, setting required flags
417
432
  */
433
+ @SuppressLint("SetJavaScriptEnabled")
418
434
  private void initWebView() {
419
435
  WebSettings settings = webView.getSettings();
420
436
  settings.setJavaScriptEnabled(true);
@@ -1204,6 +1220,10 @@ public class Bridge {
1204
1220
  this.routeProcessor = routeProcessor;
1205
1221
  }
1206
1222
 
1223
+ ServerPath getServerPath() {
1224
+ return serverPath;
1225
+ }
1226
+
1207
1227
  /**
1208
1228
  * Add a listener that the WebViewClient can trigger on certain events.
1209
1229
  * @param webViewListener A {@link WebViewListener} to add.
@@ -1229,6 +1249,7 @@ public class Bridge {
1229
1249
  private Fragment fragment;
1230
1250
  private RouteProcessor routeProcessor;
1231
1251
  private final List<WebViewListener> webViewListeners = new ArrayList<>();
1252
+ private ServerPath serverPath;
1232
1253
 
1233
1254
  public Builder(AppCompatActivity activity) {
1234
1255
  this.activity = activity;
@@ -1285,6 +1306,11 @@ public class Bridge {
1285
1306
  return this;
1286
1307
  }
1287
1308
 
1309
+ public Builder setServerPath(ServerPath serverPath) {
1310
+ this.serverPath = serverPath;
1311
+ return this;
1312
+ }
1313
+
1288
1314
  public Bridge create() {
1289
1315
  // Cordova initialization
1290
1316
  ConfigXmlParser parser = new ConfigXmlParser();
@@ -1305,7 +1331,17 @@ public class Bridge {
1305
1331
  cordovaInterface.onCordovaInit(pluginManager);
1306
1332
 
1307
1333
  // Bridge initialization
1308
- Bridge bridge = new Bridge(activity, fragment, webView, plugins, cordovaInterface, pluginManager, preferences, config);
1334
+ Bridge bridge = new Bridge(
1335
+ activity,
1336
+ serverPath,
1337
+ fragment,
1338
+ webView,
1339
+ plugins,
1340
+ cordovaInterface,
1341
+ pluginManager,
1342
+ preferences,
1343
+ config
1344
+ );
1309
1345
  bridge.setCordovaWebView(mockWebView);
1310
1346
  bridge.setWebViewListeners(webViewListeners);
1311
1347
  bridge.setRouteProcessor(routeProcessor);
@@ -0,0 +1,25 @@
1
+ package com.getcapacitor;
2
+
3
+ public class ServerPath {
4
+
5
+ public enum PathType {
6
+ BASE_PATH,
7
+ ASSET_PATH
8
+ }
9
+
10
+ private final PathType type;
11
+ private final String path;
12
+
13
+ public ServerPath(PathType type, String path) {
14
+ this.type = type;
15
+ this.path = path;
16
+ }
17
+
18
+ public PathType getType() {
19
+ return type;
20
+ }
21
+
22
+ public String getPath() {
23
+ return path;
24
+ }
25
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor/android",
3
- "version": "3.8.0",
3
+ "version": "3.9.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.8.0"
25
+ "@capacitor/core": "^3.9.0"
26
26
  },
27
27
  "publishConfig": {
28
28
  "access": "public"
29
29
  },
30
- "gitHead": "8ec9df5d4a8c5760c834c7706aaedea1b402108b"
30
+ "gitHead": "70a7e72b7461acd5b9bdc89fc9e0232ae8597005"
31
31
  }