From f180ffd03e10641756a41a4141ee84b7dce285d8 Mon Sep 17 00:00:00 2001 From: Amin Shaikh Date: Tue, 24 Apr 2018 14:44:45 -0400 Subject: [PATCH] Ellipsize long QS labels. Since marqueeing only works when a TextView is a single line, make the label a single line if the layout would otherwise require 3+ lines. Change-Id: Ib1f47145e01696b01cdce893fe96eca8fbe2ff99 Fixes: 78345638 Test: visual --- packages/SystemUI/res/layout/qs_tile_label.xml | 1 - .../src/com/android/systemui/qs/tileimpl/QSTileView.java | 8 +++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/SystemUI/res/layout/qs_tile_label.xml b/packages/SystemUI/res/layout/qs_tile_label.xml index 49d142a1e6d69..8ca867f65ef76 100644 --- a/packages/SystemUI/res/layout/qs_tile_label.xml +++ b/packages/SystemUI/res/layout/qs_tile_label.xml @@ -41,7 +41,6 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:clickable="false" - android:maxLines="2" android:padding="0dp" android:gravity="center" android:ellipsize="marquee" 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 5649f7f5d7640..22ad550b56f59 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileView.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileView.java @@ -36,6 +36,7 @@ import java.util.Objects; /** View that represents a standard quick settings tile. **/ public class QSTileView extends QSTileBaseView { + private static final int MAX_LABEL_LINES = 2; private static final boolean DUAL_TARGET_ALLOWED = false; private View mDivider; protected TextView mLabel; @@ -98,9 +99,10 @@ public class QSTileView extends QSTileBaseView { protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); - // Remeasure view if the secondary label text will be cut off. - if (!TextUtils.isEmpty(mSecondLine.getText()) - && mSecondLine.getLineHeight() > mSecondLine.getHeight()) { + // Remeasure view if the primary label requires more then 2 lines or the secondary label + // text will be cut off. + if (mLabel.getLineCount() > MAX_LABEL_LINES || !TextUtils.isEmpty(mSecondLine.getText()) + && mSecondLine.getLineHeight() > mSecondLine.getHeight()) { mLabel.setSingleLine(); super.onMeasure(widthMeasureSpec, heightMeasureSpec); }