From dd5ae4520230832d9de924d55b96693034293adf Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Fri, 19 Sep 2025 11:36:37 +0200 Subject: [PATCH 1/3] open thread from notification although it's not a nice solution to pass around and modify the intent, i will stick with this to avoid too many changes before the 22.0.0 release Signed-off-by: Marcel Hibbe --- .../java/com/nextcloud/talk/jobs/NotificationWorker.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.kt b/app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.kt index df264362187..5fdfb8493c8 100644 --- a/app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.kt +++ b/app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.kt @@ -85,6 +85,7 @@ import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_ONE_TO_ONE import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_TOKEN import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_SHARE_RECORDING_TO_CHAT_URL import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_SYSTEM_NOTIFICATION_ID +import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_THREAD_ID import com.nextcloud.talk.utils.preferences.AppPreferences import io.reactivex.Observable import io.reactivex.Observer @@ -397,6 +398,10 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor val ncNotification = notificationOverall.ocs!!.notification if (ncNotification != null) { enrichPushMessageByNcNotificationData(ncNotification) + + val threadId = parseThreadId(ncNotification.objectId) + threadId?.let { intent.putExtra(KEY_THREAD_ID, it) } + showNotification(intent, ncNotification) } } @@ -827,6 +832,8 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor } } + private fun parseThreadId(objectId: String?): Long? = objectId?.split("/")?.getOrNull(2)?.toLongOrNull() + private fun sendNotification(notificationId: Int, notification: Notification) { Log.d(TAG, "show notification with id $notificationId") if (ActivityCompat.checkSelfPermission( From a612de1eadd9ef5166ba301b46544a4039f35554 Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Fri, 19 Sep 2025 12:08:49 +0200 Subject: [PATCH 2/3] fix + modify backpress when being in a thread fix: when opened via notification, backpress will now open chat instead bluescreen from MainActivity modify: this will affect that backpress from thread after coming from threadlist will open the chat, which is not expected to be improved... Signed-off-by: Marcel Hibbe --- app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt b/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt index c24bf1b7bf5..43b9964f175 100644 --- a/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt @@ -410,11 +410,11 @@ class ChatActivity : private val onBackPressedCallback = object : OnBackPressedCallback(true) { override fun handleOnBackPressed() { if (isChatThread()) { - isEnabled = false - onBackPressedDispatcher.onBackPressed() + val intent = Intent(this@ChatActivity, ChatActivity::class.java) + intent.putExtra(KEY_ROOM_TOKEN, roomToken) + startActivity(intent) } else { val intent = Intent(this@ChatActivity, ConversationsListActivity::class.java) - intent.putExtras(Bundle()) startActivity(intent) } } From 63e06c8f6c2dd8b2e1667cef1e8aa3cdd0635543 Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Fri, 19 Sep 2025 12:52:05 +0200 Subject: [PATCH 3/3] modify backpress handling for threads only when coming from notification and backpress is done in a thread, then open the conversationlist Introducing the extra openedViaNotification for this is not a nice solution. But for release of 22.0.0 greater changes should be avoided. Best might be for take care of the backstack completely by activities intent flags instead to override handleOnBackPressed Signed-off-by: Marcel Hibbe --- .../main/java/com/nextcloud/talk/chat/ChatActivity.kt | 11 +++++++---- .../com/nextcloud/talk/jobs/NotificationWorker.kt | 2 ++ .../com/nextcloud/talk/utils/bundle/BundleKeys.kt | 1 + 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt b/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt index 43b9964f175..aecdd392da4 100644 --- a/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt @@ -205,6 +205,7 @@ import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_FILE_PATHS import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_INTERNAL_USER_ID import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_IS_BREAKOUT_ROOM import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_IS_MODERATOR +import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_OPENED_VIA_NOTIFICATION import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_RECORDING_STATE import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_TOKEN import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_START_CALL_AFTER_ROOM_SWITCH @@ -367,6 +368,7 @@ class ChatActivity : var sessionIdAfterRoomJoined: String? = null lateinit var roomToken: String var conversationThreadId: Long? = null + var openedViaNotification: Boolean = false var conversationThreadInfo: ThreadInfo? = null var conversationUser: User? = null lateinit var spreedCapabilities: SpreedCapability @@ -409,10 +411,9 @@ class ChatActivity : private val onBackPressedCallback = object : OnBackPressedCallback(true) { override fun handleOnBackPressed() { - if (isChatThread()) { - val intent = Intent(this@ChatActivity, ChatActivity::class.java) - intent.putExtra(KEY_ROOM_TOKEN, roomToken) - startActivity(intent) + if (!openedViaNotification && isChatThread()) { + isEnabled = false + onBackPressedDispatcher.onBackPressed() } else { val intent = Intent(this@ChatActivity, ConversationsListActivity::class.java) startActivity(intent) @@ -595,6 +596,8 @@ class ChatActivity : null } + openedViaNotification = extras?.getBoolean(KEY_OPENED_VIA_NOTIFICATION) ?: false + sharedText = extras?.getString(BundleKeys.KEY_SHARED_TEXT).orEmpty() Log.d(TAG, " roomToken = $roomToken") diff --git a/app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.kt b/app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.kt index 5fdfb8493c8..4a996cb5c5c 100644 --- a/app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.kt +++ b/app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.kt @@ -86,6 +86,7 @@ import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_TOKEN import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_SHARE_RECORDING_TO_CHAT_URL import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_SYSTEM_NOTIFICATION_ID import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_THREAD_ID +import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_OPENED_VIA_NOTIFICATION import com.nextcloud.talk.utils.preferences.AppPreferences import io.reactivex.Observable import io.reactivex.Observer @@ -989,6 +990,7 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor val bundle = Bundle() bundle.putString(KEY_ROOM_TOKEN, pushMessage.id) bundle.putLong(KEY_INTERNAL_USER_ID, signatureVerification.user!!.id!!) + bundle.putBoolean(KEY_OPENED_VIA_NOTIFICATION, true) intent.putExtras(bundle) return intent } diff --git a/app/src/main/java/com/nextcloud/talk/utils/bundle/BundleKeys.kt b/app/src/main/java/com/nextcloud/talk/utils/bundle/BundleKeys.kt index 7d6d5280a39..d31b7c6e388 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/bundle/BundleKeys.kt +++ b/app/src/main/java/com/nextcloud/talk/utils/bundle/BundleKeys.kt @@ -84,4 +84,5 @@ object BundleKeys { const val KEY_FOCUS_INPUT: String = "KEY_FOCUS_INPUT" const val KEY_THREAD_ID = "KEY_THREAD_ID" const val KEY_FROM_QR: String = "KEY_FROM_QR" + const val KEY_OPENED_VIA_NOTIFICATION: String = "KEY_OPENED_VIA_NOTIFICATION" }