Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e17a9499 authored by Jon Miranda's avatar Jon Miranda
Browse files

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
parent 90ff89e2
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
<?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
+21 −0
Original line number Diff line number Diff line
<?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
+21 −0
Original line number Diff line number Diff line
<?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
+4 −0
Original line number Diff line number Diff line
@@ -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>
+20 −4
Original line number Diff line number Diff line
@@ -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;
        }

Loading