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
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSAnimator.java b/packages/SystemUI/src/com/android/systemui/qs/QSAnimator.java
index ee0b0c2..2659a1f 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSAnimator.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSAnimator.java
@@ -31,6 +31,7 @@
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;
@@ -586,6 +587,15 @@
@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) {
@@ -594,12 +604,6 @@
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);
- }
}
};
@@ -628,6 +632,9 @@
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();
+ }
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/HeightOverrideable.kt b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/HeightOverrideable.kt
new file mode 100644
index 0000000..866fa09
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/HeightOverrideable.kt
@@ -0,0 +1,29 @@
+/*
+ * 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
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewHorizontal.kt b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewHorizontal.kt
index 32285cf..188e89e 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewHorizontal.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewHorizontal.kt
@@ -35,12 +35,13 @@
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 @@
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 {