Merge "Allow grids to specify if we should start align taskbar in 3 button nav." into tm-qpr-dev

This commit is contained in:
TreeHugger Robot
2023-04-05 21:46:40 +00:00
committed by Android (Google) Code Review
9 changed files with 65 additions and 71 deletions

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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) {

View File

@@ -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" />

View File

@@ -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);

View File

@@ -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;

View File

@@ -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