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

Commit 634f6008 authored by Tony Wickham's avatar Tony Wickham Committed by Android (Google) Code Review
Browse files

Merge "Align real hotseat with taskbar hotseat during drag and drop" into sc-dev

parents 239101c5 a29a046d
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -35,13 +35,14 @@ public class TaskbarActivityContext extends ContextWrapper implements ActivityCo
    private final DeviceProfile mDeviceProfile;
    private final LayoutInflater mLayoutInflater;
    private final TaskbarContainerView mTaskbarContainerView;
    private final float mIconScale;

    public TaskbarActivityContext(BaseQuickstepLauncher launcher) {
        super(launcher);
        mDeviceProfile = launcher.getDeviceProfile().copy(this);
        float taskbarIconSize = getResources().getDimension(R.dimen.taskbar_icon_size);
        float iconScale = taskbarIconSize / mDeviceProfile.iconSizePx;
        mDeviceProfile.updateIconSize(iconScale, getResources());
        mIconScale = taskbarIconSize / mDeviceProfile.iconSizePx;
        mDeviceProfile.updateIconSize(mIconScale, getResources());

        mLayoutInflater = LayoutInflater.from(this).cloneInContext(this);

@@ -75,4 +76,11 @@ public class TaskbarActivityContext extends ContextWrapper implements ActivityCo
    public Rect getFolderBoundingBox() {
        return mTaskbarContainerView.getFolderBoundingBox();
    }

    /**
     * @return The ratio of taskbar icon size vs normal workspace/hotseat icon size.
     */
    public float getTaskbarIconScale() {
        return mIconScale;
    }
}
+5 −0
Original line number Diff line number Diff line
@@ -97,7 +97,12 @@ public class TaskbarContainerView extends BaseDragLayer<TaskbarActivityContext>
            // to show a floating view like Folder. Thus, we set the contentInsets to be where
            // mTaskbarView is, since its position never changes and insets rather than overlays.
            int[] loc = mTempLoc;
            float scale = mTaskbarView.getScaleX();
            mTaskbarView.setScaleX(1);
            mTaskbarView.setScaleY(1);
            mTaskbarView.getLocationInWindow(loc);
            mTaskbarView.setScaleX(scale);
            mTaskbarView.setScaleY(scale);
            insetsInfo.contentInsets.left = loc[0];
            insetsInfo.contentInsets.top = loc[1];
            insetsInfo.contentInsets.right = getWidth() - (loc[0] + mTaskbarView.getWidth());
+28 −1
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;

import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.systemui.shared.system.WindowManagerWrapper.ITYPE_BOTTOM_TAPPABLE_ELEMENT;
import static com.android.systemui.shared.system.WindowManagerWrapper.ITYPE_EXTRA_NAVIGATION_BAR;

@@ -27,6 +29,7 @@ import android.app.ActivityOptions;
import android.content.ComponentName;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.graphics.Rect;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
@@ -207,6 +210,8 @@ public class TaskbarController {
        mTaskbarVisibilityController.init();
        mHotseatController.init();
        mRecentsController.init();

        SCALE_PROPERTY.set(mTaskbarView, mLauncher.hasBeenResumed() ? getTaskbarScaleOnHome() : 1f);
    }

    private TaskbarStateHandlerCallbacks createTaskbarStateHandlerCallbacks() {
@@ -285,16 +290,23 @@ public class TaskbarController {
     * @param toState If known, the state we will end up in when reaching Launcher.
     */
    public Animator createAnimToLauncher(@Nullable LauncherState toState, long duration) {
        alignRealHotseatWithTaskbar();

        PendingAnimation anim = new PendingAnimation(duration);
        anim.add(mTaskbarVisibilityController.createAnimToBackgroundAlpha(0, duration));
        if (toState != null) {
            mTaskbarStateHandler.setStateWithAnimation(toState, new StateAnimationConfig(), anim);
        }
        anim.addFloat(mTaskbarView, SCALE_PROPERTY, mTaskbarView.getScaleX(),
                getTaskbarScaleOnHome(), LINEAR);
        return anim.buildAnim();
    }

    private Animator createAnimToApp(long duration) {
        return mTaskbarVisibilityController.createAnimToBackgroundAlpha(1, duration);
        PendingAnimation anim = new PendingAnimation(duration);
        anim.add(mTaskbarVisibilityController.createAnimToBackgroundAlpha(1, duration));
        anim.addFloat(mTaskbarView, SCALE_PROPERTY, mTaskbarView.getScaleX(), 1f, LINEAR);
        return anim.buildAnim();
    }

    /**
@@ -377,6 +389,21 @@ public class TaskbarController {
                && mTaskbarContainerView.getWindowId().equals(v.getWindowId());
    }

    /**
     * Pads the Hotseat to line up exactly with Taskbar's copy of the Hotseat.
     */
    public void alignRealHotseatWithTaskbar() {
        Rect hotseatBounds = new Rect();
        mTaskbarView.getHotseatBoundsAtScale(getTaskbarScaleOnHome()).roundOut(hotseatBounds);
        mLauncher.getHotseat().setPadding(hotseatBounds.left, hotseatBounds.top,
                mTaskbarView.getWidth() - hotseatBounds.right,
                mTaskbarView.getHeight() - hotseatBounds.bottom);
    }

    private float getTaskbarScaleOnHome() {
        return 1f / mTaskbarContainerView.getTaskbarActivityContext().getTaskbarIconScale();
    }

    /**
     * Updates the TaskbarContainer to MATCH_PARENT vs original Taskbar size.
     */
+36 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.launcher3.taskbar;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.RectF;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
@@ -35,6 +36,7 @@ import androidx.annotation.Nullable;
import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.BubbleTextView;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.folder.FolderIcon;
import com.android.launcher3.model.data.FolderInfo;
import com.android.launcher3.model.data.ItemInfo;
@@ -50,10 +52,12 @@ public class TaskbarView extends LinearLayout implements FolderIcon.FolderIconPa
    private final ColorDrawable mBackgroundDrawable;
    private final int mItemMarginLeftRight;
    private final int mIconTouchSize;
    private final boolean mIsRtl;
    private final int mTouchSlop;
    private final RectF mTempDelegateBounds = new RectF();
    private final RectF mDelegateSlopBounds = new RectF();
    private final int[] mTempOutLocation = new int[2];
    private final Matrix mTempMatrix = new Matrix();

    // Initialized in TaskbarController constructor.
    private TaskbarController.TaskbarViewCallbacks mControllerCallbacks;
@@ -94,6 +98,7 @@ public class TaskbarView extends LinearLayout implements FolderIcon.FolderIconPa
        mBackgroundDrawable = (ColorDrawable) getBackground();
        mItemMarginLeftRight = resources.getDimensionPixelSize(R.dimen.taskbar_icon_spacing);
        mIconTouchSize = resources.getDimensionPixelSize(R.dimen.taskbar_icon_touch_size);
        mIsRtl = Utilities.isRtl(resources);
        mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    }

@@ -131,7 +136,8 @@ public class TaskbarView extends LinearLayout implements FolderIcon.FolderIconPa
     */
    protected void updateHotseatItems(ItemInfo[] hotseatItemInfos) {
        for (int i = 0; i < hotseatItemInfos.length; i++) {
            ItemInfo hotseatItemInfo = hotseatItemInfos[i];
            ItemInfo hotseatItemInfo = hotseatItemInfos[!mIsRtl ? i
                    : hotseatItemInfos.length - i - 1];
            int hotseatIndex = mHotseatStartIndex + i;
            View hotseatView = getChildAt(hotseatIndex);

@@ -390,6 +396,35 @@ public class TaskbarView extends LinearLayout implements FolderIcon.FolderIconPa
        return mIsDraggingItem;
    }

    /**
     * @return The bounding box of where the hotseat elements will be when we reach the given scale.
     */
    protected RectF getHotseatBoundsAtScale(float taskbarViewScale) {
        View firstHotseatView = null, lastHotseatView = null;
        for (int i = mHotseatStartIndex; i <= mHotseatEndIndex; i++) {
            View child = getChildAt(i);
            if (child.getVisibility() != GONE) {
                if (firstHotseatView == null) {
                    firstHotseatView = child;
                }
                lastHotseatView = child;
            }
        }
        if (firstHotseatView == null || lastHotseatView == null) {
            return new RectF();
        }
        View leftmostHotseatView = !mIsRtl ? firstHotseatView : lastHotseatView;
        View rightmostHotseatView = !mIsRtl ? lastHotseatView : firstHotseatView;
        RectF hotseatBounds = new RectF(
                leftmostHotseatView.getLeft() - mItemMarginLeftRight,
                leftmostHotseatView.getTop(),
                rightmostHotseatView.getRight() + mItemMarginLeftRight,
                rightmostHotseatView.getBottom());
        mTempMatrix.setScale(taskbarViewScale, taskbarViewScale, getPivotX(), getPivotY());
        mTempMatrix.mapRect(hotseatBounds);
        return hotseatBounds;
    }

    // FolderIconParent implemented methods.

    @Override
+5 −8
Original line number Diff line number Diff line
@@ -228,17 +228,13 @@ public class PredictedAppIcon extends DoubleShadowBubbleTextView {
     */
    public static class PredictedIconOutlineDrawing extends CellLayout.DelegatedCellDrawing {

        private int mOffsetX;
        private int mOffsetY;
        private int mIconRadius;
        private Paint mOutlinePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        private final PredictedAppIcon mIcon;
        private final Paint mOutlinePaint = new Paint(Paint.ANTI_ALIAS_FLAG);

        public PredictedIconOutlineDrawing(int cellX, int cellY, PredictedAppIcon icon) {
            mDelegateCellX = cellX;
            mDelegateCellY = cellY;
            mOffsetX = icon.getOutlineOffsetX();
            mOffsetY = icon.getOutlineOffsetY();
            mIconRadius = icon.mNormalizedIconRadius;
            mIcon = icon;
            mOutlinePaint.setStyle(Paint.Style.FILL);
            mOutlinePaint.setColor(Color.argb(24, 245, 245, 245));
        }
@@ -248,7 +244,8 @@ public class PredictedAppIcon extends DoubleShadowBubbleTextView {
         */
        @Override
        public void drawUnderItem(Canvas canvas) {
            getShape().drawShape(canvas, mOffsetX, mOffsetY, mIconRadius, mOutlinePaint);
            getShape().drawShape(canvas, mIcon.getOutlineOffsetX(), mIcon.getOutlineOffsetY(),
                    mIcon.mNormalizedIconRadius, mOutlinePaint);
        }

        /**
Loading