Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(android): viewShadowColor parity #13457

Merged
merged 2 commits into from
May 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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));
}
Expand Down
10 changes: 7 additions & 3 deletions apidoc/Titanium/UI/View.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<item name="android:ambientShadowAlpha">0.5</item>` and
`<item name="android:spotShadowAlpha">0.5</item>` 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.
Expand Down