mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 03:18:06 +00:00
Fixed account labelled as Disabled instead of Disconnected if network isn't reachable
This commit is contained in:
parent
6f1439756e
commit
719b28f0ab
5 changed files with 87 additions and 52 deletions
|
|
@ -183,6 +183,81 @@ class AccountModel
|
|||
}
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
fun computeNotificationsCount() {
|
||||
notificationsCount.postValue(account.unreadChatMessageCount + account.missedCallsCount)
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
fun updateRegistrationState() {
|
||||
val state = if (account.state == RegistrationState.None) {
|
||||
// If the account has been disabled manually, use the Cleared status instead of None
|
||||
if (!account.params.isRegisterEnabled) {
|
||||
Log.w(
|
||||
"$TAG Account real registration state is None but using Cleared instead as it was manually disabled by the user"
|
||||
)
|
||||
RegistrationState.Cleared
|
||||
} else {
|
||||
account.state
|
||||
}
|
||||
} else {
|
||||
account.state
|
||||
}
|
||||
registrationState.postValue(state)
|
||||
|
||||
val label = when (state) {
|
||||
RegistrationState.Cleared -> {
|
||||
AppUtils.getString(
|
||||
R.string.drawer_menu_account_connection_status_cleared
|
||||
)
|
||||
}
|
||||
RegistrationState.Progress -> AppUtils.getString(
|
||||
R.string.drawer_menu_account_connection_status_progress
|
||||
)
|
||||
RegistrationState.Failed -> {
|
||||
AppUtils.getString(
|
||||
R.string.drawer_menu_account_connection_status_failed
|
||||
)
|
||||
}
|
||||
RegistrationState.Ok -> {
|
||||
AppUtils.getString(
|
||||
R.string.drawer_menu_account_connection_status_connected
|
||||
)
|
||||
}
|
||||
RegistrationState.None -> {
|
||||
AppUtils.getString(
|
||||
R.string.drawer_menu_account_connection_status_disconnected
|
||||
)
|
||||
}
|
||||
RegistrationState.Refreshing -> AppUtils.getString(
|
||||
R.string.drawer_menu_account_connection_status_refreshing
|
||||
)
|
||||
else -> "$state"
|
||||
}
|
||||
registrationStateLabel.postValue(label)
|
||||
Log.i("$TAG Account registration state is [$state]")
|
||||
|
||||
val summary = when (state) {
|
||||
RegistrationState.Cleared -> AppUtils.getString(
|
||||
R.string.manage_account_status_cleared_summary
|
||||
)
|
||||
RegistrationState.Refreshing, RegistrationState.Progress -> AppUtils.getString(
|
||||
R.string.manage_account_status_progress_summary
|
||||
)
|
||||
RegistrationState.Failed -> AppUtils.getString(
|
||||
R.string.manage_account_status_failed_summary
|
||||
)
|
||||
RegistrationState.Ok -> AppUtils.getString(
|
||||
R.string.manage_account_status_connected_summary
|
||||
)
|
||||
RegistrationState.None -> AppUtils.getString(
|
||||
R.string.manage_account_status_disconnected_summary
|
||||
)
|
||||
else -> "$state"
|
||||
}
|
||||
registrationStateSummary.postValue(summary)
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
private fun update() {
|
||||
Log.i(
|
||||
|
|
@ -206,56 +281,7 @@ class AccountModel
|
|||
isDefault.postValue(coreContext.core.defaultAccount == account)
|
||||
computeNotificationsCount()
|
||||
|
||||
val state = account.state
|
||||
registrationState.postValue(state)
|
||||
|
||||
val label = when (state) {
|
||||
RegistrationState.None, RegistrationState.Cleared -> {
|
||||
AppUtils.getString(
|
||||
R.string.drawer_menu_account_connection_status_cleared
|
||||
)
|
||||
}
|
||||
RegistrationState.Progress -> AppUtils.getString(
|
||||
R.string.drawer_menu_account_connection_status_progress
|
||||
)
|
||||
RegistrationState.Failed -> {
|
||||
AppUtils.getString(
|
||||
R.string.drawer_menu_account_connection_status_failed
|
||||
)
|
||||
}
|
||||
RegistrationState.Ok -> {
|
||||
AppUtils.getString(
|
||||
R.string.drawer_menu_account_connection_status_connected
|
||||
)
|
||||
}
|
||||
RegistrationState.Refreshing -> AppUtils.getString(
|
||||
R.string.drawer_menu_account_connection_status_refreshing
|
||||
)
|
||||
else -> "${account.state}"
|
||||
}
|
||||
registrationStateLabel.postValue(label)
|
||||
|
||||
val summary = when (account.state) {
|
||||
RegistrationState.None, RegistrationState.Cleared -> AppUtils.getString(
|
||||
R.string.manage_account_status_cleared_summary
|
||||
)
|
||||
RegistrationState.Refreshing, RegistrationState.Progress -> AppUtils.getString(
|
||||
R.string.manage_account_status_progress_summary
|
||||
)
|
||||
RegistrationState.Failed -> AppUtils.getString(
|
||||
R.string.manage_account_status_failed_summary
|
||||
)
|
||||
RegistrationState.Ok -> AppUtils.getString(
|
||||
R.string.manage_account_status_connected_summary
|
||||
)
|
||||
else -> "${account.state}"
|
||||
}
|
||||
registrationStateSummary.postValue(summary)
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
fun computeNotificationsCount() {
|
||||
notificationsCount.postValue(account.unreadChatMessageCount + account.missedCallsCount)
|
||||
updateRegistrationState()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -378,7 +378,7 @@ class AccountProfileViewModel
|
|||
|
||||
@UiThread
|
||||
fun toggleRegister() {
|
||||
coreContext.postOnCoreThread {
|
||||
coreContext.postOnCoreThread { core ->
|
||||
val params = account.params
|
||||
val copy = params.clone()
|
||||
copy.isRegisterEnabled = !params.isRegisterEnabled
|
||||
|
|
@ -387,6 +387,11 @@ class AccountProfileViewModel
|
|||
)
|
||||
account.params = copy
|
||||
registerEnabled.postValue(account.params.isRegisterEnabled)
|
||||
|
||||
if (!core.isNetworkReachable) {
|
||||
// To reflect the difference between Disabled & Disconnected
|
||||
accountModel.value?.updateRegistrationState()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@
|
|||
android:background="@drawable/shape_squircle_main2_200_background"
|
||||
android:gravity="center"
|
||||
android:text="@{model.registrationStateLabel, default=@string/drawer_menu_account_connection_status_connected}"
|
||||
android:textColor="@{model.registrationState == RegistrationState.Ok ? @color/success_500 : model.registrationState == RegistrationState.Failed ? @color/danger_500 : model.registrationState == RegistrationState.Cleared || model.registrationState == RegistrationState.None ? @color/warning_600 : @color/main2_500, default=@color/success_500}"
|
||||
android:textColor="@{model.registrationState == RegistrationState.Ok ? @color/success_500 : model.registrationState == RegistrationState.Failed ? @color/danger_500 : model.registrationState == RegistrationState.Cleared ? @color/warning_600 : @color/main2_500, default=@color/success_500}"
|
||||
android:textSize="12sp"
|
||||
app:layout_constraintHorizontal_bias="0"
|
||||
app:layout_constraintStart_toStartOf="@id/name"
|
||||
|
|
|
|||
|
|
@ -151,6 +151,7 @@
|
|||
<!-- Side menu -->
|
||||
<string name="drawer_menu_manage_account">Mon compte</string>
|
||||
<string name="drawer_menu_account_connection_status_connected">Connecté</string>
|
||||
<string name="drawer_menu_account_connection_status_disconnected">Déconnecté</string>
|
||||
<string name="drawer_menu_account_connection_status_refreshing">Rafraîchissement…</string>
|
||||
<string name="drawer_menu_account_connection_status_cleared">Désactivé</string>
|
||||
<string name="drawer_menu_account_connection_status_progress">Connexion…</string>
|
||||
|
|
@ -331,6 +332,7 @@
|
|||
<string name="manage_account_edit_picture">Modifier </string>
|
||||
<string name="manage_account_remove_picture">Supprimer</string>
|
||||
<string name="manage_account_status_connected_summary">Vous êtes en ligne, on peut vous joindre.</string>
|
||||
<string name="manage_account_status_disconnected_summary">Vous êtes hors ligne, probablement car vous n\'êtes pas actuellement connecté à internet.</string>
|
||||
<string name="manage_account_status_cleared_summary">Compte désactivé, vous ne recevrez ni appel ni message.</string>
|
||||
<string name="manage_account_status_progress_summary">Connexion en cours, merci de patienter…</string>
|
||||
<string name="manage_account_status_failed_summary">Erreur de connexion, vérifiez vos paramètres.</string>
|
||||
|
|
|
|||
|
|
@ -193,6 +193,7 @@
|
|||
<!-- Side menu -->
|
||||
<string name="drawer_menu_manage_account">Manage the profile</string>
|
||||
<string name="drawer_menu_account_connection_status_connected">Connected</string>
|
||||
<string name="drawer_menu_account_connection_status_disconnected">Disconnected</string>
|
||||
<string name="drawer_menu_account_connection_status_refreshing">Refreshing</string>
|
||||
<string name="drawer_menu_account_connection_status_cleared">Disabled</string>
|
||||
<string name="drawer_menu_account_connection_status_progress">Connecting…</string>
|
||||
|
|
@ -373,6 +374,7 @@
|
|||
<string name="manage_account_edit_picture">Edit picture</string>
|
||||
<string name="manage_account_remove_picture">Remove picture</string>
|
||||
<string name="manage_account_status_connected_summary">This account in online, everybody can call you.</string>
|
||||
<string name="manage_account_status_disconnected_summary">This account in offline, probably because you aren\'t connected to internet right now.</string>
|
||||
<string name="manage_account_status_cleared_summary">Account has been disabled, you won\'t receive any call or message.</string>
|
||||
<string name="manage_account_status_progress_summary">Account is connecting to the server, please wait…</string>
|
||||
<string name="manage_account_status_failed_summary">Account connection failed, check your settings.</string>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue