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

Commit 5cb3bda2 authored by Orhan Uysal's avatar Orhan Uysal
Browse files

Fix blurred app icon on resize veil.

When we create the bitmap for the icon, we specify the size as the same
size as app header icon. Create 2 different bitmaps for resize veil and
the app header icon.

Test: atest DesktopModeWindowDecorationTests
Test: Manually check that resize veil icon is not pixelated
Bug: 339506623
Change-Id: I35283ee0b4156c10b140eedc78d40512b8a37d70
parent c913a319
Loading
Loading
Loading
Loading
+19 −6
Original line number Diff line number Diff line
@@ -110,6 +110,8 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin

    private ResizeVeil mResizeVeil;
    private Bitmap mAppIconBitmap;
    private Bitmap mResizeVeilBitmap;

    private CharSequence mAppName;

    private ExclusionRegionListener mExclusionRegionListener;
@@ -468,11 +470,15 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
            PackageManager pm = mContext.getApplicationContext().getPackageManager();
            final IconProvider provider = new IconProvider(mContext);
            final Drawable appIconDrawable = provider.getIcon(activityInfo);
            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(appIconDrawable, MODE_DEFAULT);
            final BaseIconFactory headerIconFactory = createIconFactory(mContext,
                    R.dimen.desktop_mode_caption_icon_radius);
            mAppIconBitmap = headerIconFactory.createScaledBitmap(appIconDrawable, MODE_DEFAULT);

            final BaseIconFactory resizeVeilIconFactory = createIconFactory(mContext,
                    R.dimen.desktop_mode_resize_veil_icon_size);
            mResizeVeilBitmap = resizeVeilIconFactory
                    .createScaledBitmap(appIconDrawable, MODE_DEFAULT);

            final ApplicationInfo applicationInfo = activityInfo.applicationInfo;
            mAppName = pm.getApplicationLabel(applicationInfo);
        } finally {
@@ -480,6 +486,13 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
        }
    }

    private BaseIconFactory createIconFactory(Context context, int dimensions) {
        final Resources resources = context.getResources();
        final int densityDpi = resources.getDisplayMetrics().densityDpi;
        final int iconSize = resources.getDimensionPixelSize(dimensions);
        return new BaseIconFactory(context, densityDpi, iconSize);
    }

    private void closeDragResizeListener() {
        if (mDragResizeListener == null) {
            return;
@@ -495,7 +508,7 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
    private void createResizeVeilIfNeeded() {
        if (mResizeVeil != null) return;
        loadAppInfoIfNeeded();
        mResizeVeil = new ResizeVeil(mContext, mDisplayController, mAppIconBitmap, mTaskInfo,
        mResizeVeil = new ResizeVeil(mContext, mDisplayController, mResizeVeilBitmap, mTaskInfo,
                mTaskSurface, mSurfaceControlTransactionSupplier);
    }