mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-21 18:26:57 +00:00
Fix crash in registration v2 country code drop down.
This commit is contained in:
committed by
Cody Henthorne
parent
c8a9759eba
commit
4151d123cd
@@ -186,8 +186,11 @@ class EnterPhoneNumberV2Fragment : LoggingFragment(R.layout.fragment_registratio
|
||||
|
||||
private fun initializeInputFields() {
|
||||
binding.countryCode.editText?.addTextChangedListener { s ->
|
||||
val countryCode: Int = s.toString().toInt()
|
||||
fragmentViewModel.setCountry(countryCode)
|
||||
val sanitized = s.toString().filter { c -> c.isDigit() }
|
||||
if (sanitized.isNotNullOrBlank()) {
|
||||
val countryCode: Int = sanitized.toInt()
|
||||
fragmentViewModel.setCountry(countryCode)
|
||||
}
|
||||
}
|
||||
|
||||
phoneNumberInputLayout.addTextChangedListener {
|
||||
|
||||
@@ -63,6 +63,11 @@ class EnterPhoneNumberV2ViewModel : ViewModel() {
|
||||
|
||||
fun setCountry(digits: Int) {
|
||||
val matchingIndex = countryCodeToAdapterIndex(digits)
|
||||
if (matchingIndex == -1) {
|
||||
Log.d(TAG, "Invalid country code specified $digits")
|
||||
return
|
||||
}
|
||||
|
||||
store.update {
|
||||
it.copy(countryPrefixIndex = matchingIndex)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user