diff options
author | Selim Cinek <cinek@google.com> | 2015-07-01 22:03:30 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-07-01 22:03:34 +0000 |
commit | f22e2e3998db9bcfdac5d1c524b0c02e7da7f86d (patch) | |
tree | dd27f8f6bf580ceeb43cfe29bfd675e2e221a00c /packages | |
parent | 61d7acae0cafc265e94a35ad3ba1677f60346de9 (diff) | |
parent | 4949c75f1e891e165b63db17c487cf2383bcfcd4 (diff) | |
download | frameworks_base-f22e2e3998db9bcfdac5d1c524b0c02e7da7f86d.zip frameworks_base-f22e2e3998db9bcfdac5d1c524b0c02e7da7f86d.tar.gz frameworks_base-f22e2e3998db9bcfdac5d1c524b0c02e7da7f86d.tar.bz2 |
Merge "Fixed accessibility order for quick settings" into mnc-dev
Diffstat (limited to 'packages')
5 files changed, 46 insertions, 6 deletions
diff --git a/packages/SystemUI/res/layout/quick_settings_brightness_dialog.xml b/packages/SystemUI/res/layout/quick_settings_brightness_dialog.xml index 38ea6e1..0bef513 100644 --- a/packages/SystemUI/res/layout/quick_settings_brightness_dialog.xml +++ b/packages/SystemUI/res/layout/quick_settings_brightness_dialog.xml @@ -36,6 +36,7 @@ android:layout_gravity="center_vertical" android:layout_weight="1" android:contentDescription="@string/accessibility_brightness" + android:importantForAccessibility="no" systemui:text="@string/status_bar_settings_auto_brightness_label" /> </LinearLayout> diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java index 4b1453d..2ded919 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java @@ -472,6 +472,7 @@ public class QSPanel extends ViewGroup { rows = r + 1; } + View previousView = mBrightnessView; for (TileRecord record : mRecords) { if (record.tileView.setDual(record.tile.supportsDualTargets())) { record.tileView.handleStateChanged(record.tile.getState()); @@ -480,6 +481,7 @@ public class QSPanel extends ViewGroup { final int cw = record.row == 0 ? mLargeCellWidth : mCellWidth; final int ch = record.row == 0 ? mLargeCellHeight : mCellHeight; record.tileView.measure(exactly(cw), exactly(ch)); + previousView = record.tileView.updateAccessibilityOrder(previousView); } int h = rows == 0 ? brightnessHeight : (getRowTop(rows) + mPanelPaddingBottom); if (mFooter.hasFooter()) { diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java b/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java index af9d3a5..6d26a3b 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java @@ -83,6 +83,7 @@ public class QSTileView extends ViewGroup { setClipChildren(false); mTopBackgroundView = new View(context); + mTopBackgroundView.setId(View.generateViewId()); addView(mTopBackgroundView); mIcon = createIcon(); @@ -95,8 +96,8 @@ public class QSTileView extends ViewGroup { addView(mDivider); setClickable(true); - updateTopPadding(); + setId(View.generateViewId()); } private void updateTopPadding() { @@ -137,7 +138,7 @@ public class QSTileView extends ViewGroup { final Resources res = mContext.getResources(); if (mDual) { mDualLabel = new QSDualTileLabel(mContext); - mDualLabel.setId(android.R.id.title); + mDualLabel.setId(View.generateViewId()); mDualLabel.setBackgroundResource(R.drawable.btn_borderless_rect); mDualLabel.setFirstLineCaret(mContext.getDrawable(R.drawable.qs_dual_tile_caret)); mDualLabel.setTextColor(mContext.getColor(R.color.qs_tile_text)); @@ -155,9 +156,9 @@ public class QSTileView extends ViewGroup { mDualLabel.setContentDescription(labelDescription); } addView(mDualLabel); + mDualLabel.setAccessibilityTraversalAfter(mTopBackgroundView.getId()); } else { mLabel = new TextView(mContext); - mLabel.setId(android.R.id.title); mLabel.setTextColor(mContext.getColor(R.color.qs_tile_text)); mLabel.setGravity(Gravity.CENTER_HORIZONTAL); mLabel.setMinLines(2); @@ -328,6 +329,26 @@ public class QSTileView extends ViewGroup { mHandler.obtainMessage(H.STATE_CHANGED, state).sendToTarget(); } + /** + * Update the accessibility order for this view. + * + * @param previousView the view which should be before this one + * @return the last view in this view which is accessible + */ + public View updateAccessibilityOrder(View previousView) { + View firstView; + View lastView; + if (mDual) { + lastView = mDualLabel; + firstView = mTopBackgroundView; + } else { + firstView = this; + lastView = this; + } + firstView.setAccessibilityTraversalAfter(previousView.getId()); + return lastView; + } + private class H extends Handler { private static final int STATE_CHANGED = 1; public H() { diff --git a/packages/SystemUI/src/com/android/systemui/settings/ToggleSeekBar.java b/packages/SystemUI/src/com/android/systemui/settings/ToggleSeekBar.java index a0a5561..8829794 100644 --- a/packages/SystemUI/src/com/android/systemui/settings/ToggleSeekBar.java +++ b/packages/SystemUI/src/com/android/systemui/settings/ToggleSeekBar.java @@ -19,9 +19,13 @@ package com.android.systemui.settings; import android.content.Context; import android.util.AttributeSet; import android.view.MotionEvent; +import android.view.View; +import android.view.accessibility.AccessibilityNodeInfo; import android.widget.SeekBar; public class ToggleSeekBar extends SeekBar { + private String mAccessibilityLabel; + public ToggleSeekBar(Context context) { super(context); } @@ -42,4 +46,16 @@ public class ToggleSeekBar extends SeekBar { return super.onTouchEvent(event); } + + public void setAccessibilityLabel(String label) { + mAccessibilityLabel = label; + } + + @Override + public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { + super.onInitializeAccessibilityNodeInfo(info); + if (mAccessibilityLabel != null) { + info.setText(mAccessibilityLabel); + } + } } diff --git a/packages/SystemUI/src/com/android/systemui/settings/ToggleSlider.java b/packages/SystemUI/src/com/android/systemui/settings/ToggleSlider.java index d247711..b263707 100644 --- a/packages/SystemUI/src/com/android/systemui/settings/ToggleSlider.java +++ b/packages/SystemUI/src/com/android/systemui/settings/ToggleSlider.java @@ -43,7 +43,7 @@ public class ToggleSlider extends RelativeLayout { private boolean mTracking; private CompoundButton mToggle; - private SeekBar mSlider; + private ToggleSeekBar mSlider; private TextView mLabel; private ToggleSlider mMirror; @@ -69,13 +69,13 @@ public class ToggleSlider extends RelativeLayout { mToggle = (CompoundButton) findViewById(R.id.toggle); mToggle.setOnCheckedChangeListener(mCheckListener); - mSlider = (SeekBar) findViewById(R.id.slider); + mSlider = (ToggleSeekBar) findViewById(R.id.slider); mSlider.setOnSeekBarChangeListener(mSeekListener); mLabel = (TextView) findViewById(R.id.label); mLabel.setText(a.getString(R.styleable.ToggleSlider_text)); - setLabelFor(R.id.slider); // use our a11y text to annotate, not replace, the slider's + mSlider.setAccessibilityLabel(getContentDescription().toString()); a.recycle(); } |