QS: Only put visible tiles in listening state
- Make it so the QSPanel doesn't listen until expansion starts
- Push listening state through the TileLayout
- Make PagedTileLayout only listen for visible pages
- Push setListening onto background thread
Change-Id: Id7c008c9447f9a5dac69469fef72bc580f423b0c
Fixes: 28962155
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QuickQSPanel.java b/packages/SystemUI/src/com/android/systemui/qs/QuickQSPanel.java
index 887adbe..e0b1d4a 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QuickQSPanel.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QuickQSPanel.java
@@ -55,6 +55,7 @@
removeView((View) mTileLayout);
}
mTileLayout = new HeaderTileLayout(context);
+ mTileLayout.setListening(mListening);
addView((View) mTileLayout, 1 /* Between brightness and footer */);
}
@@ -146,6 +147,7 @@
private static class HeaderTileLayout extends LinearLayout implements QSTileLayout {
protected final ArrayList<TileRecord> mRecords = new ArrayList<>();
+ private boolean mListening;
public HeaderTileLayout(Context context) {
super(context);
@@ -156,6 +158,15 @@
}
@Override
+ public void setListening(boolean listening) {
+ if (mListening == listening) return;
+ mListening = listening;
+ for (TileRecord record : mRecords) {
+ record.tile.setListening(this, mListening);
+ }
+ }
+
+ @Override
public void addTile(TileRecord tile) {
if (getChildCount() != 0) {
// Add a spacer.
@@ -163,6 +174,7 @@
}
addView(tile.tileView, getChildCount(), generateLayoutParams());
mRecords.add(tile);
+ tile.tile.setListening(this, mListening);
}
private LayoutParams generateSpaceParams() {
@@ -190,6 +202,7 @@
removeViewAt(childIndex);
}
mRecords.remove(tile);
+ tile.tile.setListening(this, false);
}
private int getChildIndex(QSTileBaseView tileView) {