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

Commit 5b119e6c authored by Fabian Kozynski's avatar Fabian Kozynski
Browse files

Enforce height override by QSAnimator

If an animation is going on, enforce the animated height instead of the
layout one.

Test: manual
Fixes: 183763542
Change-Id: I2b02511711849b11e87dc15fe4943596c0f315f8
parent ec012bc4
Loading
Loading
Loading
Loading
+13 −6
Original line number Original line 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.Builder;
import com.android.systemui.qs.TouchAnimator.Listener;
import com.android.systemui.qs.TouchAnimator.Listener;
import com.android.systemui.qs.dagger.QSScope;
import com.android.systemui.qs.dagger.QSScope;
import com.android.systemui.qs.tileimpl.HeightOverrideable;
import com.android.systemui.statusbar.FeatureFlags;
import com.android.systemui.statusbar.FeatureFlags;
import com.android.systemui.tuner.TunerService;
import com.android.systemui.tuner.TunerService;
import com.android.systemui.tuner.TunerService.Tunable;
import com.android.systemui.tuner.TunerService.Tunable;
@@ -586,6 +587,15 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha
            @Override
            @Override
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                float t = valueAnimator.getAnimatedFraction();
                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) {
                if (t == 0f) {
                    mListener.onAnimationAtStart();
                    mListener.onAnimationAtStart();
                } else if (t == 1f) {
                } else if (t == 1f) {
@@ -594,12 +604,6 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha
                    mListener.onAnimationStarted();
                    mListener.onAnimationStarted();
                }
                }
                mLastT = t;
                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);
                }
            }
            }
        };
        };


@@ -628,6 +632,9 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha
            for (int i = 0; i < viewsCount; i++) {
            for (int i = 0; i < viewsCount; i++) {
                View v = mViews.get(i);
                View v = mViews.get(i);
                v.setBottom(v.getTop() + v.getMeasuredHeight());
                v.setBottom(v.getTop() + v.getMeasuredHeight());
                if (v instanceof HeightOverrideable) {
                    ((HeightOverrideable) v).resetOverride();
                }
            }
            }
        }
        }
    }
    }
+29 −0
Original line number Original line 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 Original line Diff line number Diff line
@@ -35,12 +35,13 @@ open class QSTileViewHorizontal(
    context: Context,
    context: Context,
    icon: QSIconView,
    icon: QSIconView,
    collapsed: Boolean
    collapsed: Boolean
) : QSTileView(context, icon, collapsed) {
) : QSTileView(context, icon, collapsed), HeightOverrideable {


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


    init {
    init {
        orientation = HORIZONTAL
        orientation = HORIZONTAL
@@ -58,6 +59,13 @@ open class QSTileViewHorizontal(
        mColorLabelActive = ColorStateList.valueOf(getColorForState(getContext(), STATE_ACTIVE))
        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() {
    override fun createLabel() {
        super.createLabel()
        super.createLabel()
        findViewById<LinearLayout>(R.id.label_group)?.apply {
        findViewById<LinearLayout>(R.id.label_group)?.apply {