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

Commit 7a64815b authored by yingleiw's avatar yingleiw Committed by Zhen Zhang
Browse files

Partially revert "modify quick settings to adopt the accessibility state api"

This reverts commit 4a72a74b except for
the api part.

Fix: b/148501707

Test: not needed
Change-Id: I3cf75589ca0abd2aa58a4291a0261b5ce42d066a
parent e1eecc1d
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -133,7 +133,6 @@ public interface QSTile {
        public CharSequence label;
        public CharSequence secondaryLabel;
        public CharSequence contentDescription;
        public CharSequence stateDescription;
        public CharSequence dualLabelContentDescription;
        public boolean disabledByPolicy;
        public boolean dualTarget = false;
@@ -152,7 +151,6 @@ public interface QSTile {
                    || !Objects.equals(other.label, label)
                    || !Objects.equals(other.secondaryLabel, secondaryLabel)
                    || !Objects.equals(other.contentDescription, contentDescription)
                    || !Objects.equals(other.stateDescription, stateDescription)
                    || !Objects.equals(other.dualLabelContentDescription,
                            dualLabelContentDescription)
                    || !Objects.equals(other.expandedAccessibilityClassName,
@@ -170,7 +168,6 @@ public interface QSTile {
            other.label = label;
            other.secondaryLabel = secondaryLabel;
            other.contentDescription = contentDescription;
            other.stateDescription = stateDescription;
            other.dualLabelContentDescription = dualLabelContentDescription;
            other.expandedAccessibilityClassName = expandedAccessibilityClassName;
            other.disabledByPolicy = disabledByPolicy;
@@ -198,7 +195,6 @@ public interface QSTile {
            sb.append(",label=").append(label);
            sb.append(",secondaryLabel=").append(secondaryLabel);
            sb.append(",contentDescription=").append(contentDescription);
            sb.append(",stateDescription=").append(stateDescription);
            sb.append(",dualLabelContentDescription=").append(dualLabelContentDescription);
            sb.append(",expandedAccessibilityClassName=").append(expandedAccessibilityClassName);
            sb.append(",disabledByPolicy=").append(disabledByPolicy);
+0 −3
Original line number Diff line number Diff line
@@ -2549,7 +2549,4 @@

    <!-- Quick Controls strings [CHAR LIMIT=30] -->
    <string name="quick_controls_title">Quick Controls</string>

    <!-- The tile in quick settings is unavailable. [CHAR LIMIT=32] -->
    <string name="tile_unavailable">Unvailable</string>
</resources>
+0 −7
Original line number Diff line number Diff line
@@ -191,7 +191,6 @@ public class CustomTile extends QSTileImpl<State> implements TileChangeListener
        mTile.setLabel(tile.getLabel());
        mTile.setSubtitle(tile.getSubtitle());
        mTile.setContentDescription(tile.getContentDescription());
        mTile.setStateDescription(tile.getStateDescription());
        mTile.setState(tile.getState());
    }

@@ -346,12 +345,6 @@ public class CustomTile extends QSTileImpl<State> implements TileChangeListener
            state.contentDescription = state.label;
        }

        if (mTile.getStateDescription() != null) {
            state.stateDescription = mTile.getStateDescription();
        } else {
            state.stateDescription = null;
        }

        if (state instanceof BooleanState) {
            state.expandedAccessibilityClassName = Switch.class.getName();
            ((BooleanState) state).value = (state.state == Tile.STATE_ACTIVE);
+20 −23
Original line number Diff line number Diff line
@@ -65,6 +65,7 @@ public class QSTileBaseView extends com.android.systemui.plugins.qs.QSTileView {
    private String mAccessibilityClass;
    private boolean mTileState;
    private boolean mCollapsedView;
    private boolean mClicked;
    private boolean mShowRippleEffect = true;

    private final ImageView mBg;
@@ -233,35 +234,13 @@ public class QSTileBaseView extends com.android.systemui.plugins.qs.QSTileView {
        setLongClickable(state.handlesLongClick);
        mIcon.setIcon(state, allowAnimations);
        setContentDescription(state.contentDescription);
        final StringBuilder stateDescription = new StringBuilder();
        switch (state.state) {
            case Tile.STATE_UNAVAILABLE:
                stateDescription.append(mContext.getString(R.string.tile_unavailable));
                break;
            case Tile.STATE_INACTIVE:
                if (state instanceof QSTile.BooleanState) {
                    stateDescription.append(mContext.getString(R.string.switch_bar_off));
                }
                break;
            case Tile.STATE_ACTIVE:
                if (state instanceof QSTile.BooleanState) {
                    stateDescription.append(mContext.getString(R.string.switch_bar_on));
                }
                break;
            default:
                break;
        }
        if (!TextUtils.isEmpty(state.stateDescription)) {
            stateDescription.append(", ");
            stateDescription.append(state.stateDescription);
        }
        setStateDescription(stateDescription.toString());

        mAccessibilityClass =
                state.state == Tile.STATE_UNAVAILABLE ? null : state.expandedAccessibilityClassName;
        if (state instanceof QSTile.BooleanState) {
            boolean newState = ((BooleanState) state).value;
            if (mTileState != newState) {
                mClicked = false;
                mTileState = newState;
            }
        }
@@ -317,11 +296,24 @@ public class QSTileBaseView extends com.android.systemui.plugins.qs.QSTileView {
        return mIconFrame;
    }

    @Override
    public boolean performClick() {
        mClicked = true;
        return super.performClick();
    }

    @Override
    public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
        super.onInitializeAccessibilityEvent(event);
        if (!TextUtils.isEmpty(mAccessibilityClass)) {
            event.setClassName(mAccessibilityClass);
            if (Switch.class.getName().equals(mAccessibilityClass)) {
                boolean b = mClicked ? !mTileState : mTileState;
                String label = getResources()
                        .getString(b ? R.string.switch_bar_on : R.string.switch_bar_off);
                event.setContentDescription(label);
                event.setChecked(b);
            }
        }
    }

@@ -333,6 +325,11 @@ public class QSTileBaseView extends com.android.systemui.plugins.qs.QSTileView {
        if (!TextUtils.isEmpty(mAccessibilityClass)) {
            info.setClassName(mAccessibilityClass);
            if (Switch.class.getName().equals(mAccessibilityClass)) {
                boolean b = mClicked ? !mTileState : mTileState;
                String label = getResources()
                        .getString(b ? R.string.switch_bar_on : R.string.switch_bar_off);
                info.setText(label);
                info.setChecked(b);
                info.setCheckable(true);
                if (isLongClickable()) {
                    info.addAction(
+4 −6
Original line number Diff line number Diff line
@@ -134,27 +134,25 @@ public class BluetoothTile extends QSTileImpl<BooleanState> {
        state.label = mContext.getString(R.string.quick_settings_bluetooth_label);
        state.secondaryLabel = TextUtils.emptyIfNull(
                getSecondaryLabel(enabled, connecting, connected, state.isTransient));
        state.contentDescription = state.label;
        state.stateDescription = "";
        if (enabled) {
            if (connected) {
                state.icon = new BluetoothConnectedTileIcon();
                if (!TextUtils.isEmpty(mController.getConnectedDeviceName())) {
                    state.label = mController.getConnectedDeviceName();
                }
                state.stateDescription =
                state.contentDescription =
                        mContext.getString(R.string.accessibility_bluetooth_name, state.label)
                                + ", " + state.secondaryLabel;
            } else if (state.isTransient) {
                state.icon = ResourceIcon.get(
                        com.android.internal.R.drawable.ic_bluetooth_transient_animation);
                state.stateDescription = state.secondaryLabel;
                state.contentDescription = state.secondaryLabel;
            } else {
                state.icon =
                        ResourceIcon.get(com.android.internal.R.drawable.ic_qs_bluetooth);
                state.contentDescription = mContext.getString(
                        R.string.accessibility_quick_settings_bluetooth);
                state.stateDescription = mContext.getString(R.string.accessibility_not_connected);
                        R.string.accessibility_quick_settings_bluetooth) + ","
                        + mContext.getString(R.string.accessibility_not_connected);
            }
            state.state = Tile.STATE_ACTIVE;
        } else {
Loading