Prevents Core from shutting down when closing chat message notification bubble

This commit is contained in:
Sylvain Berfini 2021-02-03 13:37:59 +01:00
parent a93f337e89
commit 8c8de826b2
6 changed files with 16 additions and 21 deletions

View file

@ -126,8 +126,7 @@ class ChatBubbleActivity : GenericActivity() {
}
binding.setCloseBubbleClickListener {
val notificationId = coreContext.notificationsManager.getChatNotificationIdForSipUri(viewModel.chatRoom.peerAddress.asStringUriOnly())
coreContext.notificationsManager.cancel(notificationId)
coreContext.notificationsManager.cancelChatNotificationIdForSipUri(viewModel.chatRoom.peerAddress.asStringUriOnly())
}
binding.setSendMessageClickListener {

View file

@ -60,8 +60,12 @@ class CoreService : CoreService() {
override fun onTaskRemoved(rootIntent: Intent?) {
if (!corePreferences.keepServiceAlive) {
Log.i("[Service] Task removed, stopping Core")
coreContext.stop()
if (coreContext.core.isInBackground()) {
Log.i("[Service] Task removed, stopping Core")
coreContext.stop()
} else {
Log.w("[Service] Task removed but Core in not in background, skipping")
}
}
super.onTaskRemoved(rootIntent)

View file

@ -93,11 +93,7 @@ class NotificationsManager(private val context: Context) {
field = value
if (value != null) {
// When a chat room becomes visible, cancel unread chat notification if any
val notifiable: Notifiable? = chatNotificationsMap[value]
if (notifiable != null) {
cancel(notifiable.notificationId)
notifiable.messages.clear()
}
cancelChatNotificationIdForSipUri(value)
}
}
@ -246,12 +242,12 @@ class NotificationsManager(private val context: Context) {
return null
}
fun getChatNotificationIdForSipUri(sipUri: String): Int {
fun cancelChatNotificationIdForSipUri(sipUri: String) {
val notifiable: Notifiable? = chatNotificationsMap[sipUri]
if (notifiable != null) {
return notifiable.notificationId
notifiable.messages.clear()
cancel(notifiable.notificationId)
}
return 0
}
/* Service related */

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

View file

@ -32,17 +32,15 @@
android:background="?attr/lightToolbarBackgroundColor"
android:orientation="horizontal">
<!-- Disabled for now -->
<ImageView
android:contentDescription="@string/content_description_close_bubble"
android:visibility="gone"
android:onClick="@{closeBubbleClickListener}"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:layout_margin="5dp"
android:padding="15dp"
android:background="?attr/button_background_drawable"
android:src="@drawable/menu_delete_default"
android:src="@drawable/collapse_default"
app:tint="?attr/drawableTintColor" />
<LinearLayout
@ -71,18 +69,16 @@
</LinearLayout>
<!-- Disabled for now -->
<ImageView
android:onClick="@{openAppClickListener}"
android:visibility="gone"
android:contentDescription="@string/content_description_open_app"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:layout_margin="5dp"
android:padding="15dp"
android:background="?attr/button_background_drawable"
app:tint="?attr/colorPrimary"
android:src="@drawable/linphone_logo"/>
app:tint="?attr/drawableTintColor"
android:src="@drawable/fullscreen_default"/>
</LinearLayout>