diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt
index b8097f5d61..5d01b61ef3 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt
@@ -4,6 +4,8 @@ import android.annotation.SuppressLint
import android.content.ActivityNotFoundException
import android.content.Intent
import android.provider.Settings
+import android.webkit.WebStorage
+import android.webkit.WebView
import androidx.core.net.toUri
import androidx.preference.PreferenceScreen
import com.google.android.material.dialog.MaterialAlertDialogBuilder
@@ -39,8 +41,11 @@ import eu.kanade.tachiyomi.util.preference.switchPreference
import eu.kanade.tachiyomi.util.preference.titleRes
import eu.kanade.tachiyomi.util.system.DeviceUtil
import eu.kanade.tachiyomi.util.system.isPackageInstalled
+import eu.kanade.tachiyomi.util.system.logcat
import eu.kanade.tachiyomi.util.system.powerManager
+import eu.kanade.tachiyomi.util.system.setDefaultSettings
import eu.kanade.tachiyomi.util.system.toast
+import logcat.LogPriority
import rikka.sui.Sui
import uy.kohesive.injekt.injectLazy
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
@@ -139,6 +144,12 @@ class SettingsAdvancedController : SettingsController() {
titleRes = R.string.pref_auto_clear_chapter_cache
defaultValue = false
}
+ preference {
+ key = "pref_clear_webview_data"
+ titleRes = R.string.pref_clear_webview_data
+
+ onClick { clearWebViewData() }
+ }
preference {
key = "pref_clear_database"
titleRes = R.string.pref_clear_database
@@ -275,10 +286,28 @@ class SettingsAdvancedController : SettingsController() {
resources?.getString(R.string.used_cache, chapterCache.readableSize)
}
} catch (e: Throwable) {
+ logcat(LogPriority.ERROR, e)
withUIContext { activity?.toast(R.string.cache_delete_error) }
}
}
}
+
+ private fun clearWebViewData() {
+ if (activity == null) return
+ try {
+ val webview = WebView(activity!!)
+ webview.setDefaultSettings()
+ webview.clearCache(true)
+ webview.clearFormData()
+ webview.clearHistory()
+ webview.clearSslPreferences()
+ WebStorage.getInstance().deleteAllData()
+ activity?.toast(R.string.webview_data_deleted)
+ } catch (e: Throwable) {
+ logcat(LogPriority.ERROR, e)
+ activity?.toast(R.string.cache_delete_error)
+ }
+ }
}
private const val CLEAR_CACHE_KEY = "pref_clear_cache_key"
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 8346aee7a8..a3e5132861 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -469,7 +469,7 @@
Clear chapter cache
Used: %1$s
Cache cleared. %1$d files have been deleted
- An error occurred while clearing cache
+ Error occurred while clearing
Clear chapter cache on app close
Clear database
Delete history for manga that are not saved in your library
@@ -477,6 +477,8 @@
Are you sure? Read chapters and progress of non-library manga will be lost
Entries deleted
Database clean
+ Clear WebView data
+ WebView data cleared
Refresh library manga covers
Refresh tracking
Updates status, score and last chapter read from the tracking services