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

Commit fc060197 authored by Mykola Podolian's avatar Mykola Podolian Committed by Android (Google) Code Review
Browse files

Merge "Fix bubble bar drop target visibility." into main

parents 4c00545c 8c242b62
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)
    }
}