Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4949c75f authored by Selim Cinek's avatar Selim Cinek
Browse files

Fixed accessibility order for quick settings

Bug: 20535538
Change-Id: I4e464c54158eb575208f6361af295ae702b19b21
parent 4e6b2d3e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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>
+2 −0
Original line number Diff line number Diff line
@@ -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()) {
+24 −3
Original line number Diff line number Diff line
@@ -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() {
+16 −0
Original line number Diff line number Diff line
@@ -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);
        }
    }
}
+3 −3
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ public class ToggleSlider extends RelativeLayout {
    private boolean mTracking;

    private CompoundButton mToggle;
    private SeekBar mSlider;
    private ToggleSeekBar mSlider;
    private TextView mLabel;

    private ToggleSlider mMirror;
@@ -68,13 +68,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();
    }