Add shortcut suggestions for rooms, remove then when leaving (#5180)
* Report shortcut usage for outgoing messages This patch adds support for creating and pushing dynamic long-lived shortcuts for outgoing messages. This together with an existing reference to the roomId used by the shortcuts as an identifer allows conversations to be prioritized. See https://developer.android.com/training/sharing/direct-share-targets#report-usage-outgoing * Simplify how to get the other user in a DM room * Add initial avatar icons to shortcuts * Remove room shortcuts when they're no longer joined * Try using API 33 for the new tests. They worked locally with API 30, so it's weird the CI asks for a higher API version. * Add observers for the pin code and session logout states. With this we can prevent new shortcuts from being created and remove existing ones when needed. * Wrap all calls to `ShortcutManagerCompat` with `runCatchingExceptions` to avoid crashes * Make `DefaultNotificationConversationService` a singleton. --------- Co-authored-by: networkException <git@nwex.de> Co-authored-by: ElementBot <android@element.io>
This commit is contained in:
parent
35928e3630
commit
9bc2c4a776
27 changed files with 681 additions and 27 deletions
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* Copyright 2025 New Vector Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
package io.element.android.libraries.push.test.notifications.conversations
|
||||
|
||||
import io.element.android.libraries.matrix.api.core.RoomId
|
||||
import io.element.android.libraries.matrix.api.core.SessionId
|
||||
import io.element.android.libraries.push.api.notifications.conversations.NotificationConversationService
|
||||
|
||||
class FakeNotificationConversationService : NotificationConversationService {
|
||||
override suspend fun onSendMessage(
|
||||
sessionId: SessionId,
|
||||
roomId: RoomId,
|
||||
roomName: String,
|
||||
roomIsDirect: Boolean,
|
||||
roomAvatarUrl: String?,
|
||||
) = Unit
|
||||
|
||||
override suspend fun onLeftRoom(sessionId: SessionId, roomId: RoomId) = Unit
|
||||
|
||||
override suspend fun onAvailableRoomsChanged(sessionId: SessionId, roomIds: Set<RoomId>) = Unit
|
||||
}
|
||||
|
|
@ -13,11 +13,11 @@ import coil3.ImageLoader
|
|||
import io.element.android.libraries.push.api.notifications.NotificationBitmapLoader
|
||||
|
||||
class FakeNotificationBitmapLoader(
|
||||
var getRoomBitmapResult: (String?, ImageLoader) -> Bitmap? = { _, _ -> null },
|
||||
var getRoomBitmapResult: (String?, ImageLoader, Long) -> Bitmap? = { _, _, _ -> null },
|
||||
var getUserIconResult: (String?, ImageLoader) -> IconCompat? = { _, _ -> null },
|
||||
) : NotificationBitmapLoader {
|
||||
override suspend fun getRoomBitmap(path: String?, imageLoader: ImageLoader): Bitmap? {
|
||||
return getRoomBitmapResult(path, imageLoader)
|
||||
override suspend fun getRoomBitmap(path: String?, imageLoader: ImageLoader, targetSize: Long): Bitmap? {
|
||||
return getRoomBitmapResult(path, imageLoader, targetSize)
|
||||
}
|
||||
|
||||
override suspend fun getUserIcon(path: String?, imageLoader: ImageLoader): IconCompat? {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue