mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Fixed MWI icon if no count is provided in the NOTIFY (only yes/no)
This commit is contained in:
parent
612c8b3301
commit
5da87f598a
2 changed files with 41 additions and 12 deletions
|
|
@ -60,7 +60,9 @@ class AccountModel @WorkerThread constructor(
|
|||
|
||||
val notificationsCount = MutableLiveData<Int>()
|
||||
|
||||
val voicemailCount = MutableLiveData<Int>()
|
||||
val showMwi = MutableLiveData<Boolean>()
|
||||
|
||||
val voicemailCount = MutableLiveData<String>()
|
||||
|
||||
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(
|
||||
|
|
|
|||
|
|
@ -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" />
|
||||
|
||||
<include
|
||||
android:id="@+id/avatar"
|
||||
|
|
@ -81,18 +81,31 @@
|
|||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/default_text_style"
|
||||
android:id="@+id/voicemail_count"
|
||||
android:onClick="@{() -> model.callVoicemailUri()}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@{model.voicemailCount, default=`1`}"
|
||||
android:textColor="?attr/color_danger_500"
|
||||
android:textSize="13sp"
|
||||
android:visibility="@{model.showMwi ? View.VISIBLE : View.GONE, default=gone}"
|
||||
app:layout_constraintVertical_chainStyle="packed"
|
||||
app:layout_constraintBottom_toTopOf="@id/voicemail_icon"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toStartOf="@id/voicemail_icon"
|
||||
app:layout_constraintEnd_toEndOf="@id/voicemail_icon"/>
|
||||
|
||||
<ImageView
|
||||
style="@style/default_text_style"
|
||||
android:id="@+id/voicemail_icon"
|
||||
android:onClick="@{() -> model.callVoicemailUri()}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:gravity="center"
|
||||
android:text="@{String.valueOf(model.voicemailCount), default=`1`}"
|
||||
android:textColor="?attr/color_danger_500"
|
||||
android:textSize="13sp"
|
||||
android:paddingBottom="2dp"
|
||||
android:visibility="@{model.voicemailCount > 0 ? View.VISIBLE : View.GONE, default=gone}"
|
||||
android:drawableBottom="@drawable/voicemail"
|
||||
android:src="@drawable/voicemail"
|
||||
android:visibility="@{model.showMwi ? View.VISIBLE : View.GONE, default=gone}"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/voicemail_count"
|
||||
app:layout_constraintEnd_toStartOf="@id/notifications_count"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue