Toggles subtitle button's image and content description accordingly

PiperOrigin-RevId: 320323388
This commit is contained in:
insun 2020-07-09 04:02:39 +00:00 committed by Jaewan Kim
parent b1e9257de1
commit 9a42141e66

View File

@ -381,6 +381,10 @@ public class StyledPlayerControlView extends FrameLayout {
private final float buttonAlphaDisabled; private final float buttonAlphaDisabled;
private final String shuffleOnContentDescription; private final String shuffleOnContentDescription;
private final String shuffleOffContentDescription; private final String shuffleOffContentDescription;
private final Drawable subtitleOnButtonDrawable;
private final Drawable subtitleOffButtonDrawable;
private final String subtitleOnContentDescription;
private final String subtitleOffContentDescription;
private final Drawable fullScreenExitDrawable; private final Drawable fullScreenExitDrawable;
private final Drawable fullScreenEnterDrawable; private final Drawable fullScreenEnterDrawable;
private final String fullScreenExitContentDescription; private final String fullScreenExitContentDescription;
@ -437,7 +441,7 @@ public class StyledPlayerControlView extends FrameLayout {
private TrackNameProvider trackNameProvider; private TrackNameProvider trackNameProvider;
// Relating to Bottom Bar Right View // Relating to Bottom Bar Right View
@Nullable private View subtitleButton; @Nullable private ImageView subtitleButton;
@Nullable private ImageView fullScreenButton; @Nullable private ImageView fullScreenButton;
@Nullable private View settingsButton; @Nullable private View settingsButton;
@ -666,6 +670,10 @@ public class StyledPlayerControlView extends FrameLayout {
needToHideBars = true; needToHideBars = true;
trackNameProvider = new DefaultTrackNameProvider(getResources()); trackNameProvider = new DefaultTrackNameProvider(getResources());
subtitleOnButtonDrawable = resources.getDrawable(R.drawable.exo_styled_controls_subtitle_on);
subtitleOffButtonDrawable = resources.getDrawable(R.drawable.exo_styled_controls_subtitle_off);
subtitleOnContentDescription = resources.getString(R.string.exo_controls_cc_is_on);
subtitleOffContentDescription = resources.getString(R.string.exo_controls_cc_is_off);
textTrackSelectionAdapter = new TextTrackSelectionAdapter(); textTrackSelectionAdapter = new TextTrackSelectionAdapter();
audioTrackSelectionAdapter = new AudioTrackSelectionAdapter(); audioTrackSelectionAdapter = new AudioTrackSelectionAdapter();
@ -2005,6 +2013,10 @@ public class StyledPlayerControlView extends FrameLayout {
.setRendererDisabled(rendererIndex, true); .setRendererDisabled(rendererIndex, true);
} }
checkNotNull(trackSelector).setParameters(parametersBuilder); checkNotNull(trackSelector).setParameters(parametersBuilder);
if (showSubtitleButton) {
checkNotNull(subtitleButton).setImageDrawable(subtitleOffButtonDrawable);
checkNotNull(subtitleButton).setContentDescription(subtitleOffContentDescription);
}
settingsWindow.dismiss(); settingsWindow.dismiss();
} }
} }
@ -2012,8 +2024,11 @@ public class StyledPlayerControlView extends FrameLayout {
} }
@Override @Override
public void updateSettingsSubtext(String subtext) { public void onTrackSelection(String subtext) {
// Do nothing. Text track selection exists outside of Settings menu. if (showSubtitleButton) {
checkNotNull(subtitleButton).setImageDrawable(subtitleOnButtonDrawable);
checkNotNull(subtitleButton).setContentDescription(subtitleOnContentDescription);
}
} }
} }
@ -2056,7 +2071,7 @@ public class StyledPlayerControlView extends FrameLayout {
} }
@Override @Override
public void updateSettingsSubtext(String subtext) { public void onTrackSelection(String subtext) {
settingsAdapter.updateSubTexts(SETTINGS_AUDIO_TRACK_SELECTION_POSITION, subtext); settingsAdapter.updateSubTexts(SETTINGS_AUDIO_TRACK_SELECTION_POSITION, subtext);
} }
@ -2127,7 +2142,7 @@ public class StyledPlayerControlView extends FrameLayout {
public abstract void onBindViewHolderAtZeroPosition(TrackSelectionViewHolder holder); public abstract void onBindViewHolderAtZeroPosition(TrackSelectionViewHolder holder);
public abstract void updateSettingsSubtext(String subtext); public abstract void onTrackSelection(String subtext);
@Override @Override
public void onBindViewHolder(TrackSelectionViewHolder holder, int position) { public void onBindViewHolder(TrackSelectionViewHolder holder, int position) {
@ -2170,7 +2185,7 @@ public class StyledPlayerControlView extends FrameLayout {
} }
} }
checkNotNull(trackSelector).setParameters(parametersBuilder); checkNotNull(trackSelector).setParameters(parametersBuilder);
updateSettingsSubtext(track.trackName); onTrackSelection(track.trackName);
settingsWindow.dismiss(); settingsWindow.dismiss();
} }
} }