mirror of
https://github.com/mihonapp/mihon.git
synced 2025-06-25 10:37:51 +02:00
Move security settings to separate section
This commit is contained in:
@ -3,7 +3,6 @@ package eu.kanade.tachiyomi.ui.setting
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.provider.Settings
|
||||
import androidx.biometric.BiometricManager
|
||||
import androidx.preference.PreferenceScreen
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
|
||||
@ -17,8 +16,6 @@ import eu.kanade.tachiyomi.util.preference.onChange
|
||||
import eu.kanade.tachiyomi.util.preference.onClick
|
||||
import eu.kanade.tachiyomi.util.preference.preference
|
||||
import eu.kanade.tachiyomi.util.preference.preferenceCategory
|
||||
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.LocaleHelper
|
||||
|
||||
@ -144,47 +141,5 @@ class SettingsGeneralController : SettingsController() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
preferenceCategory {
|
||||
titleRes = R.string.pref_category_security
|
||||
|
||||
if (BiometricManager.from(context).canAuthenticate() == BiometricManager.BIOMETRIC_SUCCESS) {
|
||||
switchPreference {
|
||||
key = Keys.useBiometricLock
|
||||
titleRes = R.string.lock_with_biometrics
|
||||
defaultValue = false
|
||||
}
|
||||
intListPreference {
|
||||
key = Keys.lockAppAfter
|
||||
titleRes = R.string.lock_when_idle
|
||||
val values = arrayOf("0", "1", "2", "5", "10", "-1")
|
||||
entries = values.mapNotNull {
|
||||
when (it) {
|
||||
"-1" -> context.getString(R.string.lock_never)
|
||||
"0" -> context.getString(R.string.lock_always)
|
||||
else -> resources?.getQuantityString(R.plurals.lock_after_mins, it.toInt(), it)
|
||||
}
|
||||
}.toTypedArray()
|
||||
entryValues = values
|
||||
defaultValue = "0"
|
||||
summary = "%s"
|
||||
|
||||
preferences.useBiometricLock().asObservable()
|
||||
.subscribeUntilDestroy { isVisible = it }
|
||||
}
|
||||
}
|
||||
|
||||
switchPreference {
|
||||
key = Keys.secureScreen
|
||||
titleRes = R.string.secure_screen
|
||||
summaryRes = R.string.secure_screen_summary
|
||||
defaultValue = false
|
||||
}
|
||||
switchPreference {
|
||||
key = Keys.hideNotificationContent
|
||||
titleRes = R.string.hide_notification_content
|
||||
defaultValue = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -53,6 +53,12 @@ class SettingsMainController : SettingsController() {
|
||||
titleRes = R.string.backup
|
||||
onClick { navigateTo(SettingsBackupController()) }
|
||||
}
|
||||
preference {
|
||||
iconRes = R.drawable.ic_security_black_24dp
|
||||
iconTint = tintColor
|
||||
titleRes = R.string.pref_category_security
|
||||
onClick { navigateTo(SettingsSecurityController()) }
|
||||
}
|
||||
preference {
|
||||
iconRes = R.drawable.ic_code_black_24dp
|
||||
iconTint = tintColor
|
||||
|
@ -0,0 +1,56 @@
|
||||
package eu.kanade.tachiyomi.ui.setting
|
||||
|
||||
import androidx.biometric.BiometricManager
|
||||
import androidx.preference.PreferenceScreen
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
|
||||
import eu.kanade.tachiyomi.util.preference.defaultValue
|
||||
import eu.kanade.tachiyomi.util.preference.intListPreference
|
||||
import eu.kanade.tachiyomi.util.preference.summaryRes
|
||||
import eu.kanade.tachiyomi.util.preference.switchPreference
|
||||
import eu.kanade.tachiyomi.util.preference.titleRes
|
||||
|
||||
class SettingsSecurityController : SettingsController() {
|
||||
|
||||
override fun setupPreferenceScreen(screen: PreferenceScreen) = with(screen) {
|
||||
titleRes = R.string.pref_category_security
|
||||
|
||||
if (BiometricManager.from(context).canAuthenticate() == BiometricManager.BIOMETRIC_SUCCESS) {
|
||||
switchPreference {
|
||||
key = Keys.useBiometricLock
|
||||
titleRes = R.string.lock_with_biometrics
|
||||
defaultValue = false
|
||||
}
|
||||
intListPreference {
|
||||
key = Keys.lockAppAfter
|
||||
titleRes = R.string.lock_when_idle
|
||||
val values = arrayOf("0", "1", "2", "5", "10", "-1")
|
||||
entries = values.mapNotNull {
|
||||
when (it) {
|
||||
"-1" -> context.getString(R.string.lock_never)
|
||||
"0" -> context.getString(R.string.lock_always)
|
||||
else -> resources?.getQuantityString(R.plurals.lock_after_mins, it.toInt(), it)
|
||||
}
|
||||
}.toTypedArray()
|
||||
entryValues = values
|
||||
defaultValue = "0"
|
||||
summary = "%s"
|
||||
|
||||
preferences.useBiometricLock().asObservable()
|
||||
.subscribeUntilDestroy { isVisible = it }
|
||||
}
|
||||
}
|
||||
|
||||
switchPreference {
|
||||
key = Keys.secureScreen
|
||||
titleRes = R.string.secure_screen
|
||||
summaryRes = R.string.secure_screen_summary
|
||||
defaultValue = false
|
||||
}
|
||||
switchPreference {
|
||||
key = Keys.hideNotificationContent
|
||||
titleRes = R.string.hide_notification_content
|
||||
defaultValue = false
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user