mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
fix: password color #1490
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
KeePassDX(4.0.4)
|
KeePassDX(4.0.4)
|
||||||
* Fix form filled recognition #1572 #1677
|
* Fix form filled recognition #1572 #1677
|
||||||
* Fix device unlock #1682
|
* Fix device unlock #1682
|
||||||
|
* Fix password color #1490
|
||||||
|
|
||||||
KeePassDX(4.0.3)
|
KeePassDX(4.0.3)
|
||||||
* Fix "Save as" in Read Only mode #1666
|
* Fix "Save as" in Read Only mode #1666
|
||||||
|
|||||||
@@ -22,10 +22,12 @@ package com.kunzisoft.keepass.view
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.text.Editable
|
import android.text.Editable
|
||||||
import android.text.InputType
|
import android.text.InputType
|
||||||
|
import android.text.Spannable
|
||||||
import android.text.SpannableString
|
import android.text.SpannableString
|
||||||
import android.text.TextWatcher
|
import android.text.TextWatcher
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
|
import android.widget.EditText
|
||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import com.google.android.material.progressindicator.LinearProgressIndicator
|
import com.google.android.material.progressindicator.LinearProgressIndicator
|
||||||
@@ -43,7 +45,8 @@ class PassKeyView @JvmOverloads constructor(context: Context,
|
|||||||
private var mPasswordEntropyCalculator: PasswordEntropy? = null
|
private var mPasswordEntropyCalculator: PasswordEntropy? = null
|
||||||
|
|
||||||
private val passwordInputLayout: TextInputLayout
|
private val passwordInputLayout: TextInputLayout
|
||||||
private val passwordText: TextView
|
private val passwordText: EditText
|
||||||
|
private var textModified = false
|
||||||
private val passwordStrengthProgress: LinearProgressIndicator
|
private val passwordStrengthProgress: LinearProgressIndicator
|
||||||
private val passwordEntropy: TextView
|
private val passwordEntropy: TextView
|
||||||
|
|
||||||
@@ -51,27 +54,8 @@ class PassKeyView @JvmOverloads constructor(context: Context,
|
|||||||
private var mMaxLines: Int = 3
|
private var mMaxLines: Int = 3
|
||||||
private var mShowPassword: Boolean = false
|
private var mShowPassword: Boolean = false
|
||||||
|
|
||||||
private var mPasswordTextWatcher: MutableList<TextWatcher> = mutableListOf()
|
private var mPasswordTextWatchers: MutableList<TextWatcher> = mutableListOf()
|
||||||
private val passwordTextWatcher = object : TextWatcher {
|
private var mPasswordTextWatcher: TextWatcher? = null
|
||||||
override fun beforeTextChanged(charSequence: CharSequence, i: Int, i1: Int, i2: Int) {
|
|
||||||
mPasswordTextWatcher.forEach {
|
|
||||||
it.beforeTextChanged(charSequence, i, i1, i2)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onTextChanged(charSequence: CharSequence, i: Int, i1: Int, i2: Int) {
|
|
||||||
mPasswordTextWatcher.forEach {
|
|
||||||
it.onTextChanged(charSequence, i, i1, i2)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun afterTextChanged(editable: Editable) {
|
|
||||||
mPasswordTextWatcher.forEach {
|
|
||||||
it.afterTextChanged(editable)
|
|
||||||
}
|
|
||||||
getEntropyStrength(editable.toString())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
context.theme.obtainStyledAttributes(
|
context.theme.obtainStyledAttributes(
|
||||||
@@ -101,7 +85,6 @@ class PassKeyView @JvmOverloads constructor(context: Context,
|
|||||||
}
|
}
|
||||||
passwordText?.maxLines = mMaxLines
|
passwordText?.maxLines = mMaxLines
|
||||||
passwordText?.applyFontVisibility()
|
passwordText?.applyFontVisibility()
|
||||||
passwordText.addTextChangedListener(passwordTextWatcher)
|
|
||||||
passwordStrengthProgress = findViewById(R.id.password_strength_progress)
|
passwordStrengthProgress = findViewById(R.id.password_strength_progress)
|
||||||
passwordStrengthProgress?.apply {
|
passwordStrengthProgress?.apply {
|
||||||
setIndicatorColor(PasswordEntropy.Strength.RISKY.color)
|
setIndicatorColor(PasswordEntropy.Strength.RISKY.color)
|
||||||
@@ -115,6 +98,37 @@ class PassKeyView @JvmOverloads constructor(context: Context,
|
|||||||
getEntropyStrength(firstPassword)
|
getEntropyStrength(firstPassword)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mPasswordTextWatcher = object : TextWatcher {
|
||||||
|
override fun beforeTextChanged(charSequence: CharSequence, i: Int, i1: Int, i2: Int) {
|
||||||
|
mPasswordTextWatchers.forEach {
|
||||||
|
it.beforeTextChanged(charSequence, i, i1, i2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onTextChanged(charSequence: CharSequence, i: Int, i1: Int, i2: Int) {
|
||||||
|
mPasswordTextWatchers.forEach {
|
||||||
|
it.onTextChanged(charSequence, i, i1, i2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun afterTextChanged(editable: Editable) {
|
||||||
|
if (textModified) {
|
||||||
|
textModified = false
|
||||||
|
} else {
|
||||||
|
textModified = true
|
||||||
|
val selectionStart = passwordText.selectionStart
|
||||||
|
val selectionEnd = passwordText.selectionEnd
|
||||||
|
passwordString = editable.toString()
|
||||||
|
passwordText.setSelection(selectionStart, selectionEnd)
|
||||||
|
}
|
||||||
|
mPasswordTextWatchers.forEach {
|
||||||
|
it.afterTextChanged(editable)
|
||||||
|
}
|
||||||
|
getEntropyStrength(editable.toString())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
passwordText?.addTextChangedListener(mPasswordTextWatcher)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getEntropyStrength(passwordText: String) {
|
private fun getEntropyStrength(passwordText: String) {
|
||||||
@@ -134,11 +148,18 @@ class PassKeyView @JvmOverloads constructor(context: Context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun addTextChangedListener(textWatcher: TextWatcher) {
|
fun addTextChangedListener(textWatcher: TextWatcher) {
|
||||||
mPasswordTextWatcher.add(textWatcher)
|
mPasswordTextWatchers.add(textWatcher)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun removeTextChangedListener(textWatcher: TextWatcher) {
|
fun removeTextChangedListener(textWatcher: TextWatcher) {
|
||||||
mPasswordTextWatcher.remove(textWatcher)
|
mPasswordTextWatchers.remove(textWatcher)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun spannableValue(value: String): Spannable {
|
||||||
|
return if (PreferencesUtil.colorizePassword(context))
|
||||||
|
PasswordGenerator.getColorizedPassword(value)
|
||||||
|
else
|
||||||
|
SpannableString(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
var passwordString: String
|
var passwordString: String
|
||||||
@@ -146,11 +167,6 @@ class PassKeyView @JvmOverloads constructor(context: Context,
|
|||||||
return passwordText.text.toString()
|
return passwordText.text.toString()
|
||||||
}
|
}
|
||||||
set(value) {
|
set(value) {
|
||||||
val spannableString =
|
passwordText.setText(spannableValue(value))
|
||||||
if (PreferencesUtil.colorizePassword(context))
|
|
||||||
PasswordGenerator.getColorizedPassword(value)
|
|
||||||
else
|
|
||||||
SpannableString(value)
|
|
||||||
passwordText.text = spannableString
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,2 +1,3 @@
|
|||||||
* Fix form filled recognition #1572 #1677
|
* Fix form filled recognition #1572 #1677
|
||||||
* Fix device unlock #1682
|
* Fix device unlock #1682
|
||||||
|
* Fix password color #1490
|
||||||
@@ -1,2 +1,3 @@
|
|||||||
* Correction de la reconnaissance de formulaire #1572 #1677
|
* Correction de la reconnaissance de formulaire #1572 #1677
|
||||||
* Correction du déblocage de l'appareil #1682
|
* Correction du déblocage de l'appareil #1682
|
||||||
|
* Correction de la couleur de mot de passe #1490
|
||||||
Reference in New Issue
Block a user