From b10f2a3d0370d52f7e36c21e5b585cd32121ef36 Mon Sep 17 00:00:00 2001 From: Jagrut Desai Date: Thu, 26 Oct 2023 16:09:44 -0700 Subject: [PATCH] Refactor TaskbarActivityContext#applyDeviceProfile Test: presubmit Bug: 308024141 Flag: LEGACY ENABLE_TASKBAR_PINNING DISABLED Change-Id: Ic0ecc80f9b61910a917b93cbe62139e2c5d0d9d2 --- .../taskbar/TaskbarActivityContext.java | 34 ++++++++----------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java index 6aadd652e2..6ee151b317 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java @@ -129,6 +129,7 @@ import com.android.systemui.unfold.util.ScopedUnfoldTransitionProgressProvider; import java.io.PrintWriter; import java.util.Collections; import java.util.Optional; +import java.util.function.Consumer; /** * The {@link ActivityContext} with which we inflate Taskbar-related Views. This allows UI elements @@ -299,38 +300,31 @@ public class TaskbarActivityContext extends BaseTaskbarContext { * the icon size */ private void applyDeviceProfile(DeviceProfile originDeviceProfile) { - 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; + Consumer overrideProvider = 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; - // Update icon size - deviceProfile.iconSizePx = deviceProfile.taskbarIconSize; - deviceProfile.updateIconSize(1f, getResources()); - }).build(); + // Update icon size + deviceProfile.iconSizePx = deviceProfile.taskbarIconSize; + deviceProfile.updateIconSize(1f, getResources()); + }; + mDeviceProfile = originDeviceProfile.toBuilder(this) + .withDimensionsOverride(overrideProvider).build(); if (DisplayController.isTransientTaskbar(this)) { mTransientTaskbarDeviceProfile = mDeviceProfile; mPersistentTaskbarDeviceProfile = mDeviceProfile .toBuilder(this) - .withDimensionsOverride(deviceProfile -> { - // Update icon size - deviceProfile.iconSizePx = deviceProfile.taskbarIconSize; - deviceProfile.updateIconSize(1f, getResources()); - }) + .withDimensionsOverride(overrideProvider) .setIsTransientTaskbar(false) .build(); } else { mPersistentTaskbarDeviceProfile = mDeviceProfile; mTransientTaskbarDeviceProfile = mDeviceProfile .toBuilder(this) - .withDimensionsOverride(deviceProfile -> { - // Update icon size - deviceProfile.iconSizePx = deviceProfile.taskbarIconSize; - deviceProfile.updateIconSize(1f, getResources()); - }) + .withDimensionsOverride(overrideProvider) .setIsTransientTaskbar(true) .build(); }