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

Commit 23d852de authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Move the shade if expanded from mouse click on the the side statusbar chips" into main

parents ce2a0d13 101e73a1
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()