Skip to content

Commit

Permalink
Include shortcut rank in builder object
Browse files Browse the repository at this point in the history
Because profile list is already sorted by useCount, we can directly use
the profile index as rank.
  • Loading branch information
gujjwal00 committed Feb 7, 2024
1 parent 5ab6756 commit a316181
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/src/main/java/com/gaurav/avnc/ui/home/HomeActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,12 @@ class HomeActivity : AppCompatActivity() {
*/
private fun updateDynamicShortcuts(profiles: List<ServerProfile>) {
val maxShortcuts = ShortcutManagerCompat.getMaxShortcutCountPerActivity(this)
val shortcuts = profiles.take(maxShortcuts).map { p ->
val shortcuts = profiles.take(maxShortcuts).mapIndexed { i, p ->
ShortcutInfoCompat.Builder(this, createShortcutId(p))
.setIcon(IconCompat.createWithResource(this, R.drawable.ic_computer_shortcut))
.setShortLabel(p.name.ifBlank { p.host })
.setLongLabel(p.name.ifBlank { p.host })
.setRank(i)
.setIntent(IntentReceiverActivity.createShortcutIntent(this, p.ID))
.build()
}
Expand Down

0 comments on commit a316181

Please sign in to comment.