diff --git a/quickstep/res/values-sw600dp/config.xml b/quickstep/res/values-sw600dp/config.xml deleted file mode 100644 index e1e442f0a9..0000000000 --- a/quickstep/res/values-sw600dp/config.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - true - \ No newline at end of file diff --git a/quickstep/res/values-sw720dp-land/config.xml b/quickstep/res/values-sw720dp-land/config.xml deleted file mode 100644 index bf0f9adea8..0000000000 --- a/quickstep/res/values-sw720dp-land/config.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - false - \ No newline at end of file diff --git a/quickstep/res/values-sw720dp/config.xml b/quickstep/res/values-sw720dp/config.xml deleted file mode 100644 index e1e442f0a9..0000000000 --- a/quickstep/res/values-sw720dp/config.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - true - \ No newline at end of file diff --git a/quickstep/res/values/config.xml b/quickstep/res/values/config.xml index 0d3aeb3717..e45d9fd095 100644 --- a/quickstep/res/values/config.xml +++ b/quickstep/res/values/config.xml @@ -52,10 +52,6 @@ - - - false - 44 diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java index 87df5b0c76..a3e681403a 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java @@ -57,7 +57,8 @@ import java.util.function.Predicate; /** * Hosts the Taskbar content such as Hotseat and Recent Apps. Drawn on top of other apps. */ -public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconParent, Insettable { +public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconParent, Insettable, + DeviceProfile.OnDeviceProfileChangeListener { private static final String TAG = TaskbarView.class.getSimpleName(); private static final Rect sTmpRect = new Rect(); @@ -92,7 +93,7 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar private float mTransientTaskbarAllAppsButtonTranslationXOffset; - private final boolean mShouldTryStartAlign; + private boolean mShouldTryStartAlign; public TaskbarView(@NonNull Context context) { this(context, null); @@ -121,8 +122,8 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar resources.getDimension(isTransientTaskbar ? R.dimen.transient_taskbar_all_apps_button_translation_x_offset : R.dimen.taskbar_all_apps_button_translation_x_offset); - mShouldTryStartAlign = mActivityContext.isThreeButtonNav() - && resources.getBoolean(R.bool.start_align_taskbar); + + onDeviceProfileChanged(mActivityContext.getDeviceProfile()); int actualMargin = resources.getDimensionPixelSize(R.dimen.taskbar_icon_spacing); int actualIconSize = mActivityContext.getDeviceProfile().taskbarIconSize; @@ -161,6 +162,23 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar mQsb = LayoutInflater.from(context).inflate(R.layout.search_container_hotseat, this, false); } + @Override + protected void onAttachedToWindow() { + super.onAttachedToWindow(); + mActivityContext.addOnDeviceProfileChangeListener(this); + } + + @Override + protected void onDetachedFromWindow() { + super.onDetachedFromWindow(); + mActivityContext.removeOnDeviceProfileChangeListener(this); + } + + @Override + public void onDeviceProfileChanged(DeviceProfile dp) { + mShouldTryStartAlign = mActivityContext.isThreeButtonNav() && dp.startAlignTaskbar; + } + @Override public boolean performAccessibilityActionInternal(int action, Bundle arguments) { if (action == AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS) { diff --git a/res/values/attrs.xml b/res/values/attrs.xml index 682153f7e4..417ae6171e 100644 --- a/res/values/attrs.xml +++ b/res/values/attrs.xml @@ -405,6 +405,16 @@ + + + + + + + + + + diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index fcb220ebd8..86c9f1617e 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -267,6 +267,8 @@ public class DeviceProfile { public final int stashedTaskbarHeight; public final int taskbarBottomMargin; public final int taskbarIconSize; + // If true, used to layout taskbar in 3 button navigation mode. + public final boolean startAlignTaskbar; // DragController public int flingToDeleteThresholdVelocity; @@ -338,12 +340,14 @@ public class DeviceProfile { res.getDimensionPixelSize(R.dimen.transient_taskbar_stashed_height); taskbarBottomMargin = res.getDimensionPixelSize(R.dimen.transient_taskbar_bottom_margin); + startAlignTaskbar = false; } else { taskbarIconSize = pxFromDp(ResourcesCompat.getFloat(res, R.dimen.taskbar_icon_size), mMetrics); taskbarHeight = res.getDimensionPixelSize(R.dimen.taskbar_size); stashedTaskbarHeight = res.getDimensionPixelSize(R.dimen.taskbar_stashed_size); taskbarBottomMargin = 0; + startAlignTaskbar = inv.startAlignTaskbar[mTypeIndex]; } edgeMarginPx = res.getDimensionPixelSize(R.dimen.dynamic_grid_edge_margin); diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java index 485b36c174..4c34648280 100644 --- a/src/com/android/launcher3/InvariantDeviceProfile.java +++ b/src/com/android/launcher3/InvariantDeviceProfile.java @@ -149,6 +149,8 @@ public class InvariantDeviceProfile { public float[] transientTaskbarIconSize; + public boolean[] startAlignTaskbar; + /** * Number of icons inside the hotseat area. */ @@ -394,6 +396,8 @@ public class InvariantDeviceProfile { transientTaskbarIconSize = displayOption.transientTaskbarIconSize; + startAlignTaskbar = displayOption.startAlignTaskbar; + // If the partner customization apk contains any grid overrides, apply them // Supported overrides: numRows, numColumns, iconSize applyPartnerDeviceProfileOverrides(context, metrics); @@ -915,6 +919,8 @@ public class InvariantDeviceProfile { private final float[] transientTaskbarIconSize = new float[COUNT_SIZES]; + private final boolean[] startAlignTaskbar = new boolean[COUNT_SIZES]; + DisplayOption(GridOption grid, Context context, AttributeSet attrs) { this.grid = grid; @@ -1147,6 +1153,18 @@ public class InvariantDeviceProfile { R.styleable.ProfileDisplayOption_transientTaskbarIconSizeTwoPanelPortrait, transientTaskbarIconSize[INDEX_DEFAULT]); + startAlignTaskbar[INDEX_DEFAULT] = a.getBoolean( + R.styleable.ProfileDisplayOption_startAlignTaskbar, false); + startAlignTaskbar[INDEX_LANDSCAPE] = a.getBoolean( + R.styleable.ProfileDisplayOption_startAlignTaskbarLandscape, + startAlignTaskbar[INDEX_DEFAULT]); + startAlignTaskbar[INDEX_TWO_PANEL_LANDSCAPE] = a.getBoolean( + R.styleable.ProfileDisplayOption_startAlignTaskbarTwoPanelLandscape, + startAlignTaskbar[INDEX_LANDSCAPE]); + startAlignTaskbar[INDEX_TWO_PANEL_PORTRAIT] = a.getBoolean( + R.styleable.ProfileDisplayOption_startAlignTaskbarTwoPanelPortrait, + startAlignTaskbar[INDEX_DEFAULT]); + a.recycle(); } @@ -1169,6 +1187,7 @@ public class InvariantDeviceProfile { allAppsIconTextSizes[i] = 0; allAppsBorderSpaces[i] = new PointF(); transientTaskbarIconSize[i] = 0; + startAlignTaskbar[i] = false; } } @@ -1213,6 +1232,7 @@ public class InvariantDeviceProfile { allAppsBorderSpaces[i].x += p.allAppsBorderSpaces[i].x; allAppsBorderSpaces[i].y += p.allAppsBorderSpaces[i].y; transientTaskbarIconSize[i] += p.transientTaskbarIconSize[i]; + startAlignTaskbar[i] |= p.startAlignTaskbar[i]; } return this; diff --git a/tests/src/com/android/launcher3/FakeInvariantDeviceProfileTest.kt b/tests/src/com/android/launcher3/FakeInvariantDeviceProfileTest.kt index a5f33c0338..c22cf40de6 100644 --- a/tests/src/com/android/launcher3/FakeInvariantDeviceProfileTest.kt +++ b/tests/src/com/android/launcher3/FakeInvariantDeviceProfileTest.kt @@ -153,6 +153,9 @@ abstract class FakeInvariantDeviceProfileTest { isScalable = true + transientTaskbarIconSize = FloatArray(4) { 44f } + startAlignTaskbar = BooleanArray(4) { false } + inlineQsb = BooleanArray(4) { false } devicePaddingId = R.xml.paddings_handhelds @@ -233,6 +236,9 @@ abstract class FakeInvariantDeviceProfileTest { isScalable = true devicePaddingId = R.xml.paddings_6x5 + transientTaskbarIconSize = FloatArray(4) { 44f } + startAlignTaskbar = booleanArrayOf(true, false, true, true) + inlineQsb = booleanArrayOf(false, true, false, false) devicePaddingId = R.xml.paddings_handhelds @@ -308,6 +314,9 @@ abstract class FakeInvariantDeviceProfileTest { isScalable = true + transientTaskbarIconSize = FloatArray(4) { 44f } + startAlignTaskbar = BooleanArray(4) { true } + inlineQsb = booleanArrayOf(false, false, false, false) devicePaddingId = R.xml.paddings_handhelds