diff --git a/quickstep/res/values-land/dimens.xml b/quickstep/res/values-land/dimens.xml index 2b17b93e57..e862b9ea6d 100644 --- a/quickstep/res/values-land/dimens.xml +++ b/quickstep/res/values-land/dimens.xml @@ -78,7 +78,8 @@ 88dp 219.6dp - 48dp + 48dp + 48dp 96dp 24dp diff --git a/quickstep/res/values/dimens.xml b/quickstep/res/values/dimens.xml index 33313218a6..89a193b3ea 100644 --- a/quickstep/res/values/dimens.xml +++ b/quickstep/res/values/dimens.xml @@ -325,9 +325,8 @@ 8dp 44dp 48dp - 120dp 48dp - 48dp + 96dp 24dp 35dp 24dp @@ -346,6 +345,11 @@ 32dp 6dp 6dp + 64dp + 64dp + 48dp + 1dp + 72dp 12dp diff --git a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java index 2f11fd7e43..2c5aeb3fd7 100644 --- a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java @@ -142,6 +142,9 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT private static final String NAV_BUTTONS_SEPARATE_WINDOW_TITLE = "Taskbar Nav Buttons"; + private static final double SQUARE_ASPECT_RATIO_BOTTOM_BOUND = 0.95; + private static final double SQUARE_ASPECT_RATIO_UPPER_BOUND = 1.05; + public static final int ALPHA_INDEX_IMMERSIVE_MODE = 0; public static final int ALPHA_INDEX_KEYGUARD_OR_DISABLE = 1; public static final int ALPHA_INDEX_SUW = 2; @@ -735,18 +738,39 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT // end-aligned, so start-align instead. FrameLayout.LayoutParams navButtonsLayoutParams = (FrameLayout.LayoutParams) mNavButtonContainer.getLayoutParams(); + FrameLayout.LayoutParams navButtonsViewLayoutParams = (FrameLayout.LayoutParams) + mNavButtonsView.getLayoutParams(); Resources resources = mContext.getResources(); DeviceProfile deviceProfile = mContext.getDeviceProfile(); - int setupMargin = resources.getDimensionPixelSize(R.dimen.taskbar_contextual_button_margin); - navButtonsLayoutParams.setMarginStart(setupMargin); - navButtonsLayoutParams.bottomMargin = !deviceProfile.isLandscape - ? 0 - : setupMargin - - (resources.getDimensionPixelSize(R.dimen.taskbar_nav_buttons_size) / 2); + navButtonsLayoutParams.setMarginEnd(0); navButtonsLayoutParams.gravity = Gravity.START; - mNavButtonsView.getLayoutParams().height = - mControllers.taskbarActivityContext.getSetupWindowSize(); + mControllers.taskbarActivityContext.setTaskbarWindowSize( + mControllers.taskbarActivityContext.getSetupWindowSize()); + + // If SUW is on a large screen device that is landscape (or has a square aspect + // ratio) the back button has to be placed accordingly + if ((deviceProfile.isTablet && deviceProfile.isLandscape) + || (deviceProfile.aspectRatio > SQUARE_ASPECT_RATIO_BOTTOM_BOUND + && deviceProfile.aspectRatio < SQUARE_ASPECT_RATIO_UPPER_BOUND)) { + navButtonsLayoutParams.setMarginStart( + resources.getDimensionPixelSize(R.dimen.taskbar_back_button_suw_start_margin)); + navButtonsViewLayoutParams.bottomMargin = resources.getDimensionPixelSize( + R.dimen.taskbar_back_button_suw_bottom_margin); + navButtonsLayoutParams.height = resources.getDimensionPixelSize( + R.dimen.taskbar_back_button_suw_height); + } else { + int phoneOrPortraitSetupMargin = resources.getDimensionPixelSize( + R.dimen.taskbar_contextual_button_suw_margin); + navButtonsLayoutParams.setMarginStart(phoneOrPortraitSetupMargin); + navButtonsLayoutParams.bottomMargin = !deviceProfile.isLandscape + ? 0 + : phoneOrPortraitSetupMargin - (resources.getDimensionPixelSize( + R.dimen.taskbar_nav_buttons_size) / 2); + navButtonsViewLayoutParams.height = resources.getDimensionPixelSize( + R.dimen.taskbar_contextual_button_suw_height); + } + mNavButtonsView.setLayoutParams(navButtonsViewLayoutParams); mNavButtonContainer.setLayoutParams(navButtonsLayoutParams); } diff --git a/quickstep/src/com/android/launcher3/taskbar/navbutton/NavButtonLayoutFactory.kt b/quickstep/src/com/android/launcher3/taskbar/navbutton/NavButtonLayoutFactory.kt index 2b60dc0553..5bfdce9e68 100644 --- a/quickstep/src/com/android/launcher3/taskbar/navbutton/NavButtonLayoutFactory.kt +++ b/quickstep/src/com/android/launcher3/taskbar/navbutton/NavButtonLayoutFactory.kt @@ -20,7 +20,6 @@ import android.content.res.Resources import android.view.Surface.ROTATION_90 import android.view.Surface.Rotation import android.view.ViewGroup -import android.widget.FrameLayout import android.widget.ImageView import android.widget.LinearLayout import android.widget.Space @@ -56,18 +55,18 @@ class NavButtonLayoutFactory { * @param isThreeButtonNav are no-ops when taskbar is present/showing */ fun getUiLayoutter( - deviceProfile: DeviceProfile, - navButtonsView: NearestTouchFrame, - imeSwitcher: ImageView?, - rotationButton: RotationButton?, - a11yButton: ImageView?, - space: Space?, - resources: Resources, - isKidsMode: Boolean, - isInSetup: Boolean, - isThreeButtonNav: Boolean, - phoneMode: Boolean, - @Rotation surfaceRotation: Int + deviceProfile: DeviceProfile, + navButtonsView: NearestTouchFrame, + imeSwitcher: ImageView?, + rotationButton: RotationButton?, + a11yButton: ImageView?, + space: Space?, + resources: Resources, + isKidsMode: Boolean, + isInSetup: Boolean, + isThreeButtonNav: Boolean, + phoneMode: Boolean, + @Rotation surfaceRotation: Int ): NavButtonLayoutter { val navButtonContainer = navButtonsView.requireViewById(ID_END_NAV_BUTTONS) @@ -82,43 +81,6 @@ class NavButtonLayoutFactory { if (!deviceProfile.isLandscape) { navButtonsView.setIsVertical(false) PhonePortraitNavLayoutter( - resources, - navButtonContainer, - endContextualContainer, - startContextualContainer, - imeSwitcher, - rotationButton, - a11yButton, - space - ) - } else if (surfaceRotation == ROTATION_90) { - navButtonsView.setIsVertical(true) - PhoneLandscapeNavLayoutter( - resources, - navButtonContainer, - endContextualContainer, - startContextualContainer, - imeSwitcher, - rotationButton, - a11yButton, - space - ) - } else { - navButtonsView.setIsVertical(true) - PhoneSeascapeNavLayoutter( - resources, - navButtonContainer, - endContextualContainer, - startContextualContainer, - imeSwitcher, - rotationButton, - a11yButton, - space - ) - } - } - isPhoneGestureMode ->{ - PhoneGestureLayoutter( resources, navButtonContainer, endContextualContainer, @@ -127,44 +89,82 @@ class NavButtonLayoutFactory { rotationButton, a11yButton, space + ) + } else if (surfaceRotation == ROTATION_90) { + navButtonsView.setIsVertical(true) + PhoneLandscapeNavLayoutter( + resources, + navButtonContainer, + endContextualContainer, + startContextualContainer, + imeSwitcher, + rotationButton, + a11yButton, + space + ) + } else { + navButtonsView.setIsVertical(true) + PhoneSeascapeNavLayoutter( + resources, + navButtonContainer, + endContextualContainer, + startContextualContainer, + imeSwitcher, + rotationButton, + a11yButton, + space + ) + } + } + isPhoneGestureMode -> { + PhoneGestureLayoutter( + resources, + navButtonContainer, + endContextualContainer, + startContextualContainer, + imeSwitcher, + rotationButton, + a11yButton, + space ) } deviceProfile.isTaskbarPresent -> { return when { isInSetup -> { SetupNavLayoutter( - resources, - navButtonContainer, - endContextualContainer, - startContextualContainer, - imeSwitcher, - rotationButton, - a11yButton, - space + resources, + navButtonsView, + navButtonContainer, + endContextualContainer, + startContextualContainer, + imeSwitcher, + rotationButton, + a11yButton, + space ) } isKidsMode -> { KidsNavLayoutter( - resources, - navButtonContainer, - endContextualContainer, - startContextualContainer, - imeSwitcher, - rotationButton, - a11yButton, - space + resources, + navButtonContainer, + endContextualContainer, + startContextualContainer, + imeSwitcher, + rotationButton, + a11yButton, + space ) } else -> TaskbarNavLayoutter( - resources, - navButtonContainer, - endContextualContainer, - startContextualContainer, - imeSwitcher, - rotationButton, - a11yButton, - space + resources, + navButtonContainer, + endContextualContainer, + startContextualContainer, + imeSwitcher, + rotationButton, + a11yButton, + space ) } } diff --git a/quickstep/src/com/android/launcher3/taskbar/navbutton/SetupNavLayoutter.kt b/quickstep/src/com/android/launcher3/taskbar/navbutton/SetupNavLayoutter.kt index 181e0edc8a..8eff95cde8 100644 --- a/quickstep/src/com/android/launcher3/taskbar/navbutton/SetupNavLayoutter.kt +++ b/quickstep/src/com/android/launcher3/taskbar/navbutton/SetupNavLayoutter.kt @@ -24,50 +24,89 @@ import android.widget.FrameLayout import android.widget.ImageView import android.widget.LinearLayout import android.widget.Space +import com.android.launcher3.DeviceProfile import com.android.launcher3.R import com.android.launcher3.taskbar.TaskbarActivityContext import com.android.systemui.shared.rotation.RotationButton +const val SQUARE_ASPECT_RATIO_BOTTOM_BOUND = 0.95 +const val SQUARE_ASPECT_RATIO_UPPER_BOUND = 1.05 + class SetupNavLayoutter( - resources: Resources, - navButtonContainer: LinearLayout, - endContextualContainer: ViewGroup, - startContextualContainer: ViewGroup, - imeSwitcher: ImageView?, - rotationButton: RotationButton?, - a11yButton: ImageView?, - space: Space? + resources: Resources, + navButtonsView: NearestTouchFrame, + navButtonContainer: LinearLayout, + endContextualContainer: ViewGroup, + startContextualContainer: ViewGroup, + imeSwitcher: ImageView?, + rotationButton: RotationButton?, + a11yButton: ImageView?, + space: Space? ) : AbstractNavButtonLayoutter( - resources, - navButtonContainer, - endContextualContainer, - startContextualContainer, - imeSwitcher, - rotationButton, - a11yButton, - space + resources, + navButtonContainer, + endContextualContainer, + startContextualContainer, + imeSwitcher, + rotationButton, + a11yButton, + space ) { + private val mNavButtonsView = navButtonsView override fun layoutButtons(context: TaskbarActivityContext, isA11yButtonPersistent: Boolean) { // Since setup wizard only has back button enabled, it looks strange to be // end-aligned, so start-align instead. val navButtonsLayoutParams = navButtonContainer.layoutParams as FrameLayout.LayoutParams - navButtonsLayoutParams.apply { - marginStart = navButtonsLayoutParams.marginEnd - marginEnd = 0 - gravity = Gravity.START + val navButtonsViewLayoutParams = mNavButtonsView.layoutParams as FrameLayout.LayoutParams + val deviceProfile: DeviceProfile = context.deviceProfile + + navButtonsLayoutParams.marginEnd = 0 + navButtonsLayoutParams.gravity = Gravity.START + context.setTaskbarWindowSize(context.setupWindowSize) + + // If SUW is on a large screen device that is landscape (or has a square aspect + // ratio) the back button has to be placed accordingly + if ( + deviceProfile.isTablet && deviceProfile.isLandscape || + (deviceProfile.aspectRatio > SQUARE_ASPECT_RATIO_BOTTOM_BOUND && + deviceProfile.aspectRatio < SQUARE_ASPECT_RATIO_UPPER_BOUND) + ) { + navButtonsLayoutParams.marginStart = + resources.getDimensionPixelSize(R.dimen.taskbar_back_button_suw_start_margin) + navButtonsViewLayoutParams.bottomMargin = + resources.getDimensionPixelSize(R.dimen.taskbar_back_button_suw_bottom_margin) + navButtonsLayoutParams.height = + resources.getDimensionPixelSize(R.dimen.taskbar_back_button_suw_height) + } else { + val phoneOrPortraitSetupMargin = + resources.getDimensionPixelSize(R.dimen.taskbar_contextual_button_suw_margin) + navButtonsLayoutParams.marginStart = phoneOrPortraitSetupMargin + navButtonsLayoutParams.bottomMargin = + if (!deviceProfile.isLandscape) 0 + else + phoneOrPortraitSetupMargin - + resources.getDimensionPixelSize(R.dimen.taskbar_nav_buttons_size) / 2 + navButtonsViewLayoutParams.height = + resources.getDimensionPixelSize(R.dimen.taskbar_contextual_button_suw_height) } - navButtonContainer.requestLayout() + mNavButtonsView.layoutParams = navButtonsViewLayoutParams + navButtonContainer.layoutParams = navButtonsLayoutParams endContextualContainer.removeAllViews() startContextualContainer.removeAllViews() - val contextualMargin = resources.getDimensionPixelSize( - R.dimen.taskbar_contextual_button_padding) + val contextualMargin = + resources.getDimensionPixelSize(R.dimen.taskbar_contextual_button_padding) repositionContextualContainer(endContextualContainer, WRAP_CONTENT, 0, 0, Gravity.END) - repositionContextualContainer(startContextualContainer, WRAP_CONTENT, contextualMargin, - contextualMargin, Gravity.START) + repositionContextualContainer( + startContextualContainer, + WRAP_CONTENT, + contextualMargin, + contextualMargin, + Gravity.START + ) if (imeSwitcher != null) { startContextualContainer.addView(imeSwitcher) diff --git a/res/values/dimens.xml b/res/values/dimens.xml index a912e2d0e8..4c2fa1ce5d 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -396,7 +396,7 @@ 0dp 0dp 0dp - 0dp + 0dp 0dp 0dp 0dp