Clear messages history in chat notification when it is marked as read
This commit is contained in:
parent
08cb252116
commit
c86b548fa9
2 changed files with 66 additions and 56 deletions
|
@ -31,9 +31,17 @@ import org.linphone.core.tools.Log
|
|||
class NotificationBroadcastReceiver : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
val notificationId = intent.getIntExtra(NotificationsManager.INTENT_NOTIF_ID, 0)
|
||||
val localIdentity = intent.getStringExtra(NotificationsManager.INTENT_LOCAL_IDENTITY)
|
||||
|
||||
if (intent.action == NotificationsManager.INTENT_REPLY_NOTIF_ACTION || intent.action == NotificationsManager.INTENT_MARK_AS_READ_ACTION) {
|
||||
handleChatIntent(intent, notificationId)
|
||||
} else if (intent.action == NotificationsManager.INTENT_ANSWER_CALL_NOTIF_ACTION || intent.action == NotificationsManager.INTENT_HANGUP_CALL_NOTIF_ACTION) {
|
||||
handleCallIntent(intent, notificationId)
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleChatIntent(intent: Intent, notificationId: Int) {
|
||||
val localIdentity = intent.getStringExtra(NotificationsManager.INTENT_LOCAL_IDENTITY)
|
||||
|
||||
val remoteSipAddress: String? = coreContext.notificationsManager.getSipUriForChatNotificationId(notificationId)
|
||||
if (remoteSipAddress == null) {
|
||||
Log.e("[Notification Broadcast Receiver] Couldn't find remote address $remoteSipAddress for notification id $notificationId")
|
||||
|
@ -77,9 +85,11 @@ class NotificationBroadcastReceiver : BroadcastReceiver() {
|
|||
msg.send()
|
||||
Log.i("[Notification Broadcast Receiver] Reply sent for notif id $notificationId")
|
||||
} else {
|
||||
coreContext.notificationsManager.cancel(notificationId)
|
||||
coreContext.notificationsManager.dismissChatNotification(room)
|
||||
}
|
||||
} else if (intent.action == NotificationsManager.INTENT_ANSWER_CALL_NOTIF_ACTION || intent.action == NotificationsManager.INTENT_HANGUP_CALL_NOTIF_ACTION) {
|
||||
}
|
||||
|
||||
private fun handleCallIntent(intent: Intent, notificationId: Int) {
|
||||
val remoteAddress: String? = coreContext.notificationsManager.getSipUriForCallNotificationId(notificationId)
|
||||
val core: Core = coreContext.core
|
||||
|
||||
|
@ -95,7 +105,6 @@ class NotificationBroadcastReceiver : BroadcastReceiver() {
|
|||
if (call.state == Call.State.IncomingReceived || call.state == Call.State.IncomingEarlyMedia) coreContext.declineCall(call) else coreContext.terminateCall(call)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getMessageText(intent: Intent): CharSequence? {
|
||||
val remoteInput = RemoteInput.getResultsFromIntent(intent)
|
||||
|
|
|
@ -614,6 +614,7 @@ class NotificationsManager(private val context: Context) {
|
|||
val notifiable: Notifiable? = chatNotificationsMap[address]
|
||||
if (notifiable != null) {
|
||||
Log.i("[Notifications Manager] Dismissing notification for chat room $room with id ${notifiable.notificationId}")
|
||||
notifiable.messages.clear()
|
||||
cancel(notifiable.notificationId)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue