Skip to content

Commit 6d010f1

Browse files
committed
Do not exceed max number of shortcuts
1 parent 3ac0450 commit 6d010f1

File tree

2 files changed

+25
-20
lines changed

2 files changed

+25
-20
lines changed

app/src/main/java/ua/com/radiokot/photoprism/features/gallery/logic/SearchBookmarkShortcutsManager.kt

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,25 @@ class SearchBookmarkShortcutsManager(
2626

2727
ShortcutManagerCompat.setDynamicShortcuts(
2828
application,
29-
bookmarks.map { bookmark ->
30-
ShortcutInfoCompat.Builder(application, bookmark.id.toString())
31-
.setShortLabel(bookmark.name)
32-
.setIcon(
33-
IconCompat.createWithResource(
34-
application,
35-
R.drawable.ic_bookmark_shortcut
29+
bookmarks
30+
.take(ShortcutManagerCompat.getMaxShortcutCountPerActivity(application))
31+
.map { bookmark ->
32+
33+
ShortcutInfoCompat.Builder(application, bookmark.id.toString())
34+
.setShortLabel(bookmark.name)
35+
.setIcon(
36+
IconCompat.createWithResource(
37+
application,
38+
R.drawable.ic_bookmark_shortcut
39+
)
40+
)
41+
.setIntent(
42+
Intent(application, GalleryActivity::class.java)
43+
.setAction(GalleryActivity.ACTION_BOOKMARK_SHORTCUT)
44+
.putExtra(GalleryActivity.BOOKMARK_ID_EXTRA, bookmark.id)
3645
)
37-
)
38-
.setIntent(
39-
Intent(application, GalleryActivity::class.java)
40-
.setAction(GalleryActivity.ACTION_BOOKMARK_SHORTCUT)
41-
.putExtra(GalleryActivity.BOOKMARK_ID_EXTRA, bookmark.id)
42-
)
43-
.build()
44-
}
46+
.build()
47+
}
4548
)
4649
}
4750
}
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:viewportHeight="478" android:viewportWidth="478" android:width="24dp">
2-
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="478"
5+
android:viewportHeight="478">
6+
37
<group>
48

5-
<clip-path android:pathData="M0,0h478v478H0z"/>
6-
79
<path android:fillColor="#E1E0FF" android:pathData="M239,239m-239,0a239,239 0,1 1,478 0a239,239 0,1 1,-478 0"/>
810

911
<path android:fillColor="#5256A9" android:fillType="evenOdd" android:pathData="M311.7,120.8a29.6,29.6 0,0 1,29.5 29.6v177.1c0,11 -5.7,20.7 -15.3,26 -9.7,5.2 -21,4.8 -30.2,-1.1l-50.5,-32.5a7.8,7.8 0,0 0,-8.4 0l-50.5,32.5a29.2,29.2 0,0 1,-30.1 1,29.3 29.3,0 0,1 -15.4,-25.9v-177a29.6,29.6 0,0 1,29.5 -29.7h141.4ZM241,164a6.4,6.4 0,0 0,-5.8 3.6l-13.8,29 -32,4a6.4,6.4 0,0 0,-3.5 11l23.4,22 -6,31.4a6.4,6.4 0,0 0,9.4 6.8l28.3,-15.3 28.2,15.3c1,0.5 2,0.8 3.1,0.8a6.4,6.4 0,0 0,6.3 -7.6l-5.9,-31.4 23.4,-22a6.4,6.4 0,0 0,-3.6 -11l-31.9,-4 -13.8,-29a6.4,6.4 0,0 0,-5.8 -3.6Z"/>
1012

1113
</group>
12-
14+
1315
</vector>

0 commit comments

Comments
 (0)