From a7877580f2ce01b067258817b550c5d6fa7dac6e Mon Sep 17 00:00:00 2001 From: M3DZIK Date: Tue, 9 Apr 2024 23:04:31 +0200 Subject: [PATCH] Add email field in login cipher --- .../librepass/android/ui/components/CipherCard.kt | 8 ++++++-- .../android/ui/components/CipherEditFields.kt | 10 ++++++++++ .../librepass/android/ui/screens/vault/CipherView.kt | 11 ++++++++++- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/dev/medzik/librepass/android/ui/components/CipherCard.kt b/app/src/main/java/dev/medzik/librepass/android/ui/components/CipherCard.kt index 827509d8..71c30f62 100644 --- a/app/src/main/java/dev/medzik/librepass/android/ui/components/CipherCard.kt +++ b/app/src/main/java/dev/medzik/librepass/android/ui/components/CipherCard.kt @@ -15,7 +15,6 @@ import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.filled.Notes import androidx.compose.material.icons.filled.CreditCard import androidx.compose.material.icons.filled.MoreHoriz -import androidx.compose.material.icons.filled.Notes import androidx.compose.material.icons.filled.Person import androidx.compose.material3.Card import androidx.compose.material3.Icon @@ -101,7 +100,12 @@ fun CipherCard( when (cipher.type) { CipherType.Login -> { title = cipher.loginData!!.name - subtitle = cipher.loginData!!.username + + if (!cipher.loginData!!.email.isNullOrEmpty()) { + subtitle = cipher.loginData!!.email + } else if (!cipher.loginData!!.username.isNullOrEmpty()) { + subtitle = cipher.loginData!!.username + } } CipherType.SecureNote -> { title = cipher.secureNoteData!!.title diff --git a/app/src/main/java/dev/medzik/librepass/android/ui/components/CipherEditFields.kt b/app/src/main/java/dev/medzik/librepass/android/ui/components/CipherEditFields.kt index ad3d57ba..6513c675 100644 --- a/app/src/main/java/dev/medzik/librepass/android/ui/components/CipherEditFields.kt +++ b/app/src/main/java/dev/medzik/librepass/android/ui/components/CipherEditFields.kt @@ -79,6 +79,16 @@ fun CipherEditFieldsLogin( modifier = Modifier.padding(top = 8.dp) ) + TextInputFieldBase( + label = stringResource(R.string.Email), + modifier = + Modifier + .fillMaxWidth() + .padding(vertical = 4.dp), + value = cipherData.email, + onValueChange = { cipherData = cipherData.copy(email = it) } + ) + TextInputFieldBase( label = stringResource(R.string.Username), modifier = diff --git a/app/src/main/java/dev/medzik/librepass/android/ui/screens/vault/CipherView.kt b/app/src/main/java/dev/medzik/librepass/android/ui/screens/vault/CipherView.kt index a5f79e71..874b4eef 100644 --- a/app/src/main/java/dev/medzik/librepass/android/ui/screens/vault/CipherView.kt +++ b/app/src/main/java/dev/medzik/librepass/android/ui/screens/vault/CipherView.kt @@ -113,12 +113,21 @@ fun CipherViewScreen( value = cipherData.name ) - if (!cipherData.username.isNullOrEmpty() || !cipherData.password.isNullOrEmpty()) { + if (!cipherData.email.isNullOrEmpty() || + !cipherData.username.isNullOrEmpty() || + !cipherData.password.isNullOrEmpty() + ) { SecondaryText( stringResource(R.string.LoginDetails), modifier = Modifier.padding(top = 8.dp) ) + CipherField( + title = stringResource(R.string.Email), + value = cipherData.email, + copy = true + ) + CipherField( title = stringResource(R.string.Username), value = cipherData.username,