OSDN Git Service

Ensure QS tile secondary text marquees.
authorAmin Shaikh <ashaikh@google.com>
Fri, 20 Apr 2018 15:27:46 +0000 (11:27 -0400)
committerAmin Shaikh <ashaikh@google.com>
Fri, 20 Apr 2018 15:33:20 +0000 (11:33 -0400)
Update the logic to marquee only the currently selected page.

Change-Id: Idc2398e1c67c614414ae4298c43a1609431c62fa
Fixes: 78159844
Test: visual

packages/SystemUI/plugin/src/com/android/systemui/plugins/qs/QSTileView.java
packages/SystemUI/res/layout/qs_tile_label.xml
packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java
packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileView.java

index ad300f4..53f7e44 100644 (file)
@@ -50,6 +50,4 @@ public abstract class QSTileView extends LinearLayout {
     public abstract void onStateChanged(State state);
 
     public abstract int getDetailY();
-
-    public void setExpansion(float expansion) {}
 }
index 74c22b0..49d142a 100644 (file)
@@ -76,7 +76,7 @@
         android:layout_below="@id/label_group"
         android:clickable="false"
         android:ellipsize="marquee"
-        android:maxLines="1"
+        android:singleLine="true"
         android:padding="0dp"
         android:visibility="gone"
         android:gravity="center"
index d8d07c0..1fd6023 100644 (file)
@@ -56,6 +56,7 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
 
     private AnimatorSet mBounceAnimatorSet;
     private int mAnimatingToPage = -1;
+    private float mLastExpansion;
 
     public PagedTileLayout(Context context, AttributeSet attrs) {
         super(context, attrs);
@@ -172,8 +173,19 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
 
     @Override
     public void setExpansion(float expansion) {
-        for (TileRecord tr : mTiles) {
-            tr.tileView.setExpansion(expansion);
+        mLastExpansion = expansion;
+        updateSelected();
+    }
+
+    private void updateSelected() {
+        // Start the marquee when fully expanded and stop when fully collapsed. Leave as is for
+        // other expansion ratios since there is no way way to pause the marquee.
+        if (mLastExpansion > 0f && mLastExpansion < 1f) {
+            return;
+        }
+        boolean selected = mLastExpansion == 1f;
+        for (int i = 0; i < mPages.size(); i++) {
+            mPages.get(i).setSelected(i == getCurrentItem() ? selected : false);
         }
     }
 
@@ -323,6 +335,7 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
             new ViewPager.SimpleOnPageChangeListener() {
                 @Override
                 public void onPageSelected(int position) {
+                    updateSelected();
                     if (mPageIndicator == null) return;
                     if (mPageListener != null) {
                         mPageListener.onPageChanged(isLayoutRtl() ? position == mPages.size() - 1
index d21b06f..5649f7f 100644 (file)
@@ -107,15 +107,6 @@ public class QSTileView extends QSTileBaseView {
     }
 
     @Override
-    public void setExpansion(float expansion) {
-        // Start the marquee when fully expanded and stop when fully collapsed. Leave as is for
-        // other expansion ratios since there is no way way to pause the marquee.
-        boolean selected = expansion == 1f ? true : expansion == 0f ? false : mLabel.isSelected();
-        mLabel.setSelected(selected);
-        mSecondLine.setSelected(selected);
-    }
-
-    @Override
     protected void handleStateChanged(QSTile.State state) {
         super.handleStateChanged(state);
         if (!Objects.equals(mLabel.getText(), state.label) || mState != state.state) {