diff --git a/app/src/main/java/com/anthonyla/paperize/core/util/WallpaperUtil.kt b/app/src/main/java/com/anthonyla/paperize/core/util/WallpaperUtil.kt index 9e20546..4902523 100644 --- a/app/src/main/java/com/anthonyla/paperize/core/util/WallpaperUtil.kt +++ b/app/src/main/java/com/anthonyla/paperize/core/util/WallpaperUtil.kt @@ -143,6 +143,39 @@ fun getDeviceScreenSize(context: Context): Size { } } +/** + * Get the target render size for a wallpaper bitmap. + * + * For the HOME screen (and BOTH), the launcher may request a wider canvas than the physical + * screen to support horizontal parallax scrolling across multiple home-screen pages (e.g. + * Pixel Launcher with 3 pages requests ~3× screen width). If we render at physical-screen + * width and pass a null visibleCropHint to WallpaperManager.setBitmap(), Android scales the + * bitmap up to fill the launcher's desired width, which also enlarges the height and crops + * the top/bottom — making "FIT" behave identically to "FILL" from the user's perspective. + * + * Fix: use WallpaperManager.getDesiredMinimumWidth/Height as the render target for HOME/BOTH + * so the bitmap already fills the full parallax canvas. The launcher then has nothing to scale, + * and the chosen scaling mode (FIT, FILL, STRETCH, NONE) is preserved correctly. + * + * LOCK screen wallpapers are not parallax-scrolled, so the physical screen size is correct. + * LIVE wallpapers are rendered by GLRenderer directly; they do not go through this path. + */ +fun getWallpaperRenderSize(context: Context, screenType: com.anthonyla.paperize.core.ScreenType): Size { + val screen = getDeviceScreenSize(context) + return when (screenType) { + com.anthonyla.paperize.core.ScreenType.HOME, + com.anthonyla.paperize.core.ScreenType.BOTH -> { + val wm = WallpaperManager.getInstance(context) + val desiredW = wm.desiredMinimumWidth + val desiredH = wm.desiredMinimumHeight + // desiredMinimumWidth/Height return 0 when the launcher hasn't set a preference yet. + // Fall back to physical screen size in that case. + if (desiredW > 0 && desiredH > 0) Size(desiredW, desiredH) else screen + } + else -> screen + } +} + /** * Retrieve a bitmap from a URI that is scaled down to the device's screen size. * diff --git a/app/src/main/java/com/anthonyla/paperize/domain/usecase/ChangeWallpaperUseCase.kt b/app/src/main/java/com/anthonyla/paperize/domain/usecase/ChangeWallpaperUseCase.kt index 0e460ee..8cf0382 100644 --- a/app/src/main/java/com/anthonyla/paperize/domain/usecase/ChangeWallpaperUseCase.kt +++ b/app/src/main/java/com/anthonyla/paperize/domain/usecase/ChangeWallpaperUseCase.kt @@ -9,7 +9,7 @@ import com.anthonyla.paperize.core.NoValidWallpaperException import com.anthonyla.paperize.core.Result import com.anthonyla.paperize.core.ScreenType import com.anthonyla.paperize.core.util.adaptiveBrightnessAdjustment -import com.anthonyla.paperize.core.util.getDeviceScreenSize +import com.anthonyla.paperize.core.util.getWallpaperRenderSize import com.anthonyla.paperize.core.util.processBitmap import com.anthonyla.paperize.core.util.retrieveBitmap import com.anthonyla.paperize.domain.repository.SettingsRepository @@ -55,8 +55,9 @@ class ChangeWallpaperUseCase @Inject constructor( var maxRetries = Constants.MAX_WALLPAPER_LOAD_RETRIES var queueRebuildAttempts = 0 - // Get screen dimensions once for the retry loop - val screenSize = getDeviceScreenSize(context) + // Get render dimensions once for the retry loop. + // HOME/BOTH use the launcher's desired parallax canvas; LOCK uses physical screen. + val screenSize = getWallpaperRenderSize(context, screenType) val effects = when (screenType) { ScreenType.LIVE -> settings.liveEffects ScreenType.HOME, ScreenType.BOTH -> settings.homeEffects diff --git a/app/src/main/java/com/anthonyla/paperize/domain/usecase/ReapplyEffectsUseCase.kt b/app/src/main/java/com/anthonyla/paperize/domain/usecase/ReapplyEffectsUseCase.kt index d7c849d..8acc79b 100644 --- a/app/src/main/java/com/anthonyla/paperize/domain/usecase/ReapplyEffectsUseCase.kt +++ b/app/src/main/java/com/anthonyla/paperize/domain/usecase/ReapplyEffectsUseCase.kt @@ -7,7 +7,7 @@ import com.anthonyla.paperize.R import com.anthonyla.paperize.core.Result import com.anthonyla.paperize.core.ScreenType import com.anthonyla.paperize.core.util.adaptiveBrightnessAdjustment -import com.anthonyla.paperize.core.util.getDeviceScreenSize +import com.anthonyla.paperize.core.util.getWallpaperRenderSize import com.anthonyla.paperize.core.util.isValid import com.anthonyla.paperize.core.util.processBitmap import com.anthonyla.paperize.core.util.retrieveBitmap @@ -36,7 +36,7 @@ class ReapplyEffectsUseCase @Inject constructor( ?: return Result.Error(Exception(context.getString(R.string.error_no_valid_wallpaper_after_retries))) val settings = settingsRepository.getScheduleSettings() - val screenSize = getDeviceScreenSize(context) + val screenSize = getWallpaperRenderSize(context, screenType) val effects = when (screenType) { ScreenType.LIVE -> settings.liveEffects