diff options
| author | 2015-06-22 20:55:10 +0000 | |
|---|---|---|
| committer | 2015-06-22 20:55:12 +0000 | |
| commit | 696d214946d0737a06976c9634b7095fc691fb31 (patch) | |
| tree | f7a3f34ccbd5f98915db5071e3f16956373568d3 | |
| parent | 3bd8c3618ab37a1565df4d0bc85995998808f6fc (diff) | |
| parent | 7e4019b7413511bb60e19d6011c80baf00e40b76 (diff) | |
Merge "Match default color packing for captioning settings" into mnc-dev
| -rw-r--r-- | core/java/android/view/accessibility/CaptioningManager.java | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/core/java/android/view/accessibility/CaptioningManager.java b/core/java/android/view/accessibility/CaptioningManager.java index 410d39cb18c4..14f0b0a06218 100644 --- a/core/java/android/view/accessibility/CaptioningManager.java +++ b/core/java/android/view/accessibility/CaptioningManager.java @@ -266,11 +266,19 @@ public class CaptioningManager { * background colors, edge properties, and typeface. */ public static final class CaptionStyle { - /** Packed value for a color of 'none' and a cached opacity of 100%. */ + /** + * Packed value for a color of 'none' and a cached opacity of 100%. + * + * @hide + */ private static final int COLOR_NONE_OPAQUE = 0x000000FF; - /** Packed value for an unspecified color and opacity. */ - private static final int COLOR_UNSPECIFIED = 0x000001FF; + /** + * Packed value for a color of 'default' and opacity of 100%. + * + * @hide + */ + public static final int COLOR_UNSPECIFIED = 0x00FFFFFF; private static final CaptionStyle WHITE_ON_BLACK; private static final CaptionStyle BLACK_ON_WHITE; @@ -350,11 +358,11 @@ public class CaptioningManager { private CaptionStyle(int foregroundColor, int backgroundColor, int edgeType, int edgeColor, int windowColor, String rawTypeface) { - mHasForegroundColor = foregroundColor != COLOR_UNSPECIFIED; - mHasBackgroundColor = backgroundColor != COLOR_UNSPECIFIED; + mHasForegroundColor = hasColor(foregroundColor); + mHasBackgroundColor = hasColor(backgroundColor); mHasEdgeType = edgeType != EDGE_TYPE_UNSPECIFIED; - mHasEdgeColor = edgeColor != COLOR_UNSPECIFIED; - mHasWindowColor = windowColor != COLOR_UNSPECIFIED; + mHasEdgeColor = hasColor(edgeColor); + mHasWindowColor = hasColor(windowColor); // Always use valid colors, even when no override is specified, to // ensure backwards compatibility with apps targeting KitKat MR2. @@ -368,6 +376,20 @@ public class CaptioningManager { } /** + * Returns whether a packed color indicates a non-default value. + * + * @param packedColor the packed color value + * @return {@code true} if a non-default value is specified + * @hide + */ + public static boolean hasColor(int packedColor) { + // Matches the color packing code from Settings. "Default" packed + // colors are indicated by zero alpha and non-zero red/blue. The + // cached alpha value used by Settings is stored in green. + return (packedColor >>> 24) != 0 || (packedColor & 0xFFFF00) == 0; + } + + /** * Applies a caption style, overriding any properties that are specified * in the overlay caption. * |