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

Commit 101e73a1 authored by Nicolo' Mazzucato's avatar Nicolo' Mazzucato
Browse files

Move the shade if expanded from mouse click on the the side statusbar chips

The mouse click event was triggering the expansion, but not the move of the shade, causing potential shade expansion in the wrong display.

Now we're first moving the shade and then triggering the expansion.

Bug: 362719719
Bug: 403581574
Test: PhoneStatusBarViewControllerTest
Flag: com.android.systemui.shade_window_goes_around
Change-Id: I18f44973078092be8ff5dc64f5db54ea7908d29b
parent 39f6dcef
Loading
Loading
Loading
Loading
+13 −3
Original line number Diff line number Diff line
@@ -104,6 +104,7 @@ private constructor(
                // intercepted. See [View.OnTouchEvent]
                if (event.source == InputDevice.SOURCE_MOUSE) {
                    if (event.action == MotionEvent.ACTION_UP) {
                        dispatchEventToShadeDisplayPolicy(event)
                        v.performClick()
                        shadeController.animateExpandShade()
                    }
@@ -113,6 +114,15 @@ private constructor(
            }
        }

    private fun dispatchEventToShadeDisplayPolicy(event: MotionEvent) {
        if (ShadeWindowGoesAround.isEnabled) {
            // Notify the shade display policy that the status bar was touched. This may cause
            // the shade to change display if the touch was in a display different than the shade
            // one.
            lazyStatusBarShadeDisplayPolicy.get().onStatusBarTouched(event, mView.width)
        }
    }

    private val configurationListener =
        object : ConfigurationController.ConfigurationListener {
            override fun onDensityOrFontScaleChanged() {
@@ -232,9 +242,6 @@ private constructor(
                !upOrCancel || shadeController.isExpandedVisible,
            )
        }
        if (ShadeWindowGoesAround.isEnabled && event.action == MotionEvent.ACTION_DOWN) {
            lazyStatusBarShadeDisplayPolicy.get().onStatusBarTouched(event, mView.width)
        }
    }

    private fun addDarkReceivers() {
@@ -249,6 +256,9 @@ private constructor(

    inner class PhoneStatusBarViewTouchHandler : Gefingerpoken {
        override fun onInterceptTouchEvent(event: MotionEvent): Boolean {
            if (event.action == MotionEvent.ACTION_DOWN) {
                dispatchEventToShadeDisplayPolicy(event)
            }
            return if (Flags.statusBarSwipeOverChip()) {
                shadeViewController.handleExternalInterceptTouch(event)
            } else {
+45 −0
Original line number Diff line number Diff line
@@ -470,6 +470,51 @@ class PhoneStatusBarViewControllerTest : SysuiTestCase() {
        verify(statusBarTouchShadeDisplayPolicy, never()).onStatusBarTouched(eq(event), any())
    }

    @Test
    @EnableFlags(ShadeWindowGoesAround.FLAG_NAME)
    fun onTouch_withMouseOnEndSideIcons_flagOn_propagatedToShadeDisplayPolicy() {
        val view = createViewMock()
        InstrumentationRegistry.getInstrumentation().runOnMainSync {
            controller = createAndInitController(view)
        }
        val event = getActionUpEventFromSource(InputDevice.SOURCE_MOUSE)

        val statusContainer = view.requireViewById<View>(R.id.system_icons)
        statusContainer.dispatchTouchEvent(event)

        verify(statusBarTouchShadeDisplayPolicy).onStatusBarTouched(eq(event), any())
    }

    @Test
    @EnableFlags(ShadeWindowGoesAround.FLAG_NAME)
    fun onTouch_withMouseOnStartSideIcons_flagOn_propagatedToShadeDisplayPolicy() {
        val view = createViewMock()
        InstrumentationRegistry.getInstrumentation().runOnMainSync {
            controller = createAndInitController(view)
        }
        val event = getActionUpEventFromSource(InputDevice.SOURCE_MOUSE)

        val statusContainer = view.requireViewById<View>(R.id.status_bar_start_side_content)
        statusContainer.dispatchTouchEvent(event)

        verify(statusBarTouchShadeDisplayPolicy).onStatusBarTouched(eq(event), any())
    }

    @Test
    @DisableFlags(ShadeWindowGoesAround.FLAG_NAME)
    fun onTouch_withMouseOnSystemIcons_flagOff_notPropagatedToShadeDisplayPolicy() {
        val view = createViewMock()
        InstrumentationRegistry.getInstrumentation().runOnMainSync {
            controller = createAndInitController(view)
        }
        val event = getActionUpEventFromSource(InputDevice.SOURCE_MOUSE)

        val statusContainer = view.requireViewById<View>(R.id.system_icons)
        statusContainer.dispatchTouchEvent(event)

        verify(statusBarTouchShadeDisplayPolicy, never()).onStatusBarTouched(eq(event), any())
    }

    @Test
    fun shadeIsExpandedOnStatusIconMouseClick() {
        val view = createViewMock()