@capacitor/android 4.0.1-alpha.0 → 4.0.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.
- package/CHANGELOG.md +126 -1
- package/capacitor/build.gradle +9 -7
- package/capacitor/proguard-rules.pro +26 -0
- package/capacitor/src/main/assets/native-bridge.js +8 -0
- package/capacitor/src/main/java/com/getcapacitor/AppUUID.java +65 -0
- package/capacitor/src/main/java/com/getcapacitor/Bridge.java +147 -13
- package/capacitor/src/main/java/com/getcapacitor/BridgeActivity.java +11 -54
- package/capacitor/src/main/java/com/getcapacitor/BridgeWebChromeClient.java +4 -5
- package/capacitor/src/main/java/com/getcapacitor/BridgeWebViewClient.java +11 -0
- package/capacitor/src/main/java/com/getcapacitor/CapConfig.java +65 -2
- package/capacitor/src/main/java/com/getcapacitor/CapacitorWebView.java +1 -0
- package/capacitor/src/main/java/com/getcapacitor/FileUtils.java +6 -1
- package/capacitor/src/main/java/com/getcapacitor/JSExport.java +1 -1
- package/capacitor/src/main/java/com/getcapacitor/MessageHandler.java +31 -4
- package/capacitor/src/main/java/com/getcapacitor/Plugin.java +16 -10
- package/capacitor/src/main/java/com/getcapacitor/PluginCall.java +28 -9
- package/capacitor/src/main/java/com/getcapacitor/PluginHandle.java +4 -0
- package/capacitor/src/main/java/com/getcapacitor/ProcessedRoute.java +28 -0
- package/capacitor/src/main/java/com/getcapacitor/RouteProcessor.java +8 -0
- package/capacitor/src/main/java/com/getcapacitor/WebViewLocalServer.java +27 -5
- package/capacitor/src/main/java/com/getcapacitor/cordova/CapacitorCordovaCookieManager.java +1 -2
- package/capacitor/src/main/java/com/getcapacitor/cordova/MockCordovaWebViewImpl.java +5 -0
- package/capacitor/src/main/res/values/colors.xml +4 -4
- package/capacitor/src/main/res/values/strings.xml +0 -5
- package/capacitor/src/main/res/values/styles.xml +0 -9
- package/package.json +4 -3
- package/capacitor/src/main/res/drawable/ic_transparent.xml +0 -12
|
@@ -24,7 +24,6 @@ import android.webkit.WebResourceResponse;
|
|
|
24
24
|
import java.io.IOException;
|
|
25
25
|
import java.io.InputStream;
|
|
26
26
|
import java.net.HttpURLConnection;
|
|
27
|
-
import java.net.SocketTimeoutException;
|
|
28
27
|
import java.net.URL;
|
|
29
28
|
import java.net.URLConnection;
|
|
30
29
|
import java.nio.charset.StandardCharsets;
|
|
@@ -173,7 +172,7 @@ public class WebViewLocalServer {
|
|
|
173
172
|
return null;
|
|
174
173
|
}
|
|
175
174
|
|
|
176
|
-
if (isLocalFile(loadingUrl) || isMainUrl(loadingUrl) || !isAllowedUrl(loadingUrl)) {
|
|
175
|
+
if (isLocalFile(loadingUrl) || isMainUrl(loadingUrl) || !isAllowedUrl(loadingUrl) || isErrorUrl(loadingUrl)) {
|
|
177
176
|
Logger.debug("Handling local request: " + request.getUrl().toString());
|
|
178
177
|
return handleLocalRequest(request, handler);
|
|
179
178
|
} else {
|
|
@@ -186,6 +185,11 @@ public class WebViewLocalServer {
|
|
|
186
185
|
return path.startsWith(capacitorContentStart) || path.startsWith(capacitorFileStart);
|
|
187
186
|
}
|
|
188
187
|
|
|
188
|
+
private boolean isErrorUrl(Uri uri) {
|
|
189
|
+
String url = uri.toString();
|
|
190
|
+
return url.equals(bridge.getErrorUrl());
|
|
191
|
+
}
|
|
192
|
+
|
|
189
193
|
private boolean isMainUrl(Uri loadingUrl) {
|
|
190
194
|
return (bridge.getServerUrl() == null && loadingUrl.getHost().equalsIgnoreCase(bridge.getHost()));
|
|
191
195
|
}
|
|
@@ -227,7 +231,7 @@ public class WebViewLocalServer {
|
|
|
227
231
|
);
|
|
228
232
|
}
|
|
229
233
|
|
|
230
|
-
if (isLocalFile(request.getUrl())) {
|
|
234
|
+
if (isLocalFile(request.getUrl()) || isErrorUrl(request.getUrl())) {
|
|
231
235
|
InputStream responseStream = new LollipopLazyInputStream(handler, request);
|
|
232
236
|
String mimeType = getMimeType(request.getUrl().getPath(), responseStream);
|
|
233
237
|
int statusCode = getStatusCode(responseStream, handler.getStatusCode());
|
|
@@ -256,6 +260,12 @@ public class WebViewLocalServer {
|
|
|
256
260
|
InputStream responseStream;
|
|
257
261
|
try {
|
|
258
262
|
String startPath = this.basePath + "/index.html";
|
|
263
|
+
if (bridge.getRouteProcessor() != null) {
|
|
264
|
+
ProcessedRoute processedRoute = bridge.getRouteProcessor().process(this.basePath, "/index.html");
|
|
265
|
+
startPath = processedRoute.getPath();
|
|
266
|
+
isAsset = processedRoute.isAsset();
|
|
267
|
+
}
|
|
268
|
+
|
|
259
269
|
if (isAsset) {
|
|
260
270
|
responseStream = protocolHandler.openAsset(startPath);
|
|
261
271
|
} else {
|
|
@@ -467,13 +477,25 @@ public class WebViewLocalServer {
|
|
|
467
477
|
public InputStream handle(Uri url) {
|
|
468
478
|
InputStream stream = null;
|
|
469
479
|
String path = url.getPath();
|
|
480
|
+
|
|
481
|
+
// Pass path to routeProcessor if present
|
|
482
|
+
RouteProcessor routeProcessor = bridge.getRouteProcessor();
|
|
483
|
+
if (routeProcessor != null) {
|
|
484
|
+
ProcessedRoute processedRoute = bridge.getRouteProcessor().process("", path);
|
|
485
|
+
path = processedRoute.getPath();
|
|
486
|
+
isAsset = processedRoute.isAsset();
|
|
487
|
+
}
|
|
488
|
+
|
|
470
489
|
try {
|
|
471
490
|
if (path.startsWith(capacitorContentStart)) {
|
|
472
491
|
stream = protocolHandler.openContentUrl(url);
|
|
473
|
-
} else if (path.startsWith(capacitorFileStart)
|
|
474
|
-
|
|
492
|
+
} else if (path.startsWith(capacitorFileStart)) {
|
|
493
|
+
stream = protocolHandler.openFile(path);
|
|
494
|
+
} else if (!isAsset) {
|
|
495
|
+
if (routeProcessor == null) {
|
|
475
496
|
path = basePath + url.getPath();
|
|
476
497
|
}
|
|
498
|
+
|
|
477
499
|
stream = protocolHandler.openFile(path);
|
|
478
500
|
} else {
|
|
479
501
|
stream = protocolHandler.openAsset(assetPath + path);
|
|
@@ -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.
|
|
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": "4.0.1
|
|
3
|
+
"version": "4.0.1",
|
|
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)",
|
|
@@ -16,16 +16,17 @@
|
|
|
16
16
|
"capacitor/build.gradle",
|
|
17
17
|
"capacitor/lint-baseline.xml",
|
|
18
18
|
"capacitor/lint.xml",
|
|
19
|
+
"capacitor/proguard-rules.pro",
|
|
19
20
|
"capacitor/src/main/"
|
|
20
21
|
],
|
|
21
22
|
"scripts": {
|
|
22
23
|
"verify": "./gradlew clean lint build test -b capacitor/build.gradle"
|
|
23
24
|
},
|
|
24
25
|
"peerDependencies": {
|
|
25
|
-
"@capacitor/core": "^
|
|
26
|
+
"@capacitor/core": "^4.0.0"
|
|
26
27
|
},
|
|
27
28
|
"publishConfig": {
|
|
28
29
|
"access": "public"
|
|
29
30
|
},
|
|
30
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "a14824b660ccd39b7ed150a26debb15e9a161303"
|
|
31
32
|
}
|
|
@@ -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>
|