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

Commit ac9df38e authored by Alex Chau's avatar Alex Chau
Browse files

Make icon drawable for non-focused grid tasks smaller

- Center the icon drawable in center of IconView with and allow a smlaler size to be set

Bug: 194194694
Test: dismiss focus task, swipe from app etc.
Change-Id: I2855249b13e2ccdb45f101bfb7afef4311f7b46f
parent 4b878f53
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

<resources>
    <dimen name="task_thumbnail_icon_size">48dp</dimen>
    <dimen name="task_thumbnail_icon_drawable_size">48dp</dimen>
    <dimen name="task_thumbnail_icon_drawable_size_grid">32dp</dimen>
    <!-- For screens without rounded corners -->
    <dimen name="task_corner_radius_small">2dp</dimen>
    <!-- For Launchers that want to override the default dialog corner radius -->
+23 −2
Original line number Diff line number Diff line
@@ -17,8 +17,10 @@ package com.android.quickstep.views;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;

import com.android.launcher3.Utilities;
@@ -30,6 +32,7 @@ import com.android.launcher3.Utilities;
public class IconView extends View {

    private Drawable mDrawable;
    private int mDrawableWidth, mDrawableHeight;

    public IconView(Context context) {
        super(context);
@@ -50,11 +53,29 @@ public class IconView extends View {
        mDrawable = d;
        if (mDrawable != null) {
            mDrawable.setCallback(this);
            mDrawable.setBounds(0, 0, getWidth(), getHeight());
            setDrawableSizeInternal(getWidth(), getHeight());
        }
        invalidate();
    }

    /**
     * Sets the size of the icon drawable.
     */
    public void setDrawableSize(int iconWidth, int iconHeight) {
        mDrawableWidth = iconWidth;
        mDrawableHeight = iconHeight;
        if (mDrawable != null) {
            setDrawableSizeInternal(getWidth(), getHeight());
        }
    }

    private void setDrawableSizeInternal(int selfWidth, int selfHeight) {
        Rect selfRect = new Rect(0, 0, selfWidth, selfHeight);
        Rect drawableRect = new Rect();
        Gravity.apply(Gravity.CENTER, mDrawableWidth, mDrawableHeight, selfRect, drawableRect);
        mDrawable.setBounds(drawableRect);
    }

    public Drawable getDrawable() {
        return mDrawable;
    }
@@ -63,7 +84,7 @@ public class IconView extends View {
    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        super.onSizeChanged(w, h, oldw, oldh);
        if (mDrawable != null) {
            mDrawable.setBounds(0, 0, w, h);
            setDrawableSizeInternal(w, h);
        }
    }

+8 −3
Original line number Diff line number Diff line
@@ -1353,9 +1353,10 @@ public class TaskView extends FrameLayout implements Reusable {
        float boxTranslationY;
        int expectedWidth;
        int expectedHeight;
        if (mActivity.getDeviceProfile().overviewShowAsGrid) {
            final int thumbnailPadding =
                    mActivity.getDeviceProfile().overviewTaskThumbnailTopMarginPx;
        int iconDrawableSize;
        DeviceProfile deviceProfile = mActivity.getDeviceProfile();
        if (deviceProfile.overviewShowAsGrid) {
            final int thumbnailPadding = deviceProfile.overviewTaskThumbnailTopMarginPx;
            final Rect lastComputedTaskSize = getRecentsView().getLastComputedTaskSize();
            final int taskWidth = lastComputedTaskSize.width();
            final int taskHeight = lastComputedTaskSize.height();
@@ -1368,11 +1369,13 @@ public class TaskView extends FrameLayout implements Reusable {
                // that is associated with the original orientation of the focused task.
                boxWidth = taskWidth;
                boxHeight = taskHeight;
                iconDrawableSize = deviceProfile.overviewTaskIconDrawableSizePx;
            } else {
                // Otherwise task is in grid, and should use lastComputedGridTaskSize.
                Rect lastComputedGridTaskSize = getRecentsView().getLastComputedGridTaskSize();
                boxWidth = lastComputedGridTaskSize.width();
                boxHeight = lastComputedGridTaskSize.height();
                iconDrawableSize = deviceProfile.overviewTaskIconDrawableSizeGridPx;
            }

            // Bound width/height to the box size.
@@ -1389,6 +1392,7 @@ public class TaskView extends FrameLayout implements Reusable {
            boxTranslationY = 0f;
            expectedWidth = ViewGroup.LayoutParams.MATCH_PARENT;
            expectedHeight = ViewGroup.LayoutParams.MATCH_PARENT;
            iconDrawableSize = deviceProfile.overviewTaskIconDrawableSizePx;
        }

        setNonGridScale(nonGridScale);
@@ -1398,6 +1402,7 @@ public class TaskView extends FrameLayout implements Reusable {
            params.height = expectedHeight;
            setLayoutParams(params);
        }
        mIconView.setDrawableSize(iconDrawableSize, iconDrawableSize);
    }

    private float getGridTrans(float endTranslation) {
+2 −1
Original line number Diff line number Diff line
@@ -324,7 +324,8 @@

<!-- Overview placeholder to compile in Launcer3 without Quickstep -->
    <dimen name="task_thumbnail_icon_size">0dp</dimen>
    <dimen name="task_thumbnail_icon_size_grid">0dp</dimen>
    <dimen name="task_thumbnail_icon_drawable_size">0dp</dimen>
    <dimen name="task_thumbnail_icon_drawable_size_grid">0dp</dimen>
    <dimen name="overview_task_margin">0dp</dimen>
    <dimen name="overview_task_margin_grid">0dp</dimen>
    <dimen name="overview_actions_margin_gesture">0dp</dimen>
+6 −0
Original line number Diff line number Diff line
@@ -184,6 +184,8 @@ public class DeviceProfile {
    public final boolean overviewShowAsGrid;
    public int overviewTaskMarginPx;
    public int overviewTaskIconSizePx;
    public int overviewTaskIconDrawableSizePx;
    public int overviewTaskIconDrawableSizeGridPx;
    public int overviewTaskThumbnailTopMarginPx;
    public final int overviewActionsMarginThreeButtonPx;
    public final int overviewActionsTopMarginGesturePx;
@@ -362,6 +364,10 @@ public class DeviceProfile {
                ? res.getDimensionPixelSize(R.dimen.overview_task_margin_grid)
                : res.getDimensionPixelSize(R.dimen.overview_task_margin);
        overviewTaskIconSizePx = res.getDimensionPixelSize(R.dimen.task_thumbnail_icon_size);
        overviewTaskIconDrawableSizePx =
                res.getDimensionPixelSize(R.dimen.task_thumbnail_icon_drawable_size);
        overviewTaskIconDrawableSizeGridPx =
                res.getDimensionPixelSize(R.dimen.task_thumbnail_icon_drawable_size_grid);
        overviewTaskThumbnailTopMarginPx = overviewTaskIconSizePx + overviewTaskMarginPx * 2;
        if (overviewShowAsGrid) {
            if (isLandscape) {