feat: restore an in-app change-now action
Integrates the aligned portion of #537 while retaining platform-controlled home-screen sizing.
This commit is contained in:
1 parent
bc513d666e
commit
063f05bdba
5 files changed
+54
-2
No files matched your search
@@ -125,6 +125,9 @@ fun HomeScreen(
|
||||
onSelectLiveAlbum = { album -> viewModel.selectLiveAlbum(album) },
|
||||
onUpdateScheduleSettings = { viewModel.updateScheduleSettings(it) },
|
||||
onUpdateScheduleSettingsDebounced = { viewModel.updateScheduleSettingsDebounced(it) },
|
||||
onChangeWallpaperNow = {
|
||||
viewModel.changeWallpaperNowForActiveScreens()
|
||||
},
|
||||
homeWallpaperUri = currentHomeWallpaperUri,
|
||||
lockWallpaperUri = currentLockWallpaperUri
|
||||
)
|
||||
|
||||
@@ -468,6 +468,33 @@ class HomeViewModel @Inject constructor(
|
||||
context.startForegroundService(intent)
|
||||
}
|
||||
|
||||
/**
|
||||
* Change whichever wallpaper destinations are currently configured.
|
||||
*
|
||||
* Synchronized home/lock settings use one BOTH request; independent schedules are
|
||||
* changed separately. LIVE is routed through the service to reload the renderer.
|
||||
*/
|
||||
fun changeWallpaperNowForActiveScreens() {
|
||||
val settings = scheduleSettings.value
|
||||
if (wallpaperMode.value == com.anthonyla.paperize.core.WallpaperMode.LIVE) {
|
||||
changeWallpaperNow(ScreenType.LIVE)
|
||||
return
|
||||
}
|
||||
|
||||
val homeActive = settings.homeEnabled && settings.homeAlbumId != null
|
||||
val lockActive = settings.lockEnabled && settings.lockAlbumId != null
|
||||
val synchronized = homeActive && lockActive &&
|
||||
settings.homeAlbumId == settings.lockAlbumId &&
|
||||
!settings.separateSchedules
|
||||
|
||||
if (synchronized) {
|
||||
changeWallpaperNow(ScreenType.BOTH)
|
||||
} else {
|
||||
if (homeActive) changeWallpaperNow(ScreenType.HOME)
|
||||
if (lockActive) changeWallpaperNow(ScreenType.LOCK)
|
||||
}
|
||||
}
|
||||
|
||||
fun reapplyEffectsNow(screenType: ScreenType) {
|
||||
val intent = Intent(context, WallpaperChangeService::class.java).apply {
|
||||
action = WallpaperChangeService.ACTION_REAPPLY_EFFECTS
|
||||
|
||||
+18
@@ -15,6 +15,7 @@ import androidx.compose.material.icons.automirrored.filled.ArrowForward
|
||||
import androidx.compose.material.icons.filled.Home
|
||||
import androidx.compose.material.icons.filled.Lock
|
||||
import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.CardDefaults
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
@@ -70,6 +71,7 @@ fun WallpaperScreen(
|
||||
onSelectLiveAlbum: (AlbumSummary?) -> Unit,
|
||||
onUpdateScheduleSettings: (ScheduleSettings) -> Unit,
|
||||
onUpdateScheduleSettingsDebounced: (ScheduleSettings) -> Unit,
|
||||
onChangeWallpaperNow: () -> Unit,
|
||||
homeWallpaperUri: String?,
|
||||
lockWallpaperUri: String?,
|
||||
modifier: Modifier = Modifier
|
||||
@@ -632,6 +634,22 @@ fun WallpaperScreen(
|
||||
}
|
||||
}
|
||||
|
||||
if (scheduleSettings.enableChanger) {
|
||||
Button(
|
||||
onClick = onChangeWallpaperNow,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(
|
||||
PaddingValues(
|
||||
horizontal = AppSpacing.small,
|
||||
vertical = AppSpacing.extraSmall
|
||||
)
|
||||
)
|
||||
) {
|
||||
Text(text = stringResource(R.string.change_wallpaper_now))
|
||||
}
|
||||
}
|
||||
|
||||
// Shuffle Card
|
||||
Card(
|
||||
shape = MaterialTheme.shapes.medium,
|
||||
|
||||
+5
-2
@@ -119,8 +119,11 @@ class WallpaperChangeService : Service() {
|
||||
|
||||
when (screenType) {
|
||||
ScreenType.LIVE -> {
|
||||
// Live wallpaper changes are handled by the live wallpaper service
|
||||
Log.d(TAG, "Live wallpaper - no action needed in service")
|
||||
val reloadIntent = Intent(Constants.ACTION_RELOAD_WALLPAPER).apply {
|
||||
setPackage(packageName)
|
||||
}
|
||||
sendBroadcast(reloadIntent)
|
||||
Log.d(TAG, "Requested immediate live wallpaper reload")
|
||||
}
|
||||
ScreenType.HOME -> {
|
||||
val homeAlbumId = settings.homeAlbumId
|
||||
|
||||
@@ -210,5 +210,6 @@
|
||||
<string name="ignoring">Ignoring (Recommended)</string>
|
||||
<string name="optimizing">Optimizing (May delay changes)</string>
|
||||
<string name="reliability">Reliability</string>
|
||||
<string name="change_wallpaper_now">Change wallpaper now</string>
|
||||
|
||||
</resources>
|
||||
Reference in new issue
Block a user