diff --git a/quickstep/res/layout/taskbar.xml b/quickstep/res/layout/taskbar.xml index 3b1d217ec5..94388b42ec 100644 --- a/quickstep/res/layout/taskbar.xml +++ b/quickstep/res/layout/taskbar.xml @@ -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"/> diff --git a/quickstep/res/values-land/dimens.xml b/quickstep/res/values-land/dimens.xml index 732f511367..83680696ad 100644 --- a/quickstep/res/values-land/dimens.xml +++ b/quickstep/res/values-land/dimens.xml @@ -74,4 +74,10 @@ 218dp + + + 94.5dp + 94.5dp + 84dp + 79dp \ No newline at end of file diff --git a/quickstep/res/values/dimens.xml b/quickstep/res/values/dimens.xml index fa4eaedc88..0232f8652c 100644 --- a/quickstep/res/values/dimens.xml +++ b/quickstep/res/values/dimens.xml @@ -250,11 +250,11 @@ 48dp 54dp 16dp - 16dp + 16dp 8dp 44dp - 40dp - 42dp + 47dp + 24dp 35dp 24dp 220dp @@ -268,4 +268,12 @@ 48dp 48dp 32dp + + + 24dp + 26dp + 26dp + 47dp + 47dp + 47dp diff --git a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java index 17da0d944b..400a3df517 100644 --- a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java @@ -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"); diff --git a/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletLandscape3ButtonTest.kt b/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletLandscape3ButtonTest.kt index 3f8d2fb13f..d0c9346e5a 100644 --- a/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletLandscape3ButtonTest.kt +++ b/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletLandscape3ButtonTest.kt @@ -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 diff --git a/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletPortrait3ButtonTest.kt b/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletPortrait3ButtonTest.kt index b53b36a9d9..eed359896f 100644 --- a/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletPortrait3ButtonTest.kt +++ b/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletPortrait3ButtonTest.kt @@ -481,6 +481,6 @@ class DeviceProfileTabletPortrait3ButtonTest : DeviceProfileBaseTest() { @Test fun hotseatBarEndOffset() { - assertThat(dp.hotseatBarEndOffset).isEqualTo(428) + assertThat(dp.hotseatBarEndOffset).isEqualTo(502) } } \ No newline at end of file diff --git a/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelLandscape3ButtonTest.kt b/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelLandscape3ButtonTest.kt index 274ca95405..6728540f71 100644 --- a/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelLandscape3ButtonTest.kt +++ b/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelLandscape3ButtonTest.kt @@ -481,6 +481,6 @@ class DeviceProfileTwoPanelLandscape3ButtonTest : DeviceProfileBaseTest() { @Test fun hotseatBarEndOffset() { - assertThat(dp.hotseatBarEndOffset).isEqualTo(428) + assertThat(dp.hotseatBarEndOffset).isEqualTo(566) } } \ No newline at end of file diff --git a/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelPortrait3ButtonTest.kt b/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelPortrait3ButtonTest.kt index 7dd95f99f6..a4b446aea1 100644 --- a/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelPortrait3ButtonTest.kt +++ b/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelPortrait3ButtonTest.kt @@ -461,7 +461,7 @@ class DeviceProfileTwoPanelPortrait3ButtonTest : DeviceProfileBaseTest() { @Test fun getHotseatLayoutPaddingLeft() { - assertThat(dp.getHotseatLayoutPadding(context).left).isEqualTo(340) + assertThat(dp.getHotseatLayoutPadding(context).left).isEqualTo(266) } @Test @@ -471,7 +471,7 @@ class DeviceProfileTwoPanelPortrait3ButtonTest : DeviceProfileBaseTest() { @Test fun getHotseatLayoutPaddingRight() { - assertThat(dp.getHotseatLayoutPadding(context).right).isEqualTo(428) + assertThat(dp.getHotseatLayoutPadding(context).right).isEqualTo(502) } @Test @@ -481,6 +481,6 @@ class DeviceProfileTwoPanelPortrait3ButtonTest : DeviceProfileBaseTest() { @Test fun hotseatBarEndOffset() { - assertThat(dp.hotseatBarEndOffset).isEqualTo(428) + assertThat(dp.hotseatBarEndOffset).isEqualTo(502) } } \ No newline at end of file diff --git a/res/values/attrs.xml b/res/values/attrs.xml index e5b588ccf8..3b7158547c 100644 --- a/res/values/attrs.xml +++ b/res/values/attrs.xml @@ -176,6 +176,10 @@ + + + diff --git a/res/values/dimens.xml b/res/values/dimens.xml index e8e318b7d5..b19e73920b 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -363,6 +363,12 @@ 0dp 0dp 0dp + 0dp + 0dp + 0dp + 0dp + 0dp + 0dp 16dp diff --git a/res/xml/device_profiles.xml b/res/xml/device_profiles.xml index 5ee291b08e..0238e7d972 100644 --- a/res/xml/device_profiles.xml +++ b/res/xml/device_profiles.xml @@ -26,7 +26,7 @@ launcher:numHotseatIcons="3" launcher:dbFile="launcher_3_by_3.db" launcher:defaultLayoutId="@xml/default_workspace_3x3" - launcher:deviceCategory="phone|multi_display" > + launcher:deviceCategory="phone" > @@ -121,6 +122,7 @@ launcher:numFolderColumns="4" launcher:numHotseatIcons="5" launcher:dbFile="launcher.db" + launcher:inlineNavButtonsEndSpacing="@dimen/taskbar_button_margin_5_5" launcher:defaultLayoutId="@xml/default_workspace_5x5" launcher:deviceCategory="phone|multi_display" > @@ -167,6 +169,7 @@ launcher:hotseatColumnSpanLandscape="4" launcher:numAllAppsColumns="6" launcher:isScalable="true" + launcher:inlineNavButtonsEndSpacing="@dimen/taskbar_button_margin_6_5" launcher:devicePaddingId="@xml/paddings_6x5" launcher:dbFile="launcher_6_by_5.db" launcher:defaultLayoutId="@xml/default_workspace_6x5" diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index adf621653f..3a2227afe4 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -413,11 +413,13 @@ public class DeviceProfile { if (areNavButtonsInline) { /* * 3 nav buttons + + * Spacing between nav buttons + * Little space at the end for contextual buttons + * Little space between icons and nav buttons */ hotseatBarEndOffset = 3 * res.getDimensionPixelSize(R.dimen.taskbar_nav_buttons_size) - + res.getDimensionPixelSize(R.dimen.taskbar_contextual_button_margin) + + 2 * res.getDimensionPixelSize(R.dimen.taskbar_button_space_inbetween) + + res.getDimensionPixelSize(inv.inlineNavButtonsEndSpacing) + res.getDimensionPixelSize(R.dimen.taskbar_hotseat_nav_spacing); } else { hotseatBarEndOffset = 0; diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java index 2085b84ac5..c051292512 100644 --- a/src/com/android/launcher3/InvariantDeviceProfile.java +++ b/src/com/android/launcher3/InvariantDeviceProfile.java @@ -127,6 +127,7 @@ public class InvariantDeviceProfile { public PointF[] borderSpaces; public float folderBorderSpace; public float[] hotseatBorderSpaces; + public int inlineNavButtonsEndSpacing; public float[] horizontalMargin; @@ -339,6 +340,8 @@ public class InvariantDeviceProfile { devicePaddingId = closestProfile.devicePaddingId; this.deviceType = deviceType; + inlineNavButtonsEndSpacing = closestProfile.inlineNavButtonsEndSpacing; + mExtraAttrs = closestProfile.extraAttrs; iconSize = displayOption.iconSizes; @@ -735,6 +738,7 @@ public class InvariantDeviceProfile { private final int[] hotseatColumnSpan = new int[COUNT_SIZES]; + private int inlineNavButtonsEndSpacing; private final String dbFile; private final int defaultLayoutId; @@ -785,6 +789,9 @@ public class InvariantDeviceProfile { R.styleable.GridDisplayOption_hotseatColumnSpanTwoPanelPortrait, numColumns); + inlineNavButtonsEndSpacing = + a.getResourceId(R.styleable.GridDisplayOption_inlineNavButtonsEndSpacing, + R.dimen.taskbar_button_margin_default); numFolderRows = a.getInt( R.styleable.GridDisplayOption_numFolderRows, numRows); numFolderColumns = a.getInt( diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/ApiWrapper.java b/src_ui_overrides/com/android/launcher3/uioverrides/ApiWrapper.java index 67157494d8..c8b5e2fa37 100644 --- a/src_ui_overrides/com/android/launcher3/uioverrides/ApiWrapper.java +++ b/src_ui_overrides/com/android/launcher3/uioverrides/ApiWrapper.java @@ -17,7 +17,6 @@ package com.android.launcher3.uioverrides; import android.app.Person; -import android.content.Context; import android.content.pm.ShortcutInfo; import com.android.launcher3.Utilities; @@ -29,11 +28,4 @@ public class ApiWrapper { public static Person[] getPersons(ShortcutInfo si) { return Utilities.EMPTY_PERSON_ARRAY; } - - /** - * Returns the minimum space that should be left empty at the end of hotseat - */ - public static int getHotseatEndOffset(Context context) { - return 0; - } } diff --git a/tests/src/com/android/launcher3/DeviceProfileBaseTest.kt b/tests/src/com/android/launcher3/DeviceProfileBaseTest.kt index 9a76336cd0..7465db5e34 100644 --- a/tests/src/com/android/launcher3/DeviceProfileBaseTest.kt +++ b/tests/src/com/android/launcher3/DeviceProfileBaseTest.kt @@ -135,6 +135,7 @@ abstract class DeviceProfileBaseTest { hotseatBorderSpaces = FloatArray(4) { 16f } hotseatColumnSpan = IntArray(4) { 4 } hotseatBarBottomSpace = FloatArray(4) { 48f } + inlineNavButtonsEndSpacing = R.dimen.taskbar_button_margin_4_4 hotseatQsbSpace = FloatArray(4) { 36f } iconSize = FloatArray(4) { 56f } allAppsIconSize = FloatArray(4) { 56f }