Generator: add Settings button; vault: lowercase service name; tweak rotate label

This commit is contained in:
Pavel Baksy 2026-03-06 19:00:03 +01:00
parent 9a8187f8c0
commit 7f5271a86b
4 changed files with 50 additions and 8 deletions

View File

@ -80,14 +80,14 @@ class DeterministicViewModel(app: Application) : AndroidViewModel(app) {
} }
} }
fun updateServiceName(name: String) = _state.update { it.copy(serviceName = name) } fun updateServiceName(name: String) = _state.update { it.copy(serviceName = name.lowercase()) }
fun updateMasterPassword(pw: CharArray) = _state.update { it.copy(masterPassword = pw) } fun updateMasterPassword(pw: CharArray) = _state.update { it.copy(masterPassword = pw) }
fun toggleMasterPasswordVisible() = fun toggleMasterPasswordVisible() =
_state.update { it.copy(masterPasswordVisible = !it.masterPasswordVisible) } _state.update { it.copy(masterPasswordVisible = !it.masterPasswordVisible) }
fun selectService(name: String) = _state.update { it.copy(serviceName = name) } fun selectService(name: String) = _state.update { it.copy(serviceName = name.lowercase()) }
fun generate() { fun generate() {
val s = _state.value val s = _state.value

View File

@ -20,7 +20,10 @@ import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.widthIn import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Settings
import androidx.compose.material3.FilledIconButton import androidx.compose.material3.FilledIconButton
import androidx.compose.material3.FilledTonalIconButton
import androidx.compose.material3.Icon import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold import androidx.compose.material3.Scaffold
@ -47,7 +50,7 @@ import cz.bugsy.passwordzebra.R
import cz.bugsy.passwordzebra.ui.components.NumberPickerView import cz.bugsy.passwordzebra.ui.components.NumberPickerView
@Composable @Composable
fun WordGeneratorScreen() { fun WordGeneratorScreen(onNavigateToSettings: () -> Unit) {
var password by rememberSaveable { mutableStateOf("") } var password by rememberSaveable { mutableStateOf("") }
var wordCount by rememberSaveable { mutableIntStateOf(4) } var wordCount by rememberSaveable { mutableIntStateOf(4) }
var withoutSpaces by rememberSaveable { mutableStateOf(false) } var withoutSpaces by rememberSaveable { mutableStateOf(false) }
@ -104,7 +107,26 @@ fun WordGeneratorScreen() {
.weight(1f), .weight(1f),
) )
Spacer(modifier = Modifier.height(12.dp)) Spacer(modifier = Modifier.height(12.dp))
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.Center,
verticalAlignment = Alignment.CenterVertically,
) {
Spacer(modifier = Modifier.size(48.dp))
Spacer(modifier = Modifier.width(20.dp))
GenerateButton(onClick = onGenerate) GenerateButton(onClick = onGenerate)
Spacer(modifier = Modifier.width(20.dp))
FilledTonalIconButton(
onClick = onNavigateToSettings,
modifier = Modifier.size(48.dp),
shape = RoundedCornerShape(16.dp),
) {
Icon(
imageVector = Icons.Default.Settings,
contentDescription = stringResource(R.string.det_settings),
)
}
}
} }
} }
} else { } else {
@ -134,8 +156,28 @@ fun WordGeneratorScreen() {
modifier = Modifier.fillMaxWidth(), modifier = Modifier.fillMaxWidth(),
) )
Spacer(modifier = Modifier.weight(3f)) Spacer(modifier = Modifier.weight(3f))
Row(
modifier = Modifier
.fillMaxWidth()
.padding(start = 16.dp, top = 14.dp, end = 16.dp, bottom = 16.dp),
horizontalArrangement = Arrangement.Center,
verticalAlignment = Alignment.CenterVertically,
) {
Spacer(modifier = Modifier.size(48.dp))
Spacer(modifier = Modifier.width(20.dp))
GenerateButton(onClick = onGenerate) GenerateButton(onClick = onGenerate)
Spacer(modifier = Modifier.height(16.dp)) Spacer(modifier = Modifier.width(20.dp))
FilledTonalIconButton(
onClick = onNavigateToSettings,
modifier = Modifier.size(48.dp),
shape = RoundedCornerShape(16.dp),
) {
Icon(
imageVector = Icons.Default.Settings,
contentDescription = stringResource(R.string.det_settings),
)
}
}
} }
} }
} }

View File

@ -32,7 +32,7 @@
<string name="det_rotate_warning_body">Pro tuto službu bylo vygenerováno nové heslo.\n\nVáš záložní QR kód tuto rotaci nezachycuje. Pokud ztratíte zařízení bez aktualizace QR kódu, TOTO HESLO BUDE TRVALE ZTRACENO — žádným jiným způsobem ho nelze obnovit.\n\nOstatní hesla nejsou dotčena.</string> <string name="det_rotate_warning_body">Pro tuto službu bylo vygenerováno nové heslo.\n\nVáš záložní QR kód tuto rotaci nezachycuje. Pokud ztratíte zařízení bez aktualizace QR kódu, TOTO HESLO BUDE TRVALE ZTRACENO — žádným jiným způsobem ho nelze obnovit.\n\nOstatní hesla nejsou dotčena.</string>
<string name="det_rotate_go_to_export">Aktualizovat QR zálohu nyní</string> <string name="det_rotate_go_to_export">Aktualizovat QR zálohu nyní</string>
<string name="det_rotate_later">Udělám to později (riskantní)</string> <string name="det_rotate_later">Udělám to později (riskantní)</string>
<string name="det_rotate_inline_label">Bylo heslo kompromitováno? Rotovat!</string> <string name="det_rotate_inline_label">Bylo heslo kompromitováno?</string>
<string name="det_rotate_confirm_title">Rotovat heslo?</string> <string name="det_rotate_confirm_title">Rotovat heslo?</string>
<string name="det_rotate_confirm_body">Tato akce zvýší čítač pro tuto službu. Předchozí heslo již nebude generováno.</string> <string name="det_rotate_confirm_body">Tato akce zvýší čítač pro tuto službu. Předchozí heslo již nebude generováno.</string>
<string name="det_rotate_confirm_ok">Rotovat</string> <string name="det_rotate_confirm_ok">Rotovat</string>

View File

@ -31,7 +31,7 @@
<string name="det_rotate_warning_body">A new password has been generated for this service.\n\nYour QR backup no longer reflects this rotation. If you lose this device without updating the QR code, THIS PASSWORD WILL BE PERMANENTLY LOST — it cannot be recovered any other way.\n\nYour other passwords are not affected.</string> <string name="det_rotate_warning_body">A new password has been generated for this service.\n\nYour QR backup no longer reflects this rotation. If you lose this device without updating the QR code, THIS PASSWORD WILL BE PERMANENTLY LOST — it cannot be recovered any other way.\n\nYour other passwords are not affected.</string>
<string name="det_rotate_go_to_export">Update QR Backup Now</string> <string name="det_rotate_go_to_export">Update QR Backup Now</string>
<string name="det_rotate_later">I\'ll do it later (risky)</string> <string name="det_rotate_later">I\'ll do it later (risky)</string>
<string name="det_rotate_inline_label">Password compromised? Rotate!</string> <string name="det_rotate_inline_label">Password compromised?</string>
<string name="det_rotate_confirm_title">Rotate password?</string> <string name="det_rotate_confirm_title">Rotate password?</string>
<string name="det_rotate_confirm_body">This will increment the counter for this service. The previous password will no longer be generated.</string> <string name="det_rotate_confirm_body">This will increment the counter for this service. The previous password will no longer be generated.</string>
<string name="det_rotate_confirm_ok">Rotate</string> <string name="det_rotate_confirm_ok">Rotate</string>