BlurView icon indicating copy to clipboard operation
BlurView copied to clipboard

Wrong activity background blurring effect

Open luongvo opened this issue 2 years ago • 6 comments

Please include:

  1. Library version: version-2.0.0
  2. Device and OS version: all API versions, tested on API 23 and 30
  3. Detailed steps to reproduce the issue
  • Added a new transparent fragment
  • Added a android:windowBackground attr
  • Checkout the blurring effect on topBlurView on transparent fragment
  1. XML layout and code for BlurView setup: Reproduce commit here https://github.com/luongvo/BlurView/commit/6835fd2b97593ec5eaf794d28f9c53a2a6953168

  2. Stacktrace in case of a crash: None

Expected: set android:background="@drawable/lines" in activity_main.xml could produce an expected result

https://user-images.githubusercontent.com/16315358/168729864-0a766a4c-7948-4954-8eed-a87b10978593.mp4

Actual: using <item name="android:windowBackground">@drawable/lines</item> in AppTheme and .setFrameClearDrawable(windowBackground) set in MainActivity does not work properly.

https://user-images.githubusercontent.com/16315358/168729902-c95bcc00-d2fa-4ce8-9095-ba130a6dc2b3.mp4

luongvo avatar May 17 '22 04:05 luongvo

Apparently, there's some weird bug with android:windowBackground as an image (BitmapDrawable). I'll see what I can do about it, but be aware that even regardless of this bug, your Expected result is probably impossible with setFrameClearDrawable, because the drawable doesn't have a trackable position on the screen.

That means, that even if I fix the bug, the bottom BlurView won't be able to properly blur the bottom of this drawable.

To fix this, you can either pass the (ViewGroup) getWindow().getDecorView() as a rootView, or set the background in activity_main.xml as you did.

Dimezis avatar May 17 '22 09:05 Dimezis

@Dimezis I tried to apply using getWindow().getDecorView() but it does not work.

This lib https://github.com/mmin18/RealtimeBlurView using the same approach but it works properly, here is the POC https://github.com/luongvo/RealtimeBlurView/commit/b87607a7fb1f76841b4cdd8f828a7c12949751b4. The bad thing is https://github.com/mmin18/RealtimeBlurView does not support latest API RenderEffect from API 31 and discontinued.

https://user-images.githubusercontent.com/16315358/168785323-c8e70297-d254-462d-b0f9-5c3d73c92e59.mp4

I think even there are some issues, we should support getWindow().getDecorView() directly from this nice library instead.

luongvo avatar May 17 '22 09:05 luongvo

I tried to apply using getWindow().getDecorView() but it does not work.

Can you post a commit with this change? It works fine for me on your branch

Dimezis avatar May 17 '22 10:05 Dimezis

@Dimezis I made a draft PR here, please check it out https://github.com/Dimezis/BlurView/pull/179 🙏

The update from the PR above still does not work:

Actual:

Expected:

luongvo avatar May 17 '22 10:05 luongvo

@Dimezis I think this logic could help https://github.com/mmin18/RealtimeBlurView/blob/master/library/src/com/github/mmin18/widget/RealtimeBlurView.java#L245-L261 🤔

luongvo avatar May 17 '22 10:05 luongvo

Responded - https://github.com/Dimezis/BlurView/pull/179#discussion_r874664955

Dimezis avatar May 17 '22 10:05 Dimezis