OSDN Git Service

Control the QS label marquees.
authorAmin Shaikh <ashaikh@google.com>
Tue, 27 Mar 2018 15:09:27 +0000 (11:09 -0400)
committerAmin Shaikh <ashaikh@google.com>
Tue, 27 Mar 2018 19:10:30 +0000 (15:10 -0400)
- Start the marquee when fully expanded and pause when collapsed.
- Also do not change qs label to multiline once it's already been resized
to single line.

Change-Id: I2dd4f6b5473a6a5147999c29441537227751b705
Fixes: 74757991
Test: visual

packages/SystemUI/plugin/src/com/android/systemui/plugins/qs/QSTileView.java
packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java
packages/SystemUI/src/com/android/systemui/qs/QSFragment.java
packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileView.java

index 53f7e44..ad300f4 100644 (file)
@@ -50,4 +50,6 @@ public abstract class QSTileView extends LinearLayout {
     public abstract void onStateChanged(State state);
 
     public abstract int getDetailY();
+
+    public void setExpansion(float expansion) {}
 }
index 8923952..c548cf6 100644 (file)
@@ -167,6 +167,13 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
         }
     }
 
+    @Override
+    public void setExpansion(float expansion) {
+        for (TileRecord tr : mTiles) {
+            tr.tileView.setExpansion(expansion);
+        }
+    }
+
     public void setPageListener(PageListener listener) {
         mPageListener = listener;
     }
index 29f3c43..e532217 100644 (file)
@@ -291,6 +291,7 @@ public class QSFragment extends Fragment implements QS {
         mHeader.setExpansion(mKeyguardShowing, expansion, panelTranslationY);
         mFooter.setExpansion(mKeyguardShowing ? 1 : expansion);
         mQSPanel.getQsTileRevealController().setExpansion(expansion);
+        mQSPanel.getTileLayout().setExpansion(expansion);
         mQSPanel.setTranslationY(translationScaleY * heightDiff);
         mQSDetail.setFullyExpanded(fullyExpanded);
 
index 61e3065..6368a6b 100644 (file)
@@ -616,5 +616,7 @@ public class QSPanel extends LinearLayout implements Tunable, Callback, Brightne
         boolean updateResources();
 
         void setListening(boolean listening);
+
+        default void setExpansion(float expansion) {}
     }
 }
index 3cb4c71..d21b06f 100644 (file)
@@ -32,12 +32,10 @@ import com.android.systemui.R;
 import com.android.systemui.plugins.qs.QSIconView;
 import com.android.systemui.plugins.qs.QSTile;
 
-
 import java.util.Objects;
 
 /** View that represents a standard quick settings tile. **/
 public class QSTileView extends QSTileBaseView {
-    private static final int DEFAULT_MAX_LINES = 2;
     private static final boolean DUAL_TARGET_ALLOWED = false;
     private View mDivider;
     protected TextView mLabel;
@@ -87,22 +85,17 @@ public class QSTileView extends QSTileBaseView {
         mLabelContainer.setClipChildren(false);
         mLabelContainer.setClipToPadding(false);
         mLabel = mLabelContainer.findViewById(R.id.tile_label);
-        mLabel.setSelected(true); // Allow marquee to work.
         mPadLock = mLabelContainer.findViewById(R.id.restricted_padlock);
         mDivider = mLabelContainer.findViewById(R.id.underline);
         mExpandIndicator = mLabelContainer.findViewById(R.id.expand_indicator);
         mExpandSpace = mLabelContainer.findViewById(R.id.expand_space);
         mSecondLine = mLabelContainer.findViewById(R.id.app_label);
         mSecondLine.setAlpha(.6f);
-        mSecondLine.setSelected(true); // Allow marquee to work.
         addView(mLabelContainer);
     }
 
     @Override
     protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
-        if (mLabel.getMaxLines() != DEFAULT_MAX_LINES) {
-            mLabel.setMaxLines(DEFAULT_MAX_LINES);
-        }
         super.onMeasure(widthMeasureSpec, heightMeasureSpec);
 
         // Remeasure view if the secondary label text will be cut off.
@@ -114,6 +107,15 @@ 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) {