Move security settings to separate section
This commit is contained in:
parent
89007923c7
commit
8ae15141f6
@ -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
|
||||
}
|
||||
}
|
||||
}
|
9
app/src/main/res/drawable/ic_security_black_24dp.xml
Normal file
9
app/src/main/res/drawable/ic_security_black_24dp.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M12,1L3,5v6c0,5.55 3.84,10.74 9,12 5.16,-1.26 9,-6.45 9,-12L21,5l-9,-4zM12,11.99h7c-0.53,4.12 -3.28,7.79 -7,8.94L12,12L5,12L5,6.3l7,-3.11v8.8z" />
|
||||
</vector>
|
Loading…
Reference in New Issue
Block a user