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

Commit 8c242b62 authored by mpodolian's avatar mpodolian
Browse files

Fix bubble bar drop target visibility.

The drop target view remained invisible after a drag operation because
its state was not cleared. This change adds logic to clear the state
when the drag concludes.

A test was also added to verify the fix.

Fixes: 427246053
Test: DragToBubblesZoneChangeListenerTest
Flag: com.android.wm.shell.enable_create_any_bubble
Change-Id: If4bef29d47bda113b2ebc173832a03c3b43fd69f
parent 0e68e023
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -44,16 +44,19 @@ class DragToBubblesZoneChangeListener(
        from: DragZone?,
        to: DragZone?,
    ) {
        val updateLocation = to.toBubbleBarLocation()
        updateBubbleBarLocation(updateLocation)
        lastUpdateLocation = updateLocation
        processLocationUpdate(to.toBubbleBarLocation())
    }

    override fun onDragEnded(zone: DragZone?) {
        updateBubbleBarLocation(updateLocation = null)
        processLocationUpdate(updateLocation = null)
    }

    private fun processLocationUpdate(updateLocation: BubbleBarLocation?) {
        actOnLocationUpdate(updateLocation)
        lastUpdateLocation = updateLocation
    }

    fun updateBubbleBarLocation(updateLocation: BubbleBarLocation?) {
    private fun actOnLocationUpdate(updateLocation: BubbleBarLocation?) {
        val updatedBefore = lastUpdateLocation != null
        val originalLocation = callback.getStartingBubbleBarLocation()
        val isLocationUpdated = isDifferentSides(lastUpdateLocation, updateLocation, isRtl)
+19 −0
Original line number Diff line number Diff line
@@ -361,4 +361,23 @@ class DragToBubblesZoneChangeListenerTest {
        // Then animate should NOT be called
        verify(mockCallback, never()).animateBubbleBarLocation(any())
    }

    @Test
    fun onDragZoneChanged_dragToSameLocationTwice_onDragEnteredLocationCalledOnSecondDrag() {
        // // Given has bubbles, starting on LEFT
        setUpListener(hasBubbles = false, startingLocation = BubbleBarLocation.LEFT)

        // First drag to the left zone
        listener.onDragZoneChanged(draggedObject, null, leftZone)
        listener.onDragEnded(leftZone)
        verify(mockCallback).onDragEnteredLocation(BubbleBarLocation.LEFT)
        clearInvocations(mockCallback) // Reset mock to clear interactions for the next assertion

        // Second drag to the same left zone
        listener.onDragZoneChanged(draggedObject, null, leftZone)
        listener.onDragEnded(leftZone)

        // Verify onDragEnteredLocation is called again for the same location
        verify(mockCallback).onDragEnteredLocation(BubbleBarLocation.LEFT)
    }
}