Skip to content

Commit 1359ecb

Browse files
committed
fix:Replace deprecated setAppCacheEnabled with setCacheMode
1 parent 6646396 commit 1359ecb

File tree

2 files changed

+30
-41
lines changed

2 files changed

+30
-41
lines changed

android/src/main/java/com/flutter_webview_plugin/WebviewManager.java

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ public boolean handleResult(int requestCode, int resultCode, Intent intent) {
6868
Uri[] results = null;
6969
if (resultCode == Activity.RESULT_OK) {
7070
if (fileUri != null && getFileSize(fileUri) > 0) {
71-
results = new Uri[]{fileUri};
71+
results = new Uri[] { fileUri };
7272
} else if (videoUri != null && getFileSize(videoUri) > 0) {
73-
results = new Uri[]{videoUri};
73+
results = new Uri[] { videoUri };
7474
} else if (intent != null) {
7575
results = getSelectedFiles(intent);
7676
}
@@ -103,7 +103,7 @@ private Uri[] getSelectedFiles(Intent data) {
103103
if (data.getData() != null) {
104104
String dataString = data.getDataString();
105105
if (dataString != null) {
106-
return new Uri[]{Uri.parse(dataString)};
106+
return new Uri[] { Uri.parse(dataString) };
107107
}
108108
}
109109
// we have multiple files selected
@@ -136,9 +136,9 @@ private Uri[] getSelectedFiles(Intent data) {
136136
webViewClient = new BrowserClient() {
137137
@Override
138138
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
139-
if (ignoreSSLErrors){
139+
if (ignoreSSLErrors) {
140140
handler.proceed();
141-
}else {
141+
} else {
142142
super.onReceivedSslError(view, handler, error);
143143
}
144144
}
@@ -175,8 +175,8 @@ public void onScroll(int x, int y, int oldx, int oldy) {
175175

176176
webView.setWebViewClient(webViewClient);
177177
webView.setWebChromeClient(new WebChromeClient() {
178-
//The undocumented magic method override
179-
//Eclipse will swear at you if you try to put @Override here
178+
// The undocumented magic method override
179+
// Eclipse will swear at you if you try to put @Override here
180180
// For Android 3.0+
181181
public void openFileChooser(ValueCallback<Uri> uploadMsg) {
182182

@@ -199,7 +199,7 @@ public void openFileChooser(ValueCallback uploadMsg, String acceptType) {
199199
FILECHOOSER_RESULTCODE);
200200
}
201201

202-
//For Android 4.1
202+
// For Android 4.1
203203
public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) {
204204
mUploadMessage = uploadMsg;
205205
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
@@ -209,7 +209,7 @@ public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, Str
209209

210210
}
211211

212-
//For Android 5.0+
212+
// For Android 5.0+
213213
public boolean onShowFileChooser(
214214
WebView webView, ValueCallback<Uri[]> filePathCallback,
215215
FileChooserParams fileChooserParams) {
@@ -253,7 +253,6 @@ public boolean onShowFileChooser(
253253
return true;
254254
}
255255

256-
257256
@Override
258257
public void onProgressChanged(WebView view, int progress) {
259258
Map<String, Object> args = new HashMap<>();
@@ -355,7 +354,8 @@ private void clearCache() {
355354
private void registerJavaScriptChannelNames(List<String> channelNames) {
356355
for (String channelName : channelNames) {
357356
webView.addJavascriptInterface(
358-
new JavaScriptChannel(FlutterWebviewPlugin.channel, channelName, platformThreadHandler), channelName);
357+
new JavaScriptChannel(FlutterWebviewPlugin.channel, channelName, platformThreadHandler),
358+
channelName);
359359
}
360360
}
361361

@@ -380,8 +380,7 @@ void openUrl(
380380
String invalidUrlRegex,
381381
boolean geolocationEnabled,
382382
boolean debuggingEnabled,
383-
boolean ignoreSSLErrors
384-
) {
383+
boolean ignoreSSLErrors) {
385384
webView.getSettings().setJavaScriptEnabled(withJavascript);
386385
webView.getSettings().setBuiltInZoomControls(withZoom);
387386
webView.getSettings().setSupportZoom(withZoom);
@@ -392,7 +391,7 @@ void openUrl(
392391

393392
webView.getSettings().setSupportMultipleWindows(supportMultipleWindows);
394393

395-
webView.getSettings().setAppCacheEnabled(appCacheEnabled);
394+
webView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
396395

397396
webView.getSettings().setAllowFileAccessFromFileURLs(allowFileURLs);
398397
webView.getSettings().setAllowUniversalAccessFromFileURLs(allowFileURLs);
@@ -407,7 +406,7 @@ void openUrl(
407406
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
408407
webView.setWebContentsDebuggingEnabled(debuggingEnabled);
409408
}
410-
//ignore SSL errors
409+
// ignore SSL errors
411410
this.ignoreSSLErrors = ignoreSSLErrors;
412411

413412
webViewClient.updateInvalidUrlRegex(invalidUrlRegex);
@@ -533,7 +532,7 @@ boolean canGoForward() {
533532
/**
534533
* Clears cache
535534
*/
536-
void cleanCache(){
535+
void cleanCache() {
537536
webView.clearCache(true);
538537
}
539538

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,25 @@
11
package io.flutter.plugins;
22

3-
// import io.flutter.plugin.common.PluginRegistry;
4-
import androidx.annotation.NonNull;
5-
import io.flutter.embedding.engine.FlutterEngine;
6-
import io.flutter.embedding.engine.plugins.shim.ShimPluginRegistry;
3+
import io.flutter.plugin.common.PluginRegistry;
74
import com.flutter_webview_plugin.FlutterWebviewPlugin;
85

96
/**
107
* Generated file. Do not edit.
118
*/
12-
// public final class GeneratedPluginRegistrant {
13-
// public static void registerWith(PluginRegistry registry) {
14-
// if (alreadyRegisteredWith(registry)) {
15-
// return;
16-
// }
17-
// FlutterWebviewPlugin.registerWith(registry.registrarFor("com.flutter_webview_plugin.FlutterWebviewPlugin"));
18-
// }
19-
20-
// private static boolean alreadyRegisteredWith(PluginRegistry registry) {
21-
// final String key = GeneratedPluginRegistrant.class.getCanonicalName();
22-
// if (registry.hasPlugin(key)) {
23-
// return true;
24-
// }
25-
// registry.registrarFor(key);
26-
// return false;
27-
// }
28-
// }
29-
309
public final class GeneratedPluginRegistrant {
31-
public static void registerWith(@NonNull FlutterEngine flutterEngine) {
32-
ShimPluginRegistry shimPluginRegistry = new ShimPluginRegistry(flutterEngine);
33-
FlutterWebviewPlugin.registerWith(shimPluginRegistry.registrarFor("com.flutter_webview_plugin.FlutterWebviewPlugin"));
10+
public static void registerWith(PluginRegistry registry) {
11+
if (alreadyRegisteredWith(registry)) {
12+
return;
13+
}
14+
FlutterWebviewPlugin.registerWith(registry.registrarFor("com.flutter_webview_plugin.FlutterWebviewPlugin"));
15+
}
16+
17+
private static boolean alreadyRegisteredWith(PluginRegistry registry) {
18+
final String key = GeneratedPluginRegistrant.class.getCanonicalName();
19+
if (registry.hasPlugin(key)) {
20+
return true;
21+
}
22+
registry.registrarFor(key);
23+
return false;
3424
}
3525
}

0 commit comments

Comments
 (0)