Skip to content
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

Bubbles API support #1124

Open
kliu128 opened this issue Mar 9, 2020 · 12 comments
Open

Bubbles API support #1124

kliu128 opened this issue Mar 9, 2020 · 12 comments
Labels
A-Notifications A-Timeline T-Enhancement New features, changes in functionality, performance boosts, user-facing improvements

Comments

@kliu128
Copy link

kliu128 commented Mar 9, 2020

The Android 11 developer preview is introducing the Bubbles API, which allows chat apps to display notifications as openable bubbles much like Facebook Messenger.

It would be nice if RiotX supported this to make opening notifications more convenient.

@dkter
Copy link
Contributor

dkter commented Aug 14, 2020

I had a go at implementing bubbles but haven't figured it out yet. There are some API changes between the Android 10 and 11 versions of bubbles so it might make sense to hold off until AndroidX supports API 30

@gediminasel
Copy link

Hi, any updates on this?

@genofire
Copy link

Here is the implementation on signal signalapp/Signal-Android@e1bf232 maybe it helps the developer

@slikie
Copy link

slikie commented Mar 31, 2022

Is there any update on this?

@ouchadam ouchadam added T-Enhancement New features, changes in functionality, performance boosts, user-facing improvements A-Timeline A-Notifications labels Jun 21, 2022
@torrybr
Copy link

torrybr commented Jan 4, 2023

Any update on this?

@jadedpasta
Copy link

I have started to work on this. I haven't done any android dev since 2016, so progress may be really slow. But I really want to use this feature, so I thought I'd give it a shot.

I am able to get bubbles to expand without immediately crashing, but I still have a lot of work left.

@gordnhoo
Copy link

I have started to work on this. I haven't done any android dev since 2016, so progress may be really slow. But I really want to use this feature, so I thought I'd give it a shot.

I am able to get bubbles to expand without immediately crashing, but I still have a lot of work left.

Hi any updates on this would love to see this feature on element keep up the nice work 😀

@AmineI
Copy link

AmineI commented Sep 30, 2023

I had a go at this as well a while ago. I ended up at roughly the same point as the user above : The bubbles themselves work, but at the cost of a few features and issues, such as having to manually clear a notification.
To clear the notification properly, Google advises to

Update the BubbleMetadata to suppress the notification. Call BubbleMetadata.Builder.setSuppressNotification().

Cancelling a notification "as usual" also cancels the bubble, closing it instantly on opening the notification.
I have a hack-ish solution simply disabling cancelling notifications. You can find some the code here develop...AmineI:element-android:conversation_features

I've been using it for a while, but I've had no time or skills to dig deeper on this unfortunately. Signal's implementation could be helpful, or this Android sample, as well as this blog from Slack

@AmineI
Copy link

AmineI commented Jul 25, 2024

Came back to this and fixed the main blockers, such as the ability to properly dismiss conversations, mark them as read, etc. Also fixed some issues I've had with duplicate notification alerts that seem to be from element upstream.

Code is a bit messy right now but is available here :
develop...AmineI:element-android:feature/conversations_api
The last thing I'm stuck on is that when started from the launcher, Element opens the home view (and not the previously open conversation/view). Help would be welcome on that, but it is not that big of an issue for my personal use.

Bubbles work great and I've been using this nicely as a daily driver.

@mpeter50
Copy link

mpeter50 commented Sep 2, 2024

That is great to hear! Would you consider opening an MR to this repo?

@AmineI
Copy link

AmineI commented Sep 28, 2024

That is great to hear! Would you consider opening an MR to this repo?

Hi - I would be glad to. As it is, a PR would not be accepted however, due to the last 1-2 bugs and code format/quality. I am not skilled enough in Android development to meet the quality bar for contributions to this repo.

I need the extra help for that, which is why my code is public and help from the community or from Element would be super appreciated 🙂

Some tech details on the last bug

The main bug left is related to the activities : Every time Element is opened from the launcher, a new activity/task is added to the Android task list view, not reusing the previous ones.

This likely happens because the launcher activity documentLaunchMode is set to "always", as required for Bubbles to work. ( See https://developer.android.com/develop/ui/views/notifications/bubbles#bubble-api ) Not sure how to proceed or which activity to set as the bubble activity instead.

@mpeter50
Copy link

The main bug left is related to the activities : Every time Element is opened from the launcher, a new activity/task is added to the Android task list view, not reusing the previous ones.

This likely happens because the launcher activity documentLaunchMode is set to "always", as required for Bubbles to work. ( See https://developer.android.com/develop/ui/views/notifications/bubbles#bubble-api ) Not sure how to proceed or which activity to set as the bubble activity instead.

I'm not an experienced android developer either, but this is likely the cause of it by looking at the docs. Fun that they dont give a recommendation for this, even though I assume this would result in having multiple tasks in the recents view even for the same person/room.

I have taken a look at an other messaging app on my phone that I know supports bubbles (telegram), and does not have this issue. It seems to solve this by having a separate activity thats being opened by the launcher icon. Element X has defined its MainActivity as the one to be started by the launcher icon, and by looking at your branch, it seems thats what is used for the chat history too, not just the room list.

The solution (or one solution) would be to make a separate activity for starting from the launcher, like Telegram does it, move the intentfilter in the AndroidManifest.xml file that has the android.intent.category.LAUNCHER category to this new activity, and start MainActivity from here.
Telegram's launcher activity is quite.. contentful, with its nearly 8000 lines of code. I dont think that is needed here, but I would expect that some things might have to be moved from the current launcher activity.

If you open an MR, the devs may be able to give some tips, but also at least it is visible that there is an almost-implemented feature for supporting bubbles. An MR also grants permission for the Element repo owners write permissions to your branch, I believe.
But before the MR, a little code formatting cleanup is a good idea. Would you like some help regarding that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Notifications A-Timeline T-Enhancement New features, changes in functionality, performance boosts, user-facing improvements
Projects
None yet
Development

No branches or pull requests