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

Commit 65769f43 authored by Behnam Heydarshahi's avatar Behnam Heydarshahi
Browse files

Allow seconday label to be off in new tiles

Introduce a new state type called AdapterState. The goal of the
AdapterState is to do everything BooleanState did, except for
overwriting the empty seconday label with default text on/off.

Fixes: 322204517
Flag: aconfig com.android.systemui.qs_new_tiles DEVELOPMENT
Test: Manual. When the flag is on, stateless tiles such as Font should
not have a secondary label, and their label should be vertically
centered.

Change-Id: I9d13874bf2dcf52f33696ae28e648c4f6bfe35eb
parent 5748db0d
Loading
Loading
Loading
Loading
+18 −3
Original line number Diff line number Diff line
@@ -264,15 +264,18 @@ public interface QSTile {
        }
    }

    @ProvidesInterface(version = BooleanState.VERSION)
    public static class BooleanState extends State {
    /**
     * Distinguished from [BooleanState] for use-case purposes such as allowing null secondary label
     */
    @ProvidesInterface(version = AdapterState.VERSION)
    class AdapterState extends State {
        public static final int VERSION = 1;
        public boolean value;
        public boolean forceExpandIcon;

        @Override
        public boolean copyTo(State other) {
            final BooleanState o = (BooleanState) other;
            final AdapterState o = (AdapterState) other;
            final boolean changed = super.copyTo(other)
                    || o.value != value
                    || o.forceExpandIcon != forceExpandIcon;
@@ -289,6 +292,18 @@ public interface QSTile {
            return rt;
        }

        @Override
        public State copy() {
            AdapterState state = new AdapterState();
            copyTo(state);
            return state;
        }
    }

    @ProvidesInterface(version = BooleanState.VERSION)
    class BooleanState extends AdapterState {
        public static final int VERSION = 1;

        @Override
        public State copy() {
            BooleanState state = new BooleanState();
+3 −4
Original line number Diff line number Diff line
@@ -52,7 +52,7 @@ import com.android.systemui.animation.LaunchableView
import com.android.systemui.animation.LaunchableViewDelegate
import com.android.systemui.plugins.qs.QSIconView
import com.android.systemui.plugins.qs.QSTile
import com.android.systemui.plugins.qs.QSTile.BooleanState
import com.android.systemui.plugins.qs.QSTile.AdapterState
import com.android.systemui.plugins.qs.QSTileView
import com.android.systemui.qs.logging.QSLogger
import com.android.systemui.qs.tileimpl.QSIconViewImpl.QS_ANIM_LENGTH
@@ -506,13 +506,12 @@ open class QSTileViewImpl @JvmOverloads constructor(
            state.expandedAccessibilityClassName
        }

        if (state is BooleanState) {
        if (state is AdapterState) {
            val newState = state.value
            if (tileState != newState) {
                tileState = newState
            }
        }
        //

        // Labels
        if (!Objects.equals(label.text, state.label)) {
@@ -625,7 +624,7 @@ open class QSTileViewImpl @JvmOverloads constructor(
            customDrawableView.setImageDrawable(state.sideViewCustomDrawable)
            customDrawableView.visibility = VISIBLE
            chevronView.visibility = GONE
        } else if (state !is BooleanState || state.forceExpandIcon) {
        } else if (state !is AdapterState || state.forceExpandIcon) {
            customDrawableView.setImageDrawable(null)
            customDrawableView.visibility = GONE
            chevronView.visibility = VISIBLE
+1 −1
Original line number Diff line number Diff line
@@ -227,7 +227,7 @@ constructor(
        ): QSTile.State =
            // we have to use QSTile.BooleanState to support different side icons
            // which are bound to instanceof QSTile.BooleanState in QSTileView.
            QSTile.BooleanState().apply {
            QSTile.AdapterState().apply {
                spec = config.tileSpec.spec
                label = viewModelState.label
                // This value is synthetic and doesn't have any meaning. It's only needed to satisfy