Skip to content

Commit

Permalink
fix:Replace deprecated setAppCacheEnabled with setCacheMode
Browse files Browse the repository at this point in the history
  • Loading branch information
hardy716 committed May 18, 2023
1 parent 6646396 commit 1359ecb
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ public boolean handleResult(int requestCode, int resultCode, Intent intent) {
Uri[] results = null;
if (resultCode == Activity.RESULT_OK) {
if (fileUri != null && getFileSize(fileUri) > 0) {
results = new Uri[]{fileUri};
results = new Uri[] { fileUri };
} else if (videoUri != null && getFileSize(videoUri) > 0) {
results = new Uri[]{videoUri};
results = new Uri[] { videoUri };
} else if (intent != null) {
results = getSelectedFiles(intent);
}
Expand Down Expand Up @@ -103,7 +103,7 @@ private Uri[] getSelectedFiles(Intent data) {
if (data.getData() != null) {
String dataString = data.getDataString();
if (dataString != null) {
return new Uri[]{Uri.parse(dataString)};
return new Uri[] { Uri.parse(dataString) };
}
}
// we have multiple files selected
Expand Down Expand Up @@ -136,9 +136,9 @@ private Uri[] getSelectedFiles(Intent data) {
webViewClient = new BrowserClient() {
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
if (ignoreSSLErrors){
if (ignoreSSLErrors) {
handler.proceed();
}else {
} else {
super.onReceivedSslError(view, handler, error);
}
}
Expand Down Expand Up @@ -175,8 +175,8 @@ public void onScroll(int x, int y, int oldx, int oldy) {

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

Expand All @@ -199,7 +199,7 @@ public void openFileChooser(ValueCallback uploadMsg, String acceptType) {
FILECHOOSER_RESULTCODE);
}

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

}

//For Android 5.0+
// For Android 5.0+
public boolean onShowFileChooser(
WebView webView, ValueCallback<Uri[]> filePathCallback,
FileChooserParams fileChooserParams) {
Expand Down Expand Up @@ -253,7 +253,6 @@ public boolean onShowFileChooser(
return true;
}


@Override
public void onProgressChanged(WebView view, int progress) {
Map<String, Object> args = new HashMap<>();
Expand Down Expand Up @@ -355,7 +354,8 @@ private void clearCache() {
private void registerJavaScriptChannelNames(List<String> channelNames) {
for (String channelName : channelNames) {
webView.addJavascriptInterface(
new JavaScriptChannel(FlutterWebviewPlugin.channel, channelName, platformThreadHandler), channelName);
new JavaScriptChannel(FlutterWebviewPlugin.channel, channelName, platformThreadHandler),
channelName);
}
}

Expand All @@ -380,8 +380,7 @@ void openUrl(
String invalidUrlRegex,
boolean geolocationEnabled,
boolean debuggingEnabled,
boolean ignoreSSLErrors
) {
boolean ignoreSSLErrors) {
webView.getSettings().setJavaScriptEnabled(withJavascript);
webView.getSettings().setBuiltInZoomControls(withZoom);
webView.getSettings().setSupportZoom(withZoom);
Expand All @@ -392,7 +391,7 @@ void openUrl(

webView.getSettings().setSupportMultipleWindows(supportMultipleWindows);

webView.getSettings().setAppCacheEnabled(appCacheEnabled);
webView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);

webView.getSettings().setAllowFileAccessFromFileURLs(allowFileURLs);
webView.getSettings().setAllowUniversalAccessFromFileURLs(allowFileURLs);
Expand All @@ -407,7 +406,7 @@ void openUrl(
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
webView.setWebContentsDebuggingEnabled(debuggingEnabled);
}
//ignore SSL errors
// ignore SSL errors
this.ignoreSSLErrors = ignoreSSLErrors;

webViewClient.updateInvalidUrlRegex(invalidUrlRegex);
Expand Down Expand Up @@ -533,7 +532,7 @@ boolean canGoForward() {
/**
* Clears cache
*/
void cleanCache(){
void cleanCache() {
webView.clearCache(true);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,25 @@
package io.flutter.plugins;

// import io.flutter.plugin.common.PluginRegistry;
import androidx.annotation.NonNull;
import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.embedding.engine.plugins.shim.ShimPluginRegistry;
import io.flutter.plugin.common.PluginRegistry;
import com.flutter_webview_plugin.FlutterWebviewPlugin;

/**
* Generated file. Do not edit.
*/
// public final class GeneratedPluginRegistrant {
// public static void registerWith(PluginRegistry registry) {
// if (alreadyRegisteredWith(registry)) {
// return;
// }
// FlutterWebviewPlugin.registerWith(registry.registrarFor("com.flutter_webview_plugin.FlutterWebviewPlugin"));
// }

// private static boolean alreadyRegisteredWith(PluginRegistry registry) {
// final String key = GeneratedPluginRegistrant.class.getCanonicalName();
// if (registry.hasPlugin(key)) {
// return true;
// }
// registry.registrarFor(key);
// return false;
// }
// }

public final class GeneratedPluginRegistrant {
public static void registerWith(@NonNull FlutterEngine flutterEngine) {
ShimPluginRegistry shimPluginRegistry = new ShimPluginRegistry(flutterEngine);
FlutterWebviewPlugin.registerWith(shimPluginRegistry.registrarFor("com.flutter_webview_plugin.FlutterWebviewPlugin"));
public static void registerWith(PluginRegistry registry) {
if (alreadyRegisteredWith(registry)) {
return;
}
FlutterWebviewPlugin.registerWith(registry.registrarFor("com.flutter_webview_plugin.FlutterWebviewPlugin"));
}

private static boolean alreadyRegisteredWith(PluginRegistry registry) {
final String key = GeneratedPluginRegistrant.class.getCanonicalName();
if (registry.hasPlugin(key)) {
return true;
}
registry.registrarFor(key);
return false;
}
}

0 comments on commit 1359ecb

Please sign in to comment.