From 3dc2f9a711a732f53f6836a40215f293af8a3cb1 Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 7 Jan 2024 16:16:26 -0500 Subject: [PATCH] Add advanced setting to revoke all trusted unknown extensions --- .../eu/kanade/domain/source/interactor/TrustExtension.kt | 4 ++++ .../more/settings/screen/SettingsAdvancedScreen.kt | 9 +++++++++ i18n/src/commonMain/resources/MR/base/strings.xml | 1 + 3 files changed, 14 insertions(+) diff --git a/app/src/main/java/eu/kanade/domain/source/interactor/TrustExtension.kt b/app/src/main/java/eu/kanade/domain/source/interactor/TrustExtension.kt index 1608d6adb4..cd0e022740 100644 --- a/app/src/main/java/eu/kanade/domain/source/interactor/TrustExtension.kt +++ b/app/src/main/java/eu/kanade/domain/source/interactor/TrustExtension.kt @@ -24,4 +24,8 @@ class TrustExtension( } } } + + fun revokeAll() { + preferences.trustedExtensions().delete() + } } diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAdvancedScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAdvancedScreen.kt index 4a486b0b43..9f046480e3 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAdvancedScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAdvancedScreen.kt @@ -24,6 +24,7 @@ import androidx.core.net.toUri import cafe.adriel.voyager.navigator.LocalNavigator import cafe.adriel.voyager.navigator.currentOrThrow import eu.kanade.domain.base.BasePreferences +import eu.kanade.domain.source.interactor.TrustExtension import eu.kanade.presentation.more.settings.Preference import eu.kanade.presentation.more.settings.screen.advanced.ClearDatabaseScreen import eu.kanade.presentation.more.settings.screen.debug.DebugInfoScreen @@ -340,6 +341,7 @@ object SettingsAdvancedScreen : SearchableSettings { val uriHandler = LocalUriHandler.current val extensionInstallerPref = basePreferences.extensionInstaller() var shizukuMissing by rememberSaveable { mutableStateOf(false) } + val trustExtension = remember { Injekt.get() } if (shizukuMissing) { val dismiss = { shizukuMissing = false } @@ -392,6 +394,13 @@ object SettingsAdvancedScreen : SearchableSettings { } }, ), + Preference.PreferenceItem.TextPreference( + title = stringResource(MR.strings.ext_revoke_trust), + onClick = { + trustExtension.revokeAll() + context.toast(MR.strings.requires_app_restart) + }, + ), ), ) } diff --git a/i18n/src/commonMain/resources/MR/base/strings.xml b/i18n/src/commonMain/resources/MR/base/strings.xml index e4b3b04d13..d19e1f5439 100644 --- a/i18n/src/commonMain/resources/MR/base/strings.xml +++ b/i18n/src/commonMain/resources/MR/base/strings.xml @@ -334,6 +334,7 @@ Private Shizuku is not running Install and start Shizuku to use Shizuku as extension installer. + Revoke trusted unknown extensions Extension repos