fix(css-android): restore elements' native features if offending css is removed while the app is running (#7789)

This commit is contained in:
Bundyo (Kamen Bundev)
2019-10-04 15:48:17 +03:00
committed by Manol Donev
parent f82cf08f95
commit 2beae5be8e

View File

@ -40,7 +40,7 @@ export module ad {
}
const background = view.style.backgroundInternal;
const drawable = nativeView.getBackground();
let drawable = nativeView.getBackground();
const androidView = <any>view as AndroidView;
// use undefined as not set. getBackground will never return undefined only Drawable or null;
if (androidView._cachedDrawable === undefined && drawable) {
@ -50,12 +50,21 @@ export module ad {
if (isSetColorFilterOnlyWidget(nativeView)
&& drawable
&& !(drawable instanceof org.nativescript.widgets.BorderDrawable)
&& !background.hasBorderWidth()
&& !background.hasBorderRadius()
&& !background.clipPath
&& !background.image
&& background.color) {
if (drawable instanceof org.nativescript.widgets.BorderDrawable) {
if (!(androidView._cachedDrawable instanceof android.graphics.drawable.Drawable.ConstantState)) {
return;
}
drawable = androidView._cachedDrawable.newDrawable(nativeView.getResources());
nativeView.setBackground(drawable);
}
const backgroundColor = (<any>drawable).backgroundColor = background.color.android;
drawable.mutate();
drawable.setColorFilter(backgroundColor, android.graphics.PorterDuff.Mode.SRC_IN);