diff options
author | Chung-yih Wang <cywang@google.com> | 2011-10-04 11:20:04 +0800 |
---|---|---|
committer | Chung-yih Wang <cywang@google.com> | 2011-10-11 10:39:58 +0800 |
commit | 26d88fce15a24362644123af5f0cce79ea572e7b (patch) | |
tree | 31589b7a98dcf1b38b4e0d17fe6bc4a24ac632b8 | |
parent | 5e99c7f1f5c07d9b728c301a5746cb15b65124fb (diff) | |
download | LegacyCamera-26d88fce15a24362644123af5f0cce79ea572e7b.tar.gz LegacyCamera-26d88fce15a24362644123af5f0cce79ea572e7b.tar.bz2 LegacyCamera-26d88fce15a24362644123af5f0cce79ea572e7b.zip |
Add content descirptions for accessibility.
bug:5230109
Change-Id: I055fccea0d30c54dc8520bf1d0424b963d2ba8a5
-rw-r--r-- | AndroidManifest.xml | 1 | ||||
-rw-r--r-- | res/layout/camera_control.xml | 1 | ||||
-rw-r--r-- | res/layout/indicator_bar.xml | 7 | ||||
-rw-r--r-- | res/layout/mode_picker.xml | 8 | ||||
-rw-r--r-- | res/layout/review_thumbnail.xml | 1 | ||||
-rw-r--r-- | res/values/strings.xml | 24 | ||||
-rw-r--r-- | src/com/android/camera/ui/AbstractIndicatorButton.java | 2 | ||||
-rw-r--r-- | src/com/android/camera/ui/CameraPicker.java | 2 | ||||
-rw-r--r-- | src/com/android/camera/ui/InLineSettingItem.java | 2 | ||||
-rw-r--r-- | src/com/android/camera/ui/InLineSettingKnob.java | 23 | ||||
-rw-r--r-- | src/com/android/camera/ui/InLineSettingSwitch.java | 22 | ||||
-rw-r--r-- | src/com/android/camera/ui/IndicatorControl.java | 3 | ||||
-rw-r--r-- | src/com/android/camera/ui/SecondLevelIndicatorControlBar.java | 11 | ||||
-rw-r--r-- | src/com/android/camera/ui/ZoomControl.java | 7 |
14 files changed, 107 insertions, 7 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 61088eca..23114dba 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -65,6 +65,7 @@ </intent-filter> </activity> <activity android:name="com.android.camera.panorama.PanoramaActivity" + android:label="@string/pano_dialog_title" android:configChanges="orientation|screenSize|keyboardHidden" android:screenOrientation="landscape" android:clearTaskOnLaunch="true" diff --git a/res/layout/camera_control.xml b/res/layout/camera_control.xml index 6aba4938..366393da 100644 --- a/res/layout/camera_control.xml +++ b/res/layout/camera_control.xml @@ -29,6 +29,7 @@ android:scaleType="center" android:clickable="true" android:focusable="true" + android:contentDescription="@string/accessibility_shutter_button" android:background="@drawable/btn_shutter" /> <include layout="@layout/mode_picker" /> </com.android.camera.ui.ControlPanelLayout> diff --git a/res/layout/indicator_bar.xml b/res/layout/indicator_bar.xml index 4fe6d458..764d6d60 100644 --- a/res/layout/indicator_bar.xml +++ b/res/layout/indicator_bar.xml @@ -41,6 +41,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" + android:contentDescription="@string/accessibility_second_level_indicators" android:src="@drawable/ic_settings_holo_light" /> </com.android.camera.ui.IndicatorControlBar> @@ -63,6 +64,12 @@ android:layout_height="0dp" android:background="@color/mode_selection_border" android:visibility="gone" /> + <com.android.camera.ui.ColorFilterImageView + android:id="@+id/back_to_first_level" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:contentDescription="@string/accessibility_back_to_first_level" + android:src="@drawable/btn_close_settings" /> </com.android.camera.ui.SecondLevelIndicatorControlBar> </RelativeLayout> diff --git a/res/layout/mode_picker.xml b/res/layout/mode_picker.xml index 5cbc8823..12c9618d 100644 --- a/res/layout/mode_picker.xml +++ b/res/layout/mode_picker.xml @@ -24,12 +24,14 @@ android:layout_alignBottom="@+id/mode_selection" android:layout_width="match_parent" android:layout_height="55dp" + android:contentDescription="@string/accessibility_mode_picker" android:background="@drawable/bg_mode_picker"> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="@android:color/white"/> <RelativeLayout android:orientation="horizontal" + android:contentDescription="@string/empty" android:layout_width="match_parent" android:layout_height="match_parent"> <com.android.camera.ui.RotateImageView android:id="@+id/mode_0" @@ -39,12 +41,14 @@ android:layout_alignParentLeft="true" android:layout_marginLeft="8dp" android:scaleType="fitCenter" + android:contentDescription="@string/empty" android:src="@drawable/ic_switch_video_holo_light" /> <com.android.camera.ui.RotateImageView android:id="@+id/mode_1" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_centerInParent="true" android:scaleType="fitCenter" + android:contentDescription="@string/empty" android:src="@drawable/ic_switch_camera_holo_light" /> <com.android.camera.ui.RotateImageView android:id="@+id/mode_2" android:layout_width="32dp" @@ -53,6 +57,7 @@ android:layout_alignParentRight="true" android:layout_marginRight="8dp" android:scaleType="fitCenter" + android:contentDescription="@string/empty" android:src="@drawable/ic_switch_pan_holo_light" /> </RelativeLayout> </RelativeLayout> @@ -72,6 +77,7 @@ android:layout_height="wrap_content" android:layout_centerVertical="true"> <com.android.camera.ui.RotateImageView android:id="@+id/mode_camera" + android:contentDescription="@string/switch_to_camera_label" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="10dp" @@ -79,6 +85,7 @@ android:background="@drawable/bg_pressed" android:src="@drawable/ic_switch_camera_holo_light" /> <com.android.camera.ui.RotateImageView android:id="@+id/mode_video" + android:contentDescription="@string/switch_to_video_label" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="10dp" @@ -86,6 +93,7 @@ android:background="@drawable/bg_pressed" android:src="@drawable/ic_switch_video_holo_light" /> <com.android.camera.ui.RotateImageView android:id="@+id/mode_panorama" + android:contentDescription="@string/switch_to_panorama_label" android:layout_width="match_parent" android:layout_height="wrap_content" android:scaleType="center" diff --git a/res/layout/review_thumbnail.xml b/res/layout/review_thumbnail.xml index 1d806873..1f94e27d 100644 --- a/res/layout/review_thumbnail.xml +++ b/res/layout/review_thumbnail.xml @@ -21,5 +21,6 @@ android:clickable="true" android:focusable="false" android:visibility="gone" + android:contentDescription="@string/accessibility_review_thumbnail" android:background="@drawable/border_last_picture"> </com.android.camera.ui.RotateImageView> diff --git a/res/values/strings.xml b/res/values/strings.xml index 0bdb819c..7cc61f4a 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -329,4 +329,28 @@ <!-- Title of category for background replacement effects. [CHAR LIMIT=26] --> <string name="effect_background">Background</string> + + <!-- The shutter button. [CHAR LIMIT = NONE] --> + <string name="accessibility_shutter_button">Shutter button</string> + <!-- The button to review the thumbnail. [CHAR LIMIT = NONE] --> + <string name="accessibility_review_thumbnail">Most recent photo</string> + <!-- The front/back camera switch. [CHAR LIMIT = NONE] --> + <string name="accessibility_camera_picker">Front and back camera switch</string> + <!-- The mode picker to switch between camera, video and panorama. [CHAR LIMIT = NONE] --> + <string name="accessibility_mode_picker">Camera, video or panorama selector</string> + <!-- The button to switch to the second-level indicators of the camera settings. [CHAR LIMIT = NONE] --> + <string name="accessibility_second_level_indicators">More setting controls</string> + <!-- The button to back to the first-level indicators of the camera settings. [CHAR LIMIT = NONE] --> + <string name="accessibility_back_to_first_level">Close setting controls</string> + <!-- The zoom control button. [CHAR LIMIT = NONE] --> + <string name="accessibility_zoom_control">Zoom control</string> + <!-- The decrement button in camera preference such as exposure, picture size. [CHAR LIMIT = NONE] --> + <string name="accessibility_decrement">Decrease %1$s</string> + <!-- The increment button in camera preference such as exposure, picture size. [CHAR LIMIT = NONE] --> + <string name="accessibility_increment">Increase %1$s</string> + <!-- The on/off switch in camera settings, such as store location. [CHAR LIMIT = NONE] --> + <string name="accessibility_switch">%1$s switch</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> </resources> diff --git a/src/com/android/camera/ui/AbstractIndicatorButton.java b/src/com/android/camera/ui/AbstractIndicatorButton.java index 037a273b..a6615869 100644 --- a/src/com/android/camera/ui/AbstractIndicatorButton.java +++ b/src/com/android/camera/ui/AbstractIndicatorButton.java @@ -50,6 +50,8 @@ public abstract class AbstractIndicatorButton extends RotateImageView implements HIGHLIGHT_COLOR = context.getResources().getColor(R.color.review_control_pressed_color); setScaleType(ImageView.ScaleType.CENTER); PopupManager.getInstance(context).setOnOtherPopupShowedListener(this); + // Set the click listener to help the comprehension of the accessibility. + setClickable(true); } @Override diff --git a/src/com/android/camera/ui/CameraPicker.java b/src/com/android/camera/ui/CameraPicker.java index 78e2b27b..ac8b8a82 100644 --- a/src/com/android/camera/ui/CameraPicker.java +++ b/src/com/android/camera/ui/CameraPicker.java @@ -38,6 +38,8 @@ public class CameraPicker extends RotateImageView implements View.OnClickListene public CameraPicker(Context context) { super(context); setImageResource(mImageResource); + setContentDescription(getResources().getString( + R.string.accessibility_camera_picker)); } public static void setImageResourceId(int imageResource) { diff --git a/src/com/android/camera/ui/InLineSettingItem.java b/src/com/android/camera/ui/InLineSettingItem.java index 6f84e6f0..bf6bdb2b 100644 --- a/src/com/android/camera/ui/InLineSettingItem.java +++ b/src/com/android/camera/ui/InLineSettingItem.java @@ -21,6 +21,7 @@ import com.android.camera.R; import android.content.Context; import android.util.AttributeSet; +import android.view.accessibility.AccessibilityEvent; import android.widget.LinearLayout; import android.widget.TextView; @@ -70,6 +71,7 @@ public abstract class InLineSettingItem extends LinearLayout { mListener.onSettingChanged(); } updateView(); + sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED); return true; } diff --git a/src/com/android/camera/ui/InLineSettingKnob.java b/src/com/android/camera/ui/InLineSettingKnob.java index 9bb771cc..99a3b661 100644 --- a/src/com/android/camera/ui/InLineSettingKnob.java +++ b/src/com/android/camera/ui/InLineSettingKnob.java @@ -16,6 +16,7 @@ package com.android.camera.ui; +import com.android.camera.ListPreference; import com.android.camera.R; import android.content.Context; @@ -25,6 +26,7 @@ import android.util.Log; import android.view.MotionEvent; import android.view.View; import android.view.View.OnTouchListener; +import android.view.accessibility.AccessibilityEvent; import android.widget.Button; import android.widget.TextView; @@ -100,6 +102,16 @@ public class InLineSettingKnob extends InLineSettingItem { mEntry = (TextView) findViewById(R.id.current_setting); } + @Override + public void initialize(ListPreference preference) { + super.initialize(preference); + // Add content descriptions for the increment and decrement buttons. + mNextButton.setContentDescription(getResources().getString( + R.string.accessibility_increment, mPreference.getTitle())); + mPrevButton.setContentDescription(getResources().getString( + R.string.accessibility_decrement, mPreference.getTitle())); + } + protected void updateView() { if (mOverrideValue == null) { mEntry.setText(mPreference.getEntry()); @@ -120,4 +132,15 @@ public class InLineSettingKnob extends InLineSettingItem { } } + @Override + public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { + onPopulateAccessibilityEvent(event); + return true; + } + + @Override + public void onPopulateAccessibilityEvent(AccessibilityEvent event) { + super.onPopulateAccessibilityEvent(event); + event.getText().add(mPreference.getTitle() + mPreference.getEntry()); + } } diff --git a/src/com/android/camera/ui/InLineSettingSwitch.java b/src/com/android/camera/ui/InLineSettingSwitch.java index 8663a057..8fc37da9 100644 --- a/src/com/android/camera/ui/InLineSettingSwitch.java +++ b/src/com/android/camera/ui/InLineSettingSwitch.java @@ -16,11 +16,13 @@ package com.android.camera.ui; +import com.android.camera.ListPreference; import com.android.camera.R; import android.content.Context; import android.util.AttributeSet; import android.view.View; +import android.view.accessibility.AccessibilityEvent; import android.widget.Button; import android.widget.CompoundButton; import android.widget.CompoundButton.OnCheckedChangeListener; @@ -47,6 +49,14 @@ public class InLineSettingSwitch extends InLineSettingItem { mSwitch.setOnCheckedChangeListener(mCheckedChangeListener); } + @Override + public void initialize(ListPreference preference) { + super.initialize(preference); + // Add content descriptions for the increment and decrement buttons. + mSwitch.setContentDescription(getContext().getResources().getString( + R.string.accessibility_switch, mPreference.getTitle())); + } + protected void updateView() { if (mOverrideValue == null) { mSwitch.setChecked(mIndex == 1); @@ -55,4 +65,16 @@ public class InLineSettingSwitch extends InLineSettingItem { mSwitch.setChecked(index == 1); } } + + @Override + public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { + onPopulateAccessibilityEvent(event); + return true; + } + + @Override + public void onPopulateAccessibilityEvent(AccessibilityEvent event) { + super.onPopulateAccessibilityEvent(event); + event.getText().add(mPreference.getTitle()); + } } diff --git a/src/com/android/camera/ui/IndicatorControl.java b/src/com/android/camera/ui/IndicatorControl.java index 03003d89..86b0cc96 100644 --- a/src/com/android/camera/ui/IndicatorControl.java +++ b/src/com/android/camera/ui/IndicatorControl.java @@ -125,6 +125,7 @@ public abstract class IndicatorControl extends RelativeLayout implements public IndicatorButton addIndicator(Context context, IconListPreference pref) { IndicatorButton b = new IndicatorButton(context, pref); b.setSettingChangedListener(this); + b.setContentDescription(pref.getTitle()); addView(b); mIndicators.add(b); return b; @@ -135,6 +136,8 @@ public abstract class IndicatorControl extends RelativeLayout implements OtherSettingIndicatorButton b = new OtherSettingIndicatorButton( context, resId, mPreferenceGroup, keys); b.setSettingChangedListener(this); + b.setContentDescription(getResources().getString( + R.string.pref_camera_settings_category)); addView(b); mIndicators.add(b); return b; diff --git a/src/com/android/camera/ui/SecondLevelIndicatorControlBar.java b/src/com/android/camera/ui/SecondLevelIndicatorControlBar.java index 8fce8a71..c9037d9b 100644 --- a/src/com/android/camera/ui/SecondLevelIndicatorControlBar.java +++ b/src/com/android/camera/ui/SecondLevelIndicatorControlBar.java @@ -35,7 +35,7 @@ public class SecondLevelIndicatorControlBar extends IndicatorControl implements View.OnClickListener, AbstractIndicatorButton.IndicatorChangeListener { private static final String TAG = "SecondLevelIndicatorControlBar"; private static int ICON_SPACING = Util.dpToPixel(16); - private ImageView mCloseIcon; + private View mCloseIcon; private View mDivider; // the divider line private View mIndicatorHighlight; // the side highlight bar private View mPopupedIndicator; @@ -54,16 +54,13 @@ public class SecondLevelIndicatorControlBar extends IndicatorControl implements protected void onFinishInflate() { mDivider = findViewById(R.id.divider); mIndicatorHighlight = findViewById(R.id.indicator_highlight); + mCloseIcon = findViewById(R.id.back_to_first_level); + mCloseIcon.setOnClickListener(this); } public void initialize(Context context, PreferenceGroup group, String[] keys, String[] otherSettingKeys) { - if (mCloseIcon == null) { - mCloseIcon = new ColorFilterImageView(context); - mCloseIcon.setImageResource(R.drawable.btn_close_settings); - mCloseIcon.setOnClickListener(this); - addView(mCloseIcon); - } + setPreferenceGroup(group); mNonIndicatorButtonCount = getChildCount(); addControls(keys, otherSettingKeys); diff --git a/src/com/android/camera/ui/ZoomControl.java b/src/com/android/camera/ui/ZoomControl.java index 60964a48..1809d18e 100644 --- a/src/com/android/camera/ui/ZoomControl.java +++ b/src/com/android/camera/ui/ZoomControl.java @@ -88,6 +88,13 @@ public abstract class ZoomControl extends RelativeLayout { protected ImageView addImageView(Context context, int iconResourceId) { ImageView image = new RotateImageView(context); image.setImageResource(iconResourceId); + if (iconResourceId == R.drawable.ic_zoom_slider) { + image.setContentDescription(getResources().getString( + R.string.accessibility_zoom_control)); + } else { + image.setContentDescription(getResources().getString( + R.string.empty)); + } addView(image); return image; } |