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

Commit f367889d authored by Yinglei Wang's avatar Yinglei Wang Committed by Android (Google) Code Review
Browse files

Merge "modify quick settings to adopt the accessibility state api"

parents 6923cdd8 4a72a74b
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -43893,11 +43893,13 @@ package android.service.quicksettings {
    method public android.graphics.drawable.Icon getIcon();
    method public android.graphics.drawable.Icon getIcon();
    method public CharSequence getLabel();
    method public CharSequence getLabel();
    method public int getState();
    method public int getState();
    method @Nullable public CharSequence getStateDescription();
    method @Nullable public CharSequence getSubtitle();
    method @Nullable public CharSequence getSubtitle();
    method public void setContentDescription(CharSequence);
    method public void setContentDescription(CharSequence);
    method public void setIcon(android.graphics.drawable.Icon);
    method public void setIcon(android.graphics.drawable.Icon);
    method public void setLabel(CharSequence);
    method public void setLabel(CharSequence);
    method public void setState(int);
    method public void setState(int);
    method public void setStateDescription(@Nullable CharSequence);
    method public void setSubtitle(@Nullable CharSequence);
    method public void setSubtitle(@Nullable CharSequence);
    method public void updateTile();
    method public void updateTile();
    method public void writeToParcel(android.os.Parcel, int);
    method public void writeToParcel(android.os.Parcel, int);
+22 −0
Original line number Original line Diff line number Diff line
@@ -65,6 +65,7 @@ public final class Tile implements Parcelable {
    private CharSequence mLabel;
    private CharSequence mLabel;
    private CharSequence mSubtitle;
    private CharSequence mSubtitle;
    private CharSequence mContentDescription;
    private CharSequence mContentDescription;
    private CharSequence mStateDescription;
    // Default to inactive until clients of the new API can update.
    // Default to inactive until clients of the new API can update.
    private int mState = STATE_INACTIVE;
    private int mState = STATE_INACTIVE;


@@ -176,6 +177,14 @@ public final class Tile implements Parcelable {
        return mContentDescription;
        return mContentDescription;
    }
    }


    /**
     * Gets the current state description for the tile.
     */
    @Nullable
    public CharSequence getStateDescription() {
        return mStateDescription;
    }

    /**
    /**
     * Sets the current content description for the tile.
     * Sets the current content description for the tile.
     *
     *
@@ -187,6 +196,17 @@ public final class Tile implements Parcelable {
        this.mContentDescription = contentDescription;
        this.mContentDescription = contentDescription;
    }
    }


    /**
     * Sets the current state description for the tile.
     *
     * Does not take effect until {@link #updateTile()} is called.
     *
     * @param stateDescription New state description to use.
     */
    public void setStateDescription(@Nullable CharSequence stateDescription) {
        this.mStateDescription = stateDescription;
    }

    @Override
    @Override
    public int describeContents() {
    public int describeContents() {
        return 0;
        return 0;
@@ -215,6 +235,7 @@ public final class Tile implements Parcelable {
        TextUtils.writeToParcel(mLabel, dest, flags);
        TextUtils.writeToParcel(mLabel, dest, flags);
        TextUtils.writeToParcel(mSubtitle, dest, flags);
        TextUtils.writeToParcel(mSubtitle, dest, flags);
        TextUtils.writeToParcel(mContentDescription, dest, flags);
        TextUtils.writeToParcel(mContentDescription, dest, flags);
        TextUtils.writeToParcel(mStateDescription, dest, flags);
    }
    }


    private void readFromParcel(Parcel source) {
    private void readFromParcel(Parcel source) {
@@ -227,6 +248,7 @@ public final class Tile implements Parcelable {
        mLabel = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
        mLabel = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
        mSubtitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
        mSubtitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
        mContentDescription = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
        mContentDescription = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
        mStateDescription = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
    }
    }


    public static final @android.annotation.NonNull Creator<Tile> CREATOR = new Creator<Tile>() {
    public static final @android.annotation.NonNull Creator<Tile> CREATOR = new Creator<Tile>() {
+4 −0
Original line number Original line Diff line number Diff line
@@ -133,6 +133,7 @@ public interface QSTile {
        public CharSequence label;
        public CharSequence label;
        public CharSequence secondaryLabel;
        public CharSequence secondaryLabel;
        public CharSequence contentDescription;
        public CharSequence contentDescription;
        public CharSequence stateDescription;
        public CharSequence dualLabelContentDescription;
        public CharSequence dualLabelContentDescription;
        public boolean disabledByPolicy;
        public boolean disabledByPolicy;
        public boolean dualTarget = false;
        public boolean dualTarget = false;
@@ -151,6 +152,7 @@ public interface QSTile {
                    || !Objects.equals(other.label, label)
                    || !Objects.equals(other.label, label)
                    || !Objects.equals(other.secondaryLabel, secondaryLabel)
                    || !Objects.equals(other.secondaryLabel, secondaryLabel)
                    || !Objects.equals(other.contentDescription, contentDescription)
                    || !Objects.equals(other.contentDescription, contentDescription)
                    || !Objects.equals(other.stateDescription, stateDescription)
                    || !Objects.equals(other.dualLabelContentDescription,
                    || !Objects.equals(other.dualLabelContentDescription,
                            dualLabelContentDescription)
                            dualLabelContentDescription)
                    || !Objects.equals(other.expandedAccessibilityClassName,
                    || !Objects.equals(other.expandedAccessibilityClassName,
@@ -168,6 +170,7 @@ public interface QSTile {
            other.label = label;
            other.label = label;
            other.secondaryLabel = secondaryLabel;
            other.secondaryLabel = secondaryLabel;
            other.contentDescription = contentDescription;
            other.contentDescription = contentDescription;
            other.stateDescription = stateDescription;
            other.dualLabelContentDescription = dualLabelContentDescription;
            other.dualLabelContentDescription = dualLabelContentDescription;
            other.expandedAccessibilityClassName = expandedAccessibilityClassName;
            other.expandedAccessibilityClassName = expandedAccessibilityClassName;
            other.disabledByPolicy = disabledByPolicy;
            other.disabledByPolicy = disabledByPolicy;
@@ -195,6 +198,7 @@ public interface QSTile {
            sb.append(",label=").append(label);
            sb.append(",label=").append(label);
            sb.append(",secondaryLabel=").append(secondaryLabel);
            sb.append(",secondaryLabel=").append(secondaryLabel);
            sb.append(",contentDescription=").append(contentDescription);
            sb.append(",contentDescription=").append(contentDescription);
            sb.append(",stateDescription=").append(stateDescription);
            sb.append(",dualLabelContentDescription=").append(dualLabelContentDescription);
            sb.append(",dualLabelContentDescription=").append(dualLabelContentDescription);
            sb.append(",expandedAccessibilityClassName=").append(expandedAccessibilityClassName);
            sb.append(",expandedAccessibilityClassName=").append(expandedAccessibilityClassName);
            sb.append(",disabledByPolicy=").append(disabledByPolicy);
            sb.append(",disabledByPolicy=").append(disabledByPolicy);
+3 −0
Original line number Original line Diff line number Diff line
@@ -2549,4 +2549,7 @@


    <!-- Quick Controls strings [CHAR LIMIT=30] -->
    <!-- Quick Controls strings [CHAR LIMIT=30] -->
    <string name="quick_controls_title">Quick Controls</string>
    <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>
</resources>
+7 −0
Original line number Original line Diff line number Diff line
@@ -191,6 +191,7 @@ public class CustomTile extends QSTileImpl<State> implements TileChangeListener
        mTile.setLabel(tile.getLabel());
        mTile.setLabel(tile.getLabel());
        mTile.setSubtitle(tile.getSubtitle());
        mTile.setSubtitle(tile.getSubtitle());
        mTile.setContentDescription(tile.getContentDescription());
        mTile.setContentDescription(tile.getContentDescription());
        mTile.setStateDescription(tile.getStateDescription());
        mTile.setState(tile.getState());
        mTile.setState(tile.getState());
    }
    }


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


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

        if (state instanceof BooleanState) {
        if (state instanceof BooleanState) {
            state.expandedAccessibilityClassName = Switch.class.getName();
            state.expandedAccessibilityClassName = Switch.class.getName();
            ((BooleanState) state).value = (state.state == Tile.STATE_ACTIVE);
            ((BooleanState) state).value = (state.state == Tile.STATE_ACTIVE);
Loading