Make shadow alpha properties public, add lighting values for TV
BUG: 17189722
BUG: 17221975
Change-Id: I4ed477b658fec96ce69fa278f67345dab6bacaa3
diff --git a/core/java/android/view/ThreadedRenderer.java b/core/java/android/view/ThreadedRenderer.java
index 50341fc..3af214d 100644
--- a/core/java/android/view/ThreadedRenderer.java
+++ b/core/java/android/view/ThreadedRenderer.java
@@ -99,15 +99,13 @@
private boolean mRootNodeNeedsUpdate;
ThreadedRenderer(Context context, boolean translucent) {
- final TypedArray a = context.obtainStyledAttributes(
- null, R.styleable.Lighting, R.attr.lightingStyle, 0);
+ final TypedArray a = context.obtainStyledAttributes(null, R.styleable.Lighting, 0, 0);
mLightY = a.getDimension(R.styleable.Lighting_lightY, 0);
mLightZ = a.getDimension(R.styleable.Lighting_lightZ, 0);
mLightRadius = a.getDimension(R.styleable.Lighting_lightRadius, 0);
- mAmbientShadowAlpha = Math.round(
- 255 * a.getFloat(R.styleable.Lighting_ambientShadowAlpha, 0));
- mSpotShadowAlpha = Math.round(
- 255 * a.getFloat(R.styleable.Lighting_spotShadowAlpha, 0));
+ mAmbientShadowAlpha =
+ (int) (255 * a.getFloat(R.styleable.Lighting_ambientShadowAlpha, 0) + 0.5f);
+ mSpotShadowAlpha = (int) (255 * a.getFloat(R.styleable.Lighting_spotShadowAlpha, 0) + 0.5f);
a.recycle();
long rootNodePtr = nCreateRootRenderNode();
diff --git a/core/res/res/values-television/dimens.xml b/core/res/res/values-television/dimens.xml
new file mode 100644
index 0000000..8266642
--- /dev/null
+++ b/core/res/res/values-television/dimens.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<resources>
+
+ <!-- Lighting and shadow properties -->
+ <dimen name="light_y">-300dp</dimen>
+ <item type="dimen" format="float" name="ambient_shadow_alpha">0.4</item>
+ <item type="dimen" format="float" name="spot_shadow_alpha">0.4</item>
+
+</resources>
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index cc8d7cf..f092f73 100644
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -1012,13 +1012,25 @@
<!-- The color applied to framework switch thumbs in their normal state. -->
<attr name="colorSwitchThumbNormal" format="color" />
- <!-- ================== -->
- <!-- Hardware rendering -->
- <!-- ================== -->
+ <!-- =================== -->
+ <!-- Lighting properties -->
+ <!-- =================== -->
<eat-comment />
- <!-- Reference to the Lighting style. -->
- <attr name="lightingStyle" format="reference" />
+ <!-- @hide The default Y position of the light used to project view shadows. -->
+ <attr name="lightY" format="dimension" />
+
+ <!-- @hide The default Z position of the light used to project view shadows. -->
+ <attr name="lightZ" format="dimension" />
+
+ <!-- @hide The default radius of the light used to project view shadows. -->
+ <attr name="lightRadius" format="dimension" />
+
+ <!-- Alpha value of the ambient shadow projected by elevated views, between 0 and 1. -->
+ <attr name="ambientShadowAlpha" format="float" />
+
+ <!-- Alpha value of the spot shadow projected by elevated views, between 0 and 1. -->
+ <attr name="spotShadowAlpha" format="float" />
</declare-styleable>
<!-- **************************************************************** -->
@@ -7383,11 +7395,11 @@
<!-- @hide -->
<declare-styleable name="Lighting">
- <attr name="lightY" format="dimension" />
- <attr name="lightZ" format="dimension" />
- <attr name="lightRadius" format="dimension" />
- <attr name="ambientShadowAlpha" format="float" />
- <attr name="spotShadowAlpha" format="float" />
+ <attr name="lightY" />
+ <attr name="lightZ" />
+ <attr name="lightRadius" />
+ <attr name="ambientShadowAlpha" />
+ <attr name="spotShadowAlpha" />
</declare-styleable>
<declare-styleable name="RestrictionEntry">
diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml
index 6fd2bb1..b152c6a 100644
--- a/core/res/res/values/dimens.xml
+++ b/core/res/res/values/dimens.xml
@@ -405,4 +405,11 @@
<dimen name="text_handle_min_size">40dp</dimen>
+ <!-- Lighting and shadow properties -->
+ <dimen name="light_y">-200dp</dimen>
+ <dimen name="light_z">800dp</dimen>
+ <dimen name="light_radius">800dp</dimen>
+ <item type="dimen" format="float" name="ambient_shadow_alpha">0.06</item>
+ <item type="dimen" format="float" name="spot_shadow_alpha">0.16</item>
+
</resources>
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index f2466f7..36e26dd 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -2278,6 +2278,8 @@
<public type="attr" name="windowSharedElementsUseOverlay" />
<public type="attr" name="reparent" />
<public type="attr" name="reparentWithOverlay" />
+ <public type="attr" name="ambientShadowAlpha" />
+ <public type="attr" name="spotShadowAlpha" />
<public-padding type="dimen" name="l_resource_pad" end="0x01050010" />
diff --git a/core/res/res/values/styles.xml b/core/res/res/values/styles.xml
index 8fc9bac..5f6f546 100644
--- a/core/res/res/values/styles.xml
+++ b/core/res/res/values/styles.xml
@@ -1355,12 +1355,4 @@
<item name="padding">16dp</item>
</style>
- <style name="Lighting">
- <item name="lightY">-200dp</item>
- <item name="lightZ">800dp</item>
- <item name="lightRadius">800dp</item>
- <item name="ambientShadowAlpha">0.06</item>
- <item name="spotShadowAlpha">0.16</item>
- </style>
-
</resources>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 3f373aa..ac17753 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -1976,7 +1976,6 @@
<java-symbol type="string" name="whichEditApplicationNamed" />
<java-symbol type="string" name="whichSendApplication" />
<java-symbol type="string" name="whichSendApplicationNamed" />
- <java-symbol type="attr" name="lightingStyle" />
<java-symbol type="attr" name="lightY" />
<java-symbol type="attr" name="lightZ" />
<java-symbol type="attr" name="lightRadius" />
diff --git a/core/res/res/values/themes.xml b/core/res/res/values/themes.xml
index 5445816..48de5ad 100644
--- a/core/res/res/values/themes.xml
+++ b/core/res/res/values/themes.xml
@@ -410,14 +410,19 @@
<item name="fastScrollPreviewBackgroundLeft">@drawable/menu_submenu_background</item>
<item name="fastScrollOverlayPosition">floating</item>
<item name="fastScrollTextColor">@color/primary_text_dark</item>
+
<!-- Pointer style -->
<item name="pointerStyle">@style/Pointer</item>
- <!-- Accessibility focused drawable. -->
+ <!-- Accessibility focused drawable -->
<item name="accessibilityFocusedDrawable">@drawable/view_accessibility_focused</item>
- <!-- Lighting and shadow style. -->
- <item name="lightingStyle">@style/Lighting</item>
+ <!-- Lighting and shadow properties -->
+ <item name="lightY">@dimen/light_y</item>
+ <item name="lightZ">@dimen/light_z</item>
+ <item name="lightRadius">@dimen/light_radius</item>
+ <item name="ambientShadowAlpha">@dimen/ambient_shadow_alpha</item>
+ <item name="spotShadowAlpha">@dimen/spot_shadow_alpha</item>
</style>
<!-- Variant of {@link #Theme} with no title bar -->