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

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

Merge changes I2b17261c,I75433972 into main

* changes:
  Implemented taskbar application icon drop onto the bubble bar drop zone.
  Add logic to show the expanded view drop target.
parents 707e6aae fbb7414f
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -95,7 +95,7 @@ abstract class BaseBubblePinController(private val screenSizeProvider: () -> Poi

    /** Signal the controller that dragging interaction has finished. */
    fun onDragEnd() {
        getDropTargetView()?.let { view -> view.animateOut { removeDropTargetView(view) } }
        hideDropTarget()
        dismissZone = null
        listener?.onRelease(if (onLeft) LEFT else RIGHT)
    }
@@ -139,7 +139,7 @@ abstract class BaseBubblePinController(private val screenSizeProvider: () -> Poi
        return rect
    }

    private fun showDropTarget(location: BubbleBarLocation) {
    fun showDropTarget(location: BubbleBarLocation) {
        val targetView = getDropTargetView() ?: createDropTargetView().apply { alpha = 0f }
        if (targetView.alpha > 0) {
            targetView.animateOut {
@@ -152,6 +152,10 @@ abstract class BaseBubblePinController(private val screenSizeProvider: () -> Poi
        }
    }

    fun hideDropTarget() {
        getDropTargetView()?.let { view -> view.animateOut { removeDropTargetView(view) } }
    }

    private fun View.animateIn() {
        dropTargetAnimator?.cancel()
        dropTargetAnimator =
+4 −0
Original line number Diff line number Diff line
@@ -70,6 +70,7 @@ enum class BubbleBarLocation : Parcelable {
        UpdateSource.A11Y_ACTION_BAR,
        UpdateSource.A11Y_ACTION_BUBBLE,
        UpdateSource.A11Y_ACTION_EXP_VIEW,
        UpdateSource.APP_ICON_DRAG
    )
    @Retention(AnnotationRetention.SOURCE)
    annotation class UpdateSource {
@@ -91,6 +92,9 @@ enum class BubbleBarLocation : Parcelable {

            /** Location changed via a11y action on the expanded view */
            const val A11Y_ACTION_EXP_VIEW = 6

            /** Location changed from dragging the application icon to the bubble bar */
            const val APP_ICON_DRAG = 7
        }
    }
}
+28 −7
Original line number Diff line number Diff line
@@ -832,6 +832,10 @@ public class BubbleController implements ConfigurationChangeListener,
            case BubbleBarLocation.UpdateSource.A11Y_ACTION_EXP_VIEW:
                // TODO(b/349845968): move logging from BubbleBarLayerView to here
                break;
            case BubbleBarLocation.UpdateSource.APP_ICON_DRAG:
                mLogger.log(onLeft ? BubbleLogger.Event.BUBBLE_BAR_MOVED_LEFT_APP_ICON_DROP
                        : BubbleLogger.Event.BUBBLE_BAR_MOVED_RIGHT_APP_ICON_DROP);
                break;
        }
    }

@@ -851,24 +855,28 @@ public class BubbleController implements ConfigurationChangeListener,
    public void onDragItemOverBubbleBarDragZone(@Nullable BubbleBarLocation bubbleBarLocation) {
        if (bubbleBarLocation == null) return;
        if (isShowingAsBubbleBar() && BubbleAnythingFlagHelper.enableCreateAnyBubble()) {
            //TODO(b/388894910) show expanded view drop
            mBubbleStateListener.onDragItemOverBubbleBarDragZone(bubbleBarLocation);
            ensureBubbleViewsAndWindowCreated();
            if (mLayerView != null) {
                mLayerView.showBubbleBarExtendedViewDropTarget(bubbleBarLocation);
            }
        }
    }

    @Override
    public void onItemDraggedOutsideBubbleBarDropZone() {
        if (isShowingAsBubbleBar() && BubbleAnythingFlagHelper.enableCreateAnyBubble()) {
            //TODO(b/388894910) hide expanded view drop
            mBubbleStateListener.onItemDraggedOutsideBubbleBarDropZone();
            hideBubbleBarExpandedViewDropTarget();
        }
    }

    @Override
    public void onItemDroppedOverBubbleBarDragZone(@Nullable BubbleBarLocation bubbleBarLocation) {
        if (bubbleBarLocation == null) return;
    public void onItemDroppedOverBubbleBarDragZone(BubbleBarLocation location, Intent appIntent,
            UserHandle userHandle) {
        if (isShowingAsBubbleBar() && BubbleAnythingFlagHelper.enableCreateAnyBubble()) {
            //TODO(b/388894910) handle item drop with expandStackAndSelectBubble()
            hideBubbleBarExpandedViewDropTarget();
            expandStackAndSelectBubble(appIntent, userHandle, location);
        }
    }

@@ -888,6 +896,12 @@ public class BubbleController implements ConfigurationChangeListener,
        return result;
    }

    private void hideBubbleBarExpandedViewDropTarget() {
        if (mLayerView != null) {
            mLayerView.hideBubbleBarExpandedViewDropTarget();
        }
    }

    /** Whether this userId belongs to the current user. */
    private boolean isCurrentProfile(int userId) {
        return userId == UserHandle.USER_ALL
@@ -1512,8 +1526,14 @@ public class BubbleController implements ConfigurationChangeListener,
     *
     * @param intent the intent for the bubble.
     */
    public void expandStackAndSelectBubble(Intent intent, UserHandle user) {
    public void expandStackAndSelectBubble(Intent intent, UserHandle user,
            @Nullable BubbleBarLocation bubbleBarLocation) {
        if (!BubbleAnythingFlagHelper.enableCreateAnyBubble()) return;
        if (bubbleBarLocation != null) {
            //TODO (b/388894910) combine location update with the setSelectedBubbleAndExpandStack &
            // fix bubble bar flicking
            setBubbleBarLocation(bubbleBarLocation, BubbleBarLocation.UpdateSource.APP_ICON_DRAG);
        }
        Bubble b = mBubbleData.getOrCreateBubble(intent, user); // Removes from overflow
        ProtoLog.v(WM_SHELL_BUBBLES, "expandStackAndSelectBubble - intent=%s", intent);
        if (b.isInflated()) {
@@ -2746,7 +2766,8 @@ public class BubbleController implements ConfigurationChangeListener,

        @Override
        public void showAppBubble(Intent intent, UserHandle user) {
            mMainExecutor.execute(() -> mController.expandStackAndSelectBubble(intent, user));
            mMainExecutor.execute(() -> mController.expandStackAndSelectBubble(intent,
                    user, /* bubbleBarLocation = */ null));
        }

        @Override
+7 −1
Original line number Diff line number Diff line
@@ -145,8 +145,14 @@ public class BubbleLogger {
        @UiEvent(doc = "bubble promoted from overflow back to bubble bar")
        BUBBLE_BAR_OVERFLOW_REMOVE_BACK_TO_BAR(1949),

        @UiEvent(doc = "application icon is dropped in the BubbleBar left drop zone")
        BUBBLE_BAR_MOVED_LEFT_APP_ICON_DROP(2082),

        @UiEvent(doc = "application icon is dropped in the BubbleBar right drop zone")
        BUBBLE_BAR_MOVED_RIGHT_APP_ICON_DROP(2083),

        @UiEvent(doc = "while bubble bar is expanded, switch to another/existing bubble")
        BUBBLE_BAR_BUBBLE_SWITCHED(1977)
        BUBBLE_BAR_BUBBLE_SWITCHED(1977),

        // endregion
        ;
+7 −1
Original line number Diff line number Diff line
@@ -16,7 +16,9 @@

package com.android.wm.shell.bubbles.bar

import android.content.Intent
import android.graphics.Rect
import android.os.UserHandle
import com.android.wm.shell.shared.bubbles.BubbleBarLocation

/** Controller that takes care of the bubble bar drag events. */
@@ -29,7 +31,11 @@ interface BubbleBarDragListener {
    fun onItemDraggedOutsideBubbleBarDropZone()

    /** Called when the drop event happens over the bubble bar drop zone. */
    fun onItemDroppedOverBubbleBarDragZone(location: BubbleBarLocation?)
    fun onItemDroppedOverBubbleBarDragZone(
        location: BubbleBarLocation,
        intent: Intent,
        userHandle: UserHandle
    )

    /**
     * Returns mapping of the bubble bar locations to the corresponding
Loading