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

Commit a5617adc authored by Fabian Kozynski's avatar Fabian Kozynski Committed by Android (Google) Code Review
Browse files

Merge "Enforce height override by QSAnimator" into sc-dev

parents dd5ed95e 5b119e6c
Loading
Loading
Loading
Loading
+13 −6
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import com.android.systemui.qs.QSPanel.QSTileLayout;
import com.android.systemui.qs.TouchAnimator.Builder;
import com.android.systemui.qs.TouchAnimator.Listener;
import com.android.systemui.qs.dagger.QSScope;
import com.android.systemui.qs.tileimpl.HeightOverrideable;
import com.android.systemui.statusbar.FeatureFlags;
import com.android.systemui.tuner.TunerService;
import com.android.systemui.tuner.TunerService.Tunable;
@@ -590,6 +591,15 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha
            @Override
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                float t = valueAnimator.getAnimatedFraction();
                final int viewCount = mViews.size();
                int height = (Integer) valueAnimator.getAnimatedValue();
                for (int i = 0; i < viewCount; i++) {
                    View v = mViews.get(i);
                    v.setBottom(v.getTop() + height);
                    if (v instanceof HeightOverrideable) {
                        ((HeightOverrideable) v).setHeightOverride(height);
                    }
                }
                if (t == 0f) {
                    mListener.onAnimationAtStart();
                } else if (t == 1f) {
@@ -598,12 +608,6 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha
                    mListener.onAnimationStarted();
                }
                mLastT = t;
                final int viewCount = mViews.size();
                int height = (Integer) valueAnimator.getAnimatedValue();
                for (int i = 0; i < viewCount; i++) {
                    View v = mViews.get(i);
                    v.setBottom(v.getTop() + height);
                }
            }
        };

@@ -632,6 +636,9 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha
            for (int i = 0; i < viewsCount; i++) {
                View v = mViews.get(i);
                v.setBottom(v.getTop() + v.getMeasuredHeight());
                if (v instanceof HeightOverrideable) {
                    ((HeightOverrideable) v).resetOverride();
                }
            }
        }
    }
+29 −0
Original line number Diff line number Diff line
/*
 * 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.
 */

package com.android.systemui.qs.tileimpl

interface HeightOverrideable {
    companion object {
        const val NO_OVERRIDE = -1
    }

    var heightOverride: Int

    fun resetOverride() {
        heightOverride = NO_OVERRIDE
    }
}
 No newline at end of file
+9 −1
Original line number Diff line number Diff line
@@ -35,12 +35,13 @@ open class QSTileViewHorizontal(
    context: Context,
    icon: QSIconView,
    collapsed: Boolean
) : QSTileView(context, icon, collapsed) {
) : QSTileView(context, icon, collapsed), HeightOverrideable {

    protected var colorBackgroundDrawable: Drawable? = null
    private var paintColor = Color.WHITE
    private var paintAnimator: ValueAnimator? = null
    private var labelAnimator: ValueAnimator? = null
    override var heightOverride: Int = HeightOverrideable.NO_OVERRIDE

    init {
        orientation = HORIZONTAL
@@ -58,6 +59,13 @@ open class QSTileViewHorizontal(
        mColorLabelActive = ColorStateList.valueOf(getColorForState(getContext(), STATE_ACTIVE))
    }

    override fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int) {
        super.onLayout(changed, l, t, r, b)
        if (heightOverride != HeightOverrideable.NO_OVERRIDE) {
            bottom = top + heightOverride
        }
    }

    override fun createLabel() {
        super.createLabel()
        findViewById<LinearLayout>(R.id.label_group)?.apply {