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

Commit ddf3da44 authored by Mady Mellor's avatar Mady Mellor
Browse files

Remove previous changes for showing bubbles in taskbar

These are from a very old version when taskbar was persistent and
are no longer used. I don't want them to get confused with new
taskbar related stuff for bubbles.

Test: treehugger
Bug: 253318833
Change-Id: Id34d658b473c765eab99fb565a16017c2726957a
parent 41769959
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -283,7 +283,7 @@ public class BubbleData {
    }

    boolean isShowingOverflow() {
        return mShowingOverflow && (isExpanded() || mPositioner.showingInTaskbar());
        return mShowingOverflow && isExpanded();
    }

    /**
+3 −109
Original line number Diff line number Diff line
@@ -18,9 +18,6 @@ package com.android.wm.shell.bubbles;

import static android.view.View.LAYOUT_DIRECTION_RTL;

import static java.lang.annotation.RetentionPolicy.SOURCE;

import android.annotation.IntDef;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
@@ -39,8 +36,6 @@ import androidx.annotation.VisibleForTesting;
import com.android.launcher3.icons.IconNormalizer;
import com.android.wm.shell.R;

import java.lang.annotation.Retention;

/**
 * Keeps track of display size, configuration, and specific bubble sizes. One place for all
 * placement and positioning calculations to refer to.
@@ -50,15 +45,6 @@ public class BubblePositioner {
            ? "BubblePositioner"
            : BubbleDebugConfig.TAG_BUBBLES;

    @Retention(SOURCE)
    @IntDef({TASKBAR_POSITION_NONE, TASKBAR_POSITION_RIGHT, TASKBAR_POSITION_LEFT,
            TASKBAR_POSITION_BOTTOM})
    @interface TaskbarPosition {}
    public static final int TASKBAR_POSITION_NONE = -1;
    public static final int TASKBAR_POSITION_RIGHT = 0;
    public static final int TASKBAR_POSITION_LEFT = 1;
    public static final int TASKBAR_POSITION_BOTTOM = 2;

    /** When the bubbles are collapsed in a stack only some of them are shown, this is how many. **/
    public static final int NUM_VISIBLE_WHEN_RESTING = 2;
    /** Indicates a bubble's height should be the maximum available space. **/
@@ -108,15 +94,9 @@ public class BubblePositioner {
    private int mOverflowHeight;
    private int mMinimumFlyoutWidthLargeScreen;

    private PointF mPinLocation;
    private PointF mRestingStackPosition;
    private int[] mPaddings = new int[4];

    private boolean mShowingInTaskbar;
    private @TaskbarPosition int mTaskbarPosition = TASKBAR_POSITION_NONE;
    private int mTaskbarIconSize;
    private int mTaskbarSize;

    public BubblePositioner(Context context, WindowManager windowManager) {
        mContext = context;
        mWindowManager = windowManager;
@@ -153,27 +133,11 @@ public class BubblePositioner {
                    + " insets: " + insets
                    + " isLargeScreen: " + mIsLargeScreen
                    + " isSmallTablet: " + mIsSmallTablet
                    + " bounds: " + bounds
                    + " showingInTaskbar: " + mShowingInTaskbar);
                    + " bounds: " + bounds);
        }
        updateInternal(mRotation, insets, bounds);
    }

    /**
     * Updates position information to account for taskbar state.
     *
     * @param taskbarPosition which position the taskbar is displayed in.
     * @param showingInTaskbar whether the taskbar is being shown.
     */
    public void updateForTaskbar(int iconSize,
            @TaskbarPosition int taskbarPosition, boolean showingInTaskbar, int taskbarSize) {
        mShowingInTaskbar = showingInTaskbar;
        mTaskbarIconSize =  iconSize;
        mTaskbarPosition = taskbarPosition;
        mTaskbarSize = taskbarSize;
        update();
    }

    @VisibleForTesting
    public void updateInternal(int rotation, Insets insets, Rect bounds) {
        mRotation = rotation;
@@ -232,10 +196,6 @@ public class BubblePositioner {
                R.dimen.bubbles_flyout_min_width_large_screen);

        mMaxBubbles = calculateMaxBubbles();

        if (mShowingInTaskbar) {
            adjustForTaskbar();
        }
    }

    /**
@@ -260,30 +220,6 @@ public class BubblePositioner {
        return mDefaultMaxBubbles;
    }

    /**
     * Taskbar insets appear as navigationBar insets, however, unlike navigationBar this should
     * not inset bubbles UI as bubbles floats above the taskbar. This adjust the available space
     * and insets to account for the taskbar.
     */
    // TODO(b/171559950): When the insets are reported correctly we can remove this logic
    private void adjustForTaskbar() {
        // When bar is showing on edges... subtract that inset because we appear on top
        if (mShowingInTaskbar && mTaskbarPosition != TASKBAR_POSITION_BOTTOM) {
            WindowInsets metricInsets = mWindowManager.getCurrentWindowMetrics().getWindowInsets();
            Insets navBarInsets = metricInsets.getInsetsIgnoringVisibility(
                    WindowInsets.Type.navigationBars());
            int newInsetLeft = mInsets.left;
            int newInsetRight = mInsets.right;
            if (mTaskbarPosition == TASKBAR_POSITION_LEFT) {
                mPositionRect.left -= navBarInsets.left;
                newInsetLeft -= navBarInsets.left;
            } else if (mTaskbarPosition == TASKBAR_POSITION_RIGHT) {
                mPositionRect.right += navBarInsets.right;
                newInsetRight -= navBarInsets.right;
            }
            mInsets = Insets.of(newInsetLeft, mInsets.top, newInsetRight, mInsets.bottom);
        }
    }

    /**
     * @return a rect of available screen space accounting for orientation, system bars and cutouts.
@@ -327,14 +263,12 @@ public class BubblePositioner {
     * to the left or right side.
     */
    public boolean showBubblesVertically() {
        return isLandscape() || mShowingInTaskbar || mIsLargeScreen;
        return isLandscape() || mIsLargeScreen;
    }

    /** Size of the bubble. */
    public int getBubbleSize() {
        return (mShowingInTaskbar && mTaskbarIconSize > 0)
                ? mTaskbarIconSize
                : mBubbleSize;
        return mBubbleSize;
    }

    /** The amount of padding at the top of the screen that the bubbles avoid when being placed. */
@@ -699,9 +633,6 @@ public class BubblePositioner {

    /** The position the bubble stack should rest at when collapsed. */
    public PointF getRestingPosition() {
        if (mPinLocation != null) {
            return mPinLocation;
        }
        if (mRestingStackPosition == null) {
            return getDefaultStartPosition();
        }
@@ -713,9 +644,6 @@ public class BubblePositioner {
     * is being shown.
     */
    public PointF getDefaultStartPosition() {
        if (mPinLocation != null) {
            return mPinLocation;
        }
        // Start on the left if we're in LTR, right otherwise.
        final boolean startOnLeft =
                mContext.getResources().getConfiguration().getLayoutDirection()
@@ -730,7 +658,6 @@ public class BubblePositioner {
                        1 /* default starts with 1 bubble */));
    }


    /**
     * Returns the region that the stack position must stay within. This goes slightly off the left
     * and right sides of the screen, below the status bar/cutout and above the navigation bar.
@@ -750,39 +677,6 @@ public class BubblePositioner {
        return allowableRegion;
    }

    /**
     * @return whether the bubble stack is pinned to the taskbar.
     */
    public boolean showingInTaskbar() {
        return mShowingInTaskbar;
    }

    /**
     * @return the taskbar position if set.
     */
    public int getTaskbarPosition() {
        return mTaskbarPosition;
    }

    public int getTaskbarSize() {
        return mTaskbarSize;
    }

    /**
     * In some situations bubbles will be pinned to a specific onscreen location. This sets whether
     * bubbles should be pinned or not.
     */
    public void setUsePinnedLocation(boolean usePinnedLocation) {
        if (usePinnedLocation) {
            mShowingInTaskbar = true;
            mPinLocation = new PointF(mPositionRect.right - mBubbleSize,
                    mPositionRect.bottom - mBubbleSize);
        } else {
            mPinLocation = null;
            mShowingInTaskbar = false;
        }
    }

    /**
     * Navigation bar has an area where system gestures can be started from.
     *
+0 −2
Original line number Diff line number Diff line
@@ -680,8 +680,6 @@ public class BubbleStackView extends FrameLayout

                    // Re-show the expanded view if we hid it.
                    showExpandedViewIfNeeded();
                } else if (mPositioner.showingInTaskbar()) {
                    mStackAnimationController.snapStackBack();
                } else {
                    // Fling the stack to the edge, and save whether or not it's going to end up on
                    // the left side of the screen.
+0 −14
Original line number Diff line number Diff line
@@ -416,24 +416,10 @@ public class StackAnimationController extends
        return destinationRelativeX;
    }

    /**
     * Snaps the stack back to the previous resting position.
     */
    public void snapStackBack() {
        if (mLayout == null) {
            return;
        }
        PointF p = getStackPositionAlongNearestHorizontalEdge();
        springStackAfterFling(p.x, p.y);
    }

    /**
     * Where the stack would be if it were snapped to the nearest horizontal edge (left or right).
     */
    public PointF getStackPositionAlongNearestHorizontalEdge() {
        if (mPositioner.showingInTaskbar()) {
            return mPositioner.getRestingPosition();
        }
        final PointF stackPos = getStackPosition();
        final boolean onLeft = mLayout.isFirstChildXLeftOfCenter(stackPos.x);
        final RectF bounds = mPositioner.getAllowableStackPositionRegion(getBubbleCount());