Merge "Sort Volume Panel buttons" into main
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/volume/panel/ui/viewmodel/DefaultComponentsLayoutManagerTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/volume/panel/ui/viewmodel/DefaultComponentsLayoutManagerTest.kt
index 71866b3..82ce6d7 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/volume/panel/ui/viewmodel/DefaultComponentsLayoutManagerTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/volume/panel/ui/viewmodel/DefaultComponentsLayoutManagerTest.kt
@@ -37,7 +37,7 @@
DefaultComponentsLayoutManager(
BOTTOM_BAR,
headerComponents = listOf(COMPONENT_1),
- footerComponents = listOf(COMPONENT_2),
+ footerComponents = listOf(COMPONENT_5, COMPONENT_2),
)
@Test
@@ -48,10 +48,18 @@
val component2 = ComponentState(COMPONENT_2, kosmos.mockVolumePanelUiComponent, false)
val component3 = ComponentState(COMPONENT_3, kosmos.mockVolumePanelUiComponent, false)
val component4 = ComponentState(COMPONENT_4, kosmos.mockVolumePanelUiComponent, false)
+ val component5 = ComponentState(COMPONENT_5, kosmos.mockVolumePanelUiComponent, false)
val layout =
underTest.layout(
VolumePanelState(0, false, false),
- setOf(bottomBarComponentState, component1, component2, component3, component4)
+ setOf(
+ bottomBarComponentState,
+ component1,
+ component2,
+ component3,
+ component4,
+ component5,
+ )
)
Truth.assertThat(layout.bottomBarComponent).isEqualTo(bottomBarComponentState)
@@ -59,7 +67,7 @@
.containsExactlyElementsIn(listOf(component1))
.inOrder()
Truth.assertThat(layout.footerComponents)
- .containsExactlyElementsIn(listOf(component2))
+ .containsExactlyElementsIn(listOf(component5, component2))
.inOrder()
Truth.assertThat(layout.contentComponents)
.containsExactlyElementsIn(listOf(component3, component4))
@@ -85,5 +93,6 @@
const val COMPONENT_2: VolumePanelComponentKey = "test_component:2"
const val COMPONENT_3: VolumePanelComponentKey = "test_component:3"
const val COMPONENT_4: VolumePanelComponentKey = "test_component:4"
+ const val COMPONENT_5: VolumePanelComponentKey = "test_component:5"
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/volume/panel/ui/layout/DefaultComponentsLayoutManager.kt b/packages/SystemUI/src/com/android/systemui/volume/panel/ui/layout/DefaultComponentsLayoutManager.kt
index 7fd9c8a..635191a 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/panel/ui/layout/DefaultComponentsLayoutManager.kt
+++ b/packages/SystemUI/src/com/android/systemui/volume/panel/ui/layout/DefaultComponentsLayoutManager.kt
@@ -46,12 +46,18 @@
!footerComponents.contains(it.key) &&
it.key != bottomBar
}
- val headerComponents = components.filter { headerComponents.contains(it.key) }
- val footerComponents = components.filter { footerComponents.contains(it.key) }
+ val headerComponents =
+ components
+ .filter { it.key in headerComponents }
+ .sortedBy { headerComponents.indexOf(it.key) }
+ val footerComponents =
+ components
+ .filter { it.key in footerComponents }
+ .sortedBy { footerComponents.indexOf(it.key) }
return ComponentsLayout(
- headerComponents = headerComponents.sortedBy { it.key },
+ headerComponents = headerComponents,
contentComponents = contentComponents.sortedBy { it.key },
- footerComponents = footerComponents.sortedBy { it.key },
+ footerComponents = footerComponents,
bottomBarComponent = components.find { it.key == bottomBar }
?: error(
"VolumePanelComponents.BOTTOM_BAR must be present in the default " +