mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-07-09 23:44:12 +01:00
Fix minimum length hint on RegV5 PIN creation screen.
This commit is contained in:
committed by
Michelle Tang
parent
91d3fa8ad5
commit
1059fcafba
+10
-7
@@ -22,9 +22,9 @@ import androidx.compose.foundation.text.KeyboardOptions
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.OutlinedButton
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.material3.TextField
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
@@ -319,7 +319,11 @@ private fun PinInputLabel(
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
Text(
|
||||
text = state.inputLabel ?: "",
|
||||
text = when {
|
||||
state.isConfirmEnabled -> stringResource(R.string.PinCreationScreen__reenter_pin)
|
||||
state.isAlphanumericKeyboard -> stringResource(R.string.PinCreationScreen__pin_at_least_4_characters)
|
||||
else -> stringResource(R.string.PinCreationScreen__pin_at_least_4_digits)
|
||||
},
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
textAlign = TextAlign.Center,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
@@ -333,7 +337,7 @@ private fun KeyboardToggleButton(
|
||||
onToggleKeyboard: () -> Unit,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
OutlinedButton(
|
||||
TextButton(
|
||||
onClick = onToggleKeyboard,
|
||||
modifier = modifier.fillMaxWidth()
|
||||
) {
|
||||
@@ -383,11 +387,11 @@ private fun NextButton(
|
||||
|
||||
@AllDevicePreviews
|
||||
@Composable
|
||||
private fun PinCreationScreenPreview() {
|
||||
private fun PinCreationScreenNumericPreview() {
|
||||
Previews.Preview {
|
||||
PinCreationScreen(
|
||||
state = PinCreationState(
|
||||
inputLabel = "PIN must be at least 4 digits"
|
||||
isAlphanumericKeyboard = false
|
||||
),
|
||||
onEvent = {}
|
||||
)
|
||||
@@ -400,8 +404,7 @@ private fun PinCreationScreenAlphanumericPreview() {
|
||||
Previews.Preview {
|
||||
PinCreationScreen(
|
||||
state = PinCreationState(
|
||||
isAlphanumericKeyboard = false,
|
||||
inputLabel = "PIN must be at least 4 characters"
|
||||
isAlphanumericKeyboard = true
|
||||
),
|
||||
onEvent = {}
|
||||
)
|
||||
|
||||
-1
@@ -10,7 +10,6 @@ import org.signal.registration.util.DebugLoggableModel
|
||||
|
||||
data class PinCreationState(
|
||||
val isAlphanumericKeyboard: Boolean = false,
|
||||
val inputLabel: String? = null,
|
||||
val isConfirmEnabled: Boolean = false,
|
||||
val accountEntropyPool: AccountEntropyPool? = null
|
||||
) : DebugLoggableModel()
|
||||
|
||||
+9
-9
@@ -38,16 +38,12 @@ class PinCreationViewModel(
|
||||
private val TAG = Log.tag(PinCreationViewModel::class)
|
||||
}
|
||||
|
||||
private val _state = MutableStateFlow(
|
||||
PinCreationState(
|
||||
inputLabel = "PIN must be at least 4 digits"
|
||||
)
|
||||
)
|
||||
private val _state = MutableStateFlow(PinCreationState())
|
||||
|
||||
val state: StateFlow<PinCreationState> = _state
|
||||
.combine(parentState) { state, parentState -> applyParentState(state, parentState) }
|
||||
.onEach { Log.d(TAG, "[State] $it") }
|
||||
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), PinCreationState(inputLabel = "PIN must be at least 4 digits"))
|
||||
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), PinCreationState())
|
||||
|
||||
override suspend fun processEvent(event: PinCreationScreenEvents) {
|
||||
applyEvent(state.value, event)
|
||||
@@ -61,13 +57,13 @@ class PinCreationViewModel(
|
||||
val result = applyPinSubmitted(state, event.pin)
|
||||
_state.value = result
|
||||
}
|
||||
|
||||
is PinCreationScreenEvents.ToggleKeyboard -> {
|
||||
val newValue = !state.isAlphanumericKeyboard
|
||||
_state.value = state.copy(
|
||||
isAlphanumericKeyboard = newValue,
|
||||
inputLabel = if (newValue) "PIN must be at least 4 digits" else "PIN must be at least 4 characters"
|
||||
isAlphanumericKeyboard = !state.isAlphanumericKeyboard
|
||||
)
|
||||
}
|
||||
|
||||
is PinCreationScreenEvents.LearnMore -> {
|
||||
// TODO [registration] - Show learn more dialog or navigate to help screen
|
||||
throw NotImplementedError("Show learn more dialog or navigate to help screen")
|
||||
@@ -98,6 +94,7 @@ class PinCreationViewModel(
|
||||
parentEventEmitter(RegistrationFlowEvent.RegistrationComplete)
|
||||
state
|
||||
}
|
||||
|
||||
is RequestResult.NonSuccess -> {
|
||||
when (val error = result.error) {
|
||||
is NetworkController.BackupMasterKeyError.EnclaveNotFound -> {
|
||||
@@ -105,6 +102,7 @@ class PinCreationViewModel(
|
||||
// TODO [registration] - Report to UI and indicate to library user that pin could not be created
|
||||
throw NotImplementedError("Report to UI and indicate to library user that pin could not be created")
|
||||
}
|
||||
|
||||
is NetworkController.BackupMasterKeyError.NotRegistered -> {
|
||||
Log.w(TAG, "[PinSubmitted] Account not registered. This should not happen. Resetting.")
|
||||
parentEventEmitter(RegistrationFlowEvent.ResetState)
|
||||
@@ -112,11 +110,13 @@ class PinCreationViewModel(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
is RequestResult.RetryableNetworkError -> {
|
||||
Log.w(TAG, "[PinSubmitted] Network error when backing up master key.", result.networkError)
|
||||
// TODO [registration] - Report to UI and indicate to library user that pin could not be created
|
||||
throw NotImplementedError("Report to UI and indicate to library user that pin could not be created")
|
||||
}
|
||||
|
||||
is RequestResult.ApplicationError -> {
|
||||
Log.w(TAG, "[PinSubmitted] Application error when backing up master key.", result.cause)
|
||||
// TODO [registration] - Report to UI and indicate to library user that pin could not be created
|
||||
|
||||
+1
-1
@@ -341,7 +341,7 @@ private fun KeyboardToggleButton(
|
||||
onToggleKeyboard: () -> Unit,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
OutlinedButton(
|
||||
TextButton(
|
||||
onClick = onToggleKeyboard,
|
||||
modifier = modifier.fillMaxWidth()
|
||||
) {
|
||||
|
||||
@@ -327,6 +327,12 @@
|
||||
<string name="PinCreationScreen__switch_to_alphanumeric">Switch to alphanumeric</string>
|
||||
<!-- Labels the button to submit a new Signal PIN. -->
|
||||
<string name="PinCreationScreen__next">Next</string>
|
||||
<!-- Hint shown below the create PIN field when numeric keyboard is active. -->
|
||||
<string name="PinCreationScreen__pin_at_least_4_digits">PIN must be at least 4 digits</string>
|
||||
<!-- Hint shown below the create PIN field when alphanumeric keyboard is active. -->
|
||||
<string name="PinCreationScreen__pin_at_least_4_characters">PIN must be at least 4 characters</string>
|
||||
<!-- Hint shown below the create PIN field when the user is confirming their new Signal PIN. -->
|
||||
<string name="PinCreationScreen__reenter_pin">Re-enter PIN</string>
|
||||
|
||||
<!-- PIN entry screen title when registration lock is active. -->
|
||||
<string name="PinEntryScreen__registration_lock">Registration Lock</string>
|
||||
|
||||
Reference in New Issue
Block a user