mirror of
https://github.com/immich-app/immich.git
synced 2025-07-31 15:08:44 -04:00
feat: add favorites support to android widget (#20061)
This commit is contained in:
parent
7ea8783593
commit
99e5b33969
@ -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()
|
||||
}
|
||||
|
||||
|
@ -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 }
|
||||
|
@ -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(
|
||||
|
Loading…
x
Reference in New Issue
Block a user