mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 12:05:22 +00:00
Extract strings
This commit is contained in:
parent
ca0206409c
commit
4cac496edf
@ -105,7 +105,7 @@ class LinkDeviceActivity : BaseActionBarActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
supportActionBar?.title = "Load Account"
|
||||
supportActionBar?.setTitle(R.string.activity_link_load_account)
|
||||
prefs.setHasViewedSeed(true)
|
||||
prefs.setConfigurationMessageSynced(false)
|
||||
prefs.setRestorationTime(System.currentTimeMillis())
|
||||
@ -186,12 +186,12 @@ class LinkDeviceActivity : BaseActionBarActivity() {
|
||||
.padding(horizontal = 60.dp)
|
||||
) {
|
||||
Text(
|
||||
"Camera Permission permanently denied. Configure in settings.",
|
||||
stringResource(R.string.activity_link_camera_permission_permanently_denied_configure_in_settings),
|
||||
textAlign = TextAlign.Center
|
||||
)
|
||||
Spacer(modifier = Modifier.size(20.dp))
|
||||
OutlineButton(
|
||||
text = "Settings",
|
||||
text = stringResource(R.string.activity_link_settings),
|
||||
modifier = Modifier.align(Alignment.CenterHorizontally)
|
||||
) {
|
||||
Intent(ACTION_APPLICATION_DETAILS_SETTINGS).apply {
|
||||
@ -201,7 +201,7 @@ class LinkDeviceActivity : BaseActionBarActivity() {
|
||||
}
|
||||
} else {
|
||||
OutlineButton(
|
||||
text = "Grant Camera Permission",
|
||||
text = stringResource(R.string.activity_link_grant_camera_permission),
|
||||
modifier = Modifier.align(Alignment.Center)
|
||||
) {
|
||||
cameraPermissionState.run { launchPermissionRequest() }
|
||||
@ -218,8 +218,7 @@ class LinkDeviceActivity : BaseActionBarActivity() {
|
||||
errors.collect { error ->
|
||||
lifecycleScope.launch {
|
||||
scaffoldState.snackbarHostState.showSnackbar(
|
||||
message = error,
|
||||
actionLabel = "Dismiss"
|
||||
message = error
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -269,20 +268,20 @@ fun RecoveryPassword(state: LinkDeviceState, onChange: (String) -> Unit = {}, on
|
||||
) {
|
||||
Spacer(Modifier.weight(1f))
|
||||
Row {
|
||||
Text("Recovery Password", style = MaterialTheme.typography.h4)
|
||||
Text(stringResource(R.string.activity_link_recovery_password), style = MaterialTheme.typography.h4)
|
||||
Spacer(Modifier.width(6.dp))
|
||||
Icon(
|
||||
painter = painterResource(id = R.drawable.ic_recovery_phrase),
|
||||
contentDescription = "",
|
||||
contentDescription = null,
|
||||
)
|
||||
}
|
||||
Spacer(Modifier.size(28.dp))
|
||||
Text("Enter your recovery password to load your account. If you haven't saved it, you can find it in your app settings.")
|
||||
Text(stringResource(R.string.activity_link_enter_your_recovery_password_to_load_your_account_if_you_haven_t_saved_it_you_can_find_it_in_your_app_settings))
|
||||
Spacer(Modifier.size(24.dp))
|
||||
OutlinedTextField(
|
||||
value = state.recoveryPhrase,
|
||||
onValueChange = { onChange(it) },
|
||||
placeholder = { Text("Enter your recovery password") },
|
||||
placeholder = { Text(stringResource(R.string.activity_link_enter_your_recovery_password)) },
|
||||
colors = TextFieldDefaults.outlinedTextFieldColors(
|
||||
textColor = state.error?.let { colorDestructive } ?: LocalContentColor.current.copy(LocalContentAlpha.current),
|
||||
focusedBorderColor = Color(0xff414141),
|
||||
|
@ -17,6 +17,7 @@ import kotlinx.coroutines.flow.take
|
||||
import kotlinx.coroutines.flow.takeWhile
|
||||
import kotlinx.coroutines.flow.update
|
||||
import kotlinx.coroutines.launch
|
||||
import network.loki.messenger.R
|
||||
import org.session.libsignal.crypto.MnemonicCodec
|
||||
import org.session.libsignal.crypto.MnemonicCodec.DecodingError.InputTooShort
|
||||
import org.session.libsignal.crypto.MnemonicCodec.DecodingError.InvalidWord
|
||||
@ -29,7 +30,7 @@ class LinkDeviceEvent(val mnemonic: ByteArray)
|
||||
|
||||
@HiltViewModel
|
||||
class LinkDeviceViewModel @Inject constructor(
|
||||
application: Application
|
||||
private val application: Application
|
||||
): AndroidViewModel(application) {
|
||||
private val QR_ERROR_TIME = 3.seconds
|
||||
private val state = MutableStateFlow(LinkDeviceState())
|
||||
@ -38,9 +39,10 @@ class LinkDeviceViewModel @Inject constructor(
|
||||
private val event = Channel<LinkDeviceEvent>()
|
||||
val eventFlow = event.receiveAsFlow().take(1)
|
||||
private val qrErrors = Channel<Throwable>()
|
||||
val qrErrorsFlow = qrErrors.receiveAsFlow().debounce(QR_ERROR_TIME).takeWhile { event.isEmpty }.mapNotNull {
|
||||
"This QR code does not contain a Recovery Password."
|
||||
}
|
||||
val qrErrorsFlow = qrErrors.receiveAsFlow()
|
||||
.debounce(QR_ERROR_TIME)
|
||||
.takeWhile { event.isEmpty }
|
||||
.mapNotNull { application.getString(R.string.activity_link_this_qr_code_does_not_contain_a_recovery_password) }
|
||||
|
||||
private val codec by lazy { MnemonicCodec { MnemonicUtilities.loadFileContents(getApplication(), it) } }
|
||||
|
||||
@ -60,7 +62,6 @@ class LinkDeviceViewModel @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun onChange(recoveryPhrase: String) {
|
||||
state.value = LinkDeviceState(recoveryPhrase)
|
||||
}
|
||||
@ -72,10 +73,10 @@ class LinkDeviceViewModel @Inject constructor(
|
||||
state.update {
|
||||
it.copy(
|
||||
error = when (error) {
|
||||
is InputTooShort -> "The Recovery Password you entered is not long enough. Please check and try again."
|
||||
is InvalidWord -> "Some of the words in your Recovery Password are incorrect. Please check and try again."
|
||||
else -> "Please check your Recovery Password and try again."
|
||||
}
|
||||
is InputTooShort -> R.string.activity_link_the_recovery_password_you_entered_is_not_long_enough_please_check_and_try_again
|
||||
is InvalidWord -> R.string.activity_link_some_of_the_words_in_your_recovery_password_are_incorrect_please_check_and_try_again
|
||||
else -> R.string.activity_link_please_check_your_recovery_password_and_try_again
|
||||
}.let(application::getString)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -1049,5 +1049,16 @@
|
||||
<string name="onboarding_create_account">Create account</string>
|
||||
<string name="onboarding_i_have_an_account">I have an account</string>
|
||||
<string name="onboarding_by_using_this_service_you_agree_to_our_terms_of_service_and_privacy_policy">By using this service, you agree to our Terms of Service and Privacy Policy</string>
|
||||
<string name="activity_link_this_qr_code_does_not_contain_a_recovery_password">This QR code does not contain a Recovery Password.</string>
|
||||
<string name="activity_link_the_recovery_password_you_entered_is_not_long_enough_please_check_and_try_again">The Recovery Password you entered is not long enough. Please check and try again.</string>
|
||||
<string name="activity_link_some_of_the_words_in_your_recovery_password_are_incorrect_please_check_and_try_again">Some of the words in your Recovery Password are incorrect. Please check and try again.</string>
|
||||
<string name="activity_link_please_check_your_recovery_password_and_try_again">Please check your Recovery Password and try again.</string>
|
||||
<string name="activity_link_load_account">Load Account</string>
|
||||
<string name="activity_link_camera_permission_permanently_denied_configure_in_settings">Camera Permission permanently denied. Configure in settings.</string>
|
||||
<string name="activity_link_settings">Settings</string>
|
||||
<string name="activity_link_grant_camera_permission">Grant Camera Permission</string>
|
||||
<string name="activity_link_recovery_password">Recovery Password</string>
|
||||
<string name="activity_link_enter_your_recovery_password_to_load_your_account_if_you_haven_t_saved_it_you_can_find_it_in_your_app_settings">Enter your recovery password to load your account. If you haven\'t saved it, you can find it in your app settings.</string>
|
||||
<string name="activity_link_enter_your_recovery_password">Enter your recovery password</string>
|
||||
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user