Add better colors to be picked

Colors picked are red, orange, yellow, green, sky and purple -100 and -900 from https://tailwindcss.com/docs/customizing-colors#default-color-palette

Signed-off-by: Ariel Costas <arielcostas@mailbox.org>
This commit is contained in:
Ariel Costas 2022-09-03 21:53:01 +02:00
parent a7312e44ee
commit 0e3abd3537
1 changed files with 530 additions and 501 deletions

View File

@ -285,7 +285,22 @@ class SettingsFragment: PreferenceFragmentCompat(), Preference.OnPreferenceChang
"background_colour_id",
ColorSheet.NO_COLOR
),
colors = listOf(Color.BLUE, Color.RED, Color.GREEN).toIntArray(),
colors = listOf(
Color.parseColor("#fee2e2"),
Color.parseColor("#ffedd5"),
Color.parseColor("#fef9c3"),
Color.parseColor("#dcfce7"),
Color.parseColor("#e0f2fe"),
Color.parseColor("#f3e8ff"),
Color.parseColor("#7f1d1d"),
Color.parseColor("#7c2d12"),
Color.parseColor("#713f12"),
Color.parseColor("#14532d"),
Color.parseColor("#0c4a6e"),
Color.parseColor("#581c87"),
).toIntArray(),
noColorOption = true,
listener = {
val editor = sharedPreferences.edit()
@ -386,7 +401,8 @@ class SettingsFragment: PreferenceFragmentCompat(), Preference.OnPreferenceChang
} else {
clientCertPassword.summary = getString(R.string.no_password)
}
clientCertPassword.isVisible = !preferenceManager.sharedPreferences.getBoolean("use_biometrics", false)
clientCertPassword.isVisible =
!preferenceManager.sharedPreferences.getBoolean("use_biometrics", false)
certificateCategory.addPreference(clientCertPassword)
val useBiometrics = SwitchPreferenceCompat(context)
@ -408,7 +424,8 @@ class SettingsFragment: PreferenceFragmentCompat(), Preference.OnPreferenceChang
certificateCategory.addPreference(passwordInitVector)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
useBiometrics.isVisible = (certPassword?.isNotEmpty() ?: false) or useBiometrics.isChecked
useBiometrics.isVisible =
(certPassword?.isNotEmpty() ?: false) or useBiometrics.isChecked
useBiometrics.setOnPreferenceChangeListener { _, newValue ->
val biometricManager = BuranBiometricManager()
@ -419,26 +436,35 @@ class SettingsFragment: PreferenceFragmentCompat(), Preference.OnPreferenceChang
println("Authentication error: $errorCode: $errString")
useBiometrics.isChecked = !(newValue as Boolean)
}
override fun onAuthenticationFailed() {
super.onAuthenticationFailed()
println("Authentication failed")
useBiometrics.isChecked = !(newValue as Boolean)
}
override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) {
super.onAuthenticationSucceeded(result)
println("Authentication succeeded")
if (newValue as Boolean) {
println(certPassword)
val encryptedData = biometricManager.encryptData(certPassword!!, result.cryptoObject?.cipher!!)
val encryptedData = biometricManager.encryptData(
certPassword!!,
result.cryptoObject?.cipher!!
)
val ciphertext = encryptedData.ciphertext
val initializationVector = encryptedData.initializationVector
passwordInitVector.text = initializationVector.contentToString()
passwordCiphertext.text = ciphertext.contentToString()
clientCertPassword.text = null
} else {
val ciphertext = biometricManager.decodeByteArray(passwordCiphertext.text)
clientCertPassword.text = biometricManager.decryptData(ciphertext, result.cryptoObject?.cipher!!)
val ciphertext =
biometricManager.decodeByteArray(passwordCiphertext.text)
clientCertPassword.text = biometricManager.decryptData(
ciphertext,
result.cryptoObject?.cipher!!
)
clientCertPassword.summary = getDots(clientCertPassword.text)
}
clientCertPassword.isVisible = !(newValue as Boolean)
@ -450,7 +476,8 @@ class SettingsFragment: PreferenceFragmentCompat(), Preference.OnPreferenceChang
if (newValue as Boolean) {
biometricManager.authenticateToEncryptData()
} else {
val initializationVector = biometricManager.decodeByteArray(passwordInitVector.text)
val initializationVector =
biometricManager.decodeByteArray(passwordInitVector.text)
biometricManager.authenticateToDecryptData(initializationVector)
}
@ -502,7 +529,8 @@ class SettingsFragment: PreferenceFragmentCompat(), Preference.OnPreferenceChang
private fun persistPermissions(uri: Uri) {
val contentResolver = requireContext().contentResolver
val takeFlags: Int = Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION
val takeFlags: Int =
Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION
contentResolver.takePersistableUriPermission(uri, takeFlags)
}
@ -512,7 +540,8 @@ class SettingsFragment: PreferenceFragmentCompat(), Preference.OnPreferenceChang
if (uri.scheme == "content") {
requireContext().contentResolver.query(uri, null, null, null, null).use { cursor ->
if (cursor != null && cursor.moveToFirst()) {
readableReference = cursor.getString(cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME))
readableReference =
cursor.getString(cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME))
}
}
}