Align taskbar to the left/right in 3 button nav for certain devices.

Otherwise we position the taskbar in the center.

Bug: 259712417
Fixes: 267997547
Test: transient taskbar unaffected
      persistent taskbar
      - test on small tablet
      - test on large tablet
      - test LTR and RTL

Change-Id: Ieb0a304d9963ebf583bc4ef2deaab747019e8d6d
This commit is contained in:
Jon Miranda
2023-03-08 16:42:20 -08:00
parent 90ff89e2b9
commit e17a949950
6 changed files with 93 additions and 10 deletions

View File

@@ -91,6 +91,8 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
private float mTransientTaskbarAllAppsButtonTranslationXOffset;
private final boolean mStartAlignTaskbar;
public TaskbarView(@NonNull Context context) {
this(context, null);
}
@@ -118,6 +120,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;
@@ -343,10 +347,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;
}