Show TOTP in 3-digit grouping #1270

This commit is contained in:
J-Jamet
2022-04-04 13:25:01 +02:00
parent 30a578257d
commit 3f6a6c864a
7 changed files with 15 additions and 7 deletions

View File

@@ -3,7 +3,7 @@ KeePassDX(3.4.0)
* Dynamically save password generator configuration #618 #696
* Add advanced password filters #1052 #448
* Add editable chars fields #539
* Add color for special password chars #454
* Better visualization of passwords #454 #1270
* Passphrase implementation #218
* Fix small bugs #1282

View File

@@ -516,7 +516,7 @@ class NodesAdapter (private val context: Context,
null -> {}
}
holder?.otpToken?.apply {
text = otpElement?.token
text = otpElement?.tokenString
setTextSize(mTextSizeUnit, mOtpTokenTextDefaultDimension, mPrefSizeMultiplier)
}
holder?.otpContainer?.setOnClickListener {

View File

@@ -178,6 +178,14 @@ data class OtpElement(var otpModel: OtpModel = OtpModel()) {
}
}
/**
* Token with space each 3 digits
*/
val tokenString: String
get() {
return token.replace("...".toRegex(), "$0 ")
}
val secondsRemaining: Int
get() = otpModel.period - (System.currentTimeMillis() / 1000 % otpModel.period).toInt()

View File

@@ -165,7 +165,7 @@ class TemplateView @JvmOverloads constructor(context: Context,
setCopyButtonState(TextFieldView.ButtonState.GONE)
} else {
label = otpElement.type.name
value = otpElement.token
value = otpElement.tokenString
setCopyButtonState(TextFieldView.ButtonState.ACTIVATE)
setCopyButtonClickListener { _, _ ->
mOnCopyActionClickListener?.invoke(Field(
@@ -175,7 +175,7 @@ class TemplateView @JvmOverloads constructor(context: Context,
mLastOtpTokenView = this
mOtpRunnable = Runnable {
if (otpElement.shouldRefreshToken()) {
value = otpElement.token
value = otpElement.tokenString
}
if (mLastOtpTokenView == null) {
mOnOtpElementUpdated?.invoke(null)

View File

@@ -144,7 +144,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
tools:text="5136" />
tools:text="513 651" />
<FrameLayout
android:layout_width="wrap_content"

View File

@@ -2,6 +2,6 @@
* Dynamically save password generator configuration #618 #696
* Add advanced password filters #1052 #448
* Add editable chars fields #539
* Add color for special password chars #454
* Better visualization of passwords #454 #1270
* Passphrase implementation #218
* Fix small bugs #1282

View File

@@ -2,6 +2,6 @@
* Sauvegarde dynamique de la configuration du générateur de mots de passe #618 #696
* Ajout des filtres de mots de passe avancés #1052 #448
* Ajout de champs éditable de génération #539
* Ajout des couleurs pour chaque caractère spécial de mots de passe #454
* Meilleure visualisation des mots de passe #454 #1270
* Phrases secrètes #218
* Correction de petits bugs #1282