summaryrefslogtreecommitdiffstats
path: root/core/java/android/view
diff options
context:
space:
mode:
authorAlan Viverette <alanv@google.com>2014-09-16 15:53:33 -0700
committerAlan Viverette <alanv@google.com>2014-09-16 15:53:33 -0700
commitf1820064d9cfcf43e4cfd16872acca3bf5a7d94b (patch)
tree89d02644713e2478feaabab72206c8399b2a7582 /core/java/android/view
parent47e3124da0ba09d8b5ea2c6273010cb2312897bd (diff)
downloadframeworks_base-f1820064d9cfcf43e4cfd16872acca3bf5a7d94b.zip
frameworks_base-f1820064d9cfcf43e4cfd16872acca3bf5a7d94b.tar.gz
frameworks_base-f1820064d9cfcf43e4cfd16872acca3bf5a7d94b.tar.bz2
Ensure we always have valid colors in CaptionStyle
BUG: 17521623 Change-Id: I861aa189970fc14dd3e4426e5487a14f373d3a2e
Diffstat (limited to 'core/java/android/view')
-rw-r--r--core/java/android/view/accessibility/CaptioningManager.java35
1 files changed, 25 insertions, 10 deletions
diff --git a/core/java/android/view/accessibility/CaptioningManager.java b/core/java/android/view/accessibility/CaptioningManager.java
index 334ff43..382a266 100644
--- a/core/java/android/view/accessibility/CaptioningManager.java
+++ b/core/java/android/view/accessibility/CaptioningManager.java
@@ -330,15 +330,30 @@ public class CaptioningManager {
*/
public final String mRawTypeface;
+ private final boolean mHasForegroundColor;
+ private final boolean mHasBackgroundColor;
+ private final boolean mHasEdgeType;
+ private final boolean mHasEdgeColor;
+ private final boolean mHasWindowColor;
+
+ /** Lazily-created typeface based on the raw typeface string. */
private Typeface mParsedTypeface;
private CaptionStyle(int foregroundColor, int backgroundColor, int edgeType, int edgeColor,
int windowColor, String rawTypeface) {
- this.foregroundColor = foregroundColor;
- this.backgroundColor = backgroundColor;
- this.edgeType = edgeType;
- this.edgeColor = edgeColor;
- this.windowColor = windowColor;
+ mHasForegroundColor = foregroundColor != COLOR_UNSPECIFIED;
+ mHasBackgroundColor = backgroundColor != COLOR_UNSPECIFIED;
+ mHasEdgeType = edgeType != EDGE_TYPE_UNSPECIFIED;
+ mHasEdgeColor = edgeColor != COLOR_UNSPECIFIED;
+ mHasWindowColor = windowColor != COLOR_UNSPECIFIED;
+
+ // Always use valid colors, even when no override is specified, to
+ // ensure backwards compatibility with apps targeting KitKat MR2.
+ this.foregroundColor = mHasForegroundColor ? foregroundColor : Color.WHITE;
+ this.backgroundColor = mHasBackgroundColor ? backgroundColor : Color.BLACK;
+ this.edgeType = mHasEdgeType ? edgeType : EDGE_TYPE_NONE;
+ this.edgeColor = mHasEdgeColor ? edgeColor : Color.BLACK;
+ this.windowColor = mHasWindowColor ? windowColor : COLOR_NONE_OPAQUE;
mRawTypeface = rawTypeface;
}
@@ -375,7 +390,7 @@ public class CaptioningManager {
* otherwise
*/
public boolean hasBackgroundColor() {
- return backgroundColor != COLOR_UNSPECIFIED;
+ return mHasBackgroundColor;
}
/**
@@ -384,7 +399,7 @@ public class CaptioningManager {
* otherwise
*/
public boolean hasForegroundColor() {
- return foregroundColor != COLOR_UNSPECIFIED;
+ return mHasForegroundColor;
}
/**
@@ -393,7 +408,7 @@ public class CaptioningManager {
* otherwise
*/
public boolean hasEdgeType() {
- return edgeType != EDGE_TYPE_UNSPECIFIED;
+ return mHasEdgeType;
}
/**
@@ -402,7 +417,7 @@ public class CaptioningManager {
* otherwise
*/
public boolean hasEdgeColor() {
- return edgeColor != COLOR_UNSPECIFIED;
+ return mHasEdgeColor;
}
/**
@@ -411,7 +426,7 @@ public class CaptioningManager {
* otherwise
*/
public boolean hasWindowColor() {
- return windowColor != COLOR_UNSPECIFIED;
+ return mHasWindowColor;
}
/**