Merge "Align taskbar to the left/right in 3 button nav for certain devices." into tm-qpr-dev

This commit is contained in:
Jon Miranda
2023-03-09 22:33:28 +00:00
committed by Android (Google) Code Review
6 changed files with 93 additions and 10 deletions

View File

@@ -0,0 +1,21 @@
<?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

@@ -0,0 +1,21 @@
<?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

@@ -0,0 +1,21 @@
<?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

@@ -51,4 +51,8 @@
</item>
<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>
</resources>

View File

@@ -94,6 +94,8 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
private float mTransientTaskbarAllAppsButtonTranslationXOffset;
private final boolean mStartAlignTaskbar;
public TaskbarView(@NonNull Context context) {
this(context, null);
}
@@ -121,6 +123,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);
mStartAlignTaskbar = mActivityContext.isThreeButtonNav()
&& resources.getBoolean(R.bool.start_align_taskbar);
int actualMargin = resources.getDimensionPixelSize(R.dimen.taskbar_icon_spacing);
int actualIconSize = mActivityContext.getDeviceProfile().iconSizePx;
@@ -372,10 +376,22 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
boolean needMoreSpaceForNav = layoutRtl ?
navSpaceNeeded > (iconEnd - spaceNeeded) :
iconEnd > (right - navSpaceNeeded);
if (needMoreSpaceForNav) {
int offset = layoutRtl ?
navSpaceNeeded - (iconEnd - spaceNeeded) :
(right - navSpaceNeeded) - iconEnd;
if (mStartAlignTaskbar) {
// Taskbar is aligned to the start
int startSpacingPx = deviceProfile.inlineNavButtonsEndSpacingPx;
if (layoutRtl) {
iconEnd = right - startSpacingPx;
} else {
iconEnd = startSpacingPx + spaceNeeded;
}
} else if (needMoreSpaceForNav) {
// Add offset to account for nav bar when taskbar is centered
int offset = layoutRtl
? navSpaceNeeded - (iconEnd - spaceNeeded)
: (right - navSpaceNeeded) - iconEnd;
iconEnd += offset;
}

View File

@@ -193,7 +193,7 @@ public class DeviceProfile {
private final int mMinHotseatIconSpacePx;
private final int mMinHotseatQsbWidthPx;
private final int mMaxHotseatIconSpacePx;
private final int mInlineNavButtonsEndSpacingPx;
public final int inlineNavButtonsEndSpacingPx;
// Bottom sheets
public int bottomSheetTopPadding;
@@ -490,7 +490,7 @@ public class DeviceProfile {
hotseatBarSidePaddingStartPx = isVerticalBarLayout() ? workspacePageIndicatorHeight : 0;
updateHotseatSizes(pxFromDp(inv.iconSize[INDEX_DEFAULT], mMetrics));
if (areNavButtonsInline && !isPhone) {
mInlineNavButtonsEndSpacingPx =
inlineNavButtonsEndSpacingPx =
res.getDimensionPixelSize(inv.inlineNavButtonsEndSpacing);
/*
* 3 nav buttons +
@@ -499,9 +499,9 @@ public class DeviceProfile {
*/
hotseatBarEndOffset = 3 * res.getDimensionPixelSize(R.dimen.taskbar_nav_buttons_size)
+ 2 * res.getDimensionPixelSize(R.dimen.taskbar_button_space_inbetween)
+ mInlineNavButtonsEndSpacingPx;
+ inlineNavButtonsEndSpacingPx;
} else {
mInlineNavButtonsEndSpacingPx = 0;
inlineNavButtonsEndSpacingPx = 0;
hotseatBarEndOffset = 0;
}
@@ -662,7 +662,7 @@ public class DeviceProfile {
}
// The side space with inline buttons should be what is defined in InvariantDeviceProfile
int sideSpacePx = mInlineNavButtonsEndSpacingPx;
int sideSpacePx = inlineNavButtonsEndSpacingPx;
int maxHotseatWidthPx = availableWidthPx - sideSpacePx - hotseatBarEndOffset;
int maxHotseatIconsWidthPx = maxHotseatWidthPx - (isQsbInline ? hotseatQsbWidth : 0);
hotseatBorderSpace = calculateHotseatBorderSpace(maxHotseatIconsWidthPx,
@@ -1320,7 +1320,7 @@ public class DeviceProfile {
int endSpacing;
// Hotseat aligns to the left with nav buttons
if (hotseatBarEndOffset > 0) {
startSpacing = mInlineNavButtonsEndSpacingPx;
startSpacing = inlineNavButtonsEndSpacingPx;
endSpacing = availableWidthPx - hotseatWidth - startSpacing + hotseatBorderSpace;
} else {
startSpacing = (availableWidthPx - hotseatWidth) / 2;