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

Commit 38ad424a authored by Ats Jenk's avatar Ats Jenk Committed by Android (Google) Code Review
Browse files

Merge "Only send bubble bar top coordinate to shell" into main

parents ad26390e b34f8c88
Loading
Loading
Loading
Loading
+9 −42
Original line number Diff line number Diff line
@@ -31,8 +31,6 @@ import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_Q
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING_OCCLUDED;

import static java.lang.Math.abs;

import android.annotation.BinderThread;
import android.annotation.Nullable;
import android.app.Notification;
@@ -47,7 +45,6 @@ import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Path;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.drawable.AdaptiveIconDrawable;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
@@ -67,7 +64,6 @@ import com.android.launcher3.R;
import com.android.launcher3.icons.BitmapInfo;
import com.android.launcher3.icons.BubbleIconFactory;
import com.android.launcher3.shortcuts.ShortcutRequest;
import com.android.launcher3.util.DisplayController;
import com.android.launcher3.util.Executors.SimpleThreadFactory;
import com.android.quickstep.SystemUiProxy;
import com.android.systemui.shared.system.QuickStepContract.SystemUiStateFlags;
@@ -153,8 +149,8 @@ public class BubbleBarController extends IBubblesListener.Stub {
    private BubbleStashedHandleViewController mBubbleStashedHandleViewController;
    private BubblePinController mBubblePinController;

    // Keep track of bubble bar bounds sent to shell to avoid sending duplicate updates
    private final Rect mLastSentBubbleBarBounds = new Rect();
    // Cache last sent top coordinate to avoid sending duplicate updates to shell
    private int mLastSentBubbleBarTop;

    /**
     * Similar to {@link BubbleBarUpdate} but rather than {@link BubbleInfo}s it uses
@@ -445,9 +441,8 @@ public class BubbleBarController extends IBubblesListener.Stub {
                        info.getFlags() | Notification.BubbleMetadata.FLAG_SUPPRESS_NOTIFICATION);
                mSelectedBubble.getView().updateDotVisibility(true /* animate */);
            }
            Rect bounds = getExpandedBubbleBarDisplayBounds();
            mLastSentBubbleBarBounds.set(bounds);
            mSystemUiProxy.showBubble(getSelectedBubbleKey(), bounds);
            mLastSentBubbleBarTop = mBarView.getRestingTopPositionOnScreen();
            mSystemUiProxy.showBubble(getSelectedBubbleKey(), mLastSentBubbleBarTop);
        } else {
            Log.w(TAG, "Trying to show the selected bubble but it's null");
        }
@@ -636,40 +631,12 @@ public class BubbleBarController extends IBubblesListener.Stub {
        return mIconFactory.createBadgedIconBitmap(drawable).icon;
    }

    private void onBubbleBarBoundsChanged(Rect newBounds) {
        Rect displayBounds = convertToDisplayBounds(newBounds);
        // Only send bounds over if they changed
        if (!displayBounds.equals(mLastSentBubbleBarBounds)) {
            mLastSentBubbleBarBounds.set(displayBounds);
            mSystemUiProxy.setBubbleBarBounds(displayBounds);
        }
    }

    /**
     * Get bounds of the bubble bar as if it would be expanded.
     * Calculates the bounds instead of retrieving current view location as the view may be
     * animating.
     */
    private Rect getExpandedBubbleBarDisplayBounds() {
        return convertToDisplayBounds(mBarView.getBubbleBarBounds());
    }

    private Rect convertToDisplayBounds(Rect currentBarBounds) {
        Point displaySize = DisplayController.INSTANCE.get(mContext).getInfo().currentSize;
        Rect displayBounds = new Rect();
        // currentBarBounds is only useful for distance from left or right edge.
        // It contains the current bounds, calculate the expanded bounds.
        if (mBarView.getBubbleBarLocation().isOnLeft(mBarView.isLayoutRtl())) {
            displayBounds.left = currentBarBounds.left;
            displayBounds.right = (int) (currentBarBounds.left + mBarView.expandedWidth());
        } else {
            displayBounds.left = (int) (currentBarBounds.right - mBarView.expandedWidth());
            displayBounds.right = currentBarBounds.right;
    private void onBubbleBarBoundsChanged() {
        int newTop = mBarView.getRestingTopPositionOnScreen();
        if (newTop != mLastSentBubbleBarTop) {
            mLastSentBubbleBarTop = newTop;
            mSystemUiProxy.updateBubbleBarTopOnScreen(newTop);
        }
        final int translation = (int) abs(mBubbleStashController.getBubbleBarTranslationY());
        displayBounds.top = displaySize.y - currentBarBounds.height() - translation;
        displayBounds.bottom = displaySize.y - translation;
        return displayBounds;
    }

    /** Interface for checking whether the IME is visible. */
+10 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import androidx.dynamicanimation.animation.SpringForce;

import com.android.launcher3.R;
import com.android.launcher3.anim.SpringAnimationBuilder;
import com.android.launcher3.util.DisplayController;
import com.android.wm.shell.common.bubbles.BubbleBarLocation;

import java.util.List;
@@ -553,6 +554,15 @@ public class BubbleBarView extends FrameLayout {
        setAlpha(1f);
    }

    /**
     * Get bubble bar top coordinate on screen when bar is resting
     */
    public int getRestingTopPositionOnScreen() {
        int displayHeight = DisplayController.INSTANCE.get(getContext()).getInfo().currentSize.y;
        int bubbleBarHeight = getBubbleBarBounds().height();
        return displayHeight - bubbleBarHeight + (int) mController.getBubbleBarTranslationY();
    }

    /**
     * Updates the bounds with translation that may have been applied and returns the result.
     */
+8 −15
Original line number Diff line number Diff line
@@ -93,8 +93,6 @@ public class BubbleBarViewController {
    @Nullable
    private BubbleBarBoundsChangeListener mBoundsChangeListener;

    private final Rect mPreviousBubbleBarBounds = new Rect();

    public BubbleBarViewController(TaskbarActivityContext activity, BubbleBarView barView) {
        mActivity = activity;
        mBarView = barView;
@@ -122,12 +120,8 @@ public class BubbleBarViewController {
        mBarView.addOnLayoutChangeListener(
                (v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> {
                    mTaskbarInsetsController.onTaskbarOrBubblebarWindowHeightOrInsetsChanged();
                    Rect bubbleBarBounds = mBarView.getBubbleBarBounds();
                    if (!bubbleBarBounds.equals(mPreviousBubbleBarBounds)) {
                        mPreviousBubbleBarBounds.set(bubbleBarBounds);
                    if (mBoundsChangeListener != null) {
                            mBoundsChangeListener.onBoundsChanged(bubbleBarBounds);
                        }
                        mBoundsChangeListener.onBoundsChanged();
                    }
                });

@@ -497,7 +491,7 @@ public class BubbleBarViewController {
     * that a bubble is being dragged to dismiss.
     * @param bubbleView dragged bubble view
     */
    public void onDragStart(@NonNull BubbleView bubbleView) {
    public void onBubbleDragStart(@NonNull BubbleView bubbleView) {
        if (bubbleView.getBubble() == null) return;

        mSystemUiProxy.startBubbleDrag(bubbleView.getBubble().getKey());
@@ -507,20 +501,19 @@ public class BubbleBarViewController {
    /**
     * Notifies SystemUI to expand the selected bubble when the bubble is released.
     */
    public void onDragRelease(BubbleBarLocation location) {
        // TODO(b/330585402): send new bubble bar bounds to shell for the animation
        mSystemUiProxy.stopBubbleDrag(location);
    public void onBubbleDragRelease(BubbleBarLocation location) {
        mSystemUiProxy.stopBubbleDrag(location, mBarView.getRestingTopPositionOnScreen());
    }

    /**
     * Notifies {@link BubbleBarView} that drag and all animations are finished.
     */
    public void onDragBubbleEnded() {
    public void onBubbleDragEnd() {
        mBarView.setDraggedBubble(null);
    }

    /** Notifies that dragging the bubble bar ended. */
    public void onDragBubbleBarEnded() {
    public void onBubbleBarDragEnd() {
        // we may have changed the bubble bar translation Y value from the value it had at the
        // beginning of the drag, so update the translation Y animator state
        mBubbleBarTranslationY.updateValue(mBarView.getTranslationY());
@@ -576,6 +569,6 @@ public class BubbleBarViewController {
     */
    public interface BubbleBarBoundsChangeListener {
        /** Called when bounds have changed */
        void onBoundsChanged(Rect newBounds);
        void onBoundsChanged();
    }
}
+4 −4
Original line number Diff line number Diff line
@@ -97,7 +97,7 @@ public class BubbleDragController {
            @Override
            void onDragStart() {
                mBubblePinController.setListener(mLocationChangeListener);
                mBubbleBarViewController.onDragStart(bubbleView);
                mBubbleBarViewController.onBubbleDragStart(bubbleView);
                mBubblePinController.onDragStart(
                        mBubbleBarViewController.getBubbleBarLocation().isOnLeft(
                                bubbleView.isLayoutRtl()));
@@ -113,7 +113,7 @@ public class BubbleDragController {
            @Override
            protected void onDragRelease() {
                mBubblePinController.onDragEnd();
                mBubbleBarViewController.onDragRelease(mReleasedLocation);
                mBubbleBarViewController.onBubbleDragRelease(mReleasedLocation);
            }

            @Override
@@ -124,7 +124,7 @@ public class BubbleDragController {
            @Override
            void onDragEnd() {
                mBubbleBarController.updateBubbleBarLocation(mReleasedLocation);
                mBubbleBarViewController.onDragBubbleEnded();
                mBubbleBarViewController.onBubbleDragEnd();
                mBubblePinController.setListener(null);
            }

@@ -192,7 +192,7 @@ public class BubbleDragController {
                bubbleBarView.setIsDragging(false);
                // Restoring the initial pivot for the bubble bar view
                bubbleBarView.setRelativePivot(initialRelativePivot.x, initialRelativePivot.y);
                mBubbleBarViewController.onDragBubbleBarEnded();
                mBubbleBarViewController.onBubbleBarDragEnd();
                mBubbleBarPinController.setListener(null);
            }

+13 −10
Original line number Diff line number Diff line
@@ -761,12 +761,12 @@ public class SystemUiProxy implements ISystemUiProxy, NavHandle, SafeCloseable {
    /**
     * Tells SysUI to show the bubble with the provided key.
     * @param key the key of the bubble to show.
     * @param bubbleBarBounds bounds of the bubble bar in display coordinates
     * @param top top coordinate of bubble bar on screen
     */
    public void showBubble(String key, Rect bubbleBarBounds) {
    public void showBubble(String key, int top) {
        if (mBubbles != null) {
            try {
                mBubbles.showBubble(key, bubbleBarBounds);
                mBubbles.showBubble(key, top);
            } catch (RemoteException e) {
                Log.w(TAG, "Failed call showBubble");
            }
@@ -815,12 +815,14 @@ public class SystemUiProxy implements ISystemUiProxy, NavHandle, SafeCloseable {
    /**
     * Tells SysUI when the bubble stops being dragged.
     * Should be called only when the bubble bar is expanded.
     *
     * @param location location of the bubble bar
     * @param top      new top coordinate for bubble bar on screen
     */
    public void stopBubbleDrag(BubbleBarLocation location) {
    public void stopBubbleDrag(BubbleBarLocation location, int top) {
        if (mBubbles == null) return;
        try {
            mBubbles.stopBubbleDrag(location);
            mBubbles.stopBubbleDrag(location, top);
        } catch (RemoteException e) {
            Log.w(TAG, "Failed call stopBubbleDrag");
        }
@@ -864,16 +866,17 @@ public class SystemUiProxy implements ISystemUiProxy, NavHandle, SafeCloseable {
    }

    /**
     * Tells SysUI the bounds for the bubble bar
     * @param bubbleBarBounds bounds of the bubble bar in display coordinates
     * Tells SysUI the top coordinate of bubble bar on screen
     *
     * @param topOnScreen top coordinate for bubble bar on screen
     */
    public void setBubbleBarBounds(Rect bubbleBarBounds) {
    public void updateBubbleBarTopOnScreen(int topOnScreen) {
        try {
            if (mBubbles != null) {
                mBubbles.setBubbleBarBounds(bubbleBarBounds);
                mBubbles.updateBubbleBarTopOnScreen(topOnScreen);
            }
        } catch (RemoteException e) {
            Log.w(TAG, "Failed call setBubbleBarBounds");
            Log.w(TAG, "Failed call updateBubbleBarTopOnScreen");
        }
    }