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

Commit 0fe7e089 authored by Jon Miranda's avatar Jon Miranda Committed by Android (Google) Code Review
Browse files

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

parents 4b0a5ed8 e17a9499
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
@@ -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;
        }

Loading