Fix display name length

This commit is contained in:
Andrew 2024-06-28 13:57:49 +09:30
parent ad2bf6e344
commit e3685f65f8
2 changed files with 4 additions and 2 deletions

View File

@ -44,8 +44,10 @@ internal class PickDisplayNameViewModel(
when {
displayName.isEmpty() -> { _states.update { it.copy(isTextErrorColor = true, error = R.string.displayNameErrorDescription) } }
displayName.length > NAME_PADDED_LENGTH -> { _states.update { it.copy(isTextErrorColor = true, error = R.string.displayNameErrorDescriptionShorter) } }
displayName.toByteArray().size > NAME_PADDED_LENGTH -> { _states.update { it.copy(isTextErrorColor = true, error = R.string.displayNameErrorDescriptionShorter) } }
else -> {
_states.update { it.copy(isTextErrorColor = false, error = null) }
prefs.setProfileName(displayName)
if (!loadFailed) {

View File

@ -308,7 +308,7 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() {
Toast.makeText(this, R.string.activity_settings_display_name_missing_error, Toast.LENGTH_SHORT).show()
return false
}
if (displayName.toByteArray().size > ProfileManagerProtocol.Companion.NAME_PADDED_LENGTH) {
if (displayName.toByteArray().size > ProfileManagerProtocol.NAME_PADDED_LENGTH) {
Toast.makeText(this, R.string.activity_settings_display_name_too_long_error, Toast.LENGTH_SHORT).show()
return false
}