Anthonyy232 / Paperize

Paperize is a dynamic wallpaper changer application built for Android using Kotlin, Jetpack Compose, and Material 3
https://anthonyy232.github.io/Paperize/
GNU General Public License v3.0
322 stars 15 forks source link

Set home and lock wallpaper with same bitmap to better support parallax #92

Closed repraze closed 3 days ago

repraze commented 3 weeks ago

On stock android 14, when setting the same image for the home screen and lock screen, the parallax position of the wallpaper is kept when locking/unlocking the device. When setting 2 different images, the parallax effect only works on the home screen.

Looking at the code, I see there is 2 wallpaper services (home, lock). We do a retrieveBitmap then a processBitmap. This means setWallpaper will generate a new bitmap every time and break the parallax effect on the lock screen.

I propose to create bitmap cache (maybe a lru limited to 2 bitmaps for now) keyed on the settings (uri, darken, blur, ...) to allow for same bitmap to be returned in each service. This might help a bit with processing / memory efficiency too - although minimal.

Anthonyy232 commented 3 weeks ago

Hey, I'll look into that if it's possible. By the way, would you mind recording what this parallax effect you're talking about is? I'm not sure I've seen it before.

repraze commented 3 weeks ago

The test wallpaper (random 1080p test shot found online):

UTm4Sg.jpg

This test is using the regular wallpaper settings menu:

https://github.com/user-attachments/assets/788c0c3d-7048-4e88-842b-ef64e256d7ed

This test is using the app:

https://github.com/user-attachments/assets/89e7b24f-3516-49b0-bb96-a9b15540d24c

Those are shot on a Pixel 7 Pro running android 14.

I believe for parallax to work great:

Anthonyy232 commented 3 weeks ago

So this seems to happen because processBitmap will scale the bitmap to either fit, fill, or stretch, then cut off the rest. Then there is no "leeway" for the parallax effect. I'll have to look into if this is fixable or not. The OEM device wallpaper doesn't really use any of the scaling methods. That doesn't work for this app because the idea is there are multiple wallpapers, so a standard crop which might look good on one wallpaper won't look good on another. I might add a NONE crop option, but that one is YMMV, it would only look good if the wallpaper is exactly the size of the device's resolution.

repraze commented 3 weeks ago

I have the same understanding. Essentially disabling scaling lets the phone take over.

I did a PR tonight with a toggle on the scaling option.

I also thought of a few alternatives for the scaling:

Unrelated / related to scaling: I found that fit is also buggy for me with artifacts where there is no wallpaper. (Worth another issue) Maybe rendering on a canvas / solid color background for fit or transparent images might help with that.

Anthonyy232 commented 3 weeks ago

Can you clarify/show what you mean by artifacts and no wallpaper?

Anthonyy232 commented 3 days ago

Added None scaling option in commit https://github.com/Anthonyy232/Paperize/commit/9f67243f0dd5d2ea350408dea2bad2bdaa1ea082