mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
Add advanced setting to clear WebView data
Co-Authored-By: arkon <4098258+arkon@users.noreply.github.com>
This commit is contained in:
parent
cb09718f21
commit
8955855d3e
2 changed files with 30 additions and 1 deletions
|
@ -53,6 +53,10 @@ import uy.kohesive.injekt.Injekt
|
|||
import uy.kohesive.injekt.api.get
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
|
||||
import android.webkit.WebStorage
|
||||
import android.webkit.WebView
|
||||
import eu.kanade.tachiyomi.util.system.setDefaultSettings
|
||||
import timber.log.Timber
|
||||
|
||||
class SettingsAdvancedController : SettingsController() {
|
||||
|
||||
|
@ -212,6 +216,12 @@ class SettingsAdvancedController : SettingsController() {
|
|||
ctrl.showDialog(router)
|
||||
}
|
||||
}
|
||||
preference {
|
||||
key = "pref_clear_webview_data"
|
||||
titleRes = R.string.pref_clear_webview_data
|
||||
|
||||
onClick { clearWebViewData() }
|
||||
}
|
||||
preference {
|
||||
key = "clear_database"
|
||||
titleRes = R.string.clear_database
|
||||
|
@ -407,6 +417,23 @@ class SettingsAdvancedController : SettingsController() {
|
|||
)
|
||||
}
|
||||
|
||||
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) {
|
||||
Timber.e(e)
|
||||
activity?.toast(R.string.cache_delete_error)
|
||||
}
|
||||
}
|
||||
|
||||
private companion object {
|
||||
const val CLEAR_CACHE_KEY = "pref_clear_cache_key"
|
||||
|
||||
|
|
|
@ -789,9 +789,11 @@
|
|||
<item quantity="one">Cache cleared. %d file has been deleted</item>
|
||||
<item quantity="other">Cache cleared. %d files have been deleted</item>
|
||||
</plurals>
|
||||
<string name="cache_delete_error">An error occurred while clearing cache</string>
|
||||
<string name="cache_delete_error">Error occurred while clearing</string>
|
||||
<string name="clear_cookies">Clear cookies</string>
|
||||
<string name="cookies_cleared">Cookies cleared</string>
|
||||
<string name="pref_clear_webview_data">Clear WebView data</string>
|
||||
<string name="webview_data_deleted">WebView data cleared</string>
|
||||
<string name="clear_database">Clear database</string>
|
||||
<string name="clear_database_source_item_count">%1$d non-library manga in database</string>
|
||||
<string name="clear_database_summary">Delete manga and chapters that are not in your library</string>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue