Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b1f69be8 authored by Bryce Lee's avatar Bryce Lee Committed by Android (Google) Code Review
Browse files

Merge "Clear selected widget on scroll." into main

parents da04198c b67c9d7c
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -361,6 +361,20 @@ class CommunalEditModeViewModelTest : SysuiTestCase() {
            assertThat(communalInteractor.firstVisibleItemOffset).isEqualTo(offset)
        }

    @Test
    fun scrollPosition_clearsSelectedItem() =
        kosmos.runTest {
            val index = 2
            val offset = 30
            val testKey = "testKey"
            underTest.setSelectedKey(testKey)
            assertThat(underTest.selectedKey.value).isNotNull()
            underTest.onScrollPositionUpdated(index, communalInteractor.firstVisibleItemOffset)
            assertThat(underTest.selectedKey.value).isEqualTo(testKey)
            underTest.onScrollPositionUpdated(index, offset)
            assertThat(underTest.selectedKey.value).isNull()
        }

    @Test
    fun onResizeWidget_logsMetrics() =
        kosmos.runTest {
+7 −0
Original line number Diff line number Diff line
@@ -199,6 +199,13 @@ constructor(
        uiEventLogger.log(CommunalUiEvent.COMMUNAL_HUB_REORDER_WIDGET_CANCEL)
    }

    override fun onScrollPositionUpdated(firstVisibleItemIndex: Int, firstVisibleItemScroll: Int) {
        super.onScrollPositionUpdated(firstVisibleItemIndex, firstVisibleItemScroll)
        if (!_reorderingWidgets.value && firstVisibleItemScroll != savedFirstScrollOffset) {
            setSelectedKey(null)
        }
    }

    val isIdleOnCommunal: StateFlow<Boolean> = communalInteractor.isIdleOnCommunal

    /** Launch the widget picker activity using the given startActivity method. */