Add sms provider failed specific messaging during registration.

This commit is contained in:
Cody Henthorne
2024-12-04 11:41:50 -05:00
committed by Greyson Parrelli
parent 0952afbba1
commit 1315724d52
5 changed files with 38 additions and 10 deletions

View File

@@ -166,6 +166,7 @@ class EnterCodeFragment : LoggingFragment(R.layout.fragment_registration_enter_c
is VerificationCodeRequestResult.RateLimited -> presentRateLimitedDialog()
is VerificationCodeRequestResult.AttemptsExhausted -> presentAccountLocked()
is VerificationCodeRequestResult.RegistrationLocked -> presentRegistrationLocked(result.timeRemaining)
is VerificationCodeRequestResult.ExternalServiceFailure -> presentSmsGenericError(result)
else -> presentGenericError(result)
}
}
@@ -231,16 +232,28 @@ class EnterCodeFragment : LoggingFragment(R.layout.fragment_registration_enter_c
})
}
private fun presentSmsGenericError(requestResult: RegistrationResult) {
binding.keyboard.displayFailure().addListener(
object : AssertedSuccessListener<Boolean>() {
override fun onSuccess(result: Boolean?) {
Log.w(TAG, "Encountered sms provider error!", requestResult.getCause())
MaterialAlertDialogBuilder(requireContext()).apply {
setMessage(R.string.RegistrationActivity_sms_provider_error)
setPositiveButton(android.R.string.ok) { _, _ -> fragmentViewModel.showKeyboard() }
show()
}
}
}
)
}
private fun presentGenericError(requestResult: RegistrationResult) {
binding.keyboard.displayFailure().addListener(
object : AssertedSuccessListener<Boolean>() {
override fun onSuccess(result: Boolean?) {
Log.w(TAG, "Encountered unexpected error!", requestResult.getCause())
MaterialAlertDialogBuilder(requireContext()).apply {
null?.let<String, MaterialAlertDialogBuilder> {
setTitle(it)
}
setMessage(getString(R.string.RegistrationActivity_error_connecting_to_service))
setMessage(R.string.RegistrationActivity_error_connecting_to_service)
setPositiveButton(android.R.string.ok) { _, _ -> fragmentViewModel.showKeyboard() }
show()
}

View File

@@ -347,7 +347,7 @@ class EnterPhoneNumberFragment : LoggingFragment(R.layout.fragment_registration_
is VerificationCodeRequestResult.Success -> throw IllegalStateException("Session error handler called on successful response!")
is VerificationCodeRequestResult.AttemptsExhausted -> presentRateLimitedDialog()
is VerificationCodeRequestResult.ChallengeRequired -> handleChallenges(result.challenges)
is VerificationCodeRequestResult.ExternalServiceFailure -> presentRemoteErrorDialog(getString(R.string.RegistrationActivity_unable_to_connect_to_service), skipToNextScreen)
is VerificationCodeRequestResult.ExternalServiceFailure -> presentRemoteErrorDialog(getString(R.string.RegistrationActivity_sms_provider_error))
is VerificationCodeRequestResult.ImpossibleNumber -> {
MaterialAlertDialogBuilder(requireContext()).apply {
setMessage(getString(R.string.RegistrationActivity_the_number_you_specified_s_is_invalid, fragmentViewModel.phoneNumber?.toE164()))

View File

@@ -166,6 +166,7 @@ class EnterCodeFragment : LoggingFragment(R.layout.fragment_registration_enter_c
is VerificationCodeRequestResult.RateLimited -> presentRateLimitedDialog()
is VerificationCodeRequestResult.AttemptsExhausted -> presentAccountLocked()
is VerificationCodeRequestResult.RegistrationLocked -> presentRegistrationLocked(result.timeRemaining)
is VerificationCodeRequestResult.ExternalServiceFailure -> presentSmsGenericError(result)
else -> presentGenericError(result)
}
}
@@ -231,16 +232,28 @@ class EnterCodeFragment : LoggingFragment(R.layout.fragment_registration_enter_c
})
}
private fun presentSmsGenericError(requestResult: RegistrationResult) {
binding.keyboard.displayFailure().addListener(
object : AssertedSuccessListener<Boolean>() {
override fun onSuccess(result: Boolean?) {
Log.w(TAG, "Encountered sms provider error!", requestResult.getCause())
MaterialAlertDialogBuilder(requireContext()).apply {
setMessage(R.string.RegistrationActivity_sms_provider_error)
setPositiveButton(android.R.string.ok) { _, _ -> fragmentViewModel.showKeyboard() }
show()
}
}
}
)
}
private fun presentGenericError(requestResult: RegistrationResult) {
binding.keyboard.displayFailure().addListener(
object : AssertedSuccessListener<Boolean>() {
override fun onSuccess(result: Boolean?) {
Log.w(TAG, "Encountered unexpected error!", requestResult.getCause())
MaterialAlertDialogBuilder(requireContext()).apply {
null?.let<String, MaterialAlertDialogBuilder> {
setTitle(it)
}
setMessage(getString(R.string.RegistrationActivity_error_connecting_to_service))
setMessage(R.string.RegistrationActivity_error_connecting_to_service)
setPositiveButton(android.R.string.ok) { _, _ -> fragmentViewModel.showKeyboard() }
show()
}

View File

@@ -358,7 +358,7 @@ class EnterPhoneNumberFragment : LoggingFragment(R.layout.fragment_registration_
is VerificationCodeRequestResult.Success -> throw IllegalStateException("Session error handler called on successful response!")
is VerificationCodeRequestResult.AttemptsExhausted -> presentRateLimitedDialog()
is VerificationCodeRequestResult.ChallengeRequired -> handleChallenges(result.challenges)
is VerificationCodeRequestResult.ExternalServiceFailure -> presentRemoteErrorDialog(getString(R.string.RegistrationActivity_unable_to_connect_to_service), skipToNextScreen)
is VerificationCodeRequestResult.ExternalServiceFailure -> presentRemoteErrorDialog(getString(R.string.RegistrationActivity_sms_provider_error))
is VerificationCodeRequestResult.ImpossibleNumber -> {
MaterialAlertDialogBuilder(requireContext()).apply {
setMessage(getString(R.string.RegistrationActivity_the_number_you_specified_s_is_invalid, fragmentViewModel.phoneNumber?.toE164()))