Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1051)

Unified Diff: content/public/android/java/src/org/chromium/content/browser/accessibility/captioning/CaptioningStyle.java

Issue 1002473003: Expose text track settings in Content and implement for Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix CQ Issues Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/public/android/java/src/org/chromium/content/browser/accessibility/captioning/CaptioningStyle.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/accessibility/captioning/CaptioningStyle.java b/content/public/android/java/src/org/chromium/content/browser/accessibility/captioning/CaptioningStyle.java
new file mode 100644
index 0000000000000000000000000000000000000000..36b2889376cbbd02a34b72b69c872a62321129e1
--- /dev/null
+++ b/content/public/android/java/src/org/chromium/content/browser/accessibility/captioning/CaptioningStyle.java
@@ -0,0 +1,145 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.content.browser.accessibility.captioning;
+
+import android.annotation.SuppressLint;
+import android.annotation.TargetApi;
+import android.graphics.Typeface;
+import android.os.Build;
+import android.view.accessibility.CaptioningManager.CaptionStyle;
+
+/**
+ * This is an internal representation of the captioning. This class follows
+ * the paradigm that was introduced in KitKat while not using that API directly so that it can be
+ * used everywhere.
+ *
+ * For information on CaptionStyle, introduced in KitKat, see:
+ * @link https://developer.android.com/reference/android/view/accessibility/CaptioningManager.CaptionStyle.html
+ */
+@TargetApi(Build.VERSION_CODES.KITKAT)
+public class CaptioningStyle {
+ private Integer mBackgroundColor;
+ private Integer mEdgeColor;
+ private Integer mEdgeType;
+ private Integer mForegroundColor;
+ private Integer mWindowColor;
+ private Typeface mTypeface;
+
+ /**
+ * Construct a Chromium CaptioningStyle object.
+ *
+ * @param backgroundColor background color of the CaptioningStyle
+ * @param edgeColor edge color of the CaptioningStyle
+ * @param edgeType edgeType of the CaptioningStyle
+ * @param foregroundColor foreground color of the CaptioningStyle
+ * @param windowColor window color of the CaptioningStyle
+ * @param typeFace Typeface of the CaptioningStyle
+ */
+ public CaptioningStyle(Integer backgroundColor, Integer edgeColor, Integer edgeType,
+ Integer foregroundColor, Integer windowColor, Typeface typeface) {
+ mBackgroundColor = backgroundColor;
+ mEdgeColor = edgeColor;
+ mEdgeType = edgeType;
+ mForegroundColor = foregroundColor;
+ mWindowColor = windowColor;
+ mTypeface = typeface;
+ }
+
+ /**
+ * @return the background color specified by the platform if one was specified
+ * otherwise returns null
+ */
+ public Integer getBackgroundColor() {
+ return mBackgroundColor;
+ }
+
+ /**
+ * @return the edge color specified by the platform if one was specified
+ * otherwise returns null
+ */
+ public Integer getEdgeColor() {
+ return mEdgeColor;
+ }
+
+ /**
+ * @return the edge type specified by the platform if one was specified
+ * otherwise returns null
+ */
+ public Integer getEdgeType() {
+ return mEdgeType;
+ }
+
+ /**
+ * @return the foreground color specified by the platform if one was specified
+ * otherwise returns null
+ */
+ public Integer getForegroundColor() {
+ return mForegroundColor;
+ }
+
+ /**
+ * @return the window color specified by the platform if one was specified
+ * otherwise returns null
+ */
+ public Integer getWindowColor() {
+ return mWindowColor;
+ }
+
+ /**
+ * @return the Typeface specified by the platform if one was specified
+ * otherwise returns null
+ */
+ public Typeface getTypeface() {
+ return mTypeface;
+ }
+
+ /**
+ * Converts from a platform CaptionStyle to a Chromium CaptioningStyle. In the case that null
+ * is passed in, a CaptioningStyle that includes no settings is returned.
+ * This is safe to call on KitKat.
+ *
+ * KitKat CaptionStyle supported neither windowColor nor a few enum values of edgeType.
+ *
+ * @param captionStyle an Android platform CaptionStyle object
+ * @return a Chromium CaptioningStyle object
+ */
+ @SuppressLint("NewApi")
+ public static CaptioningStyle createFrom(CaptionStyle captionStyle) {
+ if (captionStyle == null) {
+ return new CaptioningStyle(null, null, null, null, null, null);
+ }
+
+ Integer backgroundColor = null;
+ Integer edgeColor = null;
+ Integer edgeType = null;
+ Integer foregroundColor = null;
+ Integer windowColor = null;
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ if (captionStyle.hasBackgroundColor()) {
+ backgroundColor = Integer.valueOf(captionStyle.backgroundColor);
+ }
+ if (captionStyle.hasEdgeColor()) {
+ edgeColor = Integer.valueOf(captionStyle.edgeColor);
+ }
+ if (captionStyle.hasEdgeType()) {
+ edgeType = Integer.valueOf(captionStyle.edgeType);
+ }
+ if (captionStyle.hasForegroundColor()) {
+ foregroundColor = Integer.valueOf(captionStyle.foregroundColor);
+ }
+ if (captionStyle.hasWindowColor()) {
+ windowColor = Integer.valueOf(captionStyle.windowColor);
+ }
+ } else {
+ backgroundColor = Integer.valueOf(captionStyle.backgroundColor);
+ edgeColor = Integer.valueOf(captionStyle.edgeColor);
+ edgeType = Integer.valueOf(captionStyle.edgeType);
+ foregroundColor = Integer.valueOf(captionStyle.foregroundColor);
+ }
+
+ return new CaptioningStyle(backgroundColor, edgeColor, edgeType, foregroundColor,
+ windowColor, captionStyle.getTypeface());
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698