From 5da87f598a452d10bd5937b734726d22d7dffdd7 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Thu, 31 Oct 2024 16:32:00 +0100 Subject: [PATCH] Fixed MWI icon if no count is provided in the NOTIFY (only yes/no) --- .../linphone/ui/main/model/AccountModel.kt | 22 +++++++++++-- app/src/main/res/layout/account_list_cell.xml | 31 +++++++++++++------ 2 files changed, 41 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/org/linphone/ui/main/model/AccountModel.kt b/app/src/main/java/org/linphone/ui/main/model/AccountModel.kt index fb1fb5067..ca5074ed3 100644 --- a/app/src/main/java/org/linphone/ui/main/model/AccountModel.kt +++ b/app/src/main/java/org/linphone/ui/main/model/AccountModel.kt @@ -60,7 +60,9 @@ class AccountModel @WorkerThread constructor( val notificationsCount = MutableLiveData() - val voicemailCount = MutableLiveData() + val showMwi = MutableLiveData() + + val voicemailCount = MutableLiveData() private val accountListener = object : AccountListenerStub() { @WorkerThread @@ -82,6 +84,7 @@ class AccountModel @WorkerThread constructor( Log.i( "$TAG Account [${account.params.identityAddress?.asStringUriOnly()}] has received a MWI NOTIFY. ${if (mwi.hasMessageWaiting()) "Message(s) are waiting." else "No message is waiting."}}" ) + showMwi.postValue(mwi.hasMessageWaiting()) for (summary in mwi.summaries) { val context = summary.contextClass val nbNew = summary.nbNew @@ -91,7 +94,8 @@ class AccountModel @WorkerThread constructor( Log.i( "$TAG [MWI] [$context]: new [$nbNew] urgent ($nbNewUrgent), old [$nbOld] urgent ($nbOldUrgent)" ) - voicemailCount.postValue(nbNew) + + voicemailCount.postValue(nbNew.toString()) } } } @@ -117,7 +121,8 @@ class AccountModel @WorkerThread constructor( coreContext.core.addListener(coreListener) presenceStatus.postValue(ConsolidatedPresence.Offline) - voicemailCount.postValue(0) + showMwi.postValue(false) + voicemailCount.postValue("") update() } @@ -162,6 +167,17 @@ class AccountModel @WorkerThread constructor( } } + @UiThread + fun callVoicemailUri() { + coreContext.postOnCoreThread { + val voicemail = account.params.voicemailAddress + if (voicemail != null) { + Log.i("$TAG Calling voicemail address [${voicemail.asStringUriOnly()}]") + coreContext.startAudioCall(voicemail) + } + } + } + @WorkerThread private fun update() { Log.i( diff --git a/app/src/main/res/layout/account_list_cell.xml b/app/src/main/res/layout/account_list_cell.xml index 008d932d7..c2aeabf7c 100644 --- a/app/src/main/res/layout/account_list_cell.xml +++ b/app/src/main/res/layout/account_list_cell.xml @@ -22,7 +22,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" app:barrierDirection="start" - app:constraint_referenced_ids="voicemail_count, notifications_count, menu" /> + app:constraint_referenced_ids="voicemail_count, voicemail_icon, notifications_count, menu" /> + +