From f0ec71d325c500796b65730942c6b4f2ff9d493d Mon Sep 17 00:00:00 2001 From: Ajinkya Chalke Date: Thu, 8 May 2025 17:00:22 +0000 Subject: [PATCH] Store startAlignTaskbar in DisplayInfoSpec - CD grids should override startAlignTaskbar. - The DP.toBuilder method should carry forward DisplayInfoSpec instead of always recalculating. Fix: 416276424 Test: m Flag: EXEMPT updating recently added logic Change-Id: I7b1cb8eab5fedc09b29e96a765d1341655474e8a --- .../launcher3/taskbar/TaskbarActivityContext.java | 2 +- src/com/android/launcher3/DeviceProfile.java | 13 +++++++++++-- .../android/launcher3/InvariantDeviceProfile.java | 3 +++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java index 94e090cf01..ea49c035f2 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java @@ -811,7 +811,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext { /** Returns whether taskbar should start align. */ public boolean shouldStartAlignTaskbar() { - return isThreeButtonNav() && mDeviceProfile.startAlignTaskbar && isPrimaryDisplay(); + return isThreeButtonNav() && mDeviceProfile.startAlignTaskbar; } public boolean isGestureNav() { diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index 30c3c46518..848b7962a5 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -96,6 +96,7 @@ public class DeviceProfile { }; public final InvariantDeviceProfile inv; + private final DisplayOptionSpec mDisplayOptionSpec; private final Info mInfo; private final DisplayMetrics mMetrics; private final IconSizeSteps mIconSizeSteps; @@ -324,6 +325,7 @@ public class DeviceProfile { @VisibleForTesting public DeviceProfile() { inv = null; + mDisplayOptionSpec = null; mInfo = null; mMetrics = null; mIconSizeSteps = null; @@ -406,6 +408,7 @@ public class DeviceProfile { windowY = windowBounds.bounds.top; this.rotationHint = windowBounds.rotationHint; mInsets.set(windowBounds.insets); + this.mDisplayOptionSpec = displayOptionSpec; // TODO(b/241386436): shouldn't change any launcher behaviour mIsResponsiveGrid = inv.workspaceSpecsId != INVALID_RESOURCE_HANDLE @@ -472,7 +475,7 @@ public class DeviceProfile { taskbarHeight = res.getDimensionPixelSize(R.dimen.taskbar_size); stashedTaskbarHeight = res.getDimensionPixelSize(R.dimen.taskbar_stashed_size); taskbarBottomMargin = 0; - startAlignTaskbar = inv.startAlignTaskbar[mTypeIndex]; + startAlignTaskbar = displayOptionSpec.startAlignTaskbar; } edgeMarginPx = res.getDimensionPixelSize(R.dimen.dynamic_grid_edge_margin); @@ -1072,7 +1075,8 @@ public class DeviceProfile { .setIsMultiDisplay(isMultiDisplay) .setMultiWindowMode(isMultiWindowMode) .setDotRendererCache(dotRendererCache) - .setGestureMode(isGestureMode); + .setGestureMode(isGestureMode) + .setDisplayOptionSpec(mDisplayOptionSpec); } public DeviceProfile copy(Context context) { @@ -2575,6 +2579,11 @@ public class DeviceProfile { return this; } + private Builder setDisplayOptionSpec(DisplayOptionSpec displayOptionSpec) { + mDisplayOptionSpec = displayOptionSpec; + return this; + } + public DeviceProfile build() { if (mWindowBounds == null) { throw new IllegalArgumentException("Window bounds not set"); diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java index ff8f1989ff..eaaa7fc137 100644 --- a/src/com/android/launcher3/InvariantDeviceProfile.java +++ b/src/com/android/launcher3/InvariantDeviceProfile.java @@ -957,6 +957,7 @@ public class InvariantDeviceProfile { @XmlRes public final int allAppsSpecsId; @XmlRes public final int folderSpecsId; @XmlRes public final int allAppsCellSpecsId; + public final boolean startAlignTaskbar; DisplayOptionSpec(DisplayOption displayOption, boolean isLandscape) { typeIndex = isLandscape ? INDEX_LANDSCAPE : INDEX_DEFAULT; @@ -968,6 +969,7 @@ public class InvariantDeviceProfile { allAppsSpecsId = displayOption.grid.mAllAppsSpecsId; folderSpecsId = displayOption.grid.mFolderSpecsId; allAppsCellSpecsId = displayOption.grid.mAllAppsCellSpecsId; + startAlignTaskbar = displayOption.startAlignTaskbar[typeIndex]; } DisplayOptionSpec(InvariantDeviceProfile inv, boolean isTwoPanels, boolean isLandscape) { @@ -995,6 +997,7 @@ public class InvariantDeviceProfile { folderSpecsId = isTwoPanels ? inv.folderSpecsTwoPanelId : inv.folderSpecsId; allAppsCellSpecsId = isTwoPanels ? inv.allAppsCellSpecsTwoPanelId : inv.allAppsCellSpecsId; + startAlignTaskbar = inv.startAlignTaskbar[typeIndex]; } }