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

Commit 66a8e732 authored by Evan Laird's avatar Evan Laird
Browse files

Add an API to Tile for subtitles

Test: create a third party tile
Change-Id: Ibcf6bd160f7132e724dd16d8dfa45191c90fa02f
Fixes: 115292064
parent 82f028ce
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -41047,10 +41047,12 @@ package android.service.quicksettings {
    method public android.graphics.drawable.Icon getIcon();
    method public java.lang.CharSequence getLabel();
    method public int getState();
    method public java.lang.CharSequence getSubtitle();
    method public void setContentDescription(java.lang.CharSequence);
    method public void setIcon(android.graphics.drawable.Icon);
    method public void setLabel(java.lang.CharSequence);
    method public void setState(int);
    method public void setSubtitle(java.lang.CharSequence);
    method public void updateTile();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.service.quicksettings.Tile> CREATOR;
+20 −0
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
 */
package android.service.quicksettings;

import android.annotation.Nullable;
import android.graphics.drawable.Icon;
import android.os.IBinder;
import android.os.Parcel;
@@ -62,6 +63,7 @@ public final class Tile implements Parcelable {
    private IBinder mToken;
    private Icon mIcon;
    private CharSequence mLabel;
    private CharSequence mSubtitle;
    private CharSequence mContentDescription;
    // Default to active until clients of the new API can update.
    private int mState = STATE_ACTIVE;
@@ -151,6 +153,22 @@ public final class Tile implements Parcelable {
        this.mLabel = label;
    }

    /**
     * Gets the current subtitle for the tile.
     */
    @Nullable
    public CharSequence getSubtitle() {
        return mSubtitle;
    }

    /**
     * Set the subtitle for the tile. Will be displayed as the secondary label.
     * @param subtitle the subtitle to show.
     */
    public void setSubtitle(@Nullable CharSequence subtitle) {
        this.mSubtitle = subtitle;
    }

    /**
     * Gets the current content description for the tile.
     */
@@ -195,6 +213,7 @@ public final class Tile implements Parcelable {
        }
        dest.writeInt(mState);
        TextUtils.writeToParcel(mLabel, dest, flags);
        TextUtils.writeToParcel(mSubtitle, dest, flags);
        TextUtils.writeToParcel(mContentDescription, dest, flags);
    }

@@ -206,6 +225,7 @@ public final class Tile implements Parcelable {
        }
        mState = source.readInt();
        mLabel = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
        mSubtitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
        mContentDescription = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
    }

+9 −0
Original line number Diff line number Diff line
@@ -183,6 +183,7 @@ public class CustomTile extends QSTileImpl<State> implements TileChangeListener
    public void updateState(Tile tile) {
        mTile.setIcon(tile.getIcon());
        mTile.setLabel(tile.getLabel());
        mTile.setSubtitle(tile.getSubtitle());
        mTile.setContentDescription(tile.getContentDescription());
        mTile.setState(tile.getState());
    }
@@ -322,6 +323,14 @@ public class CustomTile extends QSTileImpl<State> implements TileChangeListener
            return null;
        };
        state.label = mTile.getLabel();

        CharSequence subtitle = mTile.getSubtitle();
        if (subtitle != null && subtitle.length() > 0) {
            state.secondaryLabel = subtitle;
        } else {
            state.secondaryLabel = null;
        }

        if (mTile.getContentDescription() != null) {
            state.contentDescription = mTile.getContentDescription();
        } else {