diff options
author | 2025-01-14 11:28:00 -0800 | |
---|---|---|
committer | 2025-02-14 09:09:33 -0800 | |
commit | fe5101d8de38ed36c019c474d6f5511743a45d1b (patch) | |
tree | 2f57a4dff02cdf75724026d1d083b0a803b508e3 | |
parent | 17c250e9d593b7c15dc80d26927094ea0ea634b6 (diff) |
Simplifying icon normalization for adaptive icons
Bug: 366237794
Flag: EXEMPT refactor
Test: PResubmit and screenshot tests
Change-Id: Id21e57c9d4ba83983f27aa7988a08db3fd618ce3
7 files changed, 13 insertions, 34 deletions
diff --git a/quickstep/src/com/android/launcher3/uioverrides/PredictedAppIcon.java b/quickstep/src/com/android/launcher3/uioverrides/PredictedAppIcon.java index 37b8dc7bd8..15a27d15c0 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/PredictedAppIcon.java +++ b/quickstep/src/com/android/launcher3/uioverrides/PredictedAppIcon.java @@ -17,6 +17,7 @@ package com.android.launcher3.uioverrides; import static com.android.app.animation.Interpolators.ACCELERATE_DECELERATE; import static com.android.launcher3.icons.FastBitmapDrawable.getDisabledColorFilter; +import static com.android.launcher3.icons.IconNormalizer.ICON_VISIBLE_AREA_FACTOR; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; @@ -53,7 +54,6 @@ import com.android.launcher3.celllayout.CellLayoutLayoutParams; import com.android.launcher3.celllayout.DelegatedCellDrawing; import com.android.launcher3.graphics.ThemeManager; import com.android.launcher3.icons.FastBitmapDrawable; -import com.android.launcher3.icons.IconNormalizer; import com.android.launcher3.icons.LauncherIcons; import com.android.launcher3.model.data.ItemInfoWithIcon; import com.android.launcher3.model.data.WorkspaceItemInfo; @@ -138,7 +138,7 @@ public class PredictedAppIcon extends DoubleShadowBubbleTextView { public PredictedAppIcon(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); mDeviceProfile = ActivityContext.lookupContext(context).getDeviceProfile(); - mNormalizedIconSize = IconNormalizer.getNormalizedCircleSize(getIconSize()); + mNormalizedIconSize = Math.round(getIconSize() * ICON_VISIBLE_AREA_FACTOR); int shadowSize = context.getResources().getDimensionPixelSize( R.dimen.blur_size_thin_outline); mShadowFilter = new BlurMaskFilter(shadowSize, BlurMaskFilter.Blur.OUTER); diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java index 03dd943f50..bd42b2b855 100644 --- a/src/com/android/launcher3/BubbleTextView.java +++ b/src/com/android/launcher3/BubbleTextView.java @@ -27,6 +27,7 @@ import static com.android.launcher3.icons.BitmapInfo.FLAG_NO_BADGE; import static com.android.launcher3.icons.BitmapInfo.FLAG_SKIP_USER_BADGE; import static com.android.launcher3.icons.BitmapInfo.FLAG_THEMED; import static com.android.launcher3.icons.GraphicsUtils.setColorAlphaBound; +import static com.android.launcher3.icons.IconNormalizer.ICON_VISIBLE_AREA_FACTOR; import static com.android.launcher3.model.data.ItemInfoWithIcon.FLAG_INCREMENTAL_DOWNLOAD_ACTIVE; import static com.android.launcher3.model.data.ItemInfoWithIcon.FLAG_INSTALL_SESSION_ACTIVE; import static com.android.launcher3.model.data.ItemInfoWithIcon.FLAG_SHOW_DOWNLOAD_PROGRESS_MASK; @@ -76,7 +77,6 @@ import com.android.launcher3.dragndrop.DragOptions.PreDragCondition; import com.android.launcher3.dragndrop.DraggableView; import com.android.launcher3.folder.FolderIcon; import com.android.launcher3.graphics.PreloadIconDrawable; -import com.android.launcher3.graphics.ShapeDelegate; import com.android.launcher3.icons.DotRenderer; import com.android.launcher3.icons.FastBitmapDrawable; import com.android.launcher3.icons.IconCache.ItemInfoUpdateReceiver; @@ -723,8 +723,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, protected void drawDotIfNecessary(Canvas canvas) { if (!mForceHideDot && (hasDot() || mDotParams.scale > 0)) { getIconBounds(mDotParams.iconBounds); - Utilities.scaleRectAboutCenter(mDotParams.iconBounds, - ShapeDelegate.getNormalizationScale()); + Utilities.scaleRectAboutCenter(mDotParams.iconBounds, ICON_VISIBLE_AREA_FACTOR); final int scrollX = getScrollX(); final int scrollY = getScrollY(); canvas.translate(scrollX, scrollY); @@ -773,9 +772,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, return; } getIconBounds(mRunningAppIconBounds); - Utilities.scaleRectAboutCenter( - mRunningAppIconBounds, - ShapeDelegate.getNormalizationScale()); + Utilities.scaleRectAboutCenter(mRunningAppIconBounds, ICON_VISIBLE_AREA_FACTOR); final boolean isMinimized = mRunningAppState == RunningAppState.MINIMIZED; final int indicatorTop = mRunningAppIconBounds.bottom + mRunningAppIndicatorTopMargin; diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index f34add8d3f..22cc805932 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -54,7 +54,6 @@ import com.android.launcher3.DevicePaddings.DevicePadding; import com.android.launcher3.folder.ClippedFolderIconLayoutRule; import com.android.launcher3.graphics.ThemeManager; import com.android.launcher3.icons.DotRenderer; -import com.android.launcher3.icons.IconNormalizer; import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.responsive.CalculatedCellSpec; import com.android.launcher3.responsive.CalculatedHotseatSpec; @@ -1371,7 +1370,7 @@ public class DeviceProfile { updateHotseatSizes(iconSizePx); // Folder icon - folderIconSizePx = IconNormalizer.getNormalizedCircleSize(iconSizePx); + folderIconSizePx = Math.round(iconSizePx * ICON_VISIBLE_AREA_FACTOR); folderIconOffsetYPx = (iconSizePx - folderIconSizePx) / 2; // Update widget padding: diff --git a/src/com/android/launcher3/dragndrop/DragView.java b/src/com/android/launcher3/dragndrop/DragView.java index bff323ceb3..22797b247c 100644 --- a/src/com/android/launcher3/dragndrop/DragView.java +++ b/src/com/android/launcher3/dragndrop/DragView.java @@ -62,7 +62,7 @@ import com.android.launcher3.R; import com.android.launcher3.Utilities; import com.android.launcher3.graphics.ThemeManager; import com.android.launcher3.icons.FastBitmapDrawable; -import com.android.launcher3.icons.LauncherIcons; +import com.android.launcher3.icons.IconNormalizer; import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.util.RunnableList; import com.android.launcher3.views.ActivityContext; @@ -261,12 +261,7 @@ public abstract class DragView<T extends Context & ActivityContext> extends Fram // be scaled down due to icon normalization. mBadge = fullDrawable.second; FastBitmapDrawable.setBadgeBounds(mBadge, bounds); - - try (LauncherIcons li = LauncherIcons.obtain(mActivity)) { - // Since we just want the scale, avoid heavy drawing operations - Utilities.scaleRectAboutCenter(bounds, li.getNormalizer().getScale( - new AdaptiveIconDrawable(new ColorDrawable(Color.BLACK), null))); - } + Utilities.scaleRectAboutCenter(bounds, IconNormalizer.ICON_VISIBLE_AREA_FACTOR); // Shrink very tiny bit so that the clip path is smaller than the original bitmap // that has anti aliased edges and shadows. @@ -567,7 +562,7 @@ public abstract class DragView<T extends Context & ActivityContext> extends Fram return mContentViewParent; } - /** Return true if {@link mContent} is a {@link AppWidgetHostView}. */ + /** Return true if {@link #mContent} is a {@link AppWidgetHostView}. */ public boolean containsAppWidgetHostView() { return mContent instanceof AppWidgetHostView; } diff --git a/src/com/android/launcher3/graphics/ShapeDelegate.kt b/src/com/android/launcher3/graphics/ShapeDelegate.kt index df0c8f9aa6..9033eac049 100644 --- a/src/com/android/launcher3/graphics/ShapeDelegate.kt +++ b/src/com/android/launcher3/graphics/ShapeDelegate.kt @@ -43,7 +43,6 @@ import androidx.graphics.shapes.toPath import androidx.graphics.shapes.transformed import com.android.launcher3.anim.RoundedRectRevealOutlineProvider import com.android.launcher3.icons.GraphicsUtils -import com.android.launcher3.icons.IconNormalizer.normalizeAdaptiveIcon import com.android.launcher3.views.ClipPathView /** Abstract representation of the shape of an icon shape */ @@ -342,12 +341,5 @@ interface ShapeDelegate { centerY = (bottom - top) / 2, rounding = CornerRounding(cornerR), ) - - @JvmStatic - val normalizationScale = - normalizeAdaptiveIcon( - AdaptiveIconDrawable(null, ColorDrawable(Color.BLACK)), - AREA_CALC_SIZE, - ) } } diff --git a/src/com/android/launcher3/views/ClipIconView.java b/src/com/android/launcher3/views/ClipIconView.java index ddf18dfbaa..3e86c0ccd4 100644 --- a/src/com/android/launcher3/views/ClipIconView.java +++ b/src/com/android/launcher3/views/ClipIconView.java @@ -20,6 +20,7 @@ import static com.android.launcher3.Flags.enableAdditionalHomeAnimations; import static com.android.launcher3.Utilities.boundToRange; import static com.android.launcher3.Utilities.mapToRange; import static com.android.launcher3.anim.AnimatorListeners.forEndCallback; +import static com.android.launcher3.icons.IconNormalizer.ICON_VISIBLE_AREA_FACTOR; import static com.android.launcher3.views.FloatingIconView.SHAPE_PROGRESS_DURATION; import static java.lang.Math.max; @@ -47,7 +48,6 @@ import com.android.launcher3.DeviceProfile; import com.android.launcher3.R; import com.android.launcher3.Utilities; import com.android.launcher3.dragndrop.FolderAdaptiveIcon; -import com.android.launcher3.graphics.ShapeDelegate; import com.android.launcher3.graphics.ThemeManager; /** @@ -259,8 +259,7 @@ public class ClipIconView extends View implements ClipPathView { mStartRevealRect.set(0, 0, originalWidth, originalHeight); if (!isFolderIcon) { - Utilities.scaleRectAboutCenter(mStartRevealRect, - ShapeDelegate.getNormalizationScale()); + Utilities.scaleRectAboutCenter(mStartRevealRect, ICON_VISIBLE_AREA_FACTOR); } if (dp.isLandscape) { diff --git a/src/com/android/launcher3/views/FloatingIconView.java b/src/com/android/launcher3/views/FloatingIconView.java index 22857b1f40..5b3abc383a 100644 --- a/src/com/android/launcher3/views/FloatingIconView.java +++ b/src/com/android/launcher3/views/FloatingIconView.java @@ -55,7 +55,7 @@ import com.android.launcher3.dragndrop.DragLayer; import com.android.launcher3.folder.FolderIcon; import com.android.launcher3.graphics.PreloadIconDrawable; import com.android.launcher3.icons.FastBitmapDrawable; -import com.android.launcher3.icons.LauncherIcons; +import com.android.launcher3.icons.IconNormalizer; import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.model.data.ItemInfoWithIcon; import com.android.launcher3.popup.SystemShortcut; @@ -463,10 +463,7 @@ public class FloatingIconView extends FrameLayout implements Rect bounds = new Rect(0, 0, (int) position.width() + blurSizeOutline, (int) position.height() + blurSizeOutline); bounds.inset(blurSizeOutline / 2, blurSizeOutline / 2); - - try (LauncherIcons li = LauncherIcons.obtain(l)) { - Utilities.scaleRectAboutCenter(bounds, li.getNormalizer().getScale(drawable)); - } + Utilities.scaleRectAboutCenter(bounds, IconNormalizer.ICON_VISIBLE_AREA_FACTOR); bounds.inset( (int) (-bounds.width() * AdaptiveIconDrawable.getExtraInsetFraction()), |