Improved error snack message in case of call error

This commit is contained in:
Sylvain Berfini 2021-05-19 10:56:25 +02:00
parent 3ee0a986a2
commit 3aa8e49eb9
9 changed files with 26 additions and 25 deletions

View file

@ -104,8 +104,8 @@ class MainActivity : GenericActivity(), SnackBarActivity, NavController.OnDestin
})
coreContext.callErrorMessageResourceId.observe(this, {
it.consume { messageResourceId ->
showSnackBar(messageResourceId)
it.consume { message ->
showSnackBar(message)
}
})

View file

@ -91,8 +91,8 @@ class CoreContext(val context: Context, coreConfig: Config) {
NotificationsManager(context)
}
val callErrorMessageResourceId: MutableLiveData<Event<Int>> by lazy {
MutableLiveData<Event<Int>>()
val callErrorMessageResourceId: MutableLiveData<Event<String>> by lazy {
MutableLiveData<Event<String>>()
}
private val loggingService = Factory.instance().loggingService
@ -218,21 +218,23 @@ class CoreContext(val context: Context, coreConfig: Config) {
}
if (state == Call.State.Error) {
Log.w("[Context] Call error reason is ${call.errorInfo.reason}")
val id = when (call.errorInfo.reason) {
Reason.Busy -> R.string.call_error_user_busy
Reason.IOError -> R.string.call_error_io_error
Reason.NotAcceptable -> R.string.call_error_incompatible_media_params
Reason.NotFound -> R.string.call_error_user_not_found
else -> R.string.call_error_unknown
Log.w("[Context] Call error reason is ${call.errorInfo.protocolCode} / ${call.errorInfo.reason} / ${call.errorInfo.phrase}")
val message = when (call.errorInfo.reason) {
Reason.Busy -> context.getString(R.string.call_error_user_busy)
Reason.IOError -> context.getString(R.string.call_error_io_error)
Reason.NotAcceptable -> context.getString(R.string.call_error_incompatible_media_params)
Reason.NotFound -> context.getString(R.string.call_error_user_not_found)
Reason.ServerTimeout -> context.getString(R.string.call_error_server_timeout)
Reason.TemporarilyUnavailable -> context.getString(R.string.call_error_temporarily_unavailable)
else -> context.getString(R.string.call_error_generic).format("${call.errorInfo.protocolCode} / ${call.errorInfo.phrase}")
}
callErrorMessageResourceId.value = Event(id)
callErrorMessageResourceId.value = Event(message)
} else if (state == Call.State.End &&
call.dir == Call.Dir.Outgoing &&
call.errorInfo.reason == Reason.Declined) {
Log.i("[Context] Call has been declined")
val id = R.string.call_error_declined
callErrorMessageResourceId.value = Event(id)
val message = context.getString(R.string.call_error_declined)
callErrorMessageResourceId.value = Event(message)
}
}
@ -461,7 +463,7 @@ class CoreContext(val context: Context, coreConfig: Config) {
val address: Address? = core.interpretUrl(stringAddress)
if (address == null) {
Log.e("[Context] Failed to parse $stringAddress, abort outgoing call")
callErrorMessageResourceId.value = Event(R.string.call_error_network_unreachable)
callErrorMessageResourceId.value = Event(context.getString(R.string.call_error_network_unreachable))
return
}
@ -471,7 +473,7 @@ class CoreContext(val context: Context, coreConfig: Config) {
fun startCall(address: Address, forceZRTP: Boolean = false) {
if (!core.isNetworkReachable) {
Log.e("[Context] Network unreachable, abort outgoing call")
callErrorMessageResourceId.value = Event(R.string.call_error_network_unreachable)
callErrorMessageResourceId.value = Event(context.getString(R.string.call_error_network_unreachable))
return
}

View file

@ -349,7 +349,6 @@
<string name="call_error_incompatible_media_params">Parámetros de medios incompatibles</string>
<string name="call_error_network_unreachable">La red es inalcanzable</string>
<string name="call_error_io_error">Error de red</string>
<string name="call_error_unknown">Error desconocido</string>
<string name="call_stats_audio">Audio</string>
<string name="call_stats_video">Video</string>
<string name="call_stats_codec">Codec:</string>

View file

@ -162,8 +162,7 @@
<string name="call_error_user_busy">L\'utilisateur est occupé</string>
<string name="call_error_user_not_found">L\'utilisateur n\'a pu être trouvé</string>
<string name="call_error_network_unreachable">Le réseau n\'est pas joignable</string>
<string name="call_error_io_error">Erreur réseau</string>
<string name="call_error_unknown">Erreur inconnue</string>
<string name="call_error_io_error">Service indisponible ou erreur réseau</string>
<string name="call_video_update_requested_dialog">Votre interlocuteur souhaite activer la vidéo</string>
<string name="call_stats_audio">Audio</string>
<string name="video_settings_camera_device_title">Appareil photo</string>
@ -598,4 +597,7 @@
<string name="logs_upload_failure">Erreur pendant l\'envoi des journaux !</string>
<string name="logs_reset_complete">Les journaux ont été néttoyés</string>
<string name="call_settings_redirect_to_voice_mail_declined_calls_title">Rediriger les appels déclinés vers la boîte vocale</string>
<string name="call_error_server_timeout">Délai d\'attente serveur expiré</string>
<string name="call_error_temporarily_unavailable">Temporairement indisponible</string>
<string name="call_error_generic">Erreur : %s</string>
</resources>

View file

@ -391,7 +391,6 @@
<string name="chat_room_delete_one_dialog">Biztosan törli ezt a beszélgetést\?</string>
<string name="chat_message_cant_open_file_in_app_dialog_title">Úgy tűnik, hogy nem tudjuk megjeleníteni a fájlt.</string>
<string name="call_incoming_title">Bejövő hívás</string>
<string name="call_error_unknown">Ismeretlen hiba</string>
<string name="call_stats_estimated_download">Becsült letöltési sávszélesség:</string>
<string name="call_video_update_requested_dialog">A hívott fél szeretné bekapcsolni a videót</string>
<string name="call_stats_decoder_name">Dekóder:</string>

View file

@ -188,7 +188,6 @@
<string name="call_error_incompatible_media_params">Incompatibele media parameters</string>
<string name="call_error_network_unreachable">Netwerk is onbereikbaar</string>
<string name="call_error_io_error">Netwerkfout</string>
<string name="call_error_unknown">Onbekende fout</string>
<string name="call_video_update_requested_dialog">Tegenpartij wenst dat u video inschakelt</string>
<string name="call_stats_audio">Audio</string>
<string name="call_stats_video">Video</string>

View file

@ -458,7 +458,6 @@
<string name="call_error_incompatible_media_params">不兼容的媒体参数</string>
<string name="call_error_network_unreachable">无法获取网络</string>
<string name="call_error_io_error">网络出错</string>
<string name="call_error_unknown">未知错误</string>
<string name="call_stats_audio">音频</string>
<string name="call_stats_video">视频</string>
<string name="call_stats_codec">编解码器:</string>

View file

@ -152,7 +152,6 @@
<string name="call_error_incompatible_media_params">不兼容的媒體參數</string>
<string name="call_error_network_unreachable">無法連接網路</string>
<string name="call_error_io_error">網路錯誤</string>
<string name="call_error_unknown">未知錯誤</string>
<string name="call_stats_audio">音頻</string>
<string name="call_stats_video">視頻</string>
<string name="call_stats_codec">編解碼器:</string>

View file

@ -228,8 +228,10 @@
<string name="call_error_user_not_found">User hasn\'t been found</string>
<string name="call_error_incompatible_media_params">Incompatible media parameters</string>
<string name="call_error_network_unreachable">Network is unreachable</string>
<string name="call_error_io_error">Network error</string>
<string name="call_error_unknown">Unknown error</string>
<string name="call_error_io_error">Service unavailable or network error</string>
<string name="call_error_server_timeout">Server timeout</string>
<string name="call_error_temporarily_unavailable">Temporarily unavailable</string>
<string name="call_error_generic">Error: %s</string>
<string name="call_video_update_requested_dialog">Correspondent would like to turn the video on</string>
<!-- Call stats -->