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

Commit 13e05e63 authored by Juan Sebastian Martinez's avatar Juan Sebastian Martinez Committed by Android (Google) Code Review
Browse files

Merge "Allowing IDLE long clicks on QSLongPressEffect." into main

parents 9ab69a88 3527f237
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -398,6 +398,16 @@ class QSLongPressEffectTest : SysuiTestCase() {
            verify(controller).onTransitionAnimationCancelled(newOccludedState)
        }

    @Test
    fun onTileLongClick_whileIdle_performsLongClick() =
        testWhileInState(QSLongPressEffect.State.IDLE) {
            // WHEN a long-click is detected by the view
            val longClicks = longPressEffect.onTileLongClick()

            // THEN the long click is handled
            assertThat(longClicks).isTrue()
        }

    private fun testWithScope(initialize: Boolean = true, test: suspend TestScope.() -> Unit) =
        with(kosmos) {
            testScope.runTest {
+15 −0
Original line number Diff line number Diff line
@@ -215,6 +215,21 @@ constructor(
        return true
    }

    fun onTileLongClick(): Boolean {
        if (state == State.IDLE) {
            // This case represents a long-click detected outside of the QSLongPressEffect. This can
            // be due to accessibility services
            qsTile?.longClick(expandable)
            logEvent(
                qsTile?.tileSpec,
                state,
                "long click action triggered from OnLongClickListener",
            )
            return true
        }
        return false
    }

    /**
     * Get the appropriate state for a click action.
     *
+4 −1
Original line number Diff line number Diff line
@@ -415,7 +415,10 @@ constructor(
            initLongPressEffectCallback()
            init(
                { _: View -> longPressEffect.onTileClick() },
                { _: View -> true }, // Haptics and long-clicks are handled by [QSLongPressEffect]
                { _: View ->
                    longPressEffect.onTileLongClick()
                    true
                }, // Haptics and long-clicks are handled by [QSLongPressEffect]
            )
        } else {
            val expandable = Expandable.fromView(this)