Improved bubbles
This commit is contained in:
parent
337236da4c
commit
b414016a00
4 changed files with 35 additions and 10 deletions
|
@ -23,8 +23,11 @@ import android.content.Intent
|
|||
import android.os.Bundle
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.R
|
||||
import org.linphone.activities.GenericActivity
|
||||
|
@ -135,6 +138,26 @@ class ChatBubbleActivity : GenericActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
|
||||
val peerAddress = viewModel.chatRoom.peerAddress.asStringUriOnly()
|
||||
coreContext.notificationsManager.currentlyDisplayedChatRoomAddress = peerAddress
|
||||
coreContext.notificationsManager.resetChatNotificationCounterForSipUri(peerAddress)
|
||||
|
||||
lifecycleScope.launch {
|
||||
// Without the delay the scroll to bottom doesn't happen...
|
||||
delay(100)
|
||||
scrollToBottom()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
coreContext.notificationsManager.currentlyDisplayedChatRoomAddress = null
|
||||
|
||||
super.onPause()
|
||||
}
|
||||
|
||||
private fun scrollToBottom() {
|
||||
if (adapter.itemCount > 0) {
|
||||
binding.chatMessagesList.scrollToPosition(adapter.itemCount - 1)
|
||||
|
|
|
@ -325,7 +325,9 @@ class DetailChatRoomFragment : MasterFragment<ChatRoomDetailFragmentBinding, Cha
|
|||
super.onResume()
|
||||
|
||||
// Prevent notifications for this chat room to be displayed
|
||||
coreContext.notificationsManager.currentlyDisplayedChatRoomAddress = viewModel.chatRoom.peerAddress.asStringUriOnly()
|
||||
val peerAddress = viewModel.chatRoom.peerAddress.asStringUriOnly()
|
||||
coreContext.notificationsManager.currentlyDisplayedChatRoomAddress = peerAddress
|
||||
coreContext.notificationsManager.cancelChatNotificationIdForSipUri(peerAddress)
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
|
|
|
@ -88,15 +88,6 @@ class NotificationsManager(private val context: Context) {
|
|||
private const val MISSED_CALLS_NOTIF_ID = 2
|
||||
}
|
||||
|
||||
var currentlyDisplayedChatRoomAddress: String? = null
|
||||
set(value) {
|
||||
field = value
|
||||
if (value != null) {
|
||||
// When a chat room becomes visible, cancel unread chat notification if any
|
||||
cancelChatNotificationIdForSipUri(value)
|
||||
}
|
||||
}
|
||||
|
||||
private val notificationManager: NotificationManagerCompat by lazy {
|
||||
NotificationManagerCompat.from(context)
|
||||
}
|
||||
|
@ -106,8 +97,11 @@ class NotificationsManager(private val context: Context) {
|
|||
private var lastNotificationId: Int = 5
|
||||
private var currentForegroundServiceNotificationId: Int = 0
|
||||
private var serviceNotification: Notification? = null
|
||||
|
||||
var service: CoreService? = null
|
||||
|
||||
var currentlyDisplayedChatRoomAddress: String? = null
|
||||
|
||||
private val listener: CoreListenerStub = object : CoreListenerStub() {
|
||||
override fun onCallStateChanged(
|
||||
core: Core,
|
||||
|
@ -250,6 +244,11 @@ class NotificationsManager(private val context: Context) {
|
|||
}
|
||||
}
|
||||
|
||||
fun resetChatNotificationCounterForSipUri(sipUri: String) {
|
||||
val notifiable: Notifiable? = chatNotificationsMap[sipUri]
|
||||
notifiable?.messages?.clear()
|
||||
}
|
||||
|
||||
/* Service related */
|
||||
|
||||
fun startForeground() {
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
<ImageView
|
||||
android:contentDescription="@string/content_description_close_bubble"
|
||||
android:onClick="@{closeBubbleClickListener}"
|
||||
android:visibility="invisible"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.2"
|
||||
|
|
Loading…
Reference in a new issue