|
@@ -25,10 +25,12 @@ import eu.kanade.tachiyomi.data.preference.minusAssign
|
|
|
import eu.kanade.tachiyomi.data.preference.plusAssign
|
|
|
import eu.kanade.tachiyomi.databinding.ExtensionDetailControllerBinding
|
|
|
import eu.kanade.tachiyomi.extension.model.Extension
|
|
|
+import eu.kanade.tachiyomi.network.NetworkHelper
|
|
|
import eu.kanade.tachiyomi.source.CatalogueSource
|
|
|
import eu.kanade.tachiyomi.source.ConfigurableSource
|
|
|
import eu.kanade.tachiyomi.source.Source
|
|
|
import eu.kanade.tachiyomi.source.getPreferenceKey
|
|
|
+import eu.kanade.tachiyomi.source.online.HttpSource
|
|
|
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
|
|
|
import eu.kanade.tachiyomi.ui.base.controller.openInBrowser
|
|
|
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
|
@@ -38,8 +40,10 @@ import eu.kanade.tachiyomi.util.preference.preferenceCategory
|
|
|
import eu.kanade.tachiyomi.util.preference.switchPreference
|
|
|
import eu.kanade.tachiyomi.util.preference.switchSettingsPreference
|
|
|
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
|
|
+import eu.kanade.tachiyomi.util.system.logcat
|
|
|
import kotlinx.coroutines.flow.launchIn
|
|
|
import kotlinx.coroutines.flow.onEach
|
|
|
+import okhttp3.HttpUrl.Companion.toHttpUrl
|
|
|
import uy.kohesive.injekt.injectLazy
|
|
|
|
|
|
@SuppressLint("RestrictedApi")
|
|
@@ -47,6 +51,7 @@ class ExtensionDetailsController(bundle: Bundle? = null) :
|
|
|
NucleusController<ExtensionDetailControllerBinding, ExtensionDetailsPresenter>(bundle) {
|
|
|
|
|
|
private val preferences: PreferencesHelper by injectLazy()
|
|
|
+ private val network: NetworkHelper by injectLazy()
|
|
|
|
|
|
private var preferenceScreen: PreferenceScreen? = null
|
|
|
|
|
@@ -199,6 +204,7 @@ class ExtensionDetailsController(bundle: Bundle? = null) :
|
|
|
R.id.action_history -> openCommitHistory()
|
|
|
R.id.action_enable_all -> toggleAllSources(true)
|
|
|
R.id.action_disable_all -> toggleAllSources(false)
|
|
|
+ R.id.action_clear_cookies -> clearCookies()
|
|
|
}
|
|
|
return super.onOptionsItemSelected(item)
|
|
|
}
|
|
@@ -229,6 +235,19 @@ class ExtensionDetailsController(bundle: Bundle? = null) :
|
|
|
openInBrowser(url)
|
|
|
}
|
|
|
|
|
|
+ private fun clearCookies() {
|
|
|
+ val urls = presenter.extension?.sources
|
|
|
+ ?.filterIsInstance<HttpSource>()
|
|
|
+ ?.map { it.baseUrl }
|
|
|
+ ?.distinct() ?: emptyList()
|
|
|
+
|
|
|
+ urls.forEach {
|
|
|
+ network.cookieManager.remove(it.toHttpUrl())
|
|
|
+ }
|
|
|
+
|
|
|
+ logcat { "Cleared cookies for: ${urls.joinToString()}" }
|
|
|
+ }
|
|
|
+
|
|
|
private fun Source.isEnabled(): Boolean {
|
|
|
return id.toString() !in preferences.disabledSources().get()
|
|
|
}
|