summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Olivier St-Onge <ostonge@google.com> 2024-03-18 14:06:48 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2024-03-18 14:06:48 +0000
commitbf7da78c1e60ff2fa5b06cf896b73c9754c33dc1 (patch)
tree03c0af74f8bd20500d2cca31c3b362cc9f1e86e8
parent794f9de88e47506390237a2b45d0a859be0244f1 (diff)
parent58e1e06c87a2679b55d90acd48057aa664e4e770 (diff)
Merge "Reset squishiness fraction of reused tile views when added to new layout" into main
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java6
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/TileLayout.java9
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/qs/TileLayoutTest.java11
3 files changed, 25 insertions, 1 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java b/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java
index 43f3a2242da4..5d2aeef5eb16 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java
@@ -305,6 +305,12 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
page.setMinRows(mMinRows);
page.setMaxColumns(mMaxColumns);
page.setSelected(false);
+
+ // All pages should have the same squishiness, so grabbing the value from the first page
+ // and giving it to new pages.
+ float squishiness = mPages.isEmpty() ? 1f : mPages.get(0).getSquishinessFraction();
+ page.setSquishinessFraction(squishiness);
+
return page;
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/TileLayout.java b/packages/SystemUI/src/com/android/systemui/qs/TileLayout.java
index 9d4eba5aafc2..dcb9288f74be 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/TileLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/TileLayout.java
@@ -110,6 +110,11 @@ public class TileLayout extends ViewGroup implements QSTileLayout {
}
protected void addTileView(TileRecord tile) {
+ // Re-using tile views might lead to having out-of-date squishiness. This is fixed by
+ // making sure we set the correct squishiness value when added to the layout.
+ if (tile.tileView instanceof HeightOverrideable) {
+ ((HeightOverrideable) tile.tileView).setSquishinessFraction(mSquishinessFraction);
+ }
addView(tile.tileView);
}
@@ -349,6 +354,10 @@ public class TileLayout extends ViewGroup implements QSTileLayout {
}
}
+ public float getSquishinessFraction() {
+ return mSquishinessFraction;
+ }
+
@Override
public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfoInternal(info);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/TileLayoutTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/TileLayoutTest.java
index f809259eedc1..0eae5aae3600 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/TileLayoutTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/TileLayoutTest.java
@@ -39,10 +39,11 @@ import android.view.accessibility.AccessibilityNodeInfo;
import androidx.test.runner.AndroidJUnit4;
-import com.android.systemui.res.R;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.plugins.qs.QSTile;
+import com.android.systemui.qs.tileimpl.HeightOverrideable;
import com.android.systemui.qs.tileimpl.QSTileViewImpl;
+import com.android.systemui.res.R;
import org.junit.Before;
import org.junit.Test;
@@ -88,6 +89,14 @@ public class TileLayoutTest extends SysuiTestCase {
}
@Test
+ public void testAddTile_SetsRightSquishiness() {
+ QSPanelControllerBase.TileRecord tileRecord = createTileRecord();
+ ((HeightOverrideable) tileRecord.tileView).setSquishinessFraction(.5f);
+ mTileLayout.addTile(tileRecord);
+ assertEquals(1f, ((HeightOverrideable) tileRecord.tileView).getSquishinessFraction());
+ }
+
+ @Test
public void testSetListening_CallsSetListeningOnTile() {
QSPanelControllerBase.TileRecord tileRecord = createTileRecord();
mTileLayout.addTile(tileRecord);