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

Commit 8b8e90b2 authored by mattsziklay's avatar mattsziklay
Browse files

Use BaseIconFactory to create app icon bitmap.

Introduces BaseIconFactory to caption to create a bitmap to use
for caption's app icon, compressing it more smoothly.

Change of 24 -> 28 dp for the icon ImageView is to compensate for the
mild shrinkage caused by BaseIconFactory.

Before: https://screenshot.googleplex.com/moyzAhDnMiAJuE8.png
After: https://screenshot.googleplex.com/3SA4a6Cj3wrfFoo.png
Bug: 296921992
Test: Manual
Change-Id: Ia5579338e3f9b2142445c56c391cfc216b03ffc5
parent ffdc8374
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -35,8 +35,8 @@

        <ImageView
            android:id="@+id/application_icon"
            android:layout_width="24dp"
            android:layout_height="24dp"
            android:layout_width="@dimen/desktop_mode_caption_icon_radius"
            android:layout_height="@dimen/desktop_mode_caption_icon_radius"
            android:layout_gravity="center_vertical"
            android:contentDescription="@string/app_icon_text" />

+4 −4
Original line number Diff line number Diff line
@@ -34,10 +34,10 @@

        <ImageView
            android:id="@+id/application_icon"
            android:layout_width="24dp"
            android:layout_height="24dp"
            android:layout_marginStart="14dp"
            android:layout_marginEnd="14dp"
            android:layout_width="@dimen/desktop_mode_caption_icon_radius"
            android:layout_height="@dimen/desktop_mode_caption_icon_radius"
            android:layout_marginStart="12dp"
            android:layout_marginEnd="12dp"
            android:contentDescription="@string/app_icon_text"/>

        <TextView
+3 −0
Original line number Diff line number Diff line
@@ -454,6 +454,9 @@
    <!-- The radius of the caption menu corners. -->
    <dimen name="desktop_mode_handle_menu_corner_radius">26dp</dimen>

    <!-- The radius of the caption menu icon. -->
    <dimen name="desktop_mode_caption_icon_radius">28dp</dimen>

    <!-- The radius of the caption menu shadow. -->
    <dimen name="desktop_mode_handle_menu_shadow_radius">2dp</dimen>

+17 −7
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.app.WindowConfiguration.windowingModeToString;

import static com.android.launcher3.icons.BaseIconFactory.MODE_DEFAULT;

import android.app.ActivityManager;
import android.app.WindowConfiguration.WindowingMode;
import android.content.Context;
@@ -27,6 +29,7 @@ import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Point;
import android.graphics.PointF;
import android.graphics.Rect;
@@ -44,6 +47,7 @@ import android.widget.ImageButton;
import android.window.WindowContainerTransaction;

import com.android.internal.policy.ScreenDecorationsUtils;
import com.android.launcher3.icons.BaseIconFactory;
import com.android.launcher3.icons.IconProvider;
import com.android.wm.shell.R;
import com.android.wm.shell.RootTaskDisplayAreaOrganizer;
@@ -93,7 +97,8 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin

    private ResizeVeil mResizeVeil;

    private Drawable mAppIcon;
    private Drawable mAppIconDrawable;
    private Bitmap mAppIconBitmap;
    private CharSequence mAppName;

    private ExclusionRegionListener mExclusionRegionListener;
@@ -255,7 +260,7 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
                        mOnCaptionButtonClickListener,
                        mOnCaptionLongClickListener,
                        mAppName,
                        mAppIcon
                        mAppIconBitmap
                );
            } else {
                throw new IllegalArgumentException("Unexpected layout resource id");
@@ -362,10 +367,15 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
        String packageName = mTaskInfo.realActivity.getPackageName();
        PackageManager pm = mContext.getApplicationContext().getPackageManager();
        try {
            IconProvider provider = new IconProvider(mContext);
            mAppIcon = provider.getIcon(pm.getActivityInfo(mTaskInfo.baseActivity,
            final IconProvider provider = new IconProvider(mContext);
            mAppIconDrawable = provider.getIcon(pm.getActivityInfo(mTaskInfo.baseActivity,
                    PackageManager.ComponentInfoFlags.of(0)));
            ApplicationInfo applicationInfo = pm.getApplicationInfo(packageName,
            final Resources resources = mContext.getResources();
            final BaseIconFactory factory = new BaseIconFactory(mContext,
                    resources.getDisplayMetrics().densityDpi,
                    resources.getDimensionPixelSize(R.dimen.desktop_mode_caption_icon_radius));
            mAppIconBitmap = factory.createScaledBitmap(mAppIconDrawable, MODE_DEFAULT);
            final ApplicationInfo applicationInfo = pm.getApplicationInfo(packageName,
                    PackageManager.ApplicationInfoFlags.of(0));
            mAppName = pm.getApplicationLabel(applicationInfo);
        } catch (PackageManager.NameNotFoundException e) {
@@ -386,7 +396,7 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
     * until a resize event calls showResizeVeil below.
     */
    void createResizeVeil() {
        mResizeVeil = new ResizeVeil(mContext, mAppIcon, mTaskInfo,
        mResizeVeil = new ResizeVeil(mContext, mAppIconDrawable, mTaskInfo,
                mSurfaceControlBuilderSupplier, mDisplay, mSurfaceControlTransactionSupplier);
    }

@@ -459,7 +469,7 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
     */
    void createHandleMenu() {
        mHandleMenu = new HandleMenu.Builder(this)
                .setAppIcon(mAppIcon)
                .setAppIcon(mAppIconBitmap)
                .setAppName(mAppName)
                .setOnClickListener(mOnCaptionButtonClickListener)
                .setOnTouchListener(mOnCaptionTouchListener)
+7 −7
Original line number Diff line number Diff line
@@ -29,9 +29,9 @@ import android.content.res.ColorStateList;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.PointF;
import android.graphics.drawable.Drawable;
import android.view.MotionEvent;
import android.view.SurfaceControl;
import android.view.View;
@@ -58,7 +58,7 @@ class HandleMenu {
    private WindowDecoration.AdditionalWindow mHandleMenuWindow;
    private final PointF mHandleMenuPosition = new PointF();
    private final boolean mShouldShowWindowingPill;
    private final Drawable mAppIcon;
    private final Bitmap mAppIconBitmap;
    private final CharSequence mAppName;
    private final View.OnClickListener mOnClickListener;
    private final View.OnTouchListener mOnTouchListener;
@@ -76,7 +76,7 @@ class HandleMenu {

    HandleMenu(WindowDecoration parentDecor, int layoutResId, int captionX, int captionY,
            View.OnClickListener onClickListener, View.OnTouchListener onTouchListener,
            Drawable appIcon, CharSequence appName, boolean shouldShowWindowingPill,
            Bitmap appIcon, CharSequence appName, boolean shouldShowWindowingPill,
            int captionHeight) {
        mParentDecor = parentDecor;
        mContext = mParentDecor.mDecorWindowContext;
@@ -86,7 +86,7 @@ class HandleMenu {
        mCaptionY = captionY;
        mOnClickListener = onClickListener;
        mOnTouchListener = onTouchListener;
        mAppIcon = appIcon;
        mAppIconBitmap = appIcon;
        mAppName = appName;
        mShouldShowWindowingPill = shouldShowWindowingPill;
        mCaptionHeight = captionHeight;
@@ -150,7 +150,7 @@ class HandleMenu {
        final ImageView appIcon = handleMenu.findViewById(R.id.application_icon);
        final TextView appName = handleMenu.findViewById(R.id.application_name);
        collapseBtn.setOnClickListener(mOnClickListener);
        appIcon.setImageDrawable(mAppIcon);
        appIcon.setImageBitmap(mAppIconBitmap);
        appName.setText(mAppName);
    }

@@ -335,7 +335,7 @@ class HandleMenu {
    static final class Builder {
        private final WindowDecoration mParent;
        private CharSequence mName;
        private Drawable mAppIcon;
        private Bitmap mAppIcon;
        private View.OnClickListener mOnClickListener;
        private View.OnTouchListener mOnTouchListener;
        private int mLayoutId;
@@ -354,7 +354,7 @@ class HandleMenu {
            return this;
        }

        Builder setAppIcon(@Nullable Drawable appIcon) {
        Builder setAppIcon(@Nullable Bitmap appIcon) {
            mAppIcon = appIcon;
            return this;
        }
Loading