mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-04-24 21:18:31 +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 notificationsCount = MutableLiveData<Int>()
|
||||||
|
|
||||||
val voicemailCount = MutableLiveData<Int>()
|
val showMwi = MutableLiveData<Boolean>()
|
||||||
|
|
||||||
|
val voicemailCount = MutableLiveData<String>()
|
||||||
|
|
||||||
private val accountListener = object : AccountListenerStub() {
|
private val accountListener = object : AccountListenerStub() {
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
|
|
@ -82,6 +84,7 @@ class AccountModel @WorkerThread constructor(
|
||||||
Log.i(
|
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."}}"
|
"$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) {
|
for (summary in mwi.summaries) {
|
||||||
val context = summary.contextClass
|
val context = summary.contextClass
|
||||||
val nbNew = summary.nbNew
|
val nbNew = summary.nbNew
|
||||||
|
|
@ -91,7 +94,8 @@ class AccountModel @WorkerThread constructor(
|
||||||
Log.i(
|
Log.i(
|
||||||
"$TAG [MWI] [$context]: new [$nbNew] urgent ($nbNewUrgent), old [$nbOld] urgent ($nbOldUrgent)"
|
"$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)
|
coreContext.core.addListener(coreListener)
|
||||||
|
|
||||||
presenceStatus.postValue(ConsolidatedPresence.Offline)
|
presenceStatus.postValue(ConsolidatedPresence.Offline)
|
||||||
voicemailCount.postValue(0)
|
showMwi.postValue(false)
|
||||||
|
voicemailCount.postValue("")
|
||||||
|
|
||||||
update()
|
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
|
@WorkerThread
|
||||||
private fun update() {
|
private fun update() {
|
||||||
Log.i(
|
Log.i(
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:barrierDirection="start"
|
app:barrierDirection="start"
|
||||||
app:constraint_referenced_ids="voicemail_count, notifications_count, menu" />
|
app:constraint_referenced_ids="voicemail_count, voicemail_icon, notifications_count, menu" />
|
||||||
|
|
||||||
<include
|
<include
|
||||||
android:id="@+id/avatar"
|
android:id="@+id/avatar"
|
||||||
|
|
@ -81,18 +81,31 @@
|
||||||
<androidx.appcompat.widget.AppCompatTextView
|
<androidx.appcompat.widget.AppCompatTextView
|
||||||
style="@style/default_text_style"
|
style="@style/default_text_style"
|
||||||
android:id="@+id/voicemail_count"
|
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_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginEnd="16dp"
|
android:layout_marginEnd="16dp"
|
||||||
android:gravity="center"
|
android:src="@drawable/voicemail"
|
||||||
android:text="@{String.valueOf(model.voicemailCount), default=`1`}"
|
android:visibility="@{model.showMwi ? View.VISIBLE : View.GONE, default=gone}"
|
||||||
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"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toBottomOf="@id/voicemail_count"
|
||||||
app:layout_constraintEnd_toStartOf="@id/notifications_count"/>
|
app:layout_constraintEnd_toStartOf="@id/notifications_count"/>
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatTextView
|
<androidx.appcompat.widget.AppCompatTextView
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue