diff --git a/android/titanium/src/java/org/appcelerator/titanium/TiC.java b/android/titanium/src/java/org/appcelerator/titanium/TiC.java index ba16735471d..fe784baa1c9 100644 --- a/android/titanium/src/java/org/appcelerator/titanium/TiC.java +++ b/android/titanium/src/java/org/appcelerator/titanium/TiC.java @@ -796,6 +796,7 @@ public class TiC public static final String PROPERTY_VISIBILITY = "visibility"; public static final String PROPERTY_VISIBLE_ITEM_COUNT = "visibleItemCount"; public static final String PROPERTY_VIEW = "view"; + public static final String PROPERTY_VIEW_SHADOW_COLOR = "viewShadowColor"; public static final String PROPERTY_VIEWS = "views"; public static final String PROPERTY_VOLUME = "volume"; public static final String PROPERTY_WAKE_LOCK = "wakeLock"; diff --git a/android/titanium/src/java/org/appcelerator/titanium/proxy/TiViewProxy.java b/android/titanium/src/java/org/appcelerator/titanium/proxy/TiViewProxy.java index 0a6bedb8c06..171cab8a7f0 100644 --- a/android/titanium/src/java/org/appcelerator/titanium/proxy/TiViewProxy.java +++ b/android/titanium/src/java/org/appcelerator/titanium/proxy/TiViewProxy.java @@ -85,6 +85,7 @@ TiC.PROPERTY_SOFT_KEYBOARD_ON_FOCUS, TiC.PROPERTY_TRANSFORM, TiC.PROPERTY_ELEVATION, + TiC.PROPERTY_VIEW_SHADOW_COLOR, TiC.PROPERTY_TRANSLATION_X, TiC.PROPERTY_TRANSLATION_Y, TiC.PROPERTY_TRANSLATION_Z, diff --git a/android/titanium/src/java/org/appcelerator/titanium/view/TiUIView.java b/android/titanium/src/java/org/appcelerator/titanium/view/TiUIView.java index 1af4b2f486d..1b40012fd22 100644 --- a/android/titanium/src/java/org/appcelerator/titanium/view/TiUIView.java +++ b/android/titanium/src/java/org/appcelerator/titanium/view/TiUIView.java @@ -951,6 +951,17 @@ public void propertyChanged(String key, Object oldValue, Object newValue, KrollP } } else if (key.equals(TiC.PROPERTY_HIDDEN_BEHAVIOR)) { hiddenBehavior = TiConvert.toInt(newValue, View.INVISIBLE); + } else if (key.equals(TiC.PROPERTY_VIEW_SHADOW_COLOR)) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { + if (nativeView != null) { + nativeView.setOutlineAmbientShadowColor(TiConvert.toColor(TiConvert.toString(newValue), + TiApplication.getAppCurrentActivity())); + nativeView.setOutlineSpotShadowColor(TiConvert.toColor(TiConvert.toString(newValue), + TiApplication.getAppCurrentActivity())); + } + } else { + Log.w(TAG, "Setting the 'viewShadowColor' property requires Android P or later"); + } } else if (Log.isDebugModeEnabled()) { Log.d(TAG, "Unhandled property key: " + key, Log.DEBUG_MODE); } @@ -1105,6 +1116,19 @@ public void processProperties(KrollDict d) ViewCompat.setTranslationZ(nativeView, TiConvert.toFloat(d, TiC.PROPERTY_TRANSLATION_Z)); } + if (d.containsKey(TiC.PROPERTY_VIEW_SHADOW_COLOR) && !nativeViewNull) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { + nativeView.setOutlineAmbientShadowColor( + TiConvert.toColor(TiConvert.toString(d, TiC.PROPERTY_VIEW_SHADOW_COLOR), + TiApplication.getAppCurrentActivity())); + nativeView.setOutlineSpotShadowColor( + TiConvert.toColor(TiConvert.toString(d, TiC.PROPERTY_VIEW_SHADOW_COLOR), + TiApplication.getAppCurrentActivity())); + } else { + Log.w(TAG, "Setting the 'viewShadowColor' property requires Android P or later"); + } + } + if (!nativeViewNull && d.containsKeyAndNotNull(TiC.PROPERTY_TRANSITION_NAME)) { ViewCompat.setTransitionName(nativeView, d.getString(TiC.PROPERTY_TRANSITION_NAME)); } diff --git a/apidoc/Titanium/UI/View.yml b/apidoc/Titanium/UI/View.yml index 72d48d10a56..6be902567b0 100644 --- a/apidoc/Titanium/UI/View.yml +++ b/apidoc/Titanium/UI/View.yml @@ -1982,10 +1982,14 @@ properties: - name: viewShadowColor summary: Determines the color of the shadow. - description: Defaults to `undefined`. Behaves as if transparent. + description: | + iOS Defaults to `undefined`. Behaves as if transparent. Android default is black. + On Android you can set `0.5` and + `0.5` in your theme to change the + opacity. type: [String, Titanium.UI.Color] - platforms: [iphone, ipad, macos] - since: "3.3.0" + platforms: [android, iphone, ipad, macos] + since: {android: "11.1.0", iphone: "3.3.0", ipad: "3.3.0", macos: "9.2.0"} - name: viewShadowOffset summary: Determines the offset for the shadow of the view.