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

Commit fbb7414f authored by mpodolian's avatar mpodolian
Browse files

Implemented taskbar application icon drop onto the bubble bar drop zone.

Added logic to create a new application bubble in the bubble bar
when dragging and dropping taskbar application icon.

Bug: 388894910
Flag: com.android.wm.shell.enable_create_any_bubble
Test: atest BubbleControllerTest
Test: Manual. Drag an app icon from the taskbar while inside the
application to any bubble bar drop zone and drop it there. Observe
that a new application bubble is added and the bubble bar expands,
showing the newly added bubble content in the expanded view.
video: http://recall/-/gx8ASgewUeUS3QYohfrd1J/erIYLNwEjzD0T5konPIdY6

Change-Id: I2b17261c05be456d606cb5fffe8151b1d9b5c70c
parent 500a6cc6
Loading
Loading
Loading
Loading
+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
        }
    }
}
+16 −5
Original line number Diff line number Diff line
@@ -830,6 +830,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;
        }
    }

@@ -866,11 +870,11 @@ public class BubbleController implements ConfigurationChangeListener,
    }

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

@@ -1515,8 +1519,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()) {
@@ -2749,7 +2759,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
+19 −5
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import android.annotation.SuppressLint;
import android.app.ActivityManager;
import android.app.StatusBarManager;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Color;
@@ -46,6 +47,7 @@ import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.Region;
import android.graphics.drawable.Drawable;
import android.os.UserHandle;
import android.view.DragEvent;
import android.view.SurfaceControl;
import android.view.View;
@@ -600,6 +602,12 @@ public class DragLayout extends LinearLayout

    @Nullable
    private BubbleBarLocation getBubbleBarLocation(int x, int y) {
        Intent appData = mSession.appData;
        if (appData == null || appData.getExtra(Intent.EXTRA_INTENT) == null
                || appData.getExtra(Intent.EXTRA_USER) == null) {
            // there is no app data, so drop event over the bubble bar can not be handled
            return null;
        }
        for (BubbleBarLocation location : mBubbleBarLocations.keySet()) {
            if (mBubbleBarLocations.get(location).contains(x, y)) {
                return location;
@@ -649,11 +657,17 @@ public class DragLayout extends LinearLayout
            @Nullable WindowContainerToken hideTaskToken, Runnable dropCompleteCallback) {
        final boolean handledDrop = mCurrentTarget != null || mCurrentBubbleBarTarget != null;
        mHasDropped = true;
        Intent appData = mSession.appData;

        // Process the drop
        // Process the drop exclusive by DropTarget OR by the BubbleBar
        if (mCurrentTarget != null) {
            mPolicy.onDropped(mCurrentTarget, hideTaskToken);
        //TODO(b/388894910) add info about the application
        mBubbleBarDragListener.onItemDroppedOverBubbleBarDragZone(mCurrentBubbleBarTarget);
        } else if (appData != null && mCurrentBubbleBarTarget != null) {
            Intent appIntent = (Intent) appData.getExtra(Intent.EXTRA_INTENT);
            UserHandle user = (UserHandle) appData.getExtra(Intent.EXTRA_USER);
            mBubbleBarDragListener.onItemDroppedOverBubbleBarDragZone(mCurrentBubbleBarTarget,
                    appIntent, user);
        }

        // Start animating the drop UI out with the drag surface
        hide(event, dropCompleteCallback);