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

Commit db1ba195 authored by Ats Jenk's avatar Ats Jenk
Browse files

Extract logic related to dragging bubble bar views to other side

Bubble bar can be pinned to left or right by initiating drag from
different views.
Extract common logic related to dragging and showing a drop target.
BaseBubblePinController can be used by both launcher and shell.

Bug: 330585397
Test: atest WMShellRobolectricTests:BubbleExpandedViewPinControllerTest
Test: atest WMShellMultivalentTestsOnDevice:BubbleExpandedViewPinControllerTest
Change-Id: Ief395f30e60f829c73b89fe9f49369f4fd286b12
parent 021ecf5c
Loading
Loading
Loading
Loading
+263 −0
Original line number Original line Diff line number Diff line
@@ -17,6 +17,7 @@ package com.android.wm.shell.bubbles.bar


import android.content.Context
import android.content.Context
import android.graphics.Insets
import android.graphics.Insets
import android.graphics.PointF
import android.graphics.Rect
import android.graphics.Rect
import android.view.View
import android.view.View
import android.view.WindowManager
import android.view.WindowManager
@@ -30,30 +31,43 @@ import com.android.internal.protolog.common.ProtoLog
import com.android.wm.shell.R
import com.android.wm.shell.R
import com.android.wm.shell.bubbles.BubblePositioner
import com.android.wm.shell.bubbles.BubblePositioner
import com.android.wm.shell.bubbles.DeviceConfig
import com.android.wm.shell.bubbles.DeviceConfig
import com.android.wm.shell.bubbles.bar.BubbleBarDropTargetController.Companion.DROP_TARGET_ALPHA_IN_DURATION
import com.android.wm.shell.bubbles.bar.BubbleExpandedViewPinController.Companion.DROP_TARGET_SCALE
import com.android.wm.shell.bubbles.bar.BubbleBarDropTargetController.Companion.DROP_TARGET_ALPHA_OUT_DURATION
import com.android.wm.shell.common.bubbles.BaseBubblePinController
import com.android.wm.shell.bubbles.bar.BubbleBarDropTargetController.Companion.DROP_TARGET_SCALE
import com.android.wm.shell.common.bubbles.BaseBubblePinController.Companion.DROP_TARGET_ALPHA_IN_DURATION
import com.android.wm.shell.common.bubbles.BaseBubblePinController.Companion.DROP_TARGET_ALPHA_OUT_DURATION
import com.android.wm.shell.common.bubbles.BubbleBarLocation
import com.android.wm.shell.common.bubbles.BubbleBarLocation
import com.google.common.truth.Truth.assertThat
import com.google.common.truth.Truth.assertThat
import org.junit.After
import org.junit.Before
import org.junit.Before
import org.junit.ClassRule
import org.junit.ClassRule
import org.junit.Test
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runner.RunWith


/** Tests for [BubbleBarDropTargetController] */
/** Tests for [BubbleExpandedViewPinController] */
@SmallTest
@SmallTest
@RunWith(AndroidJUnit4::class)
@RunWith(AndroidJUnit4::class)
class BubbleBarDropTargetControllerTest {
class BubbleExpandedViewPinControllerTest {


    companion object {
    companion object {
        @JvmField @ClassRule val animatorTestRule: AnimatorTestRule = AnimatorTestRule()
        @JvmField @ClassRule val animatorTestRule: AnimatorTestRule = AnimatorTestRule()

        const val SCREEN_WIDTH = 2000
        const val SCREEN_HEIGHT = 1000

        const val BUBBLE_BAR_WIDTH = 100
        const val BUBBLE_BAR_HEIGHT = 50
    }
    }


    private val context = ApplicationProvider.getApplicationContext<Context>()
    private val context = ApplicationProvider.getApplicationContext<Context>()
    private lateinit var controller: BubbleBarDropTargetController
    private lateinit var positioner: BubblePositioner
    private lateinit var positioner: BubblePositioner
    private lateinit var container: FrameLayout
    private lateinit var container: FrameLayout


    private lateinit var controller: BubbleExpandedViewPinController
    private lateinit var testListener: TestLocationChangeListener

    private val pointOnLeft = PointF(100f, 100f)
    private val pointOnRight = PointF(1900f, 500f)

    @Before
    @Before
    fun setUp() {
    fun setUp() {
        ProtoLog.REQUIRE_PROTOLOGTOOL = false
        ProtoLog.REQUIRE_PROTOLOGTOOL = false
@@ -63,7 +77,7 @@ class BubbleBarDropTargetControllerTest {
        positioner.setShowingInBubbleBar(true)
        positioner.setShowingInBubbleBar(true)
        val deviceConfig =
        val deviceConfig =
            DeviceConfig(
            DeviceConfig(
                windowBounds = Rect(0, 0, 2000, 2600),
                windowBounds = Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT),
                isLargeScreen = true,
                isLargeScreen = true,
                isSmallTablet = false,
                isSmallTablet = false,
                isLandscape = true,
                isLandscape = true,
@@ -71,87 +85,149 @@ class BubbleBarDropTargetControllerTest {
                insets = Insets.of(10, 20, 30, 40)
                insets = Insets.of(10, 20, 30, 40)
            )
            )
        positioner.update(deviceConfig)
        positioner.update(deviceConfig)
        positioner.bubbleBarBounds = Rect(1800, 2400, 1970, 2560)
        positioner.bubbleBarBounds =
            Rect(
                SCREEN_WIDTH - deviceConfig.insets.right - BUBBLE_BAR_WIDTH,
                SCREEN_HEIGHT - deviceConfig.insets.bottom - BUBBLE_BAR_HEIGHT,
                SCREEN_WIDTH - deviceConfig.insets.right,
                SCREEN_HEIGHT - deviceConfig.insets.bottom
            )


        controller = BubbleBarDropTargetController(context, container, positioner)
        controller = BubbleExpandedViewPinController(context, container, positioner)
        testListener = TestLocationChangeListener()
        controller.setListener(testListener)
    }

    @After
    fun tearDown() {
        runOnMainSync { controller.onDragEnd() }
        waitForAnimateOut()
    }
    }


    @Test
    @Test
    fun show_moveLeftToRight_isVisibleWithExpectedBounds() {
    fun onDragUpdate_stayOnSameSide() {
        val expectedBoundsOnLeft = getExpectedDropTargetBounds(onLeft = true)
        runOnMainSync {
        val expectedBoundsOnRight = getExpectedDropTargetBounds(onLeft = false)
            controller.onDragStart(initialLocationOnLeft = false)
            controller.onDragUpdate(pointOnRight.x, pointOnRight.y)
        }
        waitForAnimateIn()
        assertThat(dropTargetView).isNull()
        assertThat(testListener.locationChanges).isEmpty()
    }

    @Test
    fun onDragUpdate_toLeft() {
        runOnMainSync {
            controller.onDragStart(initialLocationOnLeft = false)
            controller.onDragUpdate(pointOnLeft.x, pointOnLeft.y)
        }
        waitForAnimateIn()

        assertThat(dropTargetView).isNotNull()
        assertThat(dropTargetView!!.alpha).isEqualTo(1f)

        val expectedDropTargetBounds = getExpectedDropTargetBounds(onLeft = true)
        assertThat(dropTargetView!!.layoutParams.width).isEqualTo(expectedDropTargetBounds.width())
        assertThat(dropTargetView!!.layoutParams.height)
            .isEqualTo(expectedDropTargetBounds.height())

        assertThat(testListener.locationChanges).containsExactly(BubbleBarLocation.LEFT)
    }


        runOnMainSync { controller.show(BubbleBarLocation.LEFT) }
    @Test
    fun onDragUpdate_toLeftAndBackToRight() {
        runOnMainSync {
            controller.onDragStart(initialLocationOnLeft = false)
            controller.onDragUpdate(pointOnLeft.x, pointOnLeft.y)
        }
        waitForAnimateIn()
        waitForAnimateIn()
        val viewOnLeft = getDropTargetView()
        assertThat(dropTargetView).isNotNull()
        assertThat(viewOnLeft).isNotNull()

        assertThat(viewOnLeft!!.alpha).isEqualTo(1f)
        runOnMainSync { controller.onDragUpdate(pointOnRight.x, pointOnRight.y) }
        assertThat(viewOnLeft.layoutParams.width).isEqualTo(expectedBoundsOnLeft.width())
        // We have to wait for existing drop target to animate out and new to animate in
        assertThat(viewOnLeft.layoutParams.height).isEqualTo(expectedBoundsOnLeft.height())
        assertThat(viewOnLeft.x).isEqualTo(expectedBoundsOnLeft.left)
        assertThat(viewOnLeft.y).isEqualTo(expectedBoundsOnLeft.top)

        runOnMainSync { controller.show(BubbleBarLocation.RIGHT) }
        waitForAnimateOut()
        waitForAnimateOut()
        waitForAnimateIn()
        waitForAnimateIn()
        val viewOnRight = getDropTargetView()

        assertThat(viewOnRight).isNotNull()
        assertThat(dropTargetView).isNotNull()
        assertThat(viewOnRight!!.alpha).isEqualTo(1f)
        assertThat(dropTargetView!!.alpha).isEqualTo(1f)
        assertThat(viewOnRight.layoutParams.width).isEqualTo(expectedBoundsOnRight.width())

        assertThat(viewOnRight.layoutParams.height).isEqualTo(expectedBoundsOnRight.height())
        val expectedDropTargetBounds = getExpectedDropTargetBounds(onLeft = false)
        assertThat(viewOnRight.x).isEqualTo(expectedBoundsOnRight.left)
        assertThat(dropTargetView!!.layoutParams.width).isEqualTo(expectedDropTargetBounds.width())
        assertThat(viewOnRight.y).isEqualTo(expectedBoundsOnRight.top)
        assertThat(dropTargetView!!.layoutParams.height)
            .isEqualTo(expectedDropTargetBounds.height())

        assertThat(testListener.locationChanges)
            .containsExactly(BubbleBarLocation.LEFT, BubbleBarLocation.RIGHT)
    }
    }


    @Test
    @Test
    fun toggleSetHidden_dropTargetShown_updatesAlpha() {
    fun onDragUpdate_toLeftInExclusionRect() {
        runOnMainSync { controller.show(BubbleBarLocation.RIGHT) }
        runOnMainSync {
            controller.onDragStart(initialLocationOnLeft = false)
            // Exclusion rect is around the bottom center area of the screen
            controller.onDragUpdate(SCREEN_WIDTH / 2f - 50, SCREEN_HEIGHT - 100f)
        }
        waitForAnimateIn()
        waitForAnimateIn()
        val view = getDropTargetView()
        assertThat(dropTargetView).isNull()
        assertThat(view).isNotNull()
        assertThat(testListener.locationChanges).isEmpty()
        assertThat(view!!.alpha).isEqualTo(1f)
    }


        runOnMainSync { controller.setHidden(true) }
    @Test
    fun toggleSetDropTargetHidden_dropTargetExists() {
        runOnMainSync {
            controller.onDragStart(initialLocationOnLeft = false)
            controller.onDragUpdate(pointOnLeft.x, pointOnLeft.y)
        }
        waitForAnimateIn()

        assertThat(dropTargetView).isNotNull()
        assertThat(dropTargetView!!.alpha).isEqualTo(1f)

        runOnMainSync { controller.setDropTargetHidden(true) }
        waitForAnimateOut()
        waitForAnimateOut()
        val hiddenView = getDropTargetView()
        assertThat(dropTargetView).isNotNull()
        assertThat(hiddenView).isNotNull()
        assertThat(dropTargetView!!.alpha).isEqualTo(0f)
        assertThat(hiddenView!!.alpha).isEqualTo(0f)


        runOnMainSync { controller.setHidden(false) }
        runOnMainSync { controller.setDropTargetHidden(false) }
        waitForAnimateIn()
        waitForAnimateIn()
        val shownView = getDropTargetView()
        assertThat(dropTargetView).isNotNull()
        assertThat(shownView).isNotNull()
        assertThat(dropTargetView!!.alpha).isEqualTo(1f)
        assertThat(shownView!!.alpha).isEqualTo(1f)
    }
    }


    @Test
    @Test
    fun toggleSetHidden_dropTargetNotShown_viewNotCreated() {
    fun toggleSetDropTargetHidden_noDropTarget() {
        runOnMainSync { controller.setHidden(true) }
        runOnMainSync { controller.setDropTargetHidden(true) }
        waitForAnimateOut()
        waitForAnimateOut()
        assertThat(getDropTargetView()).isNull()
        assertThat(dropTargetView).isNull()
        runOnMainSync { controller.setHidden(false) }

        runOnMainSync { controller.setDropTargetHidden(false) }
        waitForAnimateIn()
        waitForAnimateIn()
        assertThat(getDropTargetView()).isNull()
        assertThat(dropTargetView).isNull()
    }
    }


    @Test
    @Test
    fun dismiss_dropTargetShown_viewRemoved() {
    fun onDragEnd_dropTargetExists() {
        runOnMainSync { controller.show(BubbleBarLocation.LEFT) }
        runOnMainSync {
            controller.onDragStart(initialLocationOnLeft = false)
            controller.onDragUpdate(pointOnLeft.x, pointOnLeft.y)
        }
        waitForAnimateIn()
        waitForAnimateIn()
        assertThat(getDropTargetView()).isNotNull()
        assertThat(dropTargetView).isNotNull()
        runOnMainSync { controller.dismiss() }

        runOnMainSync { controller.onDragEnd() }
        waitForAnimateOut()
        waitForAnimateOut()
        assertThat(getDropTargetView()).isNull()
        assertThat(dropTargetView).isNull()
    }
    }


    @Test
    @Test
    fun dismiss_dropTargetNotShown_doesNothing() {
    fun onDragEnd_noDropTarget() {
        runOnMainSync { controller.dismiss() }
        runOnMainSync { controller.onDragEnd() }
        waitForAnimateOut()
        waitForAnimateOut()
        assertThat(getDropTargetView()).isNull()
        assertThat(dropTargetView).isNull()
    }
    }


    private fun getDropTargetView(): View? = container.findViewById(R.id.bubble_bar_drop_target)
    private val dropTargetView: View?
        get() = container.findViewById(R.id.bubble_bar_drop_target)


    private fun getExpectedDropTargetBounds(onLeft: Boolean): Rect {
    private fun getExpectedDropTargetBounds(onLeft: Boolean): Rect {
        val rect = Rect()
        val rect = Rect()
@@ -177,4 +253,11 @@ class BubbleBarDropTargetControllerTest {
        // Advance animator for on-device test
        // Advance animator for on-device test
        runOnMainSync { animatorTestRule.advanceTimeBy(DROP_TARGET_ALPHA_OUT_DURATION) }
        runOnMainSync { animatorTestRule.advanceTimeBy(DROP_TARGET_ALPHA_OUT_DURATION) }
    }
    }

    internal class TestLocationChangeListener : BaseBubblePinController.LocationChangeListener {
        val locationChanges = mutableListOf<BubbleBarLocation>()
        override fun onChange(location: BubbleBarLocation) {
            locationChanges.add(location)
        }
    }
}
}
+8 −58
Original line number Original line Diff line number Diff line
@@ -17,12 +17,9 @@
package com.android.wm.shell.bubbles.bar
package com.android.wm.shell.bubbles.bar


import android.annotation.SuppressLint
import android.annotation.SuppressLint
import android.graphics.RectF
import android.view.MotionEvent
import android.view.MotionEvent
import android.view.View
import android.view.View
import com.android.wm.shell.R
import com.android.wm.shell.bubbles.BubblePositioner
import com.android.wm.shell.bubbles.BubblePositioner
import com.android.wm.shell.common.bubbles.BubbleBarLocation
import com.android.wm.shell.common.bubbles.DismissView
import com.android.wm.shell.common.bubbles.DismissView
import com.android.wm.shell.common.bubbles.RelativeTouchListener
import com.android.wm.shell.common.bubbles.RelativeTouchListener
import com.android.wm.shell.common.magnetictarget.MagnetizedObject
import com.android.wm.shell.common.magnetictarget.MagnetizedObject
@@ -34,6 +31,7 @@ class BubbleBarExpandedViewDragController(
    private val dismissView: DismissView,
    private val dismissView: DismissView,
    private val animationHelper: BubbleBarAnimationHelper,
    private val animationHelper: BubbleBarAnimationHelper,
    private val bubblePositioner: BubblePositioner,
    private val bubblePositioner: BubblePositioner,
    private val pinController: BubbleExpandedViewPinController,
    private val dragListener: DragListener
    private val dragListener: DragListener
) {
) {


@@ -45,8 +43,6 @@ class BubbleBarExpandedViewDragController(
    private val magnetizedExpandedView: MagnetizedObject<BubbleBarExpandedView> =
    private val magnetizedExpandedView: MagnetizedObject<BubbleBarExpandedView> =
        MagnetizedObject.magnetizeView(expandedView)
        MagnetizedObject.magnetizeView(expandedView)
    private val magnetizedDismissTarget: MagnetizedObject.MagneticTarget
    private val magnetizedDismissTarget: MagnetizedObject.MagneticTarget
    private val dismissZoneHeight: Int
    private val dismissZoneWidth: Int


    init {
    init {
        magnetizedExpandedView.magnetListener = MagnetListener()
        magnetizedExpandedView.magnetListener = MagnetListener()
@@ -78,32 +74,10 @@ class BubbleBarExpandedViewDragController(
            }
            }
            return@setOnTouchListener dragMotionEventHandler.onTouch(view, event) || magnetConsumed
            return@setOnTouchListener dragMotionEventHandler.onTouch(view, event) || magnetConsumed
        }
        }

        dismissZoneHeight =
            dismissView.resources.getDimensionPixelSize(R.dimen.bubble_bar_dismiss_zone_height)
        dismissZoneWidth =
            dismissView.resources.getDimensionPixelSize(R.dimen.bubble_bar_dismiss_zone_width)
    }
    }


    /** Listener to receive callback about dragging events */
    /** Listener to get notified about drag events */
    interface DragListener {
    interface DragListener {
        /**
         * Bubble bar [BubbleBarLocation] has changed as a result of dragging the expanded view.
         *
         * Triggered when drag gesture passes the middle of the screen and before touch up. Can be
         * triggered multiple times per gesture.
         *
         * @param location new location of the bubble bar as a result of the ongoing drag operation
         */
        fun onLocationChanged(location: BubbleBarLocation)

        /**
         * Called when bubble bar is moved into or out of the dismiss target
         *
         * @param isStuck `true` if view is dragged inside dismiss target
         */
        fun onStuckToDismissChanged(isStuck: Boolean)

        /**
        /**
         * Bubble bar was released
         * Bubble bar was released
         *
         *
@@ -115,25 +89,11 @@ class BubbleBarExpandedViewDragController(
    private inner class HandleDragListener : RelativeTouchListener() {
    private inner class HandleDragListener : RelativeTouchListener() {


        private var isMoving = false
        private var isMoving = false
        private var screenCenterX: Int = -1
        private var isOnLeft = false
        private val dismissZone = RectF()


        override fun onDown(v: View, ev: MotionEvent): Boolean {
        override fun onDown(v: View, ev: MotionEvent): Boolean {
            // While animating, don't allow new touch events
            // While animating, don't allow new touch events
            if (expandedView.isAnimating) return false
            if (expandedView.isAnimating) return false
            isOnLeft = bubblePositioner.isBubbleBarOnLeft
            pinController.onDragStart(bubblePositioner.isBubbleBarOnLeft)

            val screenRect = bubblePositioner.screenRect
            screenCenterX = screenRect.centerX()
            val screenBottom = screenRect.bottom

            dismissZone.set(
                screenCenterX - dismissZoneWidth / 2f,
                (screenBottom - dismissZoneHeight).toFloat(),
                screenCenterX + dismissZoneHeight / 2f,
                screenBottom.toFloat()
            )
            return true
            return true
        }
        }


@@ -152,19 +112,7 @@ class BubbleBarExpandedViewDragController(
            expandedView.translationX = expandedViewInitialTranslationX + dx
            expandedView.translationX = expandedViewInitialTranslationX + dx
            expandedView.translationY = expandedViewInitialTranslationY + dy
            expandedView.translationY = expandedViewInitialTranslationY + dy
            dismissView.show()
            dismissView.show()

            pinController.onDragUpdate(ev.rawX, ev.rawY)
            // Check if we are in the zone around dismiss view where drag can only lead to dismiss
            if (dismissZone.contains(ev.rawX, ev.rawY)) {
                return
            }

            if (isOnLeft && ev.rawX > screenCenterX) {
                isOnLeft = false
                dragListener.onLocationChanged(BubbleBarLocation.RIGHT)
            } else if (!isOnLeft && ev.rawX < screenCenterX) {
                isOnLeft = true
                dragListener.onLocationChanged(BubbleBarLocation.LEFT)
            }
        }
        }


        override fun onUp(
        override fun onUp(
@@ -188,6 +136,7 @@ class BubbleBarExpandedViewDragController(
        private fun finishDrag() {
        private fun finishDrag() {
            if (!isStuckToDismiss) {
            if (!isStuckToDismiss) {
                animationHelper.animateToRestPosition()
                animationHelper.animateToRestPosition()
                pinController.onDragEnd()
                dragListener.onReleased(inDismiss = false)
                dragListener.onReleased(inDismiss = false)
                dismissView.hide()
                dismissView.hide()
            }
            }
@@ -201,7 +150,7 @@ class BubbleBarExpandedViewDragController(
            draggedObject: MagnetizedObject<*>
            draggedObject: MagnetizedObject<*>
        ) {
        ) {
            isStuckToDismiss = true
            isStuckToDismiss = true
            dragListener.onStuckToDismissChanged(isStuck = true)
            pinController.setDropTargetHidden(true)
        }
        }


        override fun onUnstuckFromTarget(
        override fun onUnstuckFromTarget(
@@ -213,7 +162,7 @@ class BubbleBarExpandedViewDragController(
        ) {
        ) {
            isStuckToDismiss = false
            isStuckToDismiss = false
            animationHelper.animateUnstuckFromDismissView(target)
            animationHelper.animateUnstuckFromDismissView(target)
            dragListener.onStuckToDismissChanged(isStuck = false)
            pinController.setDropTargetHidden(false)
        }
        }


        override fun onReleasedInTarget(
        override fun onReleasedInTarget(
@@ -221,6 +170,7 @@ class BubbleBarExpandedViewDragController(
            draggedObject: MagnetizedObject<*>
            draggedObject: MagnetizedObject<*>
        ) {
        ) {
            dragListener.onReleased(inDismiss = true)
            dragListener.onReleased(inDismiss = true)
            pinController.onDragEnd()
            dismissView.hide()
            dismissView.hide()
        }
        }
    }
    }
+10 −28
Original line number Original line Diff line number Diff line
@@ -33,8 +33,6 @@ import android.view.ViewTreeObserver;
import android.view.WindowManager;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.FrameLayout;


import androidx.annotation.NonNull;

import com.android.wm.shell.bubbles.Bubble;
import com.android.wm.shell.bubbles.Bubble;
import com.android.wm.shell.bubbles.BubbleController;
import com.android.wm.shell.bubbles.BubbleController;
import com.android.wm.shell.bubbles.BubbleData;
import com.android.wm.shell.bubbles.BubbleData;
@@ -44,7 +42,6 @@ import com.android.wm.shell.bubbles.BubbleViewProvider;
import com.android.wm.shell.bubbles.DeviceConfig;
import com.android.wm.shell.bubbles.DeviceConfig;
import com.android.wm.shell.bubbles.DismissViewUtils;
import com.android.wm.shell.bubbles.DismissViewUtils;
import com.android.wm.shell.bubbles.bar.BubbleBarExpandedViewDragController.DragListener;
import com.android.wm.shell.bubbles.bar.BubbleBarExpandedViewDragController.DragListener;
import com.android.wm.shell.common.bubbles.BubbleBarLocation;
import com.android.wm.shell.common.bubbles.DismissView;
import com.android.wm.shell.common.bubbles.DismissView;


import kotlin.Unit;
import kotlin.Unit;
@@ -71,7 +68,7 @@ public class BubbleBarLayerView extends FrameLayout
    private final BubbleBarAnimationHelper mAnimationHelper;
    private final BubbleBarAnimationHelper mAnimationHelper;
    private final BubbleEducationViewController mEducationViewController;
    private final BubbleEducationViewController mEducationViewController;
    private final View mScrimView;
    private final View mScrimView;
    private final BubbleBarDropTargetController mDropTargetController;
    private final BubbleExpandedViewPinController mBubbleExpandedViewPinController;


    @Nullable
    @Nullable
    private BubbleViewProvider mExpandedBubble;
    private BubbleViewProvider mExpandedBubble;
@@ -116,7 +113,9 @@ public class BubbleBarLayerView extends FrameLayout


        setUpDismissView();
        setUpDismissView();


        mDropTargetController = new BubbleBarDropTargetController(context, this, mPositioner);
        mBubbleExpandedViewPinController = new BubbleExpandedViewPinController(
                context, this, mPositioner);
        mBubbleExpandedViewPinController.setListener(mBubbleController::setBubbleBarLocation);


        setOnClickListener(view -> hideMenuOrCollapse());
        setOnClickListener(view -> hideMenuOrCollapse());
    }
    }
@@ -207,12 +206,17 @@ public class BubbleBarLayerView extends FrameLayout
                }
                }
            });
            });


            DragListener dragListener = createDragListener();
            DragListener dragListener = inDismiss -> {
                if (inDismiss && mExpandedBubble != null) {
                    mBubbleController.dismissBubble(mExpandedBubble.getKey(), DISMISS_USER_GESTURE);
                }
            };
            mDragController = new BubbleBarExpandedViewDragController(
            mDragController = new BubbleBarExpandedViewDragController(
                    mExpandedView,
                    mExpandedView,
                    mDismissView,
                    mDismissView,
                    mAnimationHelper,
                    mAnimationHelper,
                    mPositioner,
                    mPositioner,
                    mBubbleExpandedViewPinController,
                    dragListener);
                    dragListener);


            addView(mExpandedView, new LayoutParams(width, height, Gravity.LEFT));
            addView(mExpandedView, new LayoutParams(width, height, Gravity.LEFT));
@@ -377,26 +381,4 @@ public class BubbleBarLayerView extends FrameLayout
        }
        }
    }
    }


    private DragListener createDragListener() {
        return new DragListener() {
            @Override
            public void onLocationChanged(@NonNull BubbleBarLocation location) {
                mBubbleController.setBubbleBarLocation(location);
                mDropTargetController.show(location);
            }

            @Override
            public void onStuckToDismissChanged(boolean isStuck) {
                mDropTargetController.setHidden(isStuck);
            }

            @Override
            public void onReleased(boolean inDismiss) {
                mDropTargetController.dismiss();
                if (inDismiss && mExpandedBubble != null) {
                    mBubbleController.dismissBubble(mExpandedBubble.getKey(), DISMISS_USER_GESTURE);
                }
            }
        };
    }
}
}
+109 −0

File changed and moved.

Preview size limit exceeded, changes collapsed.

+179 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading