Ensure "default" and "none" caption colors are consistent w/ framework
Also enables scroll indicators in color grid dialog. Bug: 21602597 Change-Id: I7fabd36787fc8689966eb8dcece3d4d047ee8066
This commit is contained in:
@@ -31,7 +31,8 @@
|
|||||||
android:numColumns="auto_fit"
|
android:numColumns="auto_fit"
|
||||||
android:columnWidth="96dp"
|
android:columnWidth="96dp"
|
||||||
android:scrollbarStyle="insideOverlay"
|
android:scrollbarStyle="insideOverlay"
|
||||||
android:stretchMode="columnWidth" />
|
android:stretchMode="columnWidth"
|
||||||
|
android:scrollIndicators="top|bottom" />
|
||||||
|
|
||||||
<!-- HACK: Setting minHeight has no effect within a dialog layout,
|
<!-- HACK: Setting minHeight has no effect within a dialog layout,
|
||||||
so this view keeps the minimum height above 300dp. -->
|
so this view keeps the minimum height above 300dp. -->
|
||||||
|
@@ -829,7 +829,7 @@
|
|||||||
|
|
||||||
<!-- Values for captioning color preference. -->
|
<!-- Values for captioning color preference. -->
|
||||||
<integer-array name="captioning_color_selector_values" translatable="false" >
|
<integer-array name="captioning_color_selector_values" translatable="false" >
|
||||||
<item>0x00000100</item>
|
<item>0x00FFFFFF</item>
|
||||||
<item>0xFFFFFFFF</item>
|
<item>0xFFFFFFFF</item>
|
||||||
<item>0xFF000000</item>
|
<item>0xFF000000</item>
|
||||||
<item>0xFFFF0000</item>
|
<item>0xFFFF0000</item>
|
||||||
|
@@ -344,9 +344,17 @@ public class CaptionPropertiesFragment extends SettingsPreferenceFragment
|
|||||||
mEdgeType.setValue(attrs.edgeType);
|
mEdgeType.setValue(attrs.edgeType);
|
||||||
mEdgeColor.setValue(attrs.edgeColor);
|
mEdgeColor.setValue(attrs.edgeColor);
|
||||||
|
|
||||||
parseColorOpacity(mForegroundColor, mForegroundOpacity, attrs.foregroundColor);
|
final int foregroundColor = attrs.hasForegroundColor() ?
|
||||||
parseColorOpacity(mBackgroundColor, mBackgroundOpacity, attrs.backgroundColor);
|
attrs.foregroundColor : CaptionStyle.COLOR_UNSPECIFIED;
|
||||||
parseColorOpacity(mWindowColor, mWindowOpacity, attrs.windowColor);
|
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;
|
final String rawTypeface = attrs.mRawTypeface;
|
||||||
mTypeface.setValue(rawTypeface == null ? "" : rawTypeface);
|
mTypeface.setValue(rawTypeface == null ? "" : rawTypeface);
|
||||||
@@ -355,27 +363,48 @@ public class CaptionPropertiesFragment extends SettingsPreferenceFragment
|
|||||||
mLocale.setValue(rawLocale == null ? "" : rawLocale);
|
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) {
|
private void parseColorOpacity(ColorPreference color, ColorPreference opacity, int value) {
|
||||||
final int colorValue;
|
final int colorValue;
|
||||||
final int opacityValue;
|
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;
|
colorValue = Color.TRANSPARENT;
|
||||||
opacityValue = (value & 0xFF) << 24;
|
opacityValue = (value & 0xFF) << 24;
|
||||||
} else {
|
} else {
|
||||||
|
// Normal color.
|
||||||
colorValue = value | 0xFF000000;
|
colorValue = value | 0xFF000000;
|
||||||
opacityValue = value & 0xFF000000;
|
opacityValue = value & 0xFF000000;
|
||||||
}
|
}
|
||||||
color.setValue(colorValue);
|
|
||||||
|
// Opacity value is always white.
|
||||||
opacity.setValue(opacityValue | 0xFFFFFF);
|
opacity.setValue(opacityValue | 0xFFFFFF);
|
||||||
|
color.setValue(colorValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int mergeColorOpacity(ColorPreference color, ColorPreference opacity) {
|
private int mergeColorOpacity(ColorPreference color, ColorPreference opacity) {
|
||||||
final int colorValue = color.getValue();
|
final int colorValue = color.getValue();
|
||||||
final int opacityValue = opacity.getValue();
|
final int opacityValue = opacity.getValue();
|
||||||
final int value;
|
final int value;
|
||||||
if (Color.alpha(colorValue) == 0) {
|
// "Default" is 0x00FFFFFF or, for legacy support, 0x00000100.
|
||||||
value = colorValue & 0x00FFFF00 | Color.alpha(opacityValue);
|
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 {
|
} else {
|
||||||
|
// Encode custom color normally.
|
||||||
value = colorValue & 0x00FFFFFF | opacityValue & 0xFF000000;
|
value = colorValue & 0x00FFFFFF | opacityValue & 0xFF000000;
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
|
Reference in New Issue
Block a user