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

Commit e41dd483 authored by Jon Miranda's avatar Jon Miranda
Browse files

New folder icon style (uncropped icons).

- Switch Circle to PathShape as it allows for more flexibility on
  choosing what gets cropped.
- Remove shadows, and stroke.

Bug: 188095988
Test: manual
Change-Id: I602b3efcd35c2c11dc3461f49099c2f2a56eae59
parent 9450883e
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@
    xmlns:launcher="http://schemas.android.com/apk/res-auto"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/round_rect_folder"
    android:orientation="vertical" >

    <com.android.launcher3.folder.FolderPagedView
+5 −7
Original line number Diff line number Diff line
@@ -5,10 +5,10 @@ public class ClippedFolderIconLayoutRule {
    public static final int MAX_NUM_ITEMS_IN_PREVIEW = 4;
    private static final int MIN_NUM_ITEMS_IN_PREVIEW = 2;

    private static final float MIN_SCALE = 0.48f;
    private static final float MAX_SCALE = 0.58f;
    private static final float MAX_RADIUS_DILATION = 0.15f;
    private static final float ITEM_RADIUS_SCALE_FACTOR = 1.33f;
    private static final float MIN_SCALE = 0.44f;
    private static final float MAX_SCALE = 0.54f;
    private static final float MAX_RADIUS_DILATION = 0.10f;
    private static final float ITEM_RADIUS_SCALE_FACTOR = 1.2f;

    public static final int EXIT_INDEX = -2;
    public static final int ENTER_INDEX = -3;
@@ -130,10 +130,8 @@ public class ClippedFolderIconLayoutRule {
    public float scaleForItem(int numItems) {
        // Scale is determined by the number of items in the preview.
        final float scale;
        if (numItems <= 2) {
        if (numItems <= 3) {
            scale = MAX_SCALE;
        } else if (numItems == 3) {
            scale = (MAX_SCALE + MIN_SCALE) / 2;
        } else {
            scale = MIN_SCALE;
        }
+20 −3
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ import android.graphics.Insets;
import android.graphics.Path;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.os.Build;
import android.text.InputType;
@@ -67,6 +68,7 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.core.content.res.ResourcesCompat;
import androidx.core.graphics.ColorUtils;

import com.android.launcher3.AbstractFloatingView;
@@ -250,6 +252,8 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
    // so that we can cancel it when starting mColorChangeAnimator.
    private ObjectAnimator mOpenAnimationColorChangeAnimator;

    private GradientDrawable mBackground;

    /**
     * Used to inflate the Workspace from XML.
     *
@@ -268,6 +272,12 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
        // name is complete, we have something to focus on, thus hiding the cursor and giving
        // reliable behavior when clicking the text field (since it will always gain focus on click).
        setFocusableInTouchMode(true);

    }

    @Override
    public Drawable getBackground() {
        return mBackground;
    }

    @Override
@@ -276,6 +286,9 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
        final DeviceProfile dp = mActivityContext.getDeviceProfile();
        final int paddingLeftRight = dp.folderContentPaddingLeftRight;

        mBackground = (GradientDrawable) ResourcesCompat.getDrawable(getResources(),
                R.drawable.round_rect_folder, getContext().getTheme());

        mContent = findViewById(R.id.folder_content);
        mContent.setPadding(paddingLeftRight, dp.folderContentPaddingTop, paddingLeftRight, 0);
        mContent.setFolder(this);
@@ -1213,6 +1226,8 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
        lp.x = left;
        lp.y = top;

        mBackground.setBounds(0, 0, width, height);

        if (mColorExtractor != null) {
            mColorExtractor.removeLocations();
            mColorExtractor.setListener(mColorListener);
@@ -1714,14 +1729,16 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
    }

    @Override
    public void draw(Canvas canvas) {
    protected void dispatchDraw(Canvas canvas) {
        if (mClipPath != null) {
            int count = canvas.save();
            canvas.clipPath(mClipPath);
            super.draw(canvas);
            mBackground.draw(canvas);
            canvas.restoreToCount(count);
            super.dispatchDraw(canvas);
        } else {
            super.draw(canvas);
            mBackground.draw(canvas);
            super.dispatchDraw(canvas);
        }
    }

+18 −1
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import android.view.animation.AnimationUtils;

import com.android.launcher3.BubbleTextView;
import com.android.launcher3.CellLayout;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.R;
import com.android.launcher3.ShortcutAndWidgetContainer;
import com.android.launcher3.Utilities;
@@ -80,6 +81,8 @@ public class FolderAnimationManager {

    private ObjectAnimator mBgColorAnimator;

    private DeviceProfile mDeviceProfile;

    public FolderAnimationManager(Folder folder, boolean isOpening) {
        mFolder = folder;
        mContent = folder.mContent;
@@ -89,7 +92,8 @@ public class FolderAnimationManager {
        mPreviewBackground = mFolderIcon.mBackground;

        mContext = folder.getContext();
        mPreviewVerifier = new FolderGridOrganizer(folder.mActivityContext.getDeviceProfile().inv);
        mDeviceProfile = folder.mActivityContext.getDeviceProfile();
        mPreviewVerifier = new FolderGridOrganizer(mDeviceProfile.inv);

        mIsOpening = isOpening;

@@ -211,8 +215,21 @@ public class FolderAnimationManager {
        play(a, getAnimator(mFolder.mContent, SCALE_PROPERTY, initialScale, finalScale));
        play(a, getAnimator(mFolder.mFooter, SCALE_PROPERTY, initialScale, finalScale));
        play(a, mFolderIcon.mFolderName.createTextAlphaAnimator(!mIsOpening));

        // Create reveal animator for the folder background
        play(a, getShape().createRevealAnimator(
                mFolder, startRect, endRect, finalRadius, !mIsOpening));

        // Create reveal animator for the folder content (capture the top 4 icons 2x2)
        int width = mContent.getPaddingLeft() + mDeviceProfile.folderCellLayoutBorderSpacingPx
                + mDeviceProfile.folderCellWidthPx * 2;
        int height = mContent.getPaddingTop() + mDeviceProfile.folderCellLayoutBorderSpacingPx
                + mDeviceProfile.folderCellHeightPx * 2;
        Rect startRect2 = new Rect(0, 0, width, height);
        play(a, getShape().createRevealAnimator(
                mFolder.getContent(), startRect2, endRect, finalRadius, !mIsOpening));


        // Fade in the folder name, as the text can overlap the icons when grid size is small.
        mFolder.mFolderName.setAlpha(mIsOpening ? 0f : 1f);
        play(a, getAnimator(mFolder.mFolderName, View.ALPHA, 0, 1),
+0 −3
Original line number Diff line number Diff line
@@ -614,10 +614,7 @@ public class FolderIcon extends FrameLayout implements FolderListener, IconLabel

        if (mCurrentPreviewItems.isEmpty() && !mAnimating) return;

        final int saveCount = canvas.save();
        canvas.clipPath(mBackground.getClipPath());
        mPreviewItemManager.draw(canvas);
        canvas.restoreToCount(saveCount);

        if (!mBackground.drawingDelegated()) {
            mBackground.drawBackgroundStroke(canvas);
Loading