Commit e12c1029 authored by Finnur Thorarinsson's avatar Finnur Thorarinsson Committed by Commit Bot

[Android] Photo Picker: Add accessibility strings for video player.

This adds TalkBack strings to widgets for:
Play/Pause, Mute/Unmute, and elapsed/total time.

Bug: 895776, 656015
Change-Id: I0c815d8afa2452761d743975574156aef40e7441
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2080368
Commit-Queue: Finnur Thorarinsson <finnur@chromium.org>
Reviewed-by: default avatarBoris Sazonov <bsazonov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#747222}
parent 5645e0da
......@@ -19,6 +19,7 @@
android:layout_height="wrap_content"
android:paddingBottom="0.1dp"
android:clickable="true"
android:contentDescription="@string/accessibility_video_player"
android:layout_gravity="center">
<FrameLayout
android:id="@+id/video_controls_gradient"
......@@ -40,6 +41,7 @@
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_gravity="center"
android:contentDescription="@string/accessibility_play_video"
app:srcCompat="@drawable/ic_play_circle_filled_white_24dp" />
<TextView
android:id="@+id/remaining_time"
......@@ -47,6 +49,7 @@
android:layout_height="wrap_content"
android:layout_gravity="bottom|start"
android:layout_marginStart="16dp"
android:importantForAccessibility="yes"
android:paddingBottom="24dp"
style="@style/TextAppearance.TextMedium.Primary.Light" />
<ImageView
......@@ -56,6 +59,7 @@
android:layout_gravity="bottom|end"
android:layout_marginEnd="14dp"
android:paddingBottom="24dp"
android:contentDescription="@string/accessibility_mute_video"
app:srcCompat="@drawable/ic_volume_on_white_24dp" />
<SeekBar
android:id="@+id/seek_bar"
......
......@@ -148,7 +148,7 @@ public class PickerVideoPlayer
// away) to indicate that playback has reached the end of the video (and didn't
// break before reaching the end). This also allows the user to restart playback
// from the start, by pressing Play.
mLargePlayButton.setImageResource(R.drawable.ic_play_circle_filled_white_24dp);
switchToPlayButton();
updateProgress();
showOverlayControls(/*animateAway=*/false);
if (sProgressCallback != null) {
......@@ -284,6 +284,8 @@ public class PickerVideoPlayer
String formattedProgress =
mResources.getString(R.string.photo_picker_video_duration, current, total);
mRemainingTime.setText(formattedProgress);
mRemainingTime.setContentDescription(
mResources.getString(R.string.accessibility_playback_time, current, total));
int percentage = mVideoView.getDuration() == 0
? 0
: mVideoView.getCurrentPosition() * 100 / mVideoView.getDuration();
......@@ -296,7 +298,7 @@ public class PickerVideoPlayer
private void startVideoPlayback() {
mMediaPlayer.start();
mLargePlayButton.setImageResource(R.drawable.ic_pause_circle_outline_white_24dp);
switchToPauseButton();
showOverlayControls(/*animateAway=*/true);
}
......@@ -304,7 +306,7 @@ public class PickerVideoPlayer
stopPlaybackMonitor();
mMediaPlayer.pause();
mLargePlayButton.setImageResource(R.drawable.ic_play_circle_filled_white_24dp);
switchToPlayButton();
showOverlayControls(/*animateAway=*/false);
}
......@@ -316,6 +318,18 @@ public class PickerVideoPlayer
}
}
private void switchToPlayButton() {
mLargePlayButton.setImageResource(R.drawable.ic_play_circle_filled_white_24dp);
mLargePlayButton.setContentDescription(
mResources.getString(R.string.accessibility_play_video));
}
private void switchToPauseButton() {
mLargePlayButton.setImageResource(R.drawable.ic_pause_circle_outline_white_24dp);
mLargePlayButton.setContentDescription(
mResources.getString(R.string.accessibility_pause_video));
}
private void syncOverlayControlsSize() {
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
mVideoView.getMeasuredWidth(), mVideoView.getMeasuredHeight());
......@@ -327,9 +341,13 @@ public class PickerVideoPlayer
if (mAudioOn) {
mMediaPlayer.setVolume(1f, 1f);
mMuteButton.setImageResource(R.drawable.ic_volume_on_white_24dp);
mMuteButton.setContentDescription(
mResources.getString(R.string.accessibility_mute_video));
} else {
mMediaPlayer.setVolume(0f, 0f);
mMuteButton.setImageResource(R.drawable.ic_volume_off_white_24dp);
mMuteButton.setContentDescription(
mResources.getString(R.string.accessibility_unmute_video));
}
}
......
......@@ -3434,6 +3434,21 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
<message name="IDS_ACCESSIBILITY_PLAY_VIDEO" desc="The accessibility string for the play video button.">
Play video
</message>
<message name="IDS_ACCESSIBILITY_PAUSE_VIDEO" desc="The accessibility string for the pause video button.">
Pause video
</message>
<message name="IDS_ACCESSIBILITY_MUTE_VIDEO" desc="The accessibility string for the mute video button.">
Mute video
</message>
<message name="IDS_ACCESSIBILITY_UNMUTE_VIDEO" desc="The accessibility string for the unmute video button.">
Unmute video
</message>
<message name="IDS_ACCESSIBILITY_VIDEO_PLAYER" desc="The accessibility string for the video player.">
Video player
</message>
<message name="IDS_ACCESSIBILITY_PLAYBACK_TIME" desc="The accessibility string for how much time has elapsed while viewing the video and how long the video is in total.">
Elapsed time <ph name="ELAPSED_TIME">%1$s<ex>0:01</ex></ph> of <ph name="TOTAL_TIME">%2$s<ex>0:45</ex></ph>.
</message>
<!-- Special locale UI strings -->
<message name="IDS_SEARCH_WITH_SOGOU" desc="Text telling the user that the search engine will be switched to Sogou.">
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment