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

Commit 5e6fe328 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Space out 3 button nav on taskbar" into tm-qpr-dev

parents c6fb3821 c7293179
Loading
Loading
Loading
Loading
+2 −7
Original line number Diff line number Diff line
@@ -45,8 +45,8 @@
            android:id="@+id/start_contextual_buttons"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:paddingLeft="@dimen/taskbar_nav_buttons_spacing"
            android:paddingRight="@dimen/taskbar_nav_buttons_spacing"
            android:paddingStart="@dimen/taskbar_contextual_button_padding"
            android:paddingEnd="@dimen/taskbar_contextual_button_padding"
            android:paddingTop="@dimen/taskbar_contextual_padding_top"
            android:gravity="center_vertical"
            android:layout_gravity="start"/>
@@ -56,9 +56,6 @@
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:orientation="horizontal"
            android:paddingLeft="@dimen/taskbar_nav_buttons_spacing"
            android:paddingRight="@dimen/taskbar_nav_buttons_spacing"
            android:layout_marginEnd="@dimen/taskbar_contextual_button_margin"
            android:gravity="center_vertical"
            android:layout_gravity="end"/>

@@ -66,8 +63,6 @@
            android:id="@+id/end_contextual_buttons"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:paddingLeft="@dimen/taskbar_nav_buttons_spacing"
            android:paddingRight="@dimen/taskbar_nav_buttons_spacing"
            android:paddingTop="@dimen/taskbar_contextual_padding_top"
            android:gravity="center_vertical"
            android:layout_gravity="end"/>
+6 −0
Original line number Diff line number Diff line
@@ -74,4 +74,10 @@

    <!-- Gesture Tutorial mock taskbar -->
    <dimen name="gesture_tutorial_taskbar_padding_start_end">218dp</dimen>

    <!--  Taskbar 3 button spacing  -->
    <dimen name="taskbar_button_margin_5_5">94.5dp</dimen>
    <dimen name="taskbar_button_margin_6_5">94.5dp</dimen>
    <dimen name="taskbar_button_margin_4_5">84dp</dimen>
    <dimen name="taskbar_button_margin_4_4">79dp</dimen>
</resources>
 No newline at end of file
+11 −3
Original line number Diff line number Diff line
@@ -250,11 +250,11 @@
    <dimen name="taskbar_icon_touch_size">48dp</dimen>
    <dimen name="taskbar_icon_drag_icon_size">54dp</dimen>
    <dimen name="taskbar_folder_margin">16dp</dimen>
    <dimen name="taskbar_nav_buttons_spacing">16dp</dimen>
    <dimen name="taskbar_contextual_button_padding">16dp</dimen>
    <dimen name="taskbar_contextual_padding_top">8dp</dimen>
    <dimen name="taskbar_nav_buttons_size">44dp</dimen>
    <dimen name="taskbar_contextual_button_margin">40dp</dimen>
    <dimen name="taskbar_hotseat_nav_spacing">42dp</dimen>
    <dimen name="taskbar_contextual_button_margin">47dp</dimen>
    <dimen name="taskbar_hotseat_nav_spacing">24dp</dimen>
    <dimen name="taskbar_contextual_buttons_size">35dp</dimen>
    <dimen name="taskbar_stashed_size">24dp</dimen>
    <dimen name="taskbar_stashed_handle_width">220dp</dimen>
@@ -268,4 +268,12 @@
    <dimen name="taskbar_back_button_left_margin_kids">48dp</dimen>
    <dimen name="taskbar_home_button_left_margin_kids">48dp</dimen>
    <dimen name="taskbar_icon_size_kids">32dp</dimen>

    <!--  Taskbar 3 button spacing  -->
    <dimen name="taskbar_button_space_inbetween">24dp</dimen>
    <dimen name="taskbar_button_margin_5_5">26dp</dimen>
    <dimen name="taskbar_button_margin_6_5">26dp</dimen>
    <dimen name="taskbar_button_margin_4_5">47dp</dimen>
    <dimen name="taskbar_button_margin_4_4">47dp</dimen>
    <dimen name="taskbar_button_margin_default">47dp</dimen>
</resources>
+56 −5
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ import android.annotation.LayoutRes;
import android.content.pm.ActivityInfo.Config;
import android.content.res.ColorStateList;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.Rect;
import android.graphics.Region;
@@ -67,6 +68,7 @@ import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.android.launcher3.DeviceProfile;
import com.android.launcher3.LauncherAnimUtils;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
@@ -94,7 +96,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT

    private final Rect mTempRect = new Rect();

    private static final int FLAG_SWITCHER_SUPPORTED = 1 << 0;
    private static final int FLAG_SWITCHER_SHOWING = 1 << 0;
    private static final int FLAG_IME_VISIBLE = 1 << 1;
    private static final int FLAG_ROTATION_BUTTON_VISIBLE = 1 << 2;
    private static final int FLAG_A11Y_VISIBLE = 1 << 3;
@@ -189,7 +191,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
                    isThreeButtonNav ? mStartContextualContainer : mEndContextualContainer,
                    mControllers.navButtonController, R.id.ime_switcher);
            mPropertyHolders.add(new StatePropertyHolder(imeSwitcherButton,
                    flags -> ((flags & FLAG_SWITCHER_SUPPORTED) != 0)
                    flags -> ((flags & FLAG_SWITCHER_SHOWING) != 0)
                            && ((flags & FLAG_ROTATION_BUTTON_VISIBLE) == 0)));
        }

@@ -228,6 +230,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
        if (alwaysShowButtons) {
            initButtons(mNavButtonContainer, mEndContextualContainer,
                    mControllers.navButtonController);
            updateButtonLayoutSpacing();

            if (isInSetup) {
                // Since setup wizard only has back button enabled, it looks strange to be
@@ -451,7 +454,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT

        // TODO(b/202218289) we're getting IME as not visible on lockscreen from system
        updateStateForFlag(FLAG_IME_VISIBLE, isImeVisible);
        updateStateForFlag(FLAG_SWITCHER_SUPPORTED, isImeSwitcherShowing);
        updateStateForFlag(FLAG_SWITCHER_SHOWING, isImeSwitcherShowing);
        updateStateForFlag(FLAG_A11Y_VISIBLE, a11yVisible);
        updateStateForFlag(FLAG_DISABLE_HOME, isHomeDisabled);
        updateStateForFlag(FLAG_DISABLE_RECENTS, isRecentsDisabled);
@@ -465,6 +468,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
            boolean a11yLongClickable =
                    (sysUiStateFlags & SYSUI_STATE_A11Y_BUTTON_LONG_CLICKABLE) != 0;
            mA11yButton.setLongClickable(a11yLongClickable);
            updateButtonLayoutSpacing();
        }
    }

@@ -479,6 +483,13 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
        }
    }

    /**
     * @return {@code true} if A11y is showing in 3 button nav taskbar
     */
    private boolean isContextualButtonShowing() {
        return mContext.isThreeButtonNav() && (mState & FLAG_A11Y_VISIBLE) != 0;
    }

    /**
     * Should be called when we need to show back button for bouncer
     */
@@ -508,7 +519,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
     * Returns true if IME switcher is visible
     */
    public boolean isImeSwitcherVisible() {
        return (mState & FLAG_SWITCHER_SUPPORTED) != 0;
        return (mState & FLAG_SWITCHER_SHOWING) != 0;
    }

    /**
@@ -662,6 +673,46 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
        if (mFloatingRotationButton != null) {
            mFloatingRotationButton.onConfigurationChanged(configChanges);
        }
        updateButtonLayoutSpacing();
    }

    /** Adds the correct spacing to 3 button nav container. No-op if using gesture nav */
    private void updateButtonLayoutSpacing() {
        if (!mContext.isThreeButtonNav()) {
            return;
        }
        DeviceProfile dp = mContext.getDeviceProfile();
        Resources res = mContext.getResources();

        // Add spacing after the end of the last nav button
        FrameLayout.LayoutParams navButtonParams =
                (FrameLayout.LayoutParams) mNavButtonContainer.getLayoutParams();
        int navMarginEnd = (int) res.getDimension(dp.inv.inlineNavButtonsEndSpacing);
        int contextualWidth = mEndContextualContainer.getWidth();
        // If contextual buttons are showing, we check if the end margin is enough for the
        // contextual button to be showing - if not, move the nav buttons over a smidge
        if (isContextualButtonShowing() && navMarginEnd < contextualWidth) {
            // Additional spacing, eat up half of space between last icon and nav button
            navMarginEnd += res.getDimensionPixelSize(R.dimen.taskbar_hotseat_nav_spacing) / 2;
        }
        navButtonParams.setMarginEnd(navMarginEnd);
        mNavButtonContainer.setLayoutParams(navButtonParams);

        // Add the spaces in between the nav buttons
        int spaceInBetween = res.getDimensionPixelSize(R.dimen.taskbar_button_space_inbetween);
        for (int i = 0; i < mNavButtonContainer.getChildCount(); i++) {
            View navButton = mNavButtonContainer.getChildAt(i);
            LinearLayout.LayoutParams buttonLayoutParams =
                    (LinearLayout.LayoutParams) navButton.getLayoutParams();
            if (i == 0) {
                buttonLayoutParams.setMarginEnd(spaceInBetween / 2);
            } else if (i == mNavButtonContainer.getChildCount() - 1) {
                buttonLayoutParams.setMarginStart(spaceInBetween / 2);
            } else {
                buttonLayoutParams.setMarginStart(spaceInBetween / 2);
                buttonLayoutParams.setMarginEnd(spaceInBetween / 2);
            }
        }
    }

    public void onDestroy() {
@@ -749,7 +800,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT

    private static String getStateString(int flags) {
        StringJoiner str = new StringJoiner("|");
        appendFlag(str, flags, FLAG_SWITCHER_SUPPORTED, "FLAG_SWITCHER_SUPPORTED");
        appendFlag(str, flags, FLAG_SWITCHER_SHOWING, "FLAG_SWITCHER_SHOWING");
        appendFlag(str, flags, FLAG_IME_VISIBLE, "FLAG_IME_VISIBLE");
        appendFlag(str, flags, FLAG_ROTATION_BUTTON_VISIBLE, "FLAG_ROTATION_BUTTON_VISIBLE");
        appendFlag(str, flags, FLAG_A11Y_VISIBLE, "FLAG_A11Y_VISIBLE");
+3 −3
Original line number Diff line number Diff line
@@ -461,7 +461,7 @@ class DeviceProfileTabletLandscape3ButtonTest : DeviceProfileBaseTest() {

    @Test
    fun getHotseatLayoutPaddingLeft() {
        assertThat(dp.getHotseatLayoutPadding(context).left).isEqualTo(1443)
        assertThat(dp.getHotseatLayoutPadding(context).left).isEqualTo(1305)
    }

    @Test
@@ -471,7 +471,7 @@ class DeviceProfileTabletLandscape3ButtonTest : DeviceProfileBaseTest() {

    @Test
    fun getHotseatLayoutPaddingRight() {
        assertThat(dp.getHotseatLayoutPadding(context).right).isEqualTo(428)
        assertThat(dp.getHotseatLayoutPadding(context).right).isEqualTo(566)
    }

    @Test
@@ -481,6 +481,6 @@ class DeviceProfileTabletLandscape3ButtonTest : DeviceProfileBaseTest() {

    @Test
    fun hotseatBarEndOffset() {
        assertThat(dp.hotseatBarEndOffset).isEqualTo(428)
        assertThat(dp.hotseatBarEndOffset).isEqualTo(566)
    }
}
 No newline at end of file
Loading