Update CaptionStyleCompat for L.
This commit is contained in:
parent
9cfe5fcf44
commit
e99aaa4d67
@ -104,14 +104,19 @@ public final class CaptionStyleCompat {
|
|||||||
/**
|
/**
|
||||||
* Creates a {@link CaptionStyleCompat} equivalent to a provided {@link CaptionStyle}.
|
* Creates a {@link CaptionStyleCompat} equivalent to a provided {@link CaptionStyle}.
|
||||||
*
|
*
|
||||||
* @param style A {@link CaptionStyle}.
|
* @param captionStyle A {@link CaptionStyle}.
|
||||||
* @return The equivalent {@link CaptionStyleCompat}.
|
* @return The equivalent {@link CaptionStyleCompat}.
|
||||||
*/
|
*/
|
||||||
@TargetApi(19)
|
@TargetApi(19)
|
||||||
public static CaptionStyleCompat createFromCaptionStyle(CaptionStyle style) {
|
public static CaptionStyleCompat createFromCaptionStyle(
|
||||||
int windowColor = Util.SDK_INT >= 21 ? getWindowColorV21(style) : Color.TRANSPARENT;
|
CaptioningManager.CaptionStyle captionStyle) {
|
||||||
return new CaptionStyleCompat(style.foregroundColor, style.backgroundColor, windowColor,
|
if (Util.SDK_INT >= 21) {
|
||||||
style.edgeType, style.edgeColor, style.getTypeface());
|
return createFromCaptionStyleV21(captionStyle);
|
||||||
|
} else {
|
||||||
|
// Note - Any caller must be on at least API level 19 of greater (because CaptionStyle did
|
||||||
|
// not exist in earlier API levels).
|
||||||
|
return createFromCaptionStyleV19(captionStyle);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -132,11 +137,24 @@ public final class CaptionStyleCompat {
|
|||||||
this.typeface = typeface;
|
this.typeface = typeface;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@TargetApi(19)
|
||||||
|
private static CaptionStyleCompat createFromCaptionStyleV19(
|
||||||
|
CaptioningManager.CaptionStyle captionStyle) {
|
||||||
|
return new CaptionStyleCompat(
|
||||||
|
captionStyle.foregroundColor, captionStyle.backgroundColor, Color.TRANSPARENT,
|
||||||
|
captionStyle.edgeType, captionStyle.edgeColor, captionStyle.getTypeface());
|
||||||
|
}
|
||||||
|
|
||||||
@TargetApi(21)
|
@TargetApi(21)
|
||||||
private static int getWindowColorV21(CaptioningManager.CaptionStyle captionStyle) {
|
private static CaptionStyleCompat createFromCaptionStyleV21(
|
||||||
// TODO: Uncomment when building against API level 21.
|
CaptioningManager.CaptionStyle captionStyle) {
|
||||||
return Color.TRANSPARENT; //captionStyle.windowColor;
|
return new CaptionStyleCompat(
|
||||||
|
captionStyle.hasForegroundColor() ? captionStyle.foregroundColor : DEFAULT.foregroundColor,
|
||||||
|
captionStyle.hasBackgroundColor() ? captionStyle.backgroundColor : DEFAULT.backgroundColor,
|
||||||
|
captionStyle.hasWindowColor() ? captionStyle.windowColor : DEFAULT.windowColor,
|
||||||
|
captionStyle.hasEdgeType() ? captionStyle.edgeType : DEFAULT.edgeType,
|
||||||
|
captionStyle.hasEdgeColor() ? captionStyle.edgeColor : DEFAULT.edgeColor,
|
||||||
|
captionStyle.getTypeface());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user