Fix password dialog message

This commit is contained in:
Rafał Kobyłko 2023-11-26 16:41:49 +01:00
parent c91683515d
commit 20692f7293
16 changed files with 88 additions and 30 deletions

View File

@ -3,16 +3,15 @@ package com.twofasapp.designsystem.dialog
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.IntrinsicSize
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.sizeIn
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.text.ClickableText
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
@ -49,6 +48,7 @@ fun BaseDialog(
bodyAnnotated: AnnotatedString? = null,
positive: String? = null,
negative: String? = null,
onBodyClick: ((Int) -> Unit)? = null,
onPositiveClick: (() -> Unit)? = null,
onNegativeClick: (() -> Unit)? = null,
positiveEnabled: Boolean = true,
@ -90,6 +90,7 @@ fun BaseDialog(
Body(
text = body,
textAnnotated = bodyAnnotated,
onBodyClick = onBodyClick,
)
}
@ -138,6 +139,7 @@ private fun Title(
private fun ColumnScope.Body(
text: String?,
textAnnotated: AnnotatedString?,
onBodyClick: ((Int) -> Unit)? = null,
) {
if (text != null) {
Text(
@ -151,14 +153,15 @@ private fun ColumnScope.Body(
)
} else if (textAnnotated != null) {
Text(
ClickableText(
text = textAnnotated,
style = MaterialTheme.typography.bodyMedium,
color = TwTheme.color.onSurfaceTertiary,
onClick = { onBodyClick?.invoke(it) },
style = MaterialTheme.typography.bodyMedium.copy(color = TwTheme.color.onSurfaceTertiary),
modifier = Modifier
.padding(horizontal = DialogPadding)
.padding(TitlePadding)
)
.padding(TitlePadding),
)
}
}

View File

@ -14,6 +14,7 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.DialogProperties
@ -26,10 +27,12 @@ fun PasswordDialog(
onDismissRequest: () -> Unit,
title: String? = null,
body: String? = null,
bodyAnnotated: AnnotatedString? = null,
error: String? = null,
enabled: Boolean = true,
positive: String? = TwLocale.strings.commonSave,
negative: String? = TwLocale.strings.commonCancel,
onBodyClick: ((Int) -> Unit)? = null,
onPositive: ((String) -> Unit)? = null,
onNegative: (() -> Unit)? = null,
validation: ((String) -> Boolean)? = null,
@ -57,8 +60,10 @@ fun PasswordDialog(
onDismissRequest = onDismissRequest,
title = title,
body = body,
bodyAnnotated = bodyAnnotated,
positive = positive,
negative = negative,
onBodyClick = onBodyClick,
onPositiveClick = { onPositive?.invoke(password.trim()) },
onNegativeClick = onNegative,
positiveEnabled = positiveEnabledState,

View File

@ -317,7 +317,8 @@ class Strings(c: Context) {
val backupRemoveCloudPasswordTitle = c.getString(R.string.backup__enter_password_dialog_title)
val backupRemoveCloudPasswordMsg = c.getString(R.string.backup__remove_password_msg)
val backupEnterCloudPasswordTitle = c.getString(R.string.backup__enter_password_dialog_title)
val backupEnterCloudPasswordMsg = c.getString(R.string.backup__enter_password_title)
val backupEnterCloudPasswordMsg1 = c.getString(R.string.backup__enter_password_google_drive_msg1)
val backupEnterCloudPasswordMsg2 = c.getString(R.string.backup__enter_password_google_drive_msg2)
val backupIncorrectPassword = c.getString(R.string.backup__incorrect_password)
val backupExportShareCta = c.getString(R.string.export_backup_share_cta)

View File

@ -5,7 +5,7 @@
Release: Working copy
Locale: de-DE, German (Germany)
Exported by: rafakob
Exported at: Sat, 25 Nov 2023 08:22:33 -0800
Exported at: Sun, 26 Nov 2023 03:22:29 -0800
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- InfoPlist.strings
@ -817,4 +817,6 @@
<!-- "**...**" means thar part between those asterisks will be in bold. -->
<string name="introduction__backup_icloud_description">2FAS uses iCloud for secure backup and sync of your 2FA tokens. The **encrypted** backup data is stored in iCloud, accessible **only by the 2FAS app**. Additionally, this feature aids with token **recovery and syncing** across iOS devices.\n\nIt\'s enabled by default and can disabled at any time in the app\'s backup settings.</string>
<string name="introduction__backup_icloud_cta">Learn more about backup</string>
<string name="backup__enter_password_google_drive_msg1">It looks like your Google Drive backup file is password-protected. Type in the correct password to proceed. If youd like to wipe your Google Drive backup file,</string>
<string name="backup__enter_password_google_drive_msg2">tap here to see how</string>
</resources>

View File

@ -5,7 +5,7 @@
Release: Working copy
Locale: es-ES, Spanish (Spain)
Exported by: rafakob
Exported at: Sat, 25 Nov 2023 08:22:33 -0800
Exported at: Sun, 26 Nov 2023 03:22:29 -0800
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- InfoPlist.strings
@ -817,4 +817,6 @@
<!-- "**...**" means thar part between those asterisks will be in bold. -->
<string name="introduction__backup_icloud_description">2FAS uses iCloud for secure backup and sync of your 2FA tokens. The **encrypted** backup data is stored in iCloud, accessible **only by the 2FAS app**. Additionally, this feature aids with token **recovery and syncing** across iOS devices.\n\nIt\'s enabled by default and can disabled at any time in the app\'s backup settings.</string>
<string name="introduction__backup_icloud_cta">Learn more about backup</string>
<string name="backup__enter_password_google_drive_msg1">It looks like your Google Drive backup file is password-protected. Type in the correct password to proceed. If youd like to wipe your Google Drive backup file,</string>
<string name="backup__enter_password_google_drive_msg2">tap here to see how</string>
</resources>

View File

@ -5,7 +5,7 @@
Release: Working copy
Locale: fr-FR, French (France)
Exported by: rafakob
Exported at: Sat, 25 Nov 2023 08:22:33 -0800
Exported at: Sun, 26 Nov 2023 03:22:29 -0800
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- InfoPlist.strings
@ -817,4 +817,6 @@
<!-- "**...**" means thar part between those asterisks will be in bold. -->
<string name="introduction__backup_icloud_description">2FAS uses iCloud for secure backup and sync of your 2FA tokens. The **encrypted** backup data is stored in iCloud, accessible **only by the 2FAS app**. Additionally, this feature aids with token **recovery and syncing** across iOS devices.\n\nIt\'s enabled by default and can disabled at any time in the app\'s backup settings.</string>
<string name="introduction__backup_icloud_cta">Learn more about backup</string>
<string name="backup__enter_password_google_drive_msg1">It looks like your Google Drive backup file is password-protected. Type in the correct password to proceed. If youd like to wipe your Google Drive backup file,</string>
<string name="backup__enter_password_google_drive_msg2">tap here to see how</string>
</resources>

View File

@ -5,7 +5,7 @@
Release: Working copy
Locale: id-ID, Indonesian (Indonesia)
Exported by: rafakob
Exported at: Sat, 25 Nov 2023 08:22:33 -0800
Exported at: Sun, 26 Nov 2023 03:22:29 -0800
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- InfoPlist.strings
@ -802,13 +802,15 @@
<string name="externalimport__andotp_success_msg">File JSON ini mengizinkan pengimporan token dari andOTP.</string>
<string name="externalimport__info_andotp_title">Impor token dari andOTP</string>
<string name="externalimport__andotp_msg">Ekspor akun anda dari andOTP ke file JSON yang tidak terenkripsi dan unggah menggunakan tombol \"Pilih file JSON\". Ingatlah untuk menghapus file setelah impor berhasil.</string>
<string name="introduction__backup_description">In the next step, you\'ll be asked to choose your Google Drive account, where the 2FA tokens will be stored safely.</string>
<string name="introduction__backup_take_risk_cta">I\'ll take the risk, no backup</string>
<string name="introduction__backup_success">Google Drive sync turned on successfully!</string>
<string name="backup__import_invalid_version">The backup file you\'re attempting to import is not supported in this application version. The application only supports backup format versions up to %d, while the file you\'re importing is version %d.</string>
<string name="commons__pair">Pair</string>
<string name="introduction__backup_icloud_title">Secure sync and backup</string>
<string name="introduction__backup_description">Pada langkah selanjutnya, anda akan diminta untuk memilih akun Google Drive anda, tempat token 2FA akan disimpan dengan aman.</string>
<string name="introduction__backup_take_risk_cta">Saya akan mengambil risiko, tidak ada cadangan</string>
<string name="introduction__backup_success">Sinkronisasi Google Drive berhasil diaktifkan!</string>
<string name="backup__import_invalid_version">File cadangan yang anda coba impor tidak didukung dalam versi aplikasi ini. Aplikasi hanya mendukung versi format cadangan hingga %d, sedangkan file yang anda impor adalah versi %d.</string>
<string name="commons__pair">Pasangkan</string>
<string name="introduction__backup_icloud_title">Sinkronisasi dan pencadangan yang aman</string>
<!-- "**...**" means thar part between those asterisks will be in bold. -->
<string name="introduction__backup_icloud_description">2FAS uses iCloud for secure backup and sync of your 2FA tokens. The **encrypted** backup data is stored in iCloud, accessible **only by the 2FAS app**. Additionally, this feature aids with token **recovery and syncing** across iOS devices.\n\nIt\'s enabled by default and can disabled at any time in the app\'s backup settings.</string>
<string name="introduction__backup_icloud_cta">Learn more about backup</string>
<string name="introduction__backup_icloud_description">2FAS menggunakan iCloud untuk pencadangan aman dan sinkronisasi token 2FA anda. Data cadangan **terenkripsi** disimpan di iCloud, dapat diakses **hanya melalui aplikasi 2FAS**. Selain itu, fitur ini membantu **pemulihan dan sinkronisasi** token di seluruh perangkat iOS. Ini diaktifkan secara default dan dapat dinonaktifkan kapan saja di pengaturan cadangan aplikasi.</string>
<string name="introduction__backup_icloud_cta">Pelajari lebih lanjut tentang pencadangan</string>
<string name="backup__enter_password_google_drive_msg1">It looks like your Google Drive backup file is password-protected. Type in the correct password to proceed. If youd like to wipe your Google Drive backup file,</string>
<string name="backup__enter_password_google_drive_msg2">tap here to see how</string>
</resources>

View File

@ -5,7 +5,7 @@
Release: Working copy
Locale: it-IT, Italian (Italy)
Exported by: rafakob
Exported at: Sat, 25 Nov 2023 08:22:33 -0800
Exported at: Sun, 26 Nov 2023 03:22:29 -0800
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- InfoPlist.strings
@ -817,4 +817,6 @@
<!-- "**...**" means thar part between those asterisks will be in bold. -->
<string name="introduction__backup_icloud_description">2FAS uses iCloud for secure backup and sync of your 2FA tokens. The **encrypted** backup data is stored in iCloud, accessible **only by the 2FAS app**. Additionally, this feature aids with token **recovery and syncing** across iOS devices.\n\nIt\'s enabled by default and can disabled at any time in the app\'s backup settings.</string>
<string name="introduction__backup_icloud_cta">Learn more about backup</string>
<string name="backup__enter_password_google_drive_msg1">It looks like your Google Drive backup file is password-protected. Type in the correct password to proceed. If youd like to wipe your Google Drive backup file,</string>
<string name="backup__enter_password_google_drive_msg2">tap here to see how</string>
</resources>

View File

@ -5,7 +5,7 @@
Release: Working copy
Locale: nl-NL, Dutch (Netherlands)
Exported by: rafakob
Exported at: Sat, 25 Nov 2023 08:22:33 -0800
Exported at: Sun, 26 Nov 2023 03:22:30 -0800
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- InfoPlist.strings
@ -817,4 +817,6 @@
<!-- "**...**" means thar part between those asterisks will be in bold. -->
<string name="introduction__backup_icloud_description">2FAS uses iCloud for secure backup and sync of your 2FA tokens. The **encrypted** backup data is stored in iCloud, accessible **only by the 2FAS app**. Additionally, this feature aids with token **recovery and syncing** across iOS devices.\n\nIt\'s enabled by default and can disabled at any time in the app\'s backup settings.</string>
<string name="introduction__backup_icloud_cta">Learn more about backup</string>
<string name="backup__enter_password_google_drive_msg1">It looks like your Google Drive backup file is password-protected. Type in the correct password to proceed. If youd like to wipe your Google Drive backup file,</string>
<string name="backup__enter_password_google_drive_msg2">tap here to see how</string>
</resources>

View File

@ -5,7 +5,7 @@
Release: Working copy
Locale: pl-PL, Polish (Poland)
Exported by: rafakob
Exported at: Sat, 25 Nov 2023 08:22:33 -0800
Exported at: Sun, 26 Nov 2023 03:22:29 -0800
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- InfoPlist.strings
@ -823,4 +823,6 @@
<!-- "**...**" means thar part between those asterisks will be in bold. -->
<string name="introduction__backup_icloud_description">2FAS uses iCloud for secure backup and sync of your 2FA tokens. The **encrypted** backup data is stored in iCloud, accessible **only by the 2FAS app**. Additionally, this feature aids with token **recovery and syncing** across iOS devices.\n\nIt\'s enabled by default and can disabled at any time in the app\'s backup settings.</string>
<string name="introduction__backup_icloud_cta">Learn more about backup</string>
<string name="backup__enter_password_google_drive_msg1">It looks like your Google Drive backup file is password-protected. Type in the correct password to proceed. If youd like to wipe your Google Drive backup file,</string>
<string name="backup__enter_password_google_drive_msg2">tap here to see how</string>
</resources>

View File

@ -5,7 +5,7 @@
Release: Working copy
Locale: pt-BR, Brazilian Portuguese
Exported by: rafakob
Exported at: Sat, 25 Nov 2023 08:22:33 -0800
Exported at: Sun, 26 Nov 2023 03:22:29 -0800
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- InfoPlist.strings
@ -817,4 +817,6 @@
<!-- "**...**" means thar part between those asterisks will be in bold. -->
<string name="introduction__backup_icloud_description">\"**2Fas**\" usa o icloud para backup seguro</string>
<string name="introduction__backup_icloud_cta">Leia mais sobre a cópia de segurança\u0020</string>
<string name="backup__enter_password_google_drive_msg1">It looks like your Google Drive backup file is password-protected. Type in the correct password to proceed. If youd like to wipe your Google Drive backup file,</string>
<string name="backup__enter_password_google_drive_msg2">tap here to see how</string>
</resources>

View File

@ -5,7 +5,7 @@
Release: Working copy
Locale: pt-PT, Portuguese (Portugal)
Exported by: rafakob
Exported at: Sat, 25 Nov 2023 08:22:33 -0800
Exported at: Sun, 26 Nov 2023 03:22:29 -0800
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- InfoPlist.strings
@ -817,4 +817,6 @@
<!-- "**...**" means thar part between those asterisks will be in bold. -->
<string name="introduction__backup_icloud_description">2FAS uses iCloud for secure backup and sync of your 2FA tokens. The **encrypted** backup data is stored in iCloud, accessible **only by the 2FAS app**. Additionally, this feature aids with token **recovery and syncing** across iOS devices.\n\nIt\'s enabled by default and can disabled at any time in the app\'s backup settings.</string>
<string name="introduction__backup_icloud_cta">Learn more about backup</string>
<string name="backup__enter_password_google_drive_msg1">It looks like your Google Drive backup file is password-protected. Type in the correct password to proceed. If youd like to wipe your Google Drive backup file,</string>
<string name="backup__enter_password_google_drive_msg2">tap here to see how</string>
</resources>

View File

@ -5,7 +5,7 @@
Release: Working copy
Locale: tr-TR, Turkish (Turkey)
Exported by: rafakob
Exported at: Sat, 25 Nov 2023 08:22:33 -0800
Exported at: Sun, 26 Nov 2023 03:22:30 -0800
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- InfoPlist.strings
@ -817,4 +817,6 @@
<!-- "**...**" means thar part between those asterisks will be in bold. -->
<string name="introduction__backup_icloud_description">2FAS uses iCloud for secure backup and sync of your 2FA tokens. The **encrypted** backup data is stored in iCloud, accessible **only by the 2FAS app**. Additionally, this feature aids with token **recovery and syncing** across iOS devices.\n\nIt\'s enabled by default and can disabled at any time in the app\'s backup settings.</string>
<string name="introduction__backup_icloud_cta">Learn more about backup</string>
<string name="backup__enter_password_google_drive_msg1">It looks like your Google Drive backup file is password-protected. Type in the correct password to proceed. If youd like to wipe your Google Drive backup file,</string>
<string name="backup__enter_password_google_drive_msg2">tap here to see how</string>
</resources>

View File

@ -5,7 +5,7 @@
Release: Working copy
Locale: uk-UA, Ukrainian (Ukraine)
Exported by: rafakob
Exported at: Sat, 25 Nov 2023 08:22:33 -0800
Exported at: Sun, 26 Nov 2023 03:22:29 -0800
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- InfoPlist.strings
@ -823,4 +823,6 @@
<!-- "**...**" means thar part between those asterisks will be in bold. -->
<string name="introduction__backup_icloud_description">2FAS використовує iCloud для безпечного резервного копіювання та синхронізації ваших 2FA токенів. *Зашифровані* дані резервної копії зберігаються в iCloud, доступні *тільки за допомогою програми 2FAS*. Крім того, ця функція допомагає *відновлювати та синхронізувати* токени на пристроях iOS.\\n\\nЇЇ увімкнено за умовчанням і можна будь-коли вимкнути в налаштуваннях резервного копіювання програми.</string>
<string name="introduction__backup_icloud_cta">Дізнайтеся більше про резервне копіювання</string>
<string name="backup__enter_password_google_drive_msg1">It looks like your Google Drive backup file is password-protected. Type in the correct password to proceed. If youd like to wipe your Google Drive backup file,</string>
<string name="backup__enter_password_google_drive_msg2">tap here to see how</string>
</resources>

View File

@ -5,7 +5,7 @@
Release: Working copy
Locale: en, English
Exported by: rafakob
Exported at: Sat, 25 Nov 2023 08:22:33 -0800
Exported at: Sun, 26 Nov 2023 03:22:29 -0800
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- InfoPlist.strings
@ -817,4 +817,6 @@
<!-- "**...**" means thar part between those asterisks will be in bold. -->
<string name="introduction__backup_icloud_description">2FAS uses iCloud for secure backup and sync of your 2FA tokens. The **encrypted** backup data is stored in iCloud, accessible **only by the 2FAS app**. Additionally, this feature aids with token **recovery and syncing** across iOS devices.\n\nIt\'s enabled by default and can disabled at any time in the app\'s backup settings.</string>
<string name="introduction__backup_icloud_cta">Learn more about backup</string>
<string name="backup__enter_password_google_drive_msg1">It looks like your Google Drive backup file is password-protected. Type in the correct password to proceed. If youd like to wipe your Google Drive backup file,</string>
<string name="backup__enter_password_google_drive_msg2">tap here to see how</string>
</resources>

View File

@ -20,13 +20,16 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalUriHandler
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.withStyle
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.DialogProperties
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.twofasapp.data.services.domain.CloudSyncError
import com.twofasapp.data.services.domain.CloudSyncStatus
import com.twofasapp.designsystem.TwIcons
import com.twofasapp.designsystem.TwTheme
import com.twofasapp.designsystem.common.TwSwitch
@ -34,6 +37,7 @@ import com.twofasapp.designsystem.common.TwTopAppBar
import com.twofasapp.designsystem.dialog.InfoDialog
import com.twofasapp.designsystem.dialog.PasswordDialog
import com.twofasapp.designsystem.ktx.currentActivity
import com.twofasapp.designsystem.ktx.openSafely
import com.twofasapp.designsystem.ktx.strings
import com.twofasapp.designsystem.ktx.toastLong
import com.twofasapp.designsystem.settings.SettingsDivider
@ -81,6 +85,7 @@ private fun ScreenContent(
) {
val context = LocalContext.currentActivity
val strings = LocalContext.strings
val uriHandler = LocalUriHandler.current
var showPasswordDialog by remember { mutableStateOf(false) }
var showPasswordError by remember { mutableStateOf(false) }
var showErrorDialog by remember { mutableStateOf(false) }
@ -239,6 +244,20 @@ private fun ScreenContent(
}
if (showPasswordDialog) {
val passText = buildAnnotatedString {
append("${strings.backupEnterCloudPasswordMsg1} ")
pushStringAnnotation(
tag = "link",
annotation = "https://2fas.com/support/2fas-mobile-app/how-to-wipe-remove-a-google-drive-backup-file/"
)
withStyle(style = SpanStyle(TwTheme.color.primary)) {
append(strings.backupEnterCloudPasswordMsg2)
}
pop()
append(".")
}
PasswordDialog(
onDismissRequest = {
showPasswordDialog = false
@ -246,7 +265,13 @@ private fun ScreenContent(
},
confirmRequired = false,
title = strings.backupEnterCloudPasswordTitle,
body = strings.backupEnterCloudPasswordMsg,
bodyAnnotated = passText,
onBodyClick = { offset ->
passText.getStringAnnotations(tag = "link", start = offset, end = offset).firstOrNull()?.let {
uriHandler.openSafely(it.item)
showPasswordDialog = false
}
},
error = if (showPasswordError) strings.backupIncorrectPassword else null,
positive = strings.commonContinue,
onPositive = { onEnterPassword(it) },