From 2beae5be8e59624ce4077e69b1d6194c4ae650ad Mon Sep 17 00:00:00 2001 From: "Bundyo (Kamen Bundev)" Date: Fri, 4 Oct 2019 15:48:17 +0300 Subject: [PATCH] fix(css-android): restore elements' native features if offending css is removed while the app is running (#7789) --- tns-core-modules/ui/styling/background.android.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tns-core-modules/ui/styling/background.android.ts b/tns-core-modules/ui/styling/background.android.ts index 1828f3046..d52361363 100644 --- a/tns-core-modules/ui/styling/background.android.ts +++ b/tns-core-modules/ui/styling/background.android.ts @@ -40,7 +40,7 @@ export module ad { } const background = view.style.backgroundInternal; - const drawable = nativeView.getBackground(); + let drawable = nativeView.getBackground(); const androidView = 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 = (drawable).backgroundColor = background.color.android; drawable.mutate(); drawable.setColorFilter(backgroundColor, android.graphics.PorterDuff.Mode.SRC_IN);