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

This commit is contained in:
Brandon Wees 2025-07-21 14:51:16 -07:00 committed by GitHub
parent 7ea8783593
commit 99e5b33969
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 6 deletions

View File

@ -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()
}

View File

@ -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 }

View File

@ -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(