- Slack download profile photo update#
- Slack download profile photo android#
- Slack download profile photo code#
Slack download profile photo android#
To determine whether the user is sharing into Slack is simple: we can just check if intent.action is either SEND or SEND_MULTIPLE.ĭetermining if we’re launching into a Bubble is a bit trickier: Android 11 does not provide an official way to tell your shortcut is being opened by a Bubble. To achieve this, we had to resort to a Trampoline Activity: The activity we set as the target for the shortcut only has one job: Determine which of these three cases is happening, and then open the corresponding UI before closing itself.
The three entry points for Sharing Shortcuts
Slack download profile photo update#
Instead, we create a Sharing Shortcut with a placeholder icon and then create a JobScheduler job to asynchronously download the avatars, create the shortcut icon, and update the shortcut with the new icon.
Slack download profile photo code#
To solve for this, we don’t set Sharing Shortcut icons from the notification code path unless we have them cached already. Not only do we want to minimize latency so our users will get messages as quickly as possible, but we also only have limited time to process the push before Android’s Background Execution Limits kick in. Since we are creating these shortcuts from our notification codepath, execution time is a major concern. Sample Group DM Icon Asynchronous icon updates We then save that bitmap as a png in our app’s cache so we can access it next time we need to create a shortcut for that conversation. To achieve this icon, we fetch avatars from two users in the conversation and then draw them on a bitmap canvas. We decided to go with what seems to have established itself as a bit of a platform convention: Two circular avatars on a white background. Ideally, those icons should clearly represent the conversation at hand.įor Direct Messages, finding the right icon was trivial - we just use the user’s avatar! For Group DMs, however, it was a bit trickier.
Shortcuts in Android come with icons, which are displayed in three main places: On top of a notification, in the launcher when long-pressing the app icon, and in the sharing sheet. However, there’s some tricky details that warrant further discussion: Icons Our basic flow is to create a sharing shortcut for every notification pushed and every conversation opened in the app. Supporting this feature was a high priority for our Notification team because they are not just a requirement for Bubbles, but also for Notifications showing up in the Conversations space of the notification shade. Sharing ShortcutsĪfter we had MessagingStyle in place, the next step was to add support for Sharing Shortcuts. Luckily, we had recently rewritten our notification code and migrated it to MessagingStyle. This was a huge step forward from the previous approach where developers had to style their own messaging notifications using spans and string concatenation. MessagingStyle was introduced in Android 7 and gives developers a way of building notifications for messaging apps using structured data.
The notification needs to have an associated Sharing Shortcut.The notification needs to be built using MessagingStyle, the native Android API for messaging notifications.PrerequisitesĪccording to the official Android documentation, there are three basic requirements for supporting Bubbles from a notification: Some details were simplified where it made sense to, but stayed relatively close to our actual implementation overall. This post will describe how we built support for these bubbles, the challenges we faced along the way, and how we overcame them.