Merge "Enforce height override by QSAnimator" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
a5617adc5d
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user