Skip to content

High performance self-hosted photo and video management solution.

feat: add favorites support to android widget (#20061)

Brandon Wees99e5b33969bc
diff --git a/mobile/android/app/src/main/kotlin/app/alextran/immich/widget/ImageDownloadWorker.kt b/mobile/android/app/src/main/kotlin/app/alextran/immich/widget/ImageDownloadWorker.kt
index 2a23d0ecbd..3915f291f8 100644
--- a/mobile/android/app/src/main/kotlin/app/alextran/immich/widget/ImageDownloadWorker.kt
+++ b/mobile/android/app/src/main/kotlin/app/alextran/immich/widget/ImageDownloadWorker.kt
@@ -169,13 +169,16 @@ class ImageDownloadWorker(
): WidgetEntry {
val api = ImmichAPI(serverConfig)
- val filters = SearchFilters(AssetType.IMAGE)
+ val filters = SearchFilters()
val albumId = widgetConfig[kSelectedAlbum]
val showSubtitle = widgetConfig[kShowAlbumName]
val albumName = widgetConfig[kSelectedAlbumName]
var subtitle: String? = if (showSubtitle == true) albumName else ""
- if (albumId != null) {
+
+ if (albumId == "FAVORITES") {
+ filters.isFavorite = true
+ } else if (albumId != null) {
filters.albumIds = listOf(albumId)
}
@@ -183,7 +186,7 @@ class ImageDownloadWorker(
// handle an empty album, fallback to random
if (randomSearch.isEmpty() && albumId != null) {
- randomSearch = api.fetchSearchResults(SearchFilters(AssetType.IMAGE))
+ randomSearch = api.fetchSearchResults(SearchFilters())
subtitle = ""
}
@@ -215,7 +218,7 @@ class ImageDownloadWorker(
val yearDiff = today.year - memory.data.year
subtitle = "$yearDiff ${if (yearDiff == 1) "year" else "years"} ago"
} else {
- val filters = SearchFilters(AssetType.IMAGE, size=1)
+ val filters = SearchFilters(size=1)
asset = api.fetchSearchResults(filters).first()
}
diff --git a/mobile/android/app/src/main/kotlin/app/alextran/immich/widget/configure/RandomConfigure.kt b/mobile/android/app/src/main/kotlin/app/alextran/immich/widget/configure/RandomConfigure.kt
index d0490c023e..83e404a8f1 100644
--- a/mobile/android/app/src/main/kotlin/app/alextran/immich/widget/configure/RandomConfigure.kt
+++ b/mobile/android/app/src/main/kotlin/app/alextran/immich/widget/configure/RandomConfigure.kt
@@ -98,7 +98,7 @@ fun RandomConfiguration(context: Context, appWidgetId: Int, glanceId: GlanceId,
albumItems = listOf(DropdownItem(currentAlbumName, currentAlbumId))
}
- availableAlbums = listOf(DropdownItem("None", "NONE")) + albumItems
+ availableAlbums = listOf(DropdownItem("None", "NONE"), DropdownItem("Favorites", "FAVORITES")) + albumItems
// load selected configuration
val albumEntity = availableAlbums.firstOrNull { it.id == currentAlbumId }
diff --git a/mobile/android/app/src/main/kotlin/app/alextran/immich/widget/model/Model.kt b/mobile/android/app/src/main/kotlin/app/alextran/immich/widget/model/Model.kt
index 2337de0612..9595a3b696 100644
--- a/mobile/android/app/src/main/kotlin/app/alextran/immich/widget/model/Model.kt
+++ b/mobile/android/app/src/main/kotlin/app/alextran/immich/widget/model/Model.kt
@@ -17,7 +17,8 @@ data class Asset(
data class SearchFilters(
var type: AssetType = AssetType.IMAGE,
val size: Int = 1,
- var albumIds: List<String> = listOf()
+ var albumIds: List<String> = listOf(),
+ var isFavorite: Boolean? = null
)
data class MemoryResult(