From 2abf5a180442401a44bb07c2a5e4d96d86e2979d Mon Sep 17 00:00:00 2001 From: Anthonyy232 Date: Sat, 28 Mar 2026 15:14:14 -0700 Subject: [PATCH] fix: BOTH mode renders lock screen separately at physical screen dimensions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- .../wallpaper/WallpaperChangeService.kt | 37 ++++++++++++++----- .../service/worker/WallpaperChangeWorker.kt | 34 ++++++++++++----- 2 files changed, 52 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/com/anthonyla/paperize/service/wallpaper/WallpaperChangeService.kt b/app/src/main/java/com/anthonyla/paperize/service/wallpaper/WallpaperChangeService.kt index b41d978..a35fa7a 100644 --- a/app/src/main/java/com/anthonyla/paperize/service/wallpaper/WallpaperChangeService.kt +++ b/app/src/main/java/com/anthonyla/paperize/service/wallpaper/WallpaperChangeService.kt @@ -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 { diff --git a/app/src/main/java/com/anthonyla/paperize/service/worker/WallpaperChangeWorker.kt b/app/src/main/java/com/anthonyla/paperize/service/worker/WallpaperChangeWorker.kt index 3446f6a..1029170 100644 --- a/app/src/main/java/com/anthonyla/paperize/service/worker/WallpaperChangeWorker.kt +++ b/app/src/main/java/com/anthonyla/paperize/service/worker/WallpaperChangeWorker.kt @@ -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