Adjust where the back button is rendered for new SUW requirements.
Large screen devices in landscape mode and devices that have mostly a
square aspect ratio are undergoing a redesign in Setup wizard that makes
most screens two-pane. As part of this redesign, the back button is
aligned in this change. This change doesn't use a flag because the Setup
Wizard change is not flagged.
Fixes: 323778778
Fixes: 328017929
Test: Run Setup Wizard and see if the back button aligns with the Skip
button in two pane screens.
Flag: N/A
Change-Id: I22680f40c0ddf7cd03ab1da69406eb14184b0174
Merged-In: I22680f40c0ddf7cd03ab1da69406eb14184b0174
diff --git a/quickstep/res/values-land/dimens.xml b/quickstep/res/values-land/dimens.xml
index 2b17b93..e862b9e 100644
--- a/quickstep/res/values-land/dimens.xml
+++ b/quickstep/res/values-land/dimens.xml
@@ -78,7 +78,8 @@
<!-- Taskbar 3 button spacing -->
<dimen name="taskbar_button_margin_split">88dp</dimen>
<dimen name="taskbar_button_margin_6_5">219.6dp</dimen>
- <dimen name="taskbar_contextual_button_margin">48dp</dimen>
+ <dimen name="taskbar_contextual_button_suw_margin">48dp</dimen>
+ <dimen name="taskbar_contextual_button_suw_height">48dp</dimen>
<dimen name="taskbar_suw_frame">96dp</dimen>
<dimen name="taskbar_suw_insets">24dp</dimen>
diff --git a/quickstep/res/values/dimens.xml b/quickstep/res/values/dimens.xml
index 3331321..89a193b 100644
--- a/quickstep/res/values/dimens.xml
+++ b/quickstep/res/values/dimens.xml
@@ -325,9 +325,8 @@
<dimen name="taskbar_contextual_padding_top">8dp</dimen>
<dimen name="taskbar_nav_buttons_size">44dp</dimen>
<dimen name="taskbar_split_instructions_margin">48dp</dimen>
- <dimen name="taskbar_contextual_button_margin">120dp</dimen>
<dimen name="taskbar_suw_insets">48dp</dimen>
- <dimen name="taskbar_suw_frame">48dp</dimen>
+ <dimen name="taskbar_suw_frame">96dp</dimen>
<dimen name="taskbar_hotseat_nav_spacing">24dp</dimen>
<dimen name="taskbar_contextual_buttons_size">35dp</dimen>
<dimen name="taskbar_stashed_size">24dp</dimen>
@@ -346,6 +345,11 @@
<dimen name="taskbar_icon_size_kids">32dp</dimen>
<dimen name="taskbar_all_apps_button_translation_x_offset">6dp</dimen>
<dimen name="taskbar_all_apps_search_button_translation_x_offset">6dp</dimen>
+ <dimen name="taskbar_contextual_button_suw_margin">64dp</dimen>
+ <dimen name="taskbar_contextual_button_suw_height">64dp</dimen>
+ <dimen name="taskbar_back_button_suw_start_margin">48dp</dimen>
+ <dimen name="taskbar_back_button_suw_bottom_margin">1dp</dimen>
+ <dimen name="taskbar_back_button_suw_height">72dp</dimen>
<!-- Transient taskbar -->
<dimen name="transient_taskbar_padding">12dp</dimen>
diff --git a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java
index 2f11fd7..2c5aeb3 100644
--- a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java
@@ -142,6 +142,9 @@
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 @@
// 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 2b60dc0..5bfdce9 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.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 @@
* @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<LinearLayout>(ID_END_NAV_BUTTONS)
@@ -82,43 +81,6 @@
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 @@
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 181e0ed..8eff95c 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.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 a912e2d..4c2fa1c 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -396,7 +396,7 @@
<dimen name="transient_taskbar_clamped_offset_bound">0dp</dimen>
<dimen name="taskbar_icon_spacing">0dp</dimen>
<dimen name="taskbar_nav_buttons_size">0dp</dimen>
- <dimen name="taskbar_contextual_button_margin">0dp</dimen>
+ <dimen name="taskbar_contextual_button_suw_margin">0dp</dimen>
<dimen name="taskbar_hotseat_nav_spacing">0dp</dimen>
<dimen name="taskbar_button_margin_default">0dp</dimen>
<dimen name="taskbar_button_space_inbetween">0dp</dimen>