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
|
||||
public Builder setPreferredTextLanguageAndRoleFlagsToCaptioningManagerSettings(
|
||||
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;
|
||||
}
|
||||
|
||||
@ -829,25 +843,6 @@ public class TrackSelectionParameters implements Bundleable {
|
||||
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) {
|
||||
ImmutableList.Builder<String> listBuilder = ImmutableList.builder();
|
||||
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 final AudioTrack audioTrack;
|
||||
|
@ -114,14 +114,19 @@ public final class CaptionStyleCompat {
|
||||
* @param captionStyle A {@link CaptionStyle}.
|
||||
* @return The equivalent {@link CaptionStyleCompat}.
|
||||
*/
|
||||
@SuppressWarnings("ResourceType") // DO NOT SUBMIT check this is still needed
|
||||
public static CaptionStyleCompat createFromCaptionStyle(
|
||||
CaptioningManager.CaptionStyle captionStyle) {
|
||||
if (Util.SDK_INT >= 21) {
|
||||
return createFromCaptionStyleV21(captionStyle);
|
||||
} else {
|
||||
// Note - Any caller must be on at least API level 19 or greater (because CaptionStyle did
|
||||
// not exist in earlier API levels).
|
||||
return createFromCaptionStyleV19(captionStyle);
|
||||
return new CaptionStyleCompat(
|
||||
captionStyle.foregroundColor,
|
||||
captionStyle.backgroundColor,
|
||||
Color.TRANSPARENT,
|
||||
captionStyle.edgeType,
|
||||
captionStyle.edgeColor,
|
||||
captionStyle.getTypeface());
|
||||
}
|
||||
}
|
||||
|
||||
@ -148,18 +153,6 @@ public final class CaptionStyleCompat {
|
||||
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)
|
||||
@SuppressWarnings("ResourceType")
|
||||
private static CaptionStyleCompat createFromCaptionStyleV21(
|
||||
|
Loading…
x
Reference in New Issue
Block a user