Set home and lock wallpaper with same bitmap to better support parallax
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.
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.
The test wallpaper (random 1080p test shot found online):
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:
- the image should fill the screen with no resizing, so swiping reveals more of the wallpaper (might be another option for original size in resizing)
- the same image/bitmap should be used as the lock screen/home screen so the x position is kept
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.
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:
- Add a None / Default option (you mentioned that one)
- Add a Fill with overflow, behaving like the fill, but keeping the larger dimensions (width/height)
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.
Can you clarify/show what you mean by artifacts and no wallpaper?
Added None scaling option in commit https://github.com/Anthonyy232/Paperize/commit/9f67243f0dd5d2ea350408dea2bad2bdaa1ea082