fix: BOTH mode renders lock screen separately at physical screen dimensions

In BOTH mode, the same HOME-sized bitmap (wide parallax canvas, e.g.
4032x2992) was reused for the lock screen via setBitmap(FLAG_LOCK).
The lock screen has no parallax, so Android center-cropped the wide
bitmap — defeating FIT/NONE modes which should letterbox, not crop.

Fix: after setting HOME, sync the LOCK queue, then re-render the same
wallpaper via reapplyEffectsUseCase(ScreenType.LOCK) at the physical
screen dimensions. Falls back to the old behavior if re-render fails.

Applied to both WallpaperChangeService and WallpaperChangeWorker.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Anthonyy232andClaude Opus 4.6 committed 2026-03-28 15:14:14 -07:00
1 parent 6884559b6b
commit 2abf5a1804
2 files changed
+52 -19

No files matched your search

@@ -157,22 +157,14 @@ class WallpaperChangeService : Service() {
throw IllegalStateException("Bitmap has been recycled")
}
// Set for home screen
// Set for home screen (rendered at parallax canvas size)
wallpaperManager.setBitmap(
bitmap,
null,
true,
WallpaperManager.FLAG_SYSTEM
)
// Set for lock screen
wallpaperManager.setBitmap(
bitmap,
null,
true,
WallpaperManager.FLAG_LOCK
)
Log.d(TAG, "Same wallpaper set for both screens")
Log.d(TAG, "Home wallpaper set in BOTH mode")
// Keep LOCK queue in sync with HOME so that if the user later
// switches to separate schedules, both screens continue from
@@ -195,6 +187,31 @@ class WallpaperChangeService : Service() {
} catch (e: Exception) {
Log.w(TAG, "Failed to sync LOCK queue in BOTH mode", e)
}
// Render a separate bitmap for the lock screen at physical
// screen dimensions. The HOME bitmap was sized for the
// launcher's parallax canvas which is typically wider than
// the screen; reusing it for LOCK would let Android
// center-crop it, defeating FIT/NONE scaling modes.
val lockResult = reapplyEffectsUseCase(homeAlbumId, ScreenType.LOCK)
lockResult.onSuccess { lockBitmap ->
try {
wallpaperManager.setBitmap(
lockBitmap, null, true, WallpaperManager.FLAG_LOCK
)
Log.d(TAG, "Lock wallpaper set separately in BOTH mode")
} catch (e: Exception) {
Log.e(TAG, "Error setting lock wallpaper in BOTH mode", e)
} finally {
lockBitmap.recycle()
}
}.onError {
// Fallback: use the HOME bitmap for LOCK (old behavior)
Log.w(TAG, "Lock rerender failed in BOTH mode, using HOME bitmap")
wallpaperManager.setBitmap(
bitmap, null, true, WallpaperManager.FLAG_LOCK
)
}
} catch (e: Exception) {
Log.e(TAG, "Error setting wallpaper for both screens", e)
} finally {
@@ -12,6 +12,7 @@ import com.anthonyla.paperize.core.constants.Constants
import com.anthonyla.paperize.domain.repository.SettingsRepository
import com.anthonyla.paperize.domain.repository.WallpaperRepository
import com.anthonyla.paperize.domain.usecase.ChangeWallpaperUseCase
import com.anthonyla.paperize.domain.usecase.ReapplyEffectsUseCase
import com.anthonyla.paperize.service.WallpaperChangeLock
import dagger.assisted.Assisted
import dagger.assisted.AssistedInject
@@ -28,6 +29,7 @@ class WallpaperChangeWorker @AssistedInject constructor(
@Assisted private val context: Context,
@Assisted workerParams: WorkerParameters,
private val changeWallpaperUseCase: ChangeWallpaperUseCase,
private val reapplyEffectsUseCase: ReapplyEffectsUseCase,
private val settingsRepository: SettingsRepository,
private val wallpaperRepository: WallpaperRepository,
private val wallpaperChangeLock: WallpaperChangeLock
@@ -111,21 +113,14 @@ class WallpaperChangeWorker @AssistedInject constructor(
Log.d(TAG, "Setting both screens - size: ${bitmap.width}x${bitmap.height}, config: ${bitmap.config}")
// Set HOME (rendered at parallax canvas size)
wallpaperManager.setBitmap(
bitmap,
null,
true,
WallpaperManager.FLAG_SYSTEM
)
wallpaperManager.setBitmap(
bitmap,
null,
true,
WallpaperManager.FLAG_LOCK
)
Log.d(TAG, "Both screens wallpaper changed successfully")
Log.d(TAG, "Home wallpaper set in BOTH mode")
// Keep LOCK queue in sync with HOME so that if the user later
// switches to separate schedules, both screens continue from
@@ -147,6 +142,27 @@ class WallpaperChangeWorker @AssistedInject constructor(
} catch (e: Exception) {
Log.w(TAG, "Failed to sync LOCK queue in BOTH mode", e)
}
// Render a separate bitmap for the lock screen at physical
// screen dimensions (no parallax on lock screen).
val lockResult = reapplyEffectsUseCase(homeAlbumId, ScreenType.LOCK)
lockResult.onSuccess { lockBitmap ->
try {
wallpaperManager.setBitmap(
lockBitmap, null, true, WallpaperManager.FLAG_LOCK
)
Log.d(TAG, "Lock wallpaper set separately in BOTH mode")
} catch (e: Exception) {
Log.e(TAG, "Error setting lock wallpaper in BOTH mode", e)
} finally {
lockBitmap.recycle()
}
}.onError {
Log.w(TAG, "Lock rerender failed in BOTH mode, using HOME bitmap")
wallpaperManager.setBitmap(
bitmap, null, true, WallpaperManager.FLAG_LOCK
)
}
} catch (e: Exception) {
Log.e(TAG, "Error setting wallpaper for both screens", e)
throw e