Closed brminnick closed 4 years ago
Hello.
OS: Android 5.0.1, 5.0.2
XF 4.6.0.800
I get this error every time when I go to a page with a element:
<rv:MaterialFrame IsVisible="true" MaterialTheme="Acrylic" CornerRadius="5" Margin="30,30,30,30" LightThemeBackgroundColor="#f1f1f1" />
It makes no difference, an emulator or device, a release or debug, whether the application is published in Google Play or not.
If I change MaterialTheme to a Light or AcrylicBlur , the page opens without errors.
It's an API issue with versions < 5.1. Will fix this this month after I release my next big XF component ;)
So as crazy as it seems setLayerInsetTop is only available on Marshmallow
and above (level 23).
But using LayerDrawable
for creating the Acrylic
effect is crazy efficient so I don't want to change the way it's implemented (for example using 2 views instead of one...'pouah' as we say in France).
Therefore this issue will be shamelessly fixed by just doesn't applying Acrylic
effect when api < 23, last fragmentation numbers are telling me it's nearly 10% of android devices. But for the GitTrend app for example, it should be closer to 1% since tech guys tend to have way more recent models than average population :)
@roubachof Interesting!
Instead of ignoring Acrylic on earlier versions of Android, I recommend throwing new NotSupportedException("Acrylic is only supported on Android API 23+")
and updating the README to note that Acrylic is only supported on Android 23+.
My concern is that future developers will also install Sharpnado.MaterialFrame
and implement Acrylic, unaware that their UI will look completely different on Lollipop than it does on Marshmallow (and up).
Mmmh I don't think it would be a good idea. It would mean that users with devices < api 23 will crash. Also devices with os < marshmallow represent a tiny number of all the Android devices. But it is a good idea to say that Acrylic glow is only supported on api >= 23!
The idea behind throwing a NotSupportedException
is to provide an actionable error message that helps developers discover and fix the problem before their users do.
Rather than ignoring the developer's request for Acrylic on <API 23, we want to crash the app because it isn't supported. We don't want developers to waste time debugging and troubleshooting why the UI looks different on Lollipop.
I'm not sure all developers would be ok with that. For my part I would prefer a degraded UI experience on devices < 23, but a still functioning app. Elevation on lollipop already looks ugly :) But I will also add a log error message.
@brminnick BTW, you can really easily recreate Acrylic effect with my last project https://github.com/roubachof/Sharpnado.Shadows. With 2 shades,
Platform:
Source Code is GitTrends v1.1.1: https://github.com/brminnick/GitTrends/releases/tag/v1.1.1
Describe the bug The following exception is thrown when calling
Sharpnado.MaterialFrame.Droid.AndroidMaterialFrameRenderer.SetAcrylicTheme
:non-static method "Landroid/graphics/drawable/LayerDrawable;.setLayerInsetTop(II)V
To Reproduce Unknown.
This crash has only happened once in the Google Play Store release of GitTrends v1.1.1 and I have been unable to reproduce it.
Exceptions (if applicable)