From cb20acfa5232c067163c6acf481a2fe2567787e5 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Wed, 27 Sep 2023 15:05:28 +0200 Subject: [PATCH] Display unread messages & missed calls counters on each account in side menu --- .../org/linphone/ui/main/model/AccountModel.kt | 3 +++ app/src/main/res/drawable/shape_red_round.xml | 5 +++++ app/src/main/res/layout-land/bottom_nav_bar.xml | 2 +- .../main/res/layout-land/call_extra_actions.xml | 11 ++++++----- app/src/main/res/layout/account_list_cell.xml | 15 +++++++++++++++ app/src/main/res/layout/bottom_nav_bar.xml | 2 +- app/src/main/res/layout/call_extra_actions.xml | 9 +++++---- 7 files changed, 36 insertions(+), 11 deletions(-) create mode 100644 app/src/main/res/drawable/shape_red_round.xml 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 cc9174f47..e09afef90 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 @@ -57,6 +57,8 @@ class AccountModel @WorkerThread constructor( val showTrust = MutableLiveData() + val notificationsCount = MutableLiveData() + private val accountListener = object : AccountListenerStub() { @WorkerThread override fun onRegistrationStateChanged( @@ -137,6 +139,7 @@ class AccountModel @WorkerThread constructor( } isDefault.postValue(coreContext.core.defaultAccount == account) + notificationsCount.postValue(account.unreadChatMessageCount + account.missedCallsCount) val state = account.state registrationState.postValue(state) diff --git a/app/src/main/res/drawable/shape_red_round.xml b/app/src/main/res/drawable/shape_red_round.xml new file mode 100644 index 000000000..f8bd6c05d --- /dev/null +++ b/app/src/main/res/drawable/shape_red_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout-land/bottom_nav_bar.xml b/app/src/main/res/layout-land/bottom_nav_bar.xml index 3326adb6b..cd7ae7d76 100644 --- a/app/src/main/res/layout-land/bottom_nav_bar.xml +++ b/app/src/main/res/layout-land/bottom_nav_bar.xml @@ -67,7 +67,7 @@ android:layout_width="24dp" android:layout_height="24dp" android:gravity="center" - android:background="@drawable/shape_orange_round" + android:background="@drawable/shape_red_round" android:text="@{String.valueOf(viewModel.missedCallsCount), default=`1`}" android:textColor="@color/white" android:textSize="13sp" diff --git a/app/src/main/res/layout-land/call_extra_actions.xml b/app/src/main/res/layout-land/call_extra_actions.xml index 769866bf9..bc59ee999 100644 --- a/app/src/main/res/layout-land/call_extra_actions.xml +++ b/app/src/main/res/layout-land/call_extra_actions.xml @@ -87,17 +87,18 @@ @@ -207,8 +208,8 @@ app:layout_constraintTop_toBottomOf="@id/chat" /> + +