From 984a4a7bf1d08c0d3143ea6d3ea637d7e674f0c2 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Wed, 1 May 2019 16:41:52 -0700 Subject: Add security settings for biometrics --- .../kotlin/com/pitchedapps/frost/settings/Debug.kt | 2 +- .../com/pitchedapps/frost/settings/Experimental.kt | 2 +- .../com/pitchedapps/frost/settings/Security.kt | 45 ++++++++++++++++++++++ 3 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 app/src/main/kotlin/com/pitchedapps/frost/settings/Security.kt (limited to 'app/src/main/kotlin/com/pitchedapps/frost/settings') diff --git a/app/src/main/kotlin/com/pitchedapps/frost/settings/Debug.kt b/app/src/main/kotlin/com/pitchedapps/frost/settings/Debug.kt index e0ae6de5..1ee06464 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Debug.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Debug.kt @@ -52,7 +52,7 @@ import java.io.File */ fun SettingsActivity.getDebugPrefs(): KPrefAdapterBuilder.() -> Unit = { - plainText(R.string.experimental_disclaimer) { + plainText(R.string.disclaimer) { descRes = R.string.debug_disclaimer_info } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/settings/Experimental.kt b/app/src/main/kotlin/com/pitchedapps/frost/settings/Experimental.kt index e0d314a8..41a60594 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Experimental.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Experimental.kt @@ -30,7 +30,7 @@ import com.pitchedapps.frost.utils.Showcase */ fun SettingsActivity.getExperimentalPrefs(): KPrefAdapterBuilder.() -> Unit = { - plainText(R.string.experimental_disclaimer) { + plainText(R.string.disclaimer) { descRes = R.string.experimental_disclaimer_info } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/settings/Security.kt b/app/src/main/kotlin/com/pitchedapps/frost/settings/Security.kt new file mode 100644 index 00000000..afd7c4e1 --- /dev/null +++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Security.kt @@ -0,0 +1,45 @@ +/* + * Copyright 2018 Allan Wang + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.pitchedapps.frost.settings + +import ca.allanwang.kau.kpref.activity.KPrefAdapterBuilder +import com.pitchedapps.frost.R +import com.pitchedapps.frost.activities.SettingsActivity +import com.pitchedapps.frost.utils.BiometricUtils +import com.pitchedapps.frost.utils.Prefs +import kotlinx.coroutines.launch + +/** + * Created by Allan Wang on 20179-05-01. + */ +fun SettingsActivity.getSecurityPrefs(): KPrefAdapterBuilder.() -> Unit = { + + plainText(R.string.disclaimer) { + descRes = R.string.security_disclaimer_info + } + + checkbox(R.string.enable_biometrics, Prefs::biometricsEnabled, { + launch { + BiometricUtils.authenticate(this@getSecurityPrefs, force = true).await() + Prefs.biometricsEnabled = it + reloadByTitle(R.string.enable_biometrics) + } + }) { + descRes = R.string.enable_biometrics_desc + enabler = { BiometricUtils.isSupported(this@getSecurityPrefs) } + } +} -- cgit v1.2.3