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

Commit 39334f40 authored by Jon Miranda's avatar Jon Miranda
Browse files

Allow icons to take up full width in all cases where width > height.

Previously we only let the icons take up the max width if the
device was in vertical bar layout. For tablets this meant
that the icons would be smaller than the actual window crop.

We want the full width in any cases where the profile width
is greater than the height, so created a new method to check for that.

Bug: 203157974
Test: phone/tablet in portrait/landscape
Change-Id: I467f142bac87ec7c3b369c01f8d9c96ddf74fc76
parent 3c8277d1
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -336,8 +336,7 @@ abstract class SwipeUpGestureTutorialController extends TutorialController {
                            1f - SHAPE_PROGRESS_DURATION /* shapeProgressStart */,
                            radius, 255,
                            false, /* isOpening */
                            mFakeIconView, mDp,
                            false /* isVerticalBarLayout */);
                            mFakeIconView, mDp);
                    mFakeIconView.setAlpha(1);
                    mFakeTaskView.setAlpha(getWindowAlpha(progress));
                    mFakePreviousTaskView.setAlpha(getWindowAlpha(progress));
+13 −14
Original line number Diff line number Diff line
@@ -147,8 +147,7 @@ public class ClipIconView extends View implements ClipPathView {
     * Update the icon UI to match the provided parameters during an animation frame
     */
    public void update(RectF rect, float progress, float shapeProgressStart, float cornerRadius,
            int fgIconAlpha, boolean isOpening, View container, DeviceProfile dp,
            boolean isVerticalBarLayout) {
            int fgIconAlpha, boolean isOpening, View container, DeviceProfile dp) {
        MarginLayoutParams lp = (MarginLayoutParams) container.getLayoutParams();

        float dX = mIsRtl
@@ -169,7 +168,7 @@ public class ClipIconView extends View implements ClipPathView {
        }

        update(rect, progress, shapeProgressStart, cornerRadius, fgIconAlpha, isOpening, scale,
                minSize, lp, isVerticalBarLayout, dp);
                minSize, lp, dp);

        container.setPivotX(0);
        container.setPivotY(0);
@@ -181,7 +180,7 @@ public class ClipIconView extends View implements ClipPathView {

    private void update(RectF rect, float progress, float shapeProgressStart, float cornerRadius,
            int fgIconAlpha, boolean isOpening, float scale, float minSize,
            MarginLayoutParams parentLp, boolean isVerticalBarLayout, DeviceProfile dp) {
            MarginLayoutParams parentLp, DeviceProfile dp) {
        float dX = mIsRtl
                ? rect.left - (dp.widthPx - parentLp.getMarginStart() - parentLp.width)
                : rect.left - parentLp.getMarginStart();
@@ -193,7 +192,7 @@ public class ClipIconView extends View implements ClipPathView {
        float shapeRevealProgress = boundToRange(mapToRange(max(shapeProgressStart, progress),
                shapeProgressStart, 1f, 0, toMax, LINEAR), 0, 1);

        if (isVerticalBarLayout) {
        if (dp.isLandscape) {
            mOutline.right = (int) (rect.width() / scale);
        } else {
            mOutline.bottom = (int) (rect.height() / scale);
@@ -218,16 +217,16 @@ public class ClipIconView extends View implements ClipPathView {
                mRevealAnimator.setCurrentFraction(shapeRevealProgress);
            }

            float drawableScale = (isVerticalBarLayout ? mOutline.width() : mOutline.height())
            float drawableScale = (dp.isLandscape ? mOutline.width() : mOutline.height())
                    / minSize;
            setBackgroundDrawableBounds(drawableScale, isVerticalBarLayout);
            setBackgroundDrawableBounds(drawableScale, dp.isLandscape);
            if (isOpening) {
                // Center align foreground
                int height = mFinalDrawableBounds.height();
                int width = mFinalDrawableBounds.width();
                int diffY = isVerticalBarLayout ? 0
                int diffY = dp.isLandscape ? 0
                        : (int) (((height * drawableScale) - height) / 2);
                int diffX = isVerticalBarLayout ? (int) (((width * drawableScale) - width) / 2)
                int diffX = dp.isLandscape ? (int) (((width * drawableScale) - width) / 2)
                        : 0;
                sTmpRect.set(mFinalDrawableBounds);
                sTmpRect.offset(diffX, diffY);
@@ -247,11 +246,11 @@ public class ClipIconView extends View implements ClipPathView {
        invalidateOutline();
    }

    private void setBackgroundDrawableBounds(float scale, boolean isVerticalBarLayout) {
    private void setBackgroundDrawableBounds(float scale, boolean isLandscape) {
        sTmpRect.set(mFinalDrawableBounds);
        Utilities.scaleRectAboutCenter(sTmpRect, scale);
        // Since the drawable is at the top of the view, we need to offset to keep it centered.
        if (isVerticalBarLayout) {
        if (isLandscape) {
            sTmpRect.offsetTo((int) (mFinalDrawableBounds.left * scale), sTmpRect.top);
        } else {
            sTmpRect.offsetTo(sTmpRect.left, (int) (mFinalDrawableBounds.top * scale));
@@ -269,7 +268,7 @@ public class ClipIconView extends View implements ClipPathView {
     * Sets the icon for this view as part of initial setup
     */
    public void setIcon(@Nullable Drawable drawable, int iconOffset, MarginLayoutParams lp,
            boolean isOpening, boolean isVerticalBarLayout, DeviceProfile dp) {
            boolean isOpening, DeviceProfile dp) {
        mIsAdaptiveIcon = drawable instanceof AdaptiveIconDrawable;
        if (mIsAdaptiveIcon) {
            boolean isFolderIcon = drawable instanceof FolderAdaptiveIcon;
@@ -304,7 +303,7 @@ public class ClipIconView extends View implements ClipPathView {
                Utilities.scaleRectAboutCenter(mStartRevealRect, IconShape.getNormalizationScale());
            }

            if (isVerticalBarLayout) {
            if (dp.isLandscape) {
                lp.width = (int) Math.max(lp.width, lp.height * dp.aspectRatio);
            } else {
                lp.height = (int) Math.max(lp.height, lp.width * dp.aspectRatio);
@@ -325,7 +324,7 @@ public class ClipIconView extends View implements ClipPathView {
                bgDrawableStartScale = scale;
                mOutline.set(0, 0, lp.width, lp.height);
            }
            setBackgroundDrawableBounds(bgDrawableStartScale, isVerticalBarLayout);
            setBackgroundDrawableBounds(bgDrawableStartScale, dp.isLandscape);
            mEndRevealRect.set(0, 0, lp.width, lp.height);
            setOutlineProvider(new ViewOutlineProvider() {
                @Override
+5 −6
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import androidx.annotation.UiThread;
import androidx.annotation.WorkerThread;

import com.android.launcher3.BubbleTextView;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.InsettableFrameLayout;
import com.android.launcher3.Launcher;
import com.android.launcher3.R;
@@ -82,7 +83,6 @@ public class FloatingIconView extends FrameLayout implements
    private final Launcher mLauncher;
    private final boolean mIsRtl;

    private boolean mIsVerticalBarLayout = false;
    private boolean mIsOpening;

    private IconLoadResult mIconLoadResult;
@@ -150,7 +150,7 @@ public class FloatingIconView extends FrameLayout implements
            float shapeProgressStart, float cornerRadius, boolean isOpening) {
        setAlpha(alpha);
        mClipIconView.update(rect, progress, shapeProgressStart, cornerRadius, fgIconAlpha,
                isOpening, this, mLauncher.getDeviceProfile(), mIsVerticalBarLayout);
                isOpening, this, mLauncher.getDeviceProfile());
    }

    @Override
@@ -320,11 +320,11 @@ public class FloatingIconView extends FrameLayout implements
    @UiThread
    private void setIcon(@Nullable Drawable drawable, @Nullable Drawable badge,
            @Nullable Drawable btvIcon, int iconOffset) {
        final DeviceProfile dp = mLauncher.getDeviceProfile();
        final InsettableFrameLayout.LayoutParams lp =
                (InsettableFrameLayout.LayoutParams) getLayoutParams();
        mBadge = badge;
        mClipIconView.setIcon(drawable, iconOffset, lp, mIsOpening, mIsVerticalBarLayout,
                mLauncher.getDeviceProfile());
        mClipIconView.setIcon(drawable, iconOffset, lp, mIsOpening, dp);
        if (drawable instanceof AdaptiveIconDrawable) {
            final int originalHeight = lp.height;
            final int originalWidth = lp.width;
@@ -332,7 +332,7 @@ public class FloatingIconView extends FrameLayout implements
            mFinalDrawableBounds.set(0, 0, originalWidth, originalHeight);

            float aspectRatio = mLauncher.getDeviceProfile().aspectRatio;
            if (mIsVerticalBarLayout) {
            if (dp.isLandscape) {
                lp.width = (int) Math.max(lp.width, lp.height * aspectRatio);
            } else {
                lp.height = (int) Math.max(lp.height, lp.width * aspectRatio);
@@ -565,7 +565,6 @@ public class FloatingIconView extends FrameLayout implements
        view.recycle();

        // Init properties before getting the drawable.
        view.mIsVerticalBarLayout = launcher.getDeviceProfile().isVerticalBarLayout();
        view.mIsOpening = isOpening;
        view.mOriginalIcon = originalView;
        view.mPositionOut = positionOut;