Commit 4cf6a0c4 authored by Christophe Deschamps's avatar Christophe Deschamps
Browse files

Missed count sync


Former-commit-id: 72e73a7a45cd7a04f19279376dfa82664bbd919c
parent b70c3cd9
package org.lindoor.linphonecore.extensions
import org.lindoor.LindoorApplication
import org.lindoor.LindoorApplication.Companion.coreContext
import org.linphone.core.AudioDevice
import org.linphone.core.CallLog
......@@ -52,3 +53,14 @@ fun Core.forceBluetoothAudioRoute() {
fun Core.callLogsWithNonEmptyCallId(): ArrayList<CallLog> {
return (coreContext.core.callLogs.toCollection(ArrayList()) as ArrayList<CallLog>).filterNot { it.callId == null } as ArrayList<CallLog>
}
fun Core.missedCount(): Int {
var count = 0
coreContext.core.callLogsWithNonEmptyCallId().forEach {
if (it.isNew())
count++
}
return count
}
......@@ -47,6 +47,7 @@ import org.lindoor.customisation.Theme
import org.lindoor.linphonecore.CoreService
import org.lindoor.linphonecore.extensions.extendedAcceptEarlyMedia
import org.lindoor.linphonecore.extensions.historyEvent
import org.lindoor.linphonecore.extensions.missedCount
import org.lindoor.store.DeviceStore
import org.lindoor.ui.call.CallInProgressActivity
import org.lindoor.ui.call.CallIncomingActivity
......@@ -446,7 +447,7 @@ class NotificationsManager(private val context: Context) {
.setVisibility(NotificationCompat.VISIBILITY_PRIVATE)
.setWhen(System.currentTimeMillis())
.setShowWhen(true)
.setNumber(missedCallCount)
.setNumber(coreContext.core.missedCount())
.setColor(Theme.getColor("color_s"))
.build()
notify(MISSED_CALLS_NOTIF_ID, notification)
......
......@@ -5,6 +5,7 @@ import androidx.lifecycle.ViewModel
import org.lindoor.LindoorApplication
import org.lindoor.linphonecore.extensions.callLogsWithNonEmptyCallId
import org.lindoor.linphonecore.extensions.isNew
import org.lindoor.linphonecore.extensions.missedCount
import org.linphone.core.CallLog
import org.linphone.core.Core
import org.linphone.core.CoreListenerStub
......@@ -19,12 +20,7 @@ class TabbarViewModel : ViewModel() {
}
fun updateUnreadCount() {
var count = 0
LindoorApplication.coreContext.core.callLogsWithNonEmptyCallId().forEach {
if (it.isNew())
count++
}
unreadCount.value = count
unreadCount.value = LindoorApplication.coreContext.core.missedCount()
}
init {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment