diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 32bc7e402..bac499dd1 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -28,7 +28,7 @@ android { applicationId = "eu.kanade.tachiyomi" minSdk = AndroidConfig.minSdk targetSdk = AndroidConfig.targetSdk - versionCode = 74 + versionCode = 75 versionName = "0.13.1" buildConfigField("String", "COMMIT_COUNT", "\"${getCommitCount()}\"") diff --git a/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt b/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt index b1be977b8..8598b23c1 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt @@ -7,6 +7,7 @@ import eu.kanade.tachiyomi.data.backup.BackupCreatorJob import eu.kanade.tachiyomi.data.library.LibraryUpdateJob import eu.kanade.tachiyomi.data.preference.MANGA_ONGOING import eu.kanade.tachiyomi.data.preference.PreferenceKeys +import eu.kanade.tachiyomi.data.preference.PreferenceValues import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.track.TrackManager import eu.kanade.tachiyomi.data.updater.AppUpdateJob @@ -245,6 +246,12 @@ object Migrations { preferences.libraryUpdateMangaRestriction() -= MANGA_ONGOING } } + if (oldVersion < 75) { + val oldSecureScreen = prefs.getBoolean("secure_screen", false) + if (oldSecureScreen) { + preferences.secureScreen().set(PreferenceValues.SecureScreenMode.ALWAYS) + } + } return true } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceValues.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceValues.kt index 9dd96b5b7..3e5c8d0f1 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceValues.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceValues.kt @@ -67,4 +67,10 @@ object PreferenceValues { PACKAGEINSTALLER, SHIZUKU, } + + enum class SecureScreenMode { + ALWAYS, + INCOGNITO, + NEVER, + } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt index e1861bd10..d45739468 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt @@ -57,7 +57,7 @@ class PreferencesHelper(val context: Context) { fun lastAppUnlock() = flowPrefs.getLong("last_app_unlock", 0) - fun secureScreen() = flowPrefs.getBoolean("secure_screen", false) + fun secureScreen() = flowPrefs.getEnum("secure_screen_v2", Values.SecureScreenMode.INCOGNITO) fun hideNotificationContent() = prefs.getBoolean(Keys.hideNotificationContent, false) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/security/SecureActivityDelegate.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/security/SecureActivityDelegate.kt index 69f8d5004..638de82b8 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/security/SecureActivityDelegate.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/security/SecureActivityDelegate.kt @@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.security import android.content.Intent import androidx.fragment.app.FragmentActivity import androidx.lifecycle.lifecycleScope +import eu.kanade.tachiyomi.data.preference.PreferenceValues import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.util.system.AuthenticatorUtil.isAuthenticationSupported import eu.kanade.tachiyomi.util.view.setSecureScreen @@ -19,8 +20,8 @@ class SecureActivityDelegate(private val activity: FragmentActivity) { fun onCreate() { val secureScreenFlow = preferences.secureScreen().asFlow() val incognitoModeFlow = preferences.incognitoMode().asFlow() - secureScreenFlow.combine(incognitoModeFlow) { secureScreen, incognitoMode -> - secureScreen || incognitoMode + combine(secureScreenFlow, incognitoModeFlow) { secureScreen, incognitoMode -> + secureScreen == PreferenceValues.SecureScreenMode.ALWAYS || secureScreen == PreferenceValues.SecureScreenMode.INCOGNITO && incognitoMode } .onEach { activity.window.setSecureScreen(it) } .launchIn(activity.lifecycleScope) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsSecurityController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsSecurityController.kt index 7a2d7da76..4e74facce 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsSecurityController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsSecurityController.kt @@ -5,11 +5,14 @@ import androidx.fragment.app.FragmentActivity import androidx.preference.Preference import androidx.preference.PreferenceScreen import eu.kanade.tachiyomi.R +import eu.kanade.tachiyomi.data.preference.PreferenceValues import eu.kanade.tachiyomi.util.preference.bindTo import eu.kanade.tachiyomi.util.preference.defaultValue +import eu.kanade.tachiyomi.util.preference.entriesRes +import eu.kanade.tachiyomi.util.preference.infoPreference import eu.kanade.tachiyomi.util.preference.intListPreference +import eu.kanade.tachiyomi.util.preference.listPreference import eu.kanade.tachiyomi.util.preference.requireAuthentication -import eu.kanade.tachiyomi.util.preference.summaryRes import eu.kanade.tachiyomi.util.preference.switchPreference import eu.kanade.tachiyomi.util.preference.titleRes import eu.kanade.tachiyomi.util.system.AuthenticatorUtil @@ -80,16 +83,24 @@ class SettingsSecurityController : SettingsController() { } } - switchPreference { - bindTo(preferences.secureScreen()) - titleRes = R.string.secure_screen - summaryRes = R.string.secure_screen_summary - } - switchPreference { key = Keys.hideNotificationContent titleRes = R.string.hide_notification_content defaultValue = false } + + listPreference { + bindTo(preferences.secureScreen()) + titleRes = R.string.secure_screen + summary = "%s" + entriesRes = arrayOf( + R.string.lock_always, + R.string.pref_incognito_mode, + R.string.lock_never, + ) + entryValues = PreferenceValues.SecureScreenMode.values().map { it.name }.toTypedArray() + } + + infoPreference(R.string.secure_screen_summary) } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 21b622b3e..4ed26f542 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -185,9 +185,9 @@ After 1 minute After %1$s minutes - Secure screen - Hide app contents when switching apps and block screenshots Hide notification content + Secure screen + Secure screen hides app contents when switching apps and block screenshots NSFW (18+) sources Show in sources and extensions lists