-
-
Notifications
You must be signed in to change notification settings - Fork 287
Adding bubbles support #5554
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Adding bubbles support #5554
Conversation
|
|
||
| // Use the same notification ID calculation as NotificationWorker | ||
| // Show notification with bubble | ||
| notificationManager.notify(notificationId, notification) |
Check failure
Code scanning / CodeQL
Use of implicit PendingIntents High
An implicit Intent is created
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check the details at https://github.com/nextcloud/talk-android/security/code-scanning/92 which contains recommendations how to avoid this.
Using FLAG_IMMUTABLE was also done in other parts of the app.
|
thank you @arlexTech |
mahibi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @arlexTech ! 👍
The bubbles itself work for me, however there are some things that must be changed:
Don't show conversation list and modify back button handling
I strongly suggest to not open the conversation list when pressing back button in bubbled mode.
So the bubbled view should not show the conversation list at all but only single conversations. Otherwise i'm concerned of bugs when having multiple instance of the ConversationListActivity.
For the back button in bubbled mode, either:
- just close the bubble (This is how Telegram does it)
- or replace the back button with a the talk icon which will open the app in normal mode and the conversation list is shown (This is how signal does it and it'S also my preferred solution)
Avoid multiple instance of ChatActivity for same conversation
Also, we should make sure that there are not multiple instances of ChatActivity for the same conversation.
Right now, the PR has a bug that multiple instances are shown when "open is app" is used.
https://developer.android.com/develop/ui/views/notifications/bubbles#launching-activities
But also we should not allow to have 2 instances for the same conversation when one is opened in normal mode and one in bubble mode.
This is very important to avoid bugs in the chat repository (OfflineFirstChatRepository)!
Signal solved it this way: Whenever there is a bubble for a chat and the chat is also opened in the normal mode, the bubble closes.
We should solve it the same way and try to use only one instance of ChatActivity for a conversation.
| moveTaskToBack(false) | ||
| } | ||
|
|
||
| override fun onBackPressed() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as onBackPressed is deprecated we want to avoid it and use onBackPressedDispatcher
| private fun openInMainApp() { | ||
| val intent = Intent(this, ChatActivity::class.java).apply { | ||
| putExtras(this@BubbleActivity.intent) | ||
| flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
multiple instances of the app are opened when "open is app" is used.
https://developer.android.com/develop/ui/views/notifications/bubbles#launching-activities
|
|
||
| // Use the same notification ID calculation as NotificationWorker | ||
| // Show notification with bubble | ||
| notificationManager.notify(notificationId, notification) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check the details at https://github.com/nextcloud/talk-android/security/code-scanning/92 which contains recommendations how to avoid this.
Using FLAG_IMMUTABLE was also done in other parts of the app.
| val locusId = androidx.core.content.LocusIdCompat(ensuredShortcutId) | ||
| notificationBuilder.setShortcutId(ensuredShortcutId) | ||
| notificationBuilder.setLocusId(locusId) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please try to extract the above code into a method
| // Use a consistent ID based on the room token to avoid duplicate bubbles | ||
| val systemNotificationId: Int = | ||
| activeStatusBarNotification?.id ?: calculateCRC32(System.currentTimeMillis().toString()).toInt() | ||
| activeStatusBarNotification?.id ?: NotificationUtils.calculateCRC32(pushMessage.id!!).toInt() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i am not 100% if using the room token could cause unwanted side effects. will have to think about and test when i have better internet connection ;)
|
@rapterjet2004 @sowjanyakch please also do a deep review. E.g. specially check if former notification handling is affected by the changes. |
| ) | ||
| .setPriority(NotificationCompat.PRIORITY_HIGH) | ||
| .setCategory(category) | ||
| .setLargeIcon(getLargeIcon()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this removed?
|
I'll work on it this week (don't mind the review request i miss clicked) |
Sure, thanks. Let us know if there are any questions or help is needed! |
Issue: #3384
🖼️ Screenshots
VID_20251114124529.mp4
Record_2025-11-14-12-44-40.mp4
🚧 TODO
🏁 Checklist
/backport to stable-xx.x