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

Commit cd7ecf7d authored by Fabian Kozynski's avatar Fabian Kozynski
Browse files

Add chevron to tiles that expand instead of toggling.

Logic for side view:
* If the tile has a sideViewCustomDrawable, show that regardless of
State
* Else, if the tile is not Boolean or the state has forceExpandView, it
shows a chevron.
* Else, show nothing.

Test: atest com.android.systemui.qs
Test: manual
Fixes: 187057842
Change-Id: Ib9407914f4fbe5ac833b06008fc405435d0c45b0
parent 9c8de7bd
Loading
Loading
Loading
Loading
+10 −5
Original line number Original line Diff line number Diff line
@@ -163,7 +163,7 @@ public interface QSTile {
        public SlashState slash;
        public SlashState slash;
        public boolean handlesLongClick = true;
        public boolean handlesLongClick = true;
        public boolean showRippleEffect = true;
        public boolean showRippleEffect = true;
        public Drawable sideViewDrawable;
        public Drawable sideViewCustomDrawable;


        public boolean copyTo(State other) {
        public boolean copyTo(State other) {
            if (other == null) throw new IllegalArgumentException();
            if (other == null) throw new IllegalArgumentException();
@@ -185,7 +185,7 @@ public interface QSTile {
                    || !Objects.equals(other.slash, slash)
                    || !Objects.equals(other.slash, slash)
                    || !Objects.equals(other.handlesLongClick, handlesLongClick)
                    || !Objects.equals(other.handlesLongClick, handlesLongClick)
                    || !Objects.equals(other.showRippleEffect, showRippleEffect)
                    || !Objects.equals(other.showRippleEffect, showRippleEffect)
                    || !Objects.equals(other.sideViewDrawable, sideViewDrawable);
                    || !Objects.equals(other.sideViewCustomDrawable, sideViewCustomDrawable);
            other.icon = icon;
            other.icon = icon;
            other.iconSupplier = iconSupplier;
            other.iconSupplier = iconSupplier;
            other.label = label;
            other.label = label;
@@ -201,7 +201,7 @@ public interface QSTile {
            other.slash = slash != null ? slash.copy() : null;
            other.slash = slash != null ? slash.copy() : null;
            other.handlesLongClick = handlesLongClick;
            other.handlesLongClick = handlesLongClick;
            other.showRippleEffect = showRippleEffect;
            other.showRippleEffect = showRippleEffect;
            other.sideViewDrawable = sideViewDrawable;
            other.sideViewCustomDrawable = sideViewCustomDrawable;
            return changed;
            return changed;
        }
        }


@@ -227,7 +227,7 @@ public interface QSTile {
            sb.append(",isTransient=").append(isTransient);
            sb.append(",isTransient=").append(isTransient);
            sb.append(",state=").append(state);
            sb.append(",state=").append(state);
            sb.append(",slash=\"").append(slash).append("\"");
            sb.append(",slash=\"").append(slash).append("\"");
            sb.append(",sideViewDrawable").append(sideViewDrawable);
            sb.append(",sideViewCustomDrawable=").append(sideViewCustomDrawable);
            return sb.append(']');
            return sb.append(']');
        }
        }


@@ -242,12 +242,16 @@ public interface QSTile {
    public static class BooleanState extends State {
    public static class BooleanState extends State {
        public static final int VERSION = 1;
        public static final int VERSION = 1;
        public boolean value;
        public boolean value;
        public boolean forceExpandIcon;


        @Override
        @Override
        public boolean copyTo(State other) {
        public boolean copyTo(State other) {
            final BooleanState o = (BooleanState) other;
            final BooleanState o = (BooleanState) other;
            final boolean changed = super.copyTo(other) || o.value != value;
            final boolean changed = super.copyTo(other)
                    || o.value != value
                    || o.forceExpandIcon != forceExpandIcon;
            o.value = value;
            o.value = value;
            o.forceExpandIcon = forceExpandIcon;
            return changed;
            return changed;
        }
        }


@@ -255,6 +259,7 @@ public interface QSTile {
        protected StringBuilder toStringBuilder() {
        protected StringBuilder toStringBuilder() {
            final StringBuilder rt = super.toStringBuilder();
            final StringBuilder rt = super.toStringBuilder();
            rt.insert(rt.length() - 1, ",value=" + value);
            rt.insert(rt.length() - 1, ",value=" + value);
            rt.insert(rt.length() - 1, ",forceExpandIcon=" + forceExpandIcon);
            return rt;
            return rt;
        }
        }


+41 −0
Original line number Original line Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
    Copyright (C) 2021 The Android Open Source Project

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginStart="@dimen/qs_label_container_margin"
    android:layout_gravity="center_vertical | end"
>
    <ImageView
        android:id="@+id/customDrawable"
        android:layout_width="wrap_content"
        android:layout_height="@dimen/qs_icon_size"
        android:layout_marginEnd="@dimen/qs_drawable_end_margin"
        android:adjustViewBounds="true"
        android:scaleType="fitCenter"
        android:visibility="gone"
    />

    <ImageView
        android:id="@+id/chevron"
        android:layout_width="@dimen/qs_icon_size"
        android:layout_height="@dimen/qs_icon_size"
        android:src="@*android:drawable/ic_chevron_end"
        android:visibility="gone"
        android:importantForAccessibility="no"
    />
</FrameLayout>
 No newline at end of file
+1 −0
Original line number Original line Diff line number Diff line
@@ -557,6 +557,7 @@
    <dimen name="qs_quick_tile_size">60dp</dimen>
    <dimen name="qs_quick_tile_size">60dp</dimen>
    <dimen name="qs_tile_padding">12dp</dimen>
    <dimen name="qs_tile_padding">12dp</dimen>
    <dimen name="qs_tile_start_padding">16dp</dimen>
    <dimen name="qs_tile_start_padding">16dp</dimen>
    <dimen name="qs_drawable_end_margin">4dp</dimen>
    <dimen name="qs_header_gear_translation">16dp</dimen>
    <dimen name="qs_header_gear_translation">16dp</dimen>
    <dimen name="qs_header_tile_margin_bottom">18dp</dimen>
    <dimen name="qs_header_tile_margin_bottom">18dp</dimen>
    <dimen name="qs_page_indicator_width">16dp</dimen>
    <dimen name="qs_page_indicator_width">16dp</dimen>
+7 −0
Original line number Original line Diff line number Diff line
@@ -36,10 +36,17 @@ class CustomizeTileView(
            secondaryLabel.visibility = getVisibilityState(secondaryLabel.text)
            secondaryLabel.visibility = getVisibilityState(secondaryLabel.text)
        }
        }


    var showSideView = true
        set(value) {
            field = value
            if (!showSideView) sideView.visibility = GONE
        }

    override fun handleStateChanged(state: QSTile.State) {
    override fun handleStateChanged(state: QSTile.State) {
        super.handleStateChanged(state)
        super.handleStateChanged(state)
        showRippleEffect = false
        showRippleEffect = false
        secondaryLabel.visibility = getVisibilityState(state.secondaryLabel)
        secondaryLabel.visibility = getVisibilityState(state.secondaryLabel)
        if (!showSideView) sideView.visibility = GONE
    }
    }


    private fun getVisibilityState(text: CharSequence?): Int {
    private fun getVisibilityState(text: CharSequence?): Int {
+2 −0
Original line number Original line Diff line number Diff line
@@ -366,6 +366,8 @@ public class TileAdapter extends RecyclerView.Adapter<Holder> implements TileSta
        // The holder has a tileView, therefore this call is not null
        // The holder has a tileView, therefore this call is not null
        holder.getTileAsCustomizeView().changeState(info.state);
        holder.getTileAsCustomizeView().changeState(info.state);
        holder.getTileAsCustomizeView().setShowAppLabel(position > mEditIndex && !info.isSystem);
        holder.getTileAsCustomizeView().setShowAppLabel(position > mEditIndex && !info.isSystem);
        // Don't show the side view for third party tiles, as we don't have the actual state.
        holder.getTileAsCustomizeView().setShowSideView(position < mEditIndex || info.isSystem);
        holder.mTileView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
        holder.mTileView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
        holder.mTileView.setClickable(true);
        holder.mTileView.setClickable(true);
        holder.mTileView.setOnClickListener(null);
        holder.mTileView.setOnClickListener(null);
Loading