Paperize icon indicating copy to clipboard operation
Paperize copied to clipboard

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

Open repraze opened this issue 1 year ago • 5 comments

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.

repraze avatar Aug 19 '24 09:08 repraze

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.

Anthonyy232 avatar Aug 19 '24 09:08 Anthonyy232

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:

  • 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

repraze avatar Aug 19 '24 11:08 repraze

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.

Anthonyy232 avatar Aug 20 '24 19:08 Anthonyy232

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.

repraze avatar Aug 20 '24 22:08 repraze

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

Anthonyy232 avatar Aug 22 '24 05:08 Anthonyy232

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

Anthonyy232 avatar Sep 10 '24 20:09 Anthonyy232