mirror of
https://github.com/immich-app/immich.git
synced 2025-07-09 03:04:16 -04:00
album name handling
This commit is contained in:
parent
ada0f984b8
commit
42e53232c3
@ -153,7 +153,9 @@ class ImageDownloadWorker(
|
|||||||
|
|
||||||
val filters = SearchFilters(AssetType.IMAGE, size=1)
|
val filters = SearchFilters(AssetType.IMAGE, size=1)
|
||||||
val albumId = widgetConfig[kSelectedAlbum]
|
val albumId = widgetConfig[kSelectedAlbum]
|
||||||
|
val showSubtitle = widgetConfig[kShowAlbumName]
|
||||||
val albumName = widgetConfig[kSelectedAlbumName]
|
val albumName = widgetConfig[kSelectedAlbumName]
|
||||||
|
val subtitle: String? = if (showSubtitle == true) albumName else ""
|
||||||
|
|
||||||
if (albumId != null) {
|
if (albumId != null) {
|
||||||
filters.albumIds = listOf(albumId)
|
filters.albumIds = listOf(albumId)
|
||||||
@ -162,7 +164,7 @@ class ImageDownloadWorker(
|
|||||||
val random = api.fetchSearchResults(filters).first()
|
val random = api.fetchSearchResults(filters).first()
|
||||||
val image = api.fetchImage(random)
|
val image = api.fetchImage(random)
|
||||||
|
|
||||||
return Pair(image, albumName)
|
return Pair(image, subtitle)
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun fetchMemory(
|
private suspend fun fetchMemory(
|
||||||
|
@ -3,15 +3,17 @@ package app.alextran.immich.widget
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
|
import androidx.compose.ui.unit.*
|
||||||
import androidx.datastore.preferences.core.MutablePreferences
|
import androidx.datastore.preferences.core.MutablePreferences
|
||||||
import androidx.glance.appwidget.*
|
import androidx.glance.appwidget.*
|
||||||
import androidx.glance.*
|
import androidx.glance.*
|
||||||
import androidx.glance.layout.Box
|
import androidx.glance.action.clickable
|
||||||
import androidx.glance.layout.ContentScale
|
import androidx.glance.layout.*
|
||||||
import androidx.glance.layout.fillMaxSize
|
|
||||||
import androidx.glance.state.GlanceStateDefinition
|
import androidx.glance.state.GlanceStateDefinition
|
||||||
import androidx.glance.state.PreferencesGlanceStateDefinition
|
import androidx.glance.state.PreferencesGlanceStateDefinition
|
||||||
import androidx.glance.text.Text
|
import androidx.glance.text.Text
|
||||||
|
import androidx.glance.text.TextStyle
|
||||||
|
import androidx.glance.unit.ColorProvider
|
||||||
import app.alextran.immich.R
|
import app.alextran.immich.R
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
@ -48,8 +50,28 @@ class PhotoWidget : GlanceAppWidget() {
|
|||||||
contentScale = ContentScale.Crop,
|
contentScale = ContentScale.Crop,
|
||||||
modifier = GlanceModifier.fillMaxSize()
|
modifier = GlanceModifier.fillMaxSize()
|
||||||
)
|
)
|
||||||
if (subtitle != null)
|
|
||||||
Text(subtitle)
|
if (!subtitle.isNullOrBlank()) {
|
||||||
|
Column(
|
||||||
|
verticalAlignment = Alignment.Bottom,
|
||||||
|
horizontalAlignment = Alignment.Start,
|
||||||
|
modifier = GlanceModifier
|
||||||
|
.fillMaxSize()
|
||||||
|
.padding(12.dp)
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = subtitle,
|
||||||
|
style = TextStyle(
|
||||||
|
color = ColorProvider(Color.White),
|
||||||
|
fontSize = 16.sp
|
||||||
|
),
|
||||||
|
modifier = GlanceModifier
|
||||||
|
.background(ColorProvider(Color(0x99000000))) // 60% black
|
||||||
|
.padding(8.dp)
|
||||||
|
.cornerRadius(8.dp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Image(
|
Image(
|
||||||
provider = ImageProvider(R.drawable.splash),
|
provider = ImageProvider(R.drawable.splash),
|
||||||
|
@ -27,6 +27,7 @@ import app.alextran.immich.widget.ImmichAPI
|
|||||||
import app.alextran.immich.widget.WidgetState
|
import app.alextran.immich.widget.WidgetState
|
||||||
import app.alextran.immich.widget.WidgetType
|
import app.alextran.immich.widget.WidgetType
|
||||||
import app.alextran.immich.widget.kSelectedAlbum
|
import app.alextran.immich.widget.kSelectedAlbum
|
||||||
|
import app.alextran.immich.widget.kSelectedAlbumName
|
||||||
import app.alextran.immich.widget.kShowAlbumName
|
import app.alextran.immich.widget.kShowAlbumName
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
@ -100,6 +101,7 @@ fun RandomConfiguration(context: Context, appWidgetId: Int, glanceId: GlanceId,
|
|||||||
suspend fun saveConfiguration() {
|
suspend fun saveConfiguration() {
|
||||||
updateAppWidgetState(context, glanceId) { prefs ->
|
updateAppWidgetState(context, glanceId) { prefs ->
|
||||||
prefs[kSelectedAlbum] = selectedAlbum?.id ?: ""
|
prefs[kSelectedAlbum] = selectedAlbum?.id ?: ""
|
||||||
|
prefs[kSelectedAlbumName] = selectedAlbum?.label ?: ""
|
||||||
prefs[kShowAlbumName] = showAlbumName
|
prefs[kShowAlbumName] = showAlbumName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user