Allow grids to specify if we should start align taskbar in 3 button
nav.
Bug: 259712417
Test: check layout on tablet
check layout on multi_display devices
Change-Id: I282f51e5d76a30e9ad9d8c52d03d4853e965d65a
diff --git a/quickstep/res/values-sw600dp/config.xml b/quickstep/res/values-sw600dp/config.xml
deleted file mode 100644
index e1e442f..0000000
--- a/quickstep/res/values-sw600dp/config.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2023 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<!-- Applies to large tablet screens portrait -->
-<resources>
- <!-- Taskbar -->
- <!-- Align the Taskbar to the start (Left/Right) of the device when 3 button nav is enabled. -->
- <bool name="start_align_taskbar">true</bool>
-</resources>
\ 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 bf0f9ad..0000000
--- a/quickstep/res/values-sw720dp-land/config.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2023 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<!-- Applies to large tablet screens landscape -->
-<resources>
- <!-- Taskbar -->
- <!-- Align the Taskbar to the start (Left/Right) of the device when 3 button nav is enabled. -->
- <bool name="start_align_taskbar">false</bool>
-</resources>
\ 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 e1e442f..0000000
--- a/quickstep/res/values-sw720dp/config.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2023 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<!-- Applies to large tablet screens portrait -->
-<resources>
- <!-- Taskbar -->
- <!-- Align the Taskbar to the start (Left/Right) of the device when 3 button nav is enabled. -->
- <bool name="start_align_taskbar">true</bool>
-</resources>
\ No newline at end of file
diff --git a/quickstep/res/values/config.xml b/quickstep/res/values/config.xml
index 0d3aeb3..e45d9fd 100644
--- a/quickstep/res/values/config.xml
+++ b/quickstep/res/values/config.xml
@@ -52,10 +52,6 @@
<string name="setup_wizard_pkg" translatable="false" />
- <!-- Taskbar -->
- <!-- Align the Taskbar to the start (Left/Right) of the device when 3 button nav is enabled. -->
- <bool name="start_align_taskbar">false</bool>
-
<!-- This is a float because it is converted to dp later in DeviceProfile -->
<item name="taskbar_icon_size" type="dimen" format="float">44</item>
</resources>
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java
index 87df5b0..a3e6814 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java
@@ -57,7 +57,8 @@
/**
* 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 @@
private float mTransientTaskbarAllAppsButtonTranslationXOffset;
- private final boolean mShouldTryStartAlign;
+ private boolean mShouldTryStartAlign;
public TaskbarView(@NonNull Context context) {
this(context, null);
@@ -121,8 +122,8 @@
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;
@@ -162,6 +163,23 @@
}
@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) {
announceForAccessibility(mContext.getString(R.string.taskbar_a11y_shown_title));
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 682153f..417ae61 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -405,6 +405,16 @@
<!-- defaults to iconTextSize, if not specified -->
<attr name="iconTextSizeTwoPanelLandscape" format="float" />
+ <!-- If true, used to layout taskbar in 3 button navigation mode. -->
+ <!-- defaults to false if not specified -->
+ <attr name="startAlignTaskbar" format="boolean" />
+ <!-- defaults to startAlignTaskbar, if not specified -->
+ <attr name="startAlignTaskbarLandscape" format="boolean" />
+ <!-- defaults to startAlignTaskbarLandscape, if not specified -->
+ <attr name="startAlignTaskbarTwoPanelLandscape" format="boolean" />
+ <!-- defaults to startAlignTaskbar, if not specified -->
+ <attr name="startAlignTaskbarTwoPanelPortrait" format="boolean" />
+
<!-- If set, this display option is used to determine the default grid -->
<attr name="canBeDefault" format="boolean" />
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index fcb220e..86c9f16 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -267,6 +267,8 @@
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 @@
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 485b36c..4c34648 100644
--- a/src/com/android/launcher3/InvariantDeviceProfile.java
+++ b/src/com/android/launcher3/InvariantDeviceProfile.java
@@ -149,6 +149,8 @@
public float[] transientTaskbarIconSize;
+ public boolean[] startAlignTaskbar;
+
/**
* Number of icons inside the hotseat area.
*/
@@ -394,6 +396,8 @@
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 @@
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 @@
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 @@
allAppsIconTextSizes[i] = 0;
allAppsBorderSpaces[i] = new PointF();
transientTaskbarIconSize[i] = 0;
+ startAlignTaskbar[i] = false;
}
}
@@ -1213,6 +1232,7 @@
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 a5f33c0..c22cf40 100644
--- a/tests/src/com/android/launcher3/FakeInvariantDeviceProfileTest.kt
+++ b/tests/src/com/android/launcher3/FakeInvariantDeviceProfileTest.kt
@@ -153,6 +153,9 @@
isScalable = true
+ transientTaskbarIconSize = FloatArray(4) { 44f }
+ startAlignTaskbar = BooleanArray(4) { false }
+
inlineQsb = BooleanArray(4) { false }
devicePaddingId = R.xml.paddings_handhelds
@@ -233,6 +236,9 @@
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 @@
isScalable = true
+ transientTaskbarIconSize = FloatArray(4) { 44f }
+ startAlignTaskbar = BooleanArray(4) { true }
+
inlineQsb = booleanArrayOf(false, false, false, false)
devicePaddingId = R.xml.paddings_handhelds