From 2004d357d549f968fe16aac78ea5e32abdd1fb1b Mon Sep 17 00:00:00 2001 From: David Teresi Date: Wed, 25 Aug 2021 14:58:14 -0400 Subject: [PATCH] Insert room shortcuts in order This prevents shortcuts from momentarily being shown out of order while the shortcut list is in the process of being updated. --- .../java/im/vector/app/features/home/ShortcutCreator.kt | 3 ++- .../java/im/vector/app/features/home/ShortcutsHandler.kt | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/ShortcutCreator.kt b/vector/src/main/java/im/vector/app/features/home/ShortcutCreator.kt index b40666d1cf8..9b0ba644917 100644 --- a/vector/src/main/java/im/vector/app/features/home/ShortcutCreator.kt +++ b/vector/src/main/java/im/vector/app/features/home/ShortcutCreator.kt @@ -58,7 +58,7 @@ class ShortcutCreator @Inject constructor( } @WorkerThread - fun create(roomSummary: RoomSummary): ShortcutInfoCompat { + fun create(roomSummary: RoomSummary, rank: Int = 1): ShortcutInfoCompat { val intent = RoomDetailActivity.shortcutIntent(context, roomSummary.roomId) val bitmap = try { avatarRenderer.shortcutDrawable(GlideApp.with(context), roomSummary.toMatrixItem(), iconSize) @@ -70,6 +70,7 @@ class ShortcutCreator @Inject constructor( .setIcon(bitmap?.toProfileImageIcon()) .setIntent(intent) .setLongLived(true) + .setRank(rank) // Make it show up in the direct share menu .setCategories(setOf( diff --git a/vector/src/main/java/im/vector/app/features/home/ShortcutsHandler.kt b/vector/src/main/java/im/vector/app/features/home/ShortcutsHandler.kt index 702a15b606f..c3249f5b267 100644 --- a/vector/src/main/java/im/vector/app/features/home/ShortcutsHandler.kt +++ b/vector/src/main/java/im/vector/app/features/home/ShortcutsHandler.kt @@ -58,9 +58,9 @@ class ShortcutsHandler @Inject constructor( .filter { !roomIds.contains(it) } ShortcutManagerCompat.removeLongLivedShortcuts(context, deadShortcutIds) - val shortcuts = rooms - .asReversed() - .map { shortcutCreator.create(it) } + val shortcuts = rooms.mapIndexed { index, room -> + shortcutCreator.create(room, index) + } shortcuts.forEach { shortcut -> ShortcutManagerCompat.pushDynamicShortcut(context, shortcut)