When user changes which screens are enabled (homeEnabled/lockEnabled),
clear all album selections to ensure clean state:
**Scenarios where albums are cleared:**
- Lock only → Both screens enabled
- Home only → Both screens enabled
- Both screens → Lock only
- Both screens → Home only
- Lock only → Home only (both toggles change)
**Why this is needed:**
- Album requirements change when switching between single/dual screen modes
- Both screens enabled requires TWO albums selected
- Single screen requires ONE album selected
- Clearing prevents invalid state where old selections don't match new requirements
**Implementation:**
- Detect when homeEnabled or lockEnabled changes in updateScheduleSettings()
- If screen toggles changed, clear both homeAlbumId and lockAlbumId
- Apply validation to cleared settings
- Auto-toggle logic will disable changer (no albums selected)
- User must select appropriate albums for new screen configuration
**User flow:**
1. User toggles screen on/off
2. Albums automatically cleared
3. Changer disabled (no albums)
4. User selects new albums
5. Changer re-enabled with correct albums
This ensures users always have the correct album setup for their
chosen screen configuration.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Prevent redundant WorkManager job rescheduling when app starts:
**Problem:**
- Every time app starts, wallpaper change workers were being rescheduled
- Same with album refresh worker
- This caused unnecessary database writes and WorkManager operations
- Even when jobs were already correctly scheduled
**Solution:**
Added `onlyIfNotScheduled` parameter throughout the scheduling chain:
1. **WallpaperScheduler:**
- Added `isWorkScheduled()` and `isAlbumRefreshScheduled()` helpers
- Check WorkInfo state (ENQUEUED or RUNNING) before scheduling
- Skip scheduling if work already exists and `onlyIfNotScheduled = true`
2. **HomeViewModel:**
- Added `onlyIfNotScheduled` parameter to `toggleWallpaperChanger()`
- Added `onlyIfNotScheduled` parameter to `scheduleAlarms()`
- Skip immediate wallpaper change when checking if scheduled
- Propagate parameter through scheduling chain
3. **BootReceiver:**
- Use `onlyIfNotScheduled = true` on device boot
- Prevents rescheduling if jobs survived device restart
4. **HomeScreen:**
- Auto-toggle uses `onlyIfNotScheduled = true`
- Prevents rescheduling on every app startup
- User actions still always reschedule (parameter defaults to false)
**Behavior:**
- App startup: Only schedule if not already scheduled
- Device boot: Only schedule if not already scheduled
- User actions (album selection, settings changes): Always reschedule
- Album refresh: Only schedule if not already scheduled
This improves app startup performance and reduces unnecessary
WorkManager operations while maintaining correct scheduling behavior.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Improve robustness of wallpaper queue management:
**Problem:**
When the queue runs out DURING the validation loop (all remaining
wallpapers are invalid), the code returned an error without trying
to rebuild the queue. This could happen when:
- Album has both valid and invalid wallpapers
- Queue contains only invalid wallpapers after valid ones are used
- Validation loop dequeues all invalid wallpapers
- Queue becomes empty but is never rebuilt
**Solution:**
When getAndDequeueWallpaper returns null during validation loop:
1. Try rebuilding the queue (up to 2 attempts)
2. Continue validation loop to get wallpaper from rebuilt queue
3. Only return "no wallpapers" error after 2 rebuild attempts fail
**Edge Cases Handled:**
- Queue runs out due to invalid wallpapers being removed: rebuild and retry
- Album truly has no valid wallpapers: error after 2 rebuild attempts
- Shuffle mode: queue rebuilt with correct shuffle order
- Sequential mode: queue rebuilt with correct display order
This ensures the wallpaper changer continues working even when
encountering invalid wallpapers, and properly cycles through the
album whether shuffle is enabled or not.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
When wallpaper effects are toggled on and individual scheduling is off,
hide the description text for a cleaner UI:
- Grayscale effect
- Adaptive brightness
- Shuffle
Changes:
- Make SettingSwitch description parameter nullable
- Conditionally hide description when:
- Effect is enabled (checked = true)
- AND individual scheduling is OFF (separateSchedules = false)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Multiple fixes for scheduling logic and UI behavior:
**Scheduling Fixes:**
- Add required albums validation before scheduling WorkManager jobs
- Only schedule when all required albums are selected based on enabled screens
- Prevent scheduling with incomplete album selection (both screens enabled requires both albums)
- Add hasRequiredAlbums check in HomeViewModel, WallpaperScreen, and BootReceiver
**Race Condition Fixes:**
- Fix toggleWallpaperChanger race condition with atomic updateEnableChanger()
- Prevent phantom album selections by using atomic DataStore updates
- Fix startup race condition - only cleanup stale album IDs after albums load
**Display Settings:**
- Separate scheduling changes from display changes (ScheduleSettings.kt)
- Add hasSchedulingChanges() - intervals, screen enable/disable, separate schedules
- Add hasDisplayChanges() - scaling, effects, adaptive brightness
- Reapply wallpaper immediately when display settings change (no reschedule needed)
- Prevent unnecessary WorkManager rescheduling for display-only changes
**Effect Sliders:**
- Fix effect sliders to respect separateSchedules setting
- Show synchronized slider when individual scheduling OFF
- Show separate sliders when individual scheduling ON
- Applies to brightness/darken, blur, and vignette sliders
**AlbumRefreshWorker:**
- Fix duplicate detection to check both direct and folder wallpapers
- Fix failure counting (increment failedCount on addWallpaper errors)
- Prevent false error logs and database constraint violations
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>