Allow setting elevation on any type of View

Summary:
Moved setElevation from ReactViewManager to BaseViewManager. This allows
setting elevation on any type of view such as Toolbar for exemple.
Closes https://github.com/facebook/react-native/pull/5292

Reviewed By: svcscm

Differential Revision: D2837415

Pulled By: androidtrunkagent

fb-gh-sync-id: a5aa7abd95b99303d312cd9c2414539335540925
This commit is contained in:
Janic Duplessis 2016-01-16 02:32:39 -08:00 committed by facebook-github-bot-7
parent c9f274c02d
commit 5ac848cd7f
2 changed files with 9 additions and 8 deletions

View File

@ -26,6 +26,7 @@ public abstract class BaseViewManager<T extends View, C extends LayoutShadowNode
private static final String PROP_DECOMPOSED_MATRIX_TRANSLATE_X = "translateX";
private static final String PROP_DECOMPOSED_MATRIX_TRANSLATE_Y = "translateY";
private static final String PROP_OPACITY = "opacity";
private static final String PROP_ELEVATION = "elevation";
private static final String PROP_RENDER_TO_HARDWARE_TEXTURE = "renderToHardwareTextureAndroid";
private static final String PROP_ACCESSIBILITY_LABEL = "accessibilityLabel";
private static final String PROP_ACCESSIBILITY_COMPONENT_TYPE = "accessibilityComponentType";
@ -63,6 +64,14 @@ public abstract class BaseViewManager<T extends View, C extends LayoutShadowNode
public void setOpacity(T view, float opacity) {
view.setAlpha(opacity);
}
@ReactProp(name = PROP_ELEVATION)
public void setElevation(T view, float elevation) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
view.setElevation(PixelUtil.toPixelFromDIP(elevation));
}
// Do nothing on API < 21
}
@ReactProp(name = PROP_RENDER_TO_HARDWARE_TEXTURE)
public void setRenderToHardwareTexture(T view, boolean useHWTexture) {

View File

@ -61,14 +61,6 @@ public class ReactViewManager extends ViewGroupManager<ReactViewGroup> {
view.setBorderStyle(borderStyle);
}
@ReactProp(name = "elevation")
public void setElevation(ReactViewGroup view, float elevation) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
view.setElevation(PixelUtil.toPixelFromDIP(elevation));
}
// Do nothing on API < 21
}
@ReactProp(name = "pointerEvents")
public void setPointerEvents(ReactViewGroup view, @Nullable String pointerEventsStr) {
if (pointerEventsStr != null) {