Update notification dot renderer when we update the taskbar icon size.
Test: swipe to home with an app that has a notification dot
observe no jump in dot size
Bug: 264709741
Change-Id: I5d56fe57e74ed7b094477ecd8727152f3f522042
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
index 20e4b55..d5ae276 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
@@ -285,22 +285,20 @@
* the icon size
*/
private void matchDeviceProfile(DeviceProfile originDeviceProfile, Resources resources) {
- mDeviceProfile = originDeviceProfile.copy(this);
- // Taskbar should match the number of icons of hotseat
- mDeviceProfile.numShownHotseatIcons = originDeviceProfile.numShownHotseatIcons;
- // Same QSB width to have a smooth animation
- mDeviceProfile.hotseatQsbWidth = originDeviceProfile.hotseatQsbWidth;
- // Update the size of the icons
- updateIconSize(resources);
- }
+ mDeviceProfile = originDeviceProfile.toBuilder(this)
+ .withDimensionsOverride(deviceProfile -> {
+ // Taskbar should match the number of icons of hotseat
+ deviceProfile.numShownHotseatIcons = originDeviceProfile.numShownHotseatIcons;
+ // Same QSB width to have a smooth animation
+ deviceProfile.hotseatQsbWidth = originDeviceProfile.hotseatQsbWidth;
-
- private void updateIconSize(Resources resources) {
- mDeviceProfile.iconSizePx = resources.getDimensionPixelSize(
- DisplayController.isTransientTaskbar(this)
- ? R.dimen.transient_taskbar_icon_size
- : R.dimen.taskbar_icon_size);
- mDeviceProfile.updateIconSize(1f, resources);
+ // Update icon size
+ deviceProfile.iconSizePx = resources.getDimensionPixelSize(
+ DisplayController.isTransientTaskbar(TaskbarActivityContext.this)
+ ? R.dimen.transient_taskbar_icon_size
+ : R.dimen.taskbar_icon_size);
+ deviceProfile.updateIconSize(1f, resources);
+ }).build();
}
/**
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 9f9c6f9..0cefb7e 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -57,6 +57,7 @@
import java.io.PrintWriter;
import java.util.Locale;
+import java.util.function.Consumer;
@SuppressLint("NewApi")
public class DeviceProfile {
@@ -67,6 +68,7 @@
public static final PointF DEFAULT_SCALE = new PointF(1.0f, 1.0f);
public static final ViewScaleProvider DEFAULT_PROVIDER = itemInfo -> DEFAULT_SCALE;
+ public static final Consumer<DeviceProfile> DEFAULT_DIMENSION_PROVIDER = dp -> {};
// Ratio of empty space, qsb should take up to appear visually centered.
private final float mQsbCenterFactor;
@@ -271,7 +273,8 @@
DeviceProfile(Context context, InvariantDeviceProfile inv, Info info, WindowBounds windowBounds,
SparseArray<DotRenderer> dotRendererCache, boolean isMultiWindowMode,
boolean transposeLayoutWithOrientation, boolean isMultiDisplay, boolean isGestureMode,
- @NonNull final ViewScaleProvider viewScaleProvider) {
+ @NonNull final ViewScaleProvider viewScaleProvider,
+ @NonNull final Consumer<DeviceProfile> dimensionOverrideProvider) {
this.inv = inv;
this.isLandscape = windowBounds.isLandscape();
@@ -571,6 +574,8 @@
mViewScaleProvider = viewScaleProvider;
+ dimensionOverrideProvider.accept(this);
+
// This is done last, after iconSizePx is calculated above.
mDotRendererWorkSpace = createDotRenderer(iconSizePx, dotRendererCache);
mDotRendererAllApps = createDotRenderer(allAppsIconSizePx, dotRendererCache);
@@ -1752,6 +1757,8 @@
private SparseArray<DotRenderer> mDotRendererCache;
+ private Consumer<DeviceProfile> mOverrideProvider;
+
public Builder(Context context, InvariantDeviceProfile inv, Info info) {
mContext = context;
mInv = inv;
@@ -1788,6 +1795,11 @@
return this;
}
+ public Builder withDimensionsOverride(Consumer<DeviceProfile> overrideProvider) {
+ mOverrideProvider = overrideProvider;
+ return this;
+ }
+
/**
* Set the viewScaleProvider for the builder
*
@@ -1817,9 +1829,12 @@
if (mViewScaleProvider == null) {
mViewScaleProvider = DEFAULT_PROVIDER;
}
+ if (mOverrideProvider == null) {
+ mOverrideProvider = DEFAULT_DIMENSION_PROVIDER;
+ }
return new DeviceProfile(mContext, mInv, mInfo, mWindowBounds, mDotRendererCache,
mIsMultiWindowMode, mTransposeLayoutWithOrientation, mIsMultiDisplay,
- mIsGestureMode, mViewScaleProvider);
+ mIsGestureMode, mViewScaleProvider, mOverrideProvider);
}
}
diff --git a/tests/src/com/android/launcher3/DeviceProfileBaseTest.kt b/tests/src/com/android/launcher3/DeviceProfileBaseTest.kt
index b7d0f28..0aecfb2 100644
--- a/tests/src/com/android/launcher3/DeviceProfileBaseTest.kt
+++ b/tests/src/com/android/launcher3/DeviceProfileBaseTest.kt
@@ -20,6 +20,7 @@
import android.graphics.Rect
import android.util.SparseArray
import androidx.test.core.app.ApplicationProvider
+import com.android.launcher3.DeviceProfile.DEFAULT_DIMENSION_PROVIDER
import com.android.launcher3.DeviceProfile.DEFAULT_PROVIDER
import com.android.launcher3.util.DisplayController.Info
import com.android.launcher3.util.WindowBounds
@@ -60,7 +61,8 @@
transposeLayoutWithOrientation,
useTwoPanels,
isGestureMode,
- DEFAULT_PROVIDER
+ DEFAULT_PROVIDER,
+ DEFAULT_DIMENSION_PROVIDER
)
protected fun initializeVarsForPhone(