Mark currently selected subtitle track in track list

Previously, the automatically selected subtitle track
has not been marked (with check mark) in subtitle track list,
just like audio track.

But, in subtitle track option UI, there is no 'auto' option,
which is different from audio track selection menu.

This CL marks the auto selected subtitle track name in the cc list.

PiperOrigin-RevId: 320802575
This commit is contained in:
insun 2020-07-12 03:49:56 +01:00 committed by kim-vde
parent 702568c3b6
commit 5e50e110a4

View file

@ -1982,6 +1982,18 @@ public class StyledPlayerControlView extends FrameLayout {
List<Integer> rendererIndices,
List<TrackInfo> trackInfos,
MappedTrackInfo mappedTrackInfo) {
boolean subtitleIsOn = false;
for (int i = 0; i < trackInfos.size(); i++) {
if (trackInfos.get(i).selected) {
subtitleIsOn = true;
break;
}
}
checkNotNull(subtitleButton)
.setImageDrawable(subtitleIsOn ? subtitleOnButtonDrawable : subtitleOffButtonDrawable);
checkNotNull(subtitleButton)
.setContentDescription(
subtitleIsOn ? subtitleOnContentDescription : subtitleOffContentDescription);
this.rendererIndices = rendererIndices;
this.tracks = trackInfos;
this.mappedTrackInfo = mappedTrackInfo;
@ -2013,10 +2025,6 @@ public class StyledPlayerControlView extends FrameLayout {
.setRendererDisabled(rendererIndex, true);
}
checkNotNull(trackSelector).setParameters(parametersBuilder);
if (showSubtitleButton) {
checkNotNull(subtitleButton).setImageDrawable(subtitleOffButtonDrawable);
checkNotNull(subtitleButton).setContentDescription(subtitleOffContentDescription);
}
settingsWindow.dismiss();
}
}
@ -2024,12 +2032,18 @@ public class StyledPlayerControlView extends FrameLayout {
}
@Override
public void onTrackSelection(String subtext) {
if (showSubtitleButton) {
checkNotNull(subtitleButton).setImageDrawable(subtitleOnButtonDrawable);
checkNotNull(subtitleButton).setContentDescription(subtitleOnContentDescription);
public void onBindViewHolder(TrackSelectionViewHolder holder, int position) {
super.onBindViewHolder(holder, position);
if (position > 0) {
TrackInfo track = tracks.get(position - 1);
holder.checkView.setVisibility(track.selected ? VISIBLE : INVISIBLE);
}
}
@Override
public void onTrackSelection(String subtext) {
// No-op
}
}
private final class AudioTrackSelectionAdapter extends TrackSelectionAdapter {
@ -2102,8 +2116,8 @@ public class StyledPlayerControlView extends FrameLayout {
SETTINGS_AUDIO_TRACK_SELECTION_POSITION,
getResources().getString(R.string.exo_track_selection_auto));
} else {
for (int i = 0; i < tracks.size(); i++) {
TrackInfo track = tracks.get(i);
for (int i = 0; i < trackInfos.size(); i++) {
TrackInfo track = trackInfos.get(i);
if (track.selected) {
settingsAdapter.updateSubTexts(
SETTINGS_AUDIO_TRACK_SELECTION_POSITION, track.trackName);