OSDN Git Service

Add accessibility to video player controller.
authorztenghui <ztenghui@google.com>
Tue, 16 Apr 2013 20:52:07 +0000 (13:52 -0700)
committerztenghui <ztenghui@google.com>
Wed, 17 Apr 2013 18:05:50 +0000 (11:05 -0700)
bug:5714277

cherry pick the Carlsbad CL:
https://googleplex-android-review.git.corp.google.com/#/c/297944/

Change-Id: If0de1ec250a211890e1914d89e8b61780542a675

res/values/strings.xml
src/com/android/gallery3d/app/CommonControllerOverlay.java

index 7f8e083..8fa8f34 100644 (file)
     <!-- button in review mode indicate the user want to retake another photo/video for attachment [
 CHAR LIMIT = NONE] -->
     <string name="accessibility_review_retake">Review retake</string>
+    <!-- The button to play the video. [CHAR LIMIT = NONE] -->
+    <string name="accessibility_play_video">Play video</string>
+    <!-- The button to pause the video. [CHAR LIMIT = NONE] -->
+    <string name="accessibility_pause_video">Pause video</string>
+    <!-- The button to reload the video. [CHAR LIMIT = NONE] -->
+    <string name="accessibility_reload_video">Reload video</string>
+    <!-- The time bar of the media player. [CHAR LIMIT = NONE] -->
+    <string name="accessibility_time_bar">Video player time bar</string>
+
     <!-- TODO: remove the string as it is a work-around solution to bypass the default speak of the element type. -->
     <string name="empty" translatable="false">" "</string>
 
index a5aa805..a4f5807 100644 (file)
@@ -17,6 +17,7 @@
 package com.android.gallery3d.app;
 
 import android.content.Context;
+import android.content.res.Resources;
 import android.graphics.Rect;
 import android.view.Gravity;
 import android.view.KeyEvent;
@@ -83,7 +84,8 @@ public abstract class CommonControllerOverlay extends FrameLayout implements
         // multiple ones for trimming.
         createTimeBar(context);
         addView(mTimeBar, wrapContent);
-
+        mTimeBar.setContentDescription(
+                context.getResources().getString(R.string.accessibility_time_bar));
         mLoadingView = new LinearLayout(context);
         mLoadingView.setOrientation(LinearLayout.VERTICAL);
         mLoadingView.setGravity(Gravity.CENTER_HORIZONTAL);
@@ -97,6 +99,8 @@ public abstract class CommonControllerOverlay extends FrameLayout implements
 
         mPlayPauseReplayView = new ImageView(context);
         mPlayPauseReplayView.setImageResource(R.drawable.ic_vidcontrol_play);
+        mPlayPauseReplayView.setContentDescription(
+                context.getResources().getString(R.string.accessibility_play_video));
         mPlayPauseReplayView.setBackgroundResource(R.drawable.bg_vidcontrol);
         mPlayPauseReplayView.setScaleType(ScaleType.CENTER);
         mPlayPauseReplayView.setFocusable(true);
@@ -299,10 +303,19 @@ public abstract class CommonControllerOverlay extends FrameLayout implements
     protected void updateViews() {
         mBackground.setVisibility(View.VISIBLE);
         mTimeBar.setVisibility(View.VISIBLE);
-        mPlayPauseReplayView.setImageResource(
-                mState == State.PAUSED ? R.drawable.ic_vidcontrol_play :
-                mState == State.PLAYING ? R.drawable.ic_vidcontrol_pause :
-                R.drawable.ic_vidcontrol_reload);
+        Resources resources = getContext().getResources();
+        int imageResource = R.drawable.ic_vidcontrol_reload;
+        String contentDescription = resources.getString(R.string.accessibility_reload_video);
+        if (mState == State.PAUSED) {
+            imageResource = R.drawable.ic_vidcontrol_play;
+            contentDescription = resources.getString(R.string.accessibility_play_video);
+        } else if (mState == State.PLAYING) {
+            imageResource = R.drawable.ic_vidcontrol_pause;
+            contentDescription = resources.getString(R.string.accessibility_pause_video);
+        }
+
+        mPlayPauseReplayView.setImageResource(imageResource);
+        mPlayPauseReplayView.setContentDescription(contentDescription);
         mPlayPauseReplayView.setVisibility(
                 (mState != State.LOADING && mState != State.ERROR &&
                 !(mState == State.ENDED && !mCanReplay))