Allow disabling secure screen when incognito mode is on

This commit is contained in:
arkon 2022-02-05 18:51:08 -05:00
parent 95b253db09
commit 299e52e877
7 changed files with 38 additions and 13 deletions

View file

@ -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()}\"")

View file

@ -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
}

View file

@ -67,4 +67,10 @@ object PreferenceValues {
PACKAGEINSTALLER,
SHIZUKU,
}
enum class SecureScreenMode {
ALWAYS,
INCOGNITO,
NEVER,
}
}

View file

@ -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)

View file

@ -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)

View file

@ -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)
}
}

View file

@ -185,9 +185,9 @@
<item quantity="one">After 1 minute</item>
<item quantity="other">After %1$s minutes</item>
</plurals>
<string name="secure_screen">Secure screen</string>
<string name="secure_screen_summary">Hide app contents when switching apps and block screenshots</string>
<string name="hide_notification_content">Hide notification content</string>
<string name="secure_screen">Secure screen</string>
<string name="secure_screen_summary">Secure screen hides app contents when switching apps and block screenshots</string>
<string name="pref_category_nsfw_content">NSFW (18+) sources</string>
<string name="pref_show_nsfw_source">Show in sources and extensions lists</string>