Loading libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/bubbles/DragZoneFactory.kt +17 −24 Original line number Diff line number Diff line Loading @@ -245,6 +245,21 @@ class DragZoneFactory( return dragZones } fun getBubbleBarDropRect(isLeftSide: Boolean): Rect { val dragZoneSize = if (deviceConfig.isSmallTablet) { bubbleDragZoneFoldableSize } else { bubbleDragZoneTabletSize } return Rect( if (isLeftSide) 0 else windowBounds.right - dragZoneSize, windowBounds.bottom - dragZoneSize, if (isLeftSide) dragZoneSize else windowBounds.right, windowBounds.bottom ) } private fun createDismissDragZone(): DragZone { return DragZone.Dismiss( bounds = Loading @@ -257,36 +272,14 @@ class DragZoneFactory( } private fun createBubbleCornerDragZones(showSecondDropTarget: Boolean = false): List<DragZone> { val dragZoneSize = if (deviceConfig.isSmallTablet) { bubbleDragZoneFoldableSize } else { bubbleDragZoneTabletSize } return listOf( DragZone.Bubble.Left( bounds = RectZone( Rect( 0, windowBounds.bottom - dragZoneSize, dragZoneSize, windowBounds.bottom, ), ), bounds = RectZone(getBubbleBarDropRect(isLeftSide = true)), dropTarget = expandedViewDropTargetLeft, secondDropTarget = if (showSecondDropTarget) bubbleBarDropTargetLeft else null ), DragZone.Bubble.Right( bounds = RectZone( Rect( windowBounds.right - dragZoneSize, windowBounds.bottom - dragZoneSize, windowBounds.right, windowBounds.bottom, ), ), bounds = RectZone(getBubbleBarDropRect(isLeftSide = false)), dropTarget = expandedViewDropTargetRight, secondDropTarget = if (showSecondDropTarget) bubbleBarDropTargetRight else null ) Loading libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/bubbles/DropTargetManager.kt +1 −3 Original line number Diff line number Diff line Loading @@ -140,9 +140,7 @@ class DropTargetManager( val currentDragZone = dropState.currentDragZone if (currentDragZone == null) { startFadeAnimation(dropTargetView, to = 0f) startFadeAnimation(secondDropTargetView, to = 0f) { container.removeView(secondDropTargetView) } startFadeAnimation(secondDropTargetView, to = 0f) return } val dropTargetRect = currentDragZone.dropTarget Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/shared/bubbles/DropTargetManagerTest.kt +38 −0 Original line number Diff line number Diff line Loading @@ -515,6 +515,44 @@ class DropTargetManagerTest { assertThat(runnableExecuted).isTrue() } @Test fun onDragUpdated_reEnterZoneWithMultipleDropTargetViews_dropTargetsShown() { dropTargetManager.onDragStarted( DraggedObject.LauncherIcon(bubbleBarHasBubbles = false) {}, listOf(bubbleLeftDragZoneWithSecondDropTarget, bubbleRightDragZoneWithSecondDropTarget) ) val pointX = 200 val pointY = 200 assertThat(bubbleLeftDragZone.contains(pointX, pointY)).isFalse() assertThat(bubbleRightDragZone.contains(pointX, pointY)).isFalse() InstrumentationRegistry.getInstrumentation().runOnMainSync { dropTargetManager.onDragUpdated( bubbleRightDragZoneWithSecondDropTarget.bounds.rect.centerX(), bubbleRightDragZoneWithSecondDropTarget.bounds.rect.centerY() ) animatorTestRule.advanceTimeBy(250) } InstrumentationRegistry.getInstrumentation().runOnMainSync { dropTargetManager.onDragUpdated(pointX, pointY) animatorTestRule.advanceTimeBy(250) } InstrumentationRegistry.getInstrumentation().runOnMainSync { dropTargetManager.onDragUpdated( bubbleRightDragZoneWithSecondDropTarget.bounds.rect.centerX(), bubbleRightDragZoneWithSecondDropTarget.bounds.rect.centerY() ) animatorTestRule.advanceTimeBy(250) } assertThat(container.childCount).isEqualTo(DROP_VIEWS_COUNT_FOR_LAUNCHER_ICON) assertThat(dropTargetView.alpha).isEqualTo(1) assertThat(secondDropTargetView!!.alpha).isEqualTo(1) verifyDropTargetPosition(bubbleRightDragZoneWithSecondDropTarget.dropTarget.rect) verifyDropTargetPosition( secondDropTargetView!!, bubbleRightDragZoneWithSecondDropTarget.secondDropTarget!!.rect ) } private fun verifyDropTargetPosition(rect: Rect) { verifyDropTargetPosition(dropTargetView, rect) } Loading Loading
libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/bubbles/DragZoneFactory.kt +17 −24 Original line number Diff line number Diff line Loading @@ -245,6 +245,21 @@ class DragZoneFactory( return dragZones } fun getBubbleBarDropRect(isLeftSide: Boolean): Rect { val dragZoneSize = if (deviceConfig.isSmallTablet) { bubbleDragZoneFoldableSize } else { bubbleDragZoneTabletSize } return Rect( if (isLeftSide) 0 else windowBounds.right - dragZoneSize, windowBounds.bottom - dragZoneSize, if (isLeftSide) dragZoneSize else windowBounds.right, windowBounds.bottom ) } private fun createDismissDragZone(): DragZone { return DragZone.Dismiss( bounds = Loading @@ -257,36 +272,14 @@ class DragZoneFactory( } private fun createBubbleCornerDragZones(showSecondDropTarget: Boolean = false): List<DragZone> { val dragZoneSize = if (deviceConfig.isSmallTablet) { bubbleDragZoneFoldableSize } else { bubbleDragZoneTabletSize } return listOf( DragZone.Bubble.Left( bounds = RectZone( Rect( 0, windowBounds.bottom - dragZoneSize, dragZoneSize, windowBounds.bottom, ), ), bounds = RectZone(getBubbleBarDropRect(isLeftSide = true)), dropTarget = expandedViewDropTargetLeft, secondDropTarget = if (showSecondDropTarget) bubbleBarDropTargetLeft else null ), DragZone.Bubble.Right( bounds = RectZone( Rect( windowBounds.right - dragZoneSize, windowBounds.bottom - dragZoneSize, windowBounds.right, windowBounds.bottom, ), ), bounds = RectZone(getBubbleBarDropRect(isLeftSide = false)), dropTarget = expandedViewDropTargetRight, secondDropTarget = if (showSecondDropTarget) bubbleBarDropTargetRight else null ) Loading
libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/bubbles/DropTargetManager.kt +1 −3 Original line number Diff line number Diff line Loading @@ -140,9 +140,7 @@ class DropTargetManager( val currentDragZone = dropState.currentDragZone if (currentDragZone == null) { startFadeAnimation(dropTargetView, to = 0f) startFadeAnimation(secondDropTargetView, to = 0f) { container.removeView(secondDropTargetView) } startFadeAnimation(secondDropTargetView, to = 0f) return } val dropTargetRect = currentDragZone.dropTarget Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/shared/bubbles/DropTargetManagerTest.kt +38 −0 Original line number Diff line number Diff line Loading @@ -515,6 +515,44 @@ class DropTargetManagerTest { assertThat(runnableExecuted).isTrue() } @Test fun onDragUpdated_reEnterZoneWithMultipleDropTargetViews_dropTargetsShown() { dropTargetManager.onDragStarted( DraggedObject.LauncherIcon(bubbleBarHasBubbles = false) {}, listOf(bubbleLeftDragZoneWithSecondDropTarget, bubbleRightDragZoneWithSecondDropTarget) ) val pointX = 200 val pointY = 200 assertThat(bubbleLeftDragZone.contains(pointX, pointY)).isFalse() assertThat(bubbleRightDragZone.contains(pointX, pointY)).isFalse() InstrumentationRegistry.getInstrumentation().runOnMainSync { dropTargetManager.onDragUpdated( bubbleRightDragZoneWithSecondDropTarget.bounds.rect.centerX(), bubbleRightDragZoneWithSecondDropTarget.bounds.rect.centerY() ) animatorTestRule.advanceTimeBy(250) } InstrumentationRegistry.getInstrumentation().runOnMainSync { dropTargetManager.onDragUpdated(pointX, pointY) animatorTestRule.advanceTimeBy(250) } InstrumentationRegistry.getInstrumentation().runOnMainSync { dropTargetManager.onDragUpdated( bubbleRightDragZoneWithSecondDropTarget.bounds.rect.centerX(), bubbleRightDragZoneWithSecondDropTarget.bounds.rect.centerY() ) animatorTestRule.advanceTimeBy(250) } assertThat(container.childCount).isEqualTo(DROP_VIEWS_COUNT_FOR_LAUNCHER_ICON) assertThat(dropTargetView.alpha).isEqualTo(1) assertThat(secondDropTargetView!!.alpha).isEqualTo(1) verifyDropTargetPosition(bubbleRightDragZoneWithSecondDropTarget.dropTarget.rect) verifyDropTargetPosition( secondDropTargetView!!, bubbleRightDragZoneWithSecondDropTarget.secondDropTarget!!.rect ) } private fun verifyDropTargetPosition(rect: Rect) { verifyDropTargetPosition(dropTargetView, rect) } Loading