In-line more V19 methods in TrackSelectionParameters, AudioTimestampPoller and CaptionStyleCompat
This commit is contained in:
parent
c4d9df970c
commit
205c8734cc
@ -630,7 +630,21 @@ public class TrackSelectionParameters implements Bundleable {
|
|||||||
@CanIgnoreReturnValue
|
@CanIgnoreReturnValue
|
||||||
public Builder setPreferredTextLanguageAndRoleFlagsToCaptioningManagerSettings(
|
public Builder setPreferredTextLanguageAndRoleFlagsToCaptioningManagerSettings(
|
||||||
Context context) {
|
Context context) {
|
||||||
setPreferredTextLanguageAndRoleFlagsToCaptioningManagerSettingsV19(context);
|
if (Util.SDK_INT < 23 && Looper.myLooper() == null) {
|
||||||
|
// Android platform bug (pre-Marshmallow) that causes RuntimeExceptions when
|
||||||
|
// CaptioningService is instantiated from a non-Looper thread. See [internal: b/143779904].
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
CaptioningManager captioningManager =
|
||||||
|
(CaptioningManager) context.getSystemService(Context.CAPTIONING_SERVICE);
|
||||||
|
if (captioningManager == null || !captioningManager.isEnabled()) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
preferredTextRoleFlags = C.ROLE_FLAG_CAPTION | C.ROLE_FLAG_DESCRIBES_MUSIC_AND_SOUND;
|
||||||
|
Locale preferredLocale = captioningManager.getLocale();
|
||||||
|
if (preferredLocale != null) {
|
||||||
|
preferredTextLanguages = ImmutableList.of(Util.getLocaleLanguageTag(preferredLocale));
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -829,25 +843,6 @@ public class TrackSelectionParameters implements Bundleable {
|
|||||||
return new TrackSelectionParameters(this);
|
return new TrackSelectionParameters(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setPreferredTextLanguageAndRoleFlagsToCaptioningManagerSettingsV19(
|
|
||||||
Context context) {
|
|
||||||
if (Util.SDK_INT < 23 && Looper.myLooper() == null) {
|
|
||||||
// Android platform bug (pre-Marshmallow) that causes RuntimeExceptions when
|
|
||||||
// CaptioningService is instantiated from a non-Looper thread. See [internal: b/143779904].
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
CaptioningManager captioningManager =
|
|
||||||
(CaptioningManager) context.getSystemService(Context.CAPTIONING_SERVICE);
|
|
||||||
if (captioningManager == null || !captioningManager.isEnabled()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
preferredTextRoleFlags = C.ROLE_FLAG_CAPTION | C.ROLE_FLAG_DESCRIBES_MUSIC_AND_SOUND;
|
|
||||||
Locale preferredLocale = captioningManager.getLocale();
|
|
||||||
if (preferredLocale != null) {
|
|
||||||
preferredTextLanguages = ImmutableList.of(Util.getLocaleLanguageTag(preferredLocale));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ImmutableList<String> normalizeLanguageCodes(String[] preferredTextLanguages) {
|
private static ImmutableList<String> normalizeLanguageCodes(String[] preferredTextLanguages) {
|
||||||
ImmutableList.Builder<String> listBuilder = ImmutableList.builder();
|
ImmutableList.Builder<String> listBuilder = ImmutableList.builder();
|
||||||
for (String language : checkNotNull(preferredTextLanguages)) {
|
for (String language : checkNotNull(preferredTextLanguages)) {
|
||||||
|
@ -261,6 +261,7 @@ import java.lang.annotation.Target;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DO NOT SUBMIT in-line this
|
||||||
private static final class AudioTimestampV19 {
|
private static final class AudioTimestampV19 {
|
||||||
|
|
||||||
private final AudioTrack audioTrack;
|
private final AudioTrack audioTrack;
|
||||||
|
@ -114,14 +114,19 @@ public final class CaptionStyleCompat {
|
|||||||
* @param captionStyle A {@link CaptionStyle}.
|
* @param captionStyle A {@link CaptionStyle}.
|
||||||
* @return The equivalent {@link CaptionStyleCompat}.
|
* @return The equivalent {@link CaptionStyleCompat}.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("ResourceType") // DO NOT SUBMIT check this is still needed
|
||||||
public static CaptionStyleCompat createFromCaptionStyle(
|
public static CaptionStyleCompat createFromCaptionStyle(
|
||||||
CaptioningManager.CaptionStyle captionStyle) {
|
CaptioningManager.CaptionStyle captionStyle) {
|
||||||
if (Util.SDK_INT >= 21) {
|
if (Util.SDK_INT >= 21) {
|
||||||
return createFromCaptionStyleV21(captionStyle);
|
return createFromCaptionStyleV21(captionStyle);
|
||||||
} else {
|
} else {
|
||||||
// Note - Any caller must be on at least API level 19 or greater (because CaptionStyle did
|
return new CaptionStyleCompat(
|
||||||
// not exist in earlier API levels).
|
captionStyle.foregroundColor,
|
||||||
return createFromCaptionStyleV19(captionStyle);
|
captionStyle.backgroundColor,
|
||||||
|
Color.TRANSPARENT,
|
||||||
|
captionStyle.edgeType,
|
||||||
|
captionStyle.edgeColor,
|
||||||
|
captionStyle.getTypeface());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,18 +153,6 @@ public final class CaptionStyleCompat {
|
|||||||
this.typeface = typeface;
|
this.typeface = typeface;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("ResourceType")
|
|
||||||
private static CaptionStyleCompat createFromCaptionStyleV19(
|
|
||||||
CaptioningManager.CaptionStyle captionStyle) {
|
|
||||||
return new CaptionStyleCompat(
|
|
||||||
captionStyle.foregroundColor,
|
|
||||||
captionStyle.backgroundColor,
|
|
||||||
Color.TRANSPARENT,
|
|
||||||
captionStyle.edgeType,
|
|
||||||
captionStyle.edgeColor,
|
|
||||||
captionStyle.getTypeface());
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequiresApi(21)
|
@RequiresApi(21)
|
||||||
@SuppressWarnings("ResourceType")
|
@SuppressWarnings("ResourceType")
|
||||||
private static CaptionStyleCompat createFromCaptionStyleV21(
|
private static CaptionStyleCompat createFromCaptionStyleV21(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user