diff options
author | Alan Viverette <alanv@google.com> | 2015-06-22 13:05:45 -0700 |
---|---|---|
committer | Alan Viverette <alanv@google.com> | 2015-06-22 13:05:45 -0700 |
commit | 751625e9a20cdd11073cdadb06b2c18464e9701c (patch) | |
tree | 127c4e89eaf1377b5709b290eeb11354f639716d | |
parent | 14f5da9b4d2cb1e0b6828312613bf8f4c8a1df2d (diff) | |
download | packages_apps_Settings-751625e9a20cdd11073cdadb06b2c18464e9701c.zip packages_apps_Settings-751625e9a20cdd11073cdadb06b2c18464e9701c.tar.gz packages_apps_Settings-751625e9a20cdd11073cdadb06b2c18464e9701c.tar.bz2 |
Ensure "default" and "none" caption colors are consistent w/ framework
Also enables scroll indicators in color grid dialog.
Bug: 21602597
Change-Id: I7fabd36787fc8689966eb8dcece3d4d047ee8066
-rw-r--r-- | res/layout/grid_picker_dialog.xml | 3 | ||||
-rw-r--r-- | res/values/arrays.xml | 2 | ||||
-rw-r--r-- | src/com/android/settings/accessibility/CaptionPropertiesFragment.java | 43 |
3 files changed, 39 insertions, 9 deletions
diff --git a/res/layout/grid_picker_dialog.xml b/res/layout/grid_picker_dialog.xml index 1e04188..1c3bfda 100644 --- a/res/layout/grid_picker_dialog.xml +++ b/res/layout/grid_picker_dialog.xml @@ -31,7 +31,8 @@ android:numColumns="auto_fit" android:columnWidth="96dp" android:scrollbarStyle="insideOverlay" - android:stretchMode="columnWidth" /> + android:stretchMode="columnWidth" + android:scrollIndicators="top|bottom" /> <!-- HACK: Setting minHeight has no effect within a dialog layout, so this view keeps the minimum height above 300dp. --> diff --git a/res/values/arrays.xml b/res/values/arrays.xml index 6c1f68b..93ad961 100644 --- a/res/values/arrays.xml +++ b/res/values/arrays.xml @@ -829,7 +829,7 @@ <!-- Values for captioning color preference. --> <integer-array name="captioning_color_selector_values" translatable="false" > - <item>0x00000100</item> + <item>0x00FFFFFF</item> <item>0xFFFFFFFF</item> <item>0xFF000000</item> <item>0xFFFF0000</item> diff --git a/src/com/android/settings/accessibility/CaptionPropertiesFragment.java b/src/com/android/settings/accessibility/CaptionPropertiesFragment.java index ff9c9eb..81640e8 100644 --- a/src/com/android/settings/accessibility/CaptionPropertiesFragment.java +++ b/src/com/android/settings/accessibility/CaptionPropertiesFragment.java @@ -344,9 +344,17 @@ public class CaptionPropertiesFragment extends SettingsPreferenceFragment mEdgeType.setValue(attrs.edgeType); mEdgeColor.setValue(attrs.edgeColor); - parseColorOpacity(mForegroundColor, mForegroundOpacity, attrs.foregroundColor); - parseColorOpacity(mBackgroundColor, mBackgroundOpacity, attrs.backgroundColor); - parseColorOpacity(mWindowColor, mWindowOpacity, attrs.windowColor); + final int foregroundColor = attrs.hasForegroundColor() ? + attrs.foregroundColor : CaptionStyle.COLOR_UNSPECIFIED; + parseColorOpacity(mForegroundColor, mForegroundOpacity, foregroundColor); + + final int backgroundColor = attrs.hasBackgroundColor() ? + attrs.backgroundColor : CaptionStyle.COLOR_UNSPECIFIED; + parseColorOpacity(mBackgroundColor, mBackgroundOpacity, backgroundColor); + + final int windowColor = attrs.hasWindowColor() ? + attrs.windowColor : CaptionStyle.COLOR_UNSPECIFIED; + parseColorOpacity(mWindowColor, mWindowOpacity, windowColor); final String rawTypeface = attrs.mRawTypeface; mTypeface.setValue(rawTypeface == null ? "" : rawTypeface); @@ -355,27 +363,48 @@ public class CaptionPropertiesFragment extends SettingsPreferenceFragment mLocale.setValue(rawLocale == null ? "" : rawLocale); } + /** + * Unpack the specified color value and update the preferences. + * + * @param color color preference + * @param opacity opacity preference + * @param value packed value + */ private void parseColorOpacity(ColorPreference color, ColorPreference opacity, int value) { final int colorValue; final int opacityValue; - if (Color.alpha(value) == 0) { + if (!CaptionStyle.hasColor(value)) { + // "Default" color with variable alpha. + colorValue = CaptionStyle.COLOR_UNSPECIFIED; + opacityValue = (value & 0xFF) << 24; + } else if ((value >>> 24) == 0) { + // "None" color with variable alpha. colorValue = Color.TRANSPARENT; opacityValue = (value & 0xFF) << 24; } else { + // Normal color. colorValue = value | 0xFF000000; opacityValue = value & 0xFF000000; } - color.setValue(colorValue); + + // Opacity value is always white. opacity.setValue(opacityValue | 0xFFFFFF); + color.setValue(colorValue); } private int mergeColorOpacity(ColorPreference color, ColorPreference opacity) { final int colorValue = color.getValue(); final int opacityValue = opacity.getValue(); final int value; - if (Color.alpha(colorValue) == 0) { - value = colorValue & 0x00FFFF00 | Color.alpha(opacityValue); + // "Default" is 0x00FFFFFF or, for legacy support, 0x00000100. + if (!CaptionStyle.hasColor(colorValue)) { + // Encode "default" as 0x00FFFFaa. + value = 0x00FFFF00 | Color.alpha(opacityValue); + } else if (colorValue == Color.TRANSPARENT) { + // Encode "none" as 0x000000aa. + value = Color.alpha(opacityValue); } else { + // Encode custom color normally. value = colorValue & 0x00FFFFFF | opacityValue & 0xFF000000; } return value; |