Skip to content
Permalink
Browse files
feat: add backwards compatibility mode for WebViewAssetLoader (#1222)
  • Loading branch information
NiklasMerz committed May 6, 2021
1 parent f9e8ce8 commit ff1ae2125a9fa0ef12331c2337be5faac5f16189
Showing 2 changed files with 19 additions and 2 deletions.
@@ -46,9 +46,14 @@ public ArrayList<PluginEntry> getPluginEntries() {
}

public String getLaunchUrl() {
if (launchUrl == null) {
if (launchUrl == null) {
launchUrl = "https://" + this.prefs.getString("hostname", "localhost");
}

if (this.prefs.getBoolean("AndroidInsecureFileModeEnabled", false)) {
launchUrl = "file:///android_asset/www/index.html";
}

return launchUrl;
}

@@ -142,7 +147,11 @@ private void setStartUrl(String src) {
if (src.charAt(0) == '/') {
src = src.substring(1);
}
launchUrl = "https://" + this.prefs.getString("hostname", "localhost") + "/" + src;
if (this.prefs.getBoolean("AndroidInsecureFileModeEnabled", false)) {
launchUrl = "file:///android_asset/www/" + src;
} else {
launchUrl = "https://" + this.prefs.getString("hostname", "localhost") + "/" + src;
}
}
}
}
@@ -159,6 +159,14 @@ private void initWebViewSettings() {
settings.setSaveFormData(false);
settings.setSavePassword(false);

if (preferences.getBoolean("AndroidInsecureFileModeEnabled", false)) {
//These settings are deprecated and loading content via file:// URLs is generally discouraged,
//but we allow this for compatibility reasons
LOG.d(TAG, "Enabled insecure file access");
settings.setAllowFileAccess(true);
settings.setAllowUniversalAccessFromFileURLs(true);
}

settings.setMediaPlaybackRequiresUserGesture(false);

// Enable database

0 comments on commit ff1ae21

Please sign in to comment.