@capacitor/android 7.0.0-alpha.2 → 7.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/capacitor/build.gradle +4 -4
- package/capacitor/src/main/java/com/getcapacitor/Bridge.java +16 -0
- package/capacitor/src/main/java/com/getcapacitor/CapConfig.java +18 -1
- package/package.json +2 -2
- package/capacitor/src/main/java/com/getcapacitor/BridgeFragment.java +0 -133
- package/capacitor/src/main/res/layout/fragment_bridge.xml +0 -13
- package/capacitor/src/main/res/values/attrs.xml +0 -6
package/capacitor/build.gradle
CHANGED
|
@@ -13,7 +13,7 @@ ext {
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
buildscript {
|
|
16
|
-
ext.kotlin_version = project.hasProperty("kotlin_version") ? rootProject.ext.kotlin_version : '1.9.
|
|
16
|
+
ext.kotlin_version = project.hasProperty("kotlin_version") ? rootProject.ext.kotlin_version : '1.9.25'
|
|
17
17
|
repositories {
|
|
18
18
|
google()
|
|
19
19
|
mavenCentral()
|
|
@@ -22,7 +22,7 @@ buildscript {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
dependencies {
|
|
25
|
-
classpath 'com.android.tools.build:gradle:8.7.
|
|
25
|
+
classpath 'com.android.tools.build:gradle:8.7.2'
|
|
26
26
|
|
|
27
27
|
if (System.getenv("CAP_PUBLISH") == "true") {
|
|
28
28
|
classpath 'io.github.gradle-nexus:publish-plugin:1.3.0'
|
|
@@ -64,8 +64,8 @@ android {
|
|
|
64
64
|
lintConfig file('lint.xml')
|
|
65
65
|
}
|
|
66
66
|
compileOptions {
|
|
67
|
-
sourceCompatibility JavaVersion.
|
|
68
|
-
targetCompatibility JavaVersion.
|
|
67
|
+
sourceCompatibility JavaVersion.VERSION_21
|
|
68
|
+
targetCompatibility JavaVersion.VERSION_21
|
|
69
69
|
}
|
|
70
70
|
publishing {
|
|
71
71
|
singleVariant("release")
|
|
@@ -15,7 +15,11 @@ import android.os.Build;
|
|
|
15
15
|
import android.os.Bundle;
|
|
16
16
|
import android.os.Handler;
|
|
17
17
|
import android.os.HandlerThread;
|
|
18
|
+
import android.webkit.ServiceWorkerClient;
|
|
19
|
+
import android.webkit.ServiceWorkerController;
|
|
18
20
|
import android.webkit.ValueCallback;
|
|
21
|
+
import android.webkit.WebResourceRequest;
|
|
22
|
+
import android.webkit.WebResourceResponse;
|
|
19
23
|
import android.webkit.WebSettings;
|
|
20
24
|
import android.webkit.WebView;
|
|
21
25
|
import androidx.activity.result.ActivityResultCallback;
|
|
@@ -274,6 +278,18 @@ public class Bridge {
|
|
|
274
278
|
webView.setWebChromeClient(new BridgeWebChromeClient(this));
|
|
275
279
|
webView.setWebViewClient(this.webViewClient);
|
|
276
280
|
|
|
281
|
+
if (Build.VERSION.SDK_INT >= 24 && config.isResolveServiceWorkerRequests()) {
|
|
282
|
+
ServiceWorkerController swController = ServiceWorkerController.getInstance();
|
|
283
|
+
swController.setServiceWorkerClient(
|
|
284
|
+
new ServiceWorkerClient() {
|
|
285
|
+
@Override
|
|
286
|
+
public WebResourceResponse shouldInterceptRequest(WebResourceRequest request) {
|
|
287
|
+
return getLocalServer().shouldInterceptRequest(request);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
|
|
277
293
|
if (!isDeployDisabled() && !isNewBinary()) {
|
|
278
294
|
SharedPreferences prefs = getContext()
|
|
279
295
|
.getSharedPreferences(com.getcapacitor.plugin.WebView.WEBVIEW_PREFS_NAME, Activity.MODE_PRIVATE);
|
|
@@ -53,6 +53,7 @@ public class CapConfig {
|
|
|
53
53
|
private int minHuaweiWebViewVersion = DEFAULT_HUAWEI_WEBVIEW_VERSION;
|
|
54
54
|
private String errorPath;
|
|
55
55
|
private boolean zoomableWebView = false;
|
|
56
|
+
private boolean resolveServiceWorkerRequests = true;
|
|
56
57
|
|
|
57
58
|
// Embedded
|
|
58
59
|
private String startPath;
|
|
@@ -179,6 +180,7 @@ public class CapConfig {
|
|
|
179
180
|
this.minHuaweiWebViewVersion = builder.minHuaweiWebViewVersion;
|
|
180
181
|
this.errorPath = builder.errorPath;
|
|
181
182
|
this.zoomableWebView = builder.zoomableWebView;
|
|
183
|
+
this.resolveServiceWorkerRequests = builder.resolveServiceWorkerRequests;
|
|
182
184
|
|
|
183
185
|
// Embedded
|
|
184
186
|
this.startPath = builder.startPath;
|
|
@@ -282,6 +284,7 @@ public class CapConfig {
|
|
|
282
284
|
useLegacyBridge = JSONUtils.getBoolean(configJSON, "android.useLegacyBridge", useLegacyBridge);
|
|
283
285
|
webContentsDebuggingEnabled = JSONUtils.getBoolean(configJSON, "android.webContentsDebuggingEnabled", isDebug);
|
|
284
286
|
zoomableWebView = JSONUtils.getBoolean(configJSON, "android.zoomEnabled", JSONUtils.getBoolean(configJSON, "zoomEnabled", false));
|
|
287
|
+
resolveServiceWorkerRequests = JSONUtils.getBoolean(configJSON, "android.resolveServiceWorkerRequests", true);
|
|
285
288
|
|
|
286
289
|
String logBehavior = JSONUtils.getString(
|
|
287
290
|
configJSON,
|
|
@@ -299,7 +302,11 @@ public class CapConfig {
|
|
|
299
302
|
loggingEnabled = isDebug;
|
|
300
303
|
}
|
|
301
304
|
|
|
302
|
-
initialFocus = JSONUtils.getBoolean(
|
|
305
|
+
initialFocus = JSONUtils.getBoolean(
|
|
306
|
+
configJSON,
|
|
307
|
+
"android.initialFocus",
|
|
308
|
+
JSONUtils.getBoolean(configJSON, "initialFocus", initialFocus)
|
|
309
|
+
);
|
|
303
310
|
|
|
304
311
|
// Plugins
|
|
305
312
|
pluginsConfiguration = deserializePluginsConfig(JSONUtils.getObject(configJSON, "plugins"));
|
|
@@ -370,6 +377,10 @@ public class CapConfig {
|
|
|
370
377
|
return captureInput;
|
|
371
378
|
}
|
|
372
379
|
|
|
380
|
+
public boolean isResolveServiceWorkerRequests() {
|
|
381
|
+
return resolveServiceWorkerRequests;
|
|
382
|
+
}
|
|
383
|
+
|
|
373
384
|
public boolean isWebContentsDebuggingEnabled() {
|
|
374
385
|
return webContentsDebuggingEnabled;
|
|
375
386
|
}
|
|
@@ -569,6 +580,7 @@ public class CapConfig {
|
|
|
569
580
|
private int minWebViewVersion = DEFAULT_ANDROID_WEBVIEW_VERSION;
|
|
570
581
|
private int minHuaweiWebViewVersion = DEFAULT_HUAWEI_WEBVIEW_VERSION;
|
|
571
582
|
private boolean zoomableWebView = false;
|
|
583
|
+
private boolean resolveServiceWorkerRequests = true;
|
|
572
584
|
|
|
573
585
|
// Embedded
|
|
574
586
|
private String startPath = null;
|
|
@@ -668,6 +680,11 @@ public class CapConfig {
|
|
|
668
680
|
return this;
|
|
669
681
|
}
|
|
670
682
|
|
|
683
|
+
public Builder setResolveServiceWorkerRequests(boolean resolveServiceWorkerRequests) {
|
|
684
|
+
this.resolveServiceWorkerRequests = resolveServiceWorkerRequests;
|
|
685
|
+
return this;
|
|
686
|
+
}
|
|
687
|
+
|
|
671
688
|
public Builder setWebContentsDebuggingEnabled(boolean webContentsDebuggingEnabled) {
|
|
672
689
|
this.webContentsDebuggingEnabled = webContentsDebuggingEnabled;
|
|
673
690
|
return this;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capacitor/android",
|
|
3
|
-
"version": "7.0.0-
|
|
3
|
+
"version": "7.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)",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"verify": "./gradlew clean lint build test -b capacitor/build.gradle"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"@capacitor/core": "^7.0.0-
|
|
26
|
+
"@capacitor/core": "^7.0.0-beta.0"
|
|
27
27
|
},
|
|
28
28
|
"publishConfig": {
|
|
29
29
|
"access": "public"
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
package com.getcapacitor;
|
|
2
|
-
|
|
3
|
-
import android.content.Context;
|
|
4
|
-
import android.content.res.TypedArray;
|
|
5
|
-
import android.os.Bundle;
|
|
6
|
-
import android.util.AttributeSet;
|
|
7
|
-
import android.view.LayoutInflater;
|
|
8
|
-
import android.view.View;
|
|
9
|
-
import android.view.ViewGroup;
|
|
10
|
-
import androidx.fragment.app.Fragment;
|
|
11
|
-
import com.getcapacitor.android.R;
|
|
12
|
-
import java.util.ArrayList;
|
|
13
|
-
import java.util.List;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* A simple {@link Fragment} subclass.
|
|
17
|
-
* Use the {@link BridgeFragment#newInstance} factory method to
|
|
18
|
-
* create an instance of this fragment.
|
|
19
|
-
*/
|
|
20
|
-
public class BridgeFragment extends Fragment {
|
|
21
|
-
|
|
22
|
-
private static final String ARG_START_DIR = "startDir";
|
|
23
|
-
|
|
24
|
-
protected Bridge bridge;
|
|
25
|
-
protected boolean keepRunning = true;
|
|
26
|
-
|
|
27
|
-
private final List<Class<? extends Plugin>> initialPlugins = new ArrayList<>();
|
|
28
|
-
private CapConfig config = null;
|
|
29
|
-
|
|
30
|
-
private final List<WebViewListener> webViewListeners = new ArrayList<>();
|
|
31
|
-
|
|
32
|
-
public BridgeFragment() {
|
|
33
|
-
// Required empty public constructor
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Use this factory method to create a new instance of
|
|
38
|
-
* this fragment using the provided parameters.
|
|
39
|
-
*
|
|
40
|
-
* @param startDir the directory to serve content from
|
|
41
|
-
* @return A new instance of fragment BridgeFragment.
|
|
42
|
-
*/
|
|
43
|
-
public static BridgeFragment newInstance(String startDir) {
|
|
44
|
-
BridgeFragment fragment = new BridgeFragment();
|
|
45
|
-
Bundle args = new Bundle();
|
|
46
|
-
args.putString(ARG_START_DIR, startDir);
|
|
47
|
-
fragment.setArguments(args);
|
|
48
|
-
return fragment;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
public void addPlugin(Class<? extends Plugin> plugin) {
|
|
52
|
-
this.initialPlugins.add(plugin);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
public void setConfig(CapConfig config) {
|
|
56
|
-
this.config = config;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
public Bridge getBridge() {
|
|
60
|
-
return bridge;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
public void addWebViewListener(WebViewListener webViewListener) {
|
|
64
|
-
webViewListeners.add(webViewListener);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Load the WebView and create the Bridge
|
|
69
|
-
*/
|
|
70
|
-
protected void load(Bundle savedInstanceState) {
|
|
71
|
-
Logger.debug("Loading Bridge with BridgeFragment");
|
|
72
|
-
|
|
73
|
-
Bundle args = getArguments();
|
|
74
|
-
String startDir = null;
|
|
75
|
-
|
|
76
|
-
if (args != null) {
|
|
77
|
-
startDir = getArguments().getString(ARG_START_DIR);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
bridge = new Bridge.Builder(this)
|
|
81
|
-
.setInstanceState(savedInstanceState)
|
|
82
|
-
.setPlugins(initialPlugins)
|
|
83
|
-
.setConfig(config)
|
|
84
|
-
.addWebViewListeners(webViewListeners)
|
|
85
|
-
.create();
|
|
86
|
-
|
|
87
|
-
if (startDir != null) {
|
|
88
|
-
bridge.setServerAssetPath(startDir);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
this.keepRunning = bridge.shouldKeepRunning();
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
@Override
|
|
95
|
-
public void onInflate(Context context, AttributeSet attrs, Bundle savedInstanceState) {
|
|
96
|
-
super.onInflate(context, attrs, savedInstanceState);
|
|
97
|
-
|
|
98
|
-
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.bridge_fragment);
|
|
99
|
-
CharSequence c = a.getString(R.styleable.bridge_fragment_start_dir);
|
|
100
|
-
|
|
101
|
-
if (c != null) {
|
|
102
|
-
String startDir = c.toString();
|
|
103
|
-
Bundle args = new Bundle();
|
|
104
|
-
args.putString(ARG_START_DIR, startDir);
|
|
105
|
-
setArguments(args);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
@Override
|
|
110
|
-
public void onCreate(Bundle savedInstanceState) {
|
|
111
|
-
super.onCreate(savedInstanceState);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
@Override
|
|
115
|
-
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
|
116
|
-
// Inflate the layout for this fragment
|
|
117
|
-
return inflater.inflate(R.layout.fragment_bridge, container, false);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
@Override
|
|
121
|
-
public void onViewCreated(View view, Bundle savedInstanceState) {
|
|
122
|
-
super.onViewCreated(view, savedInstanceState);
|
|
123
|
-
this.load(savedInstanceState);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
@Override
|
|
127
|
-
public void onDestroy() {
|
|
128
|
-
super.onDestroy();
|
|
129
|
-
if (this.bridge != null) {
|
|
130
|
-
this.bridge.onDestroy();
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
2
|
-
xmlns:tools="http://schemas.android.com/tools"
|
|
3
|
-
android:layout_width="match_parent"
|
|
4
|
-
android:layout_height="match_parent"
|
|
5
|
-
android:background="#F0FF1414"
|
|
6
|
-
tools:context="com.getcapacitor.BridgeFragment">
|
|
7
|
-
|
|
8
|
-
<com.getcapacitor.CapacitorWebView
|
|
9
|
-
android:id="@+id/webview"
|
|
10
|
-
android:layout_width="fill_parent"
|
|
11
|
-
android:layout_height="fill_parent" />
|
|
12
|
-
|
|
13
|
-
</FrameLayout>
|