diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/qs/QSTileView.java b/packages/SystemUI/plugin/src/com/android/systemui/plugins/qs/QSTileView.java index 2dae716ef03fa..2213d1c5c8449 100644 --- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/qs/QSTileView.java +++ b/packages/SystemUI/plugin/src/com/android/systemui/plugins/qs/QSTileView.java @@ -63,4 +63,8 @@ public abstract class QSTileView extends LinearLayout { public View getLabelContainer() { return null; } + + public View getSecondaryLabel() { + return null; + } } diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSAnimator.java b/packages/SystemUI/src/com/android/systemui/qs/QSAnimator.java index 2ad9d3b888937..488ada97aa421 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSAnimator.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSAnimator.java @@ -336,8 +336,11 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha translationYBuilder ); + firstPageBuilder.addFloat(quickTileView.getSecondaryLabel(), "alpha", 0, 1); + mQuickQsViews.add(tileView); mAllViews.add(quickTileView); + mAllViews.add(quickTileView.getSecondaryLabel()); } else if (mFullRows && isIconInAnimatedRow(count)) { firstPageBuilder.addFloat(tileView, "translationY", -heightDiff, 0); diff --git a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/ButtonRelativeLayout.java b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/ButtonRelativeLayout.java index 2c17b874dcab6..962537a01fe20 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/ButtonRelativeLayout.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/ButtonRelativeLayout.java @@ -16,11 +16,17 @@ package com.android.systemui.qs.tileimpl; import android.content.Context; import android.util.AttributeSet; +import android.view.View; import android.widget.Button; import android.widget.RelativeLayout; +/** + * Used for QS tile labels + */ public class ButtonRelativeLayout extends RelativeLayout { + private View mIgnoredView; + public ButtonRelativeLayout(Context context, AttributeSet attrs) { super(context, attrs); } @@ -29,4 +35,27 @@ public class ButtonRelativeLayout extends RelativeLayout { public CharSequence getAccessibilityClassName() { return Button.class.getName(); } + + /** + * Set a view to be ignored for measure. + * + * The view will be measured and laid out, but its size will be subtracted from the total size + * of this view. It assumes that this view only contributes vertical height. + */ + public void setIgnoredView(View view) { + if (mIgnoredView == null || mIgnoredView.getParent() == this) { + mIgnoredView = view; + } + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + if (mIgnoredView != null && mIgnoredView.getVisibility() != GONE) { + int height = mIgnoredView.getMeasuredHeight(); + MarginLayoutParams lp = (MarginLayoutParams) mIgnoredView.getLayoutParams(); + height = height - lp.bottomMargin - lp.topMargin; + setMeasuredDimension(getMeasuredWidth(), getMeasuredHeight() - height); + } + } } diff --git a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileView.java b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileView.java index 3d5a709a5fddd..50417e9ab2592 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileView.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileView.java @@ -22,7 +22,6 @@ import android.text.TextUtils; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; -import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; @@ -44,7 +43,7 @@ public class QSTileView extends QSTileBaseView { protected TextView mSecondLine; private ImageView mPadLock; protected int mState; - protected ViewGroup mLabelContainer; + protected ButtonRelativeLayout mLabelContainer; private View mExpandIndicator; private View mExpandSpace; protected ColorStateList mColorLabelActive; @@ -92,7 +91,7 @@ public class QSTileView extends QSTileBaseView { } protected void createLabel() { - mLabelContainer = (ViewGroup) LayoutInflater.from(getContext()) + mLabelContainer = (ButtonRelativeLayout) LayoutInflater.from(getContext()) .inflate(R.layout.qs_tile_label, this, false); mLabelContainer.setClipChildren(false); mLabelContainer.setClipToPadding(false); @@ -140,7 +139,7 @@ public class QSTileView extends QSTileBaseView { } if (!Objects.equals(mSecondLine.getText(), state.secondaryLabel)) { mSecondLine.setText(state.secondaryLabel); - mSecondLine.setVisibility(TextUtils.isEmpty(state.secondaryLabel) || mCollapsedView + mSecondLine.setVisibility(TextUtils.isEmpty(state.secondaryLabel) ? View.GONE : View.VISIBLE); } boolean dualTarget = mDualTargetAllowed && state.dualTarget; @@ -193,4 +192,9 @@ public class QSTileView extends QSTileBaseView { public View getLabelContainer() { return mLabelContainer; } + + @Override + public View getSecondaryLabel() { + return mSecondLine; + } } 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 dcfe62ce0d344..70d51ee1c516b 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewHorizontal.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewHorizontal.kt @@ -100,7 +100,8 @@ open class QSTileViewHorizontal( mSecondLine.textDirection = TEXT_DIRECTION_LOCALE if (mCollapsedView) { - mSecondLine.visibility = GONE + mSecondLine.alpha = 0f + mLabelContainer.setIgnoredView(mSecondLine) } } @@ -185,9 +186,7 @@ open class QSTileViewHorizontal( private fun setLabelsColor(color: ColorStateList) { mLabel.setTextColor(color) - if (!mCollapsedView) { - mSecondLine.setTextColor(color) - } + mSecondLine.setTextColor(color) } private fun clearBackgroundAnimator() {