Ensure back button shows up in Simple View for SUW

This change adds support for the dynamic changing of navigation modes in
SUW such that the back button will be visible in both states. Previously
there was no way to switch navigation modes during Setup Wizard, before the
introduction of Simple View. The buttons were not being drawn correctly
(or at all).

Fix: 381016997
Fix: 381363853
Test: Rerun SUW, enable simple view and ensure that the back buttons
works in both orientations and that the SUW buttons are unaffected
Flag: EXEMPT bugfix

Change-Id: Ifbdf0c9cd06f1347e6c2c9a943711cefbf6bff2c
This commit is contained in:
Saumya Prakash
2025-03-13 06:14:24 +00:00
parent 4b40d05ebb
commit 850ee61de6
5 changed files with 56 additions and 72 deletions
@@ -349,13 +349,17 @@ class TaskbarInsetsController(val context: TaskbarActivityContext) : LoggableTas
controllers.bubbleControllers.isPresent &&
controllers.bubbleControllers.get().bubbleBarViewController.isBubbleBarVisible()
var insetsIsTouchableRegion = true
// Prevents the taskbar from taking touches and conflicting with setup wizard
if (
context.isPhoneButtonNavMode &&
context.isUserSetupComplete &&
(!controllers.navbarButtonsViewController.isImeVisible ||
!controllers.navbarButtonsViewController.isImeRenderingNavButtons)
) {
insetsInfo.setTouchableInsets(TOUCHABLE_INSETS_FRAME)
insetsIsTouchableRegion = false
debugTouchableRegion.lastSetTouchableReason =
"Phone button nav mode: Fullscreen touchable, IME not affecting nav buttons"
} else if (context.dragLayer.alpha < AlphaUpdateListener.ALPHA_CUTOFF_THRESHOLD) {
// Let touches pass through us.
insetsInfo.setTouchableInsets(TOUCHABLE_INSETS_REGION)
@@ -27,7 +27,6 @@ import android.widget.Space
import com.android.launcher3.DeviceProfile
import com.android.launcher3.R
import com.android.launcher3.Utilities
import com.android.launcher3.taskbar.TaskbarActivityContext
import com.android.launcher3.taskbar.navbutton.NavButtonLayoutFactory.NavButtonLayoutter
/**
@@ -48,7 +47,7 @@ abstract class AbstractNavButtonLayoutter(
protected val startContextualContainer: ViewGroup,
protected val imeSwitcher: ImageView?,
protected val a11yButton: ImageView?,
protected val space: Space?
protected val space: Space?,
) : NavButtonLayoutter {
protected val homeButton: ImageView? = navButtonContainer.findViewById(R.id.home)
protected val recentsButton: ImageView? = navButtonContainer.findViewById(R.id.recent_apps)
@@ -69,26 +68,34 @@ abstract class AbstractNavButtonLayoutter(
val params =
FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
ViewGroup.LayoutParams.MATCH_PARENT,
)
params.gravity = Gravity.CENTER
return params
}
/**
* Adjusts the layout parameters of the nav bar container for setup in phone mode.
*
* @param nearestTouchFrameLayoutParams The layout parameters of the navButtonsView, which is
* the ViewGroup that contains start, end, nav button ViewGroups
* @param deviceProfile The device profile containing information about the device's
* configuration.
*/
fun adjustForSetupInPhoneMode(
navButtonsLayoutParams: FrameLayout.LayoutParams,
navButtonsViewLayoutParams: FrameLayout.LayoutParams,
deviceProfile: DeviceProfile
nearestTouchFrameLayoutParams: FrameLayout.LayoutParams,
deviceProfile: DeviceProfile,
) {
val phoneOrPortraitSetupMargin =
resources.getDimensionPixelSize(R.dimen.taskbar_contextual_button_suw_margin)
navButtonsLayoutParams.marginStart = phoneOrPortraitSetupMargin
navButtonsLayoutParams.bottomMargin =
nearestTouchFrameLayoutParams.marginStart = phoneOrPortraitSetupMargin
nearestTouchFrameLayoutParams.bottomMargin =
if (!deviceProfile.isLandscape) 0
else
phoneOrPortraitSetupMargin -
resources.getDimensionPixelSize(R.dimen.taskbar_nav_buttons_size) / 2
navButtonsViewLayoutParams.height =
resources.getDimensionPixelSize(R.dimen.taskbar_nav_buttons_size) / 2
nearestTouchFrameLayoutParams.height =
resources.getDimensionPixelSize(R.dimen.taskbar_contextual_button_suw_height)
}
@@ -97,7 +104,7 @@ abstract class AbstractNavButtonLayoutter(
buttonSize: Int,
barAxisMarginStart: Int,
barAxisMarginEnd: Int,
gravity: Int
gravity: Int,
) {
val contextualContainerParams =
FrameLayout.LayoutParams(buttonSize, ViewGroup.LayoutParams.MATCH_PARENT)
@@ -66,7 +66,7 @@ class NavButtonLayoutFactory {
isInSetup: Boolean,
isThreeButtonNav: Boolean,
phoneMode: Boolean,
@Rotation surfaceRotation: Int
@Rotation surfaceRotation: Int,
): NavButtonLayoutter {
val navButtonContainer =
navButtonsView.requireViewById<LinearLayout>(ID_END_NAV_BUTTONS)
@@ -77,6 +77,18 @@ class NavButtonLayoutFactory {
val isPhoneNavMode = phoneMode && isThreeButtonNav
val isPhoneGestureMode = phoneMode && !isThreeButtonNav
return when {
isInSetup -> {
SetupNavLayoutter(
resources,
navButtonsView,
navButtonContainer,
endContextualContainer,
startContextualContainer,
imeSwitcher,
a11yButton,
space,
)
}
isPhoneNavMode -> {
if (!deviceProfile.isLandscape) {
navButtonsView.setIsVertical(false)
@@ -87,7 +99,7 @@ class NavButtonLayoutFactory {
startContextualContainer,
imeSwitcher,
a11yButton,
space
space,
)
} else if (surfaceRotation == ROTATION_90) {
navButtonsView.setIsVertical(true)
@@ -98,7 +110,7 @@ class NavButtonLayoutFactory {
startContextualContainer,
imeSwitcher,
a11yButton,
space
space,
)
} else {
navButtonsView.setIsVertical(true)
@@ -109,36 +121,23 @@ class NavButtonLayoutFactory {
startContextualContainer,
imeSwitcher,
a11yButton,
space
space,
)
}
}
isPhoneGestureMode -> {
PhoneGestureLayoutter(
resources,
navButtonsView,
navButtonContainer,
endContextualContainer,
startContextualContainer,
imeSwitcher,
a11yButton,
space
space,
)
}
deviceProfile.isTaskbarPresent -> {
return when {
isInSetup -> {
SetupNavLayoutter(
resources,
navButtonsView,
navButtonContainer,
endContextualContainer,
startContextualContainer,
imeSwitcher,
a11yButton,
space
)
}
isKidsMode -> {
KidsNavLayoutter(
resources,
@@ -147,7 +146,7 @@ class NavButtonLayoutFactory {
startContextualContainer,
imeSwitcher,
a11yButton,
space
space,
)
}
else ->
@@ -158,7 +157,7 @@ class NavButtonLayoutFactory {
startContextualContainer,
imeSwitcher,
a11yButton,
space
space,
)
}
}
@@ -17,25 +17,21 @@
package com.android.launcher3.taskbar.navbutton
import android.content.res.Resources
import android.view.Gravity
import android.view.ViewGroup
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.taskbar.TaskbarActivityContext
/** Layoutter for showing gesture navigation on phone screen. No buttons here, no-op container */
class PhoneGestureLayoutter(
resources: Resources,
navButtonsView: NearestTouchFrame,
navBarContainer: LinearLayout,
endContextualContainer: ViewGroup,
startContextualContainer: ViewGroup,
imeSwitcher: ImageView?,
a11yButton: ImageView?,
space: Space?
space: Space?,
) :
AbstractNavButtonLayoutter(
resources,
@@ -44,33 +40,10 @@ class PhoneGestureLayoutter(
startContextualContainer,
imeSwitcher,
a11yButton,
space
space,
) {
private val mNavButtonsView = navButtonsView
override fun layoutButtons(context: TaskbarActivityContext, isA11yButtonPersistent: Boolean) {
// TODO: look into if we should use SetupNavLayoutter instead.
if (!context.isUserSetupComplete) {
// 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
val navButtonsViewLayoutParams =
mNavButtonsView.layoutParams as FrameLayout.LayoutParams
val deviceProfile: DeviceProfile = context.deviceProfile
navButtonsLayoutParams.marginEnd = 0
navButtonsLayoutParams.gravity = Gravity.START
context.setTaskbarWindowSize(context.setupWindowSize)
adjustForSetupInPhoneMode(
navButtonsLayoutParams,
navButtonsViewLayoutParams,
deviceProfile
)
mNavButtonsView.layoutParams = navButtonsViewLayoutParams
navButtonContainer.layoutParams = navButtonsLayoutParams
}
endContextualContainer.removeAllViews()
startContextualContainer.removeAllViews()
}
@@ -29,12 +29,15 @@ import com.android.launcher3.DeviceProfile
import com.android.launcher3.R
import com.android.launcher3.taskbar.TaskbarActivityContext
const val SUW_THEME_SYSTEM_PROPERTY = "setupwizard.theme"
const val GLIF_EXPRESSIVE_THEME = "glif_expressive"
const val GLIF_EXPRESSIVE_LIGHT_THEME = "glif_expressive_light"
const val SQUARE_ASPECT_RATIO_BOTTOM_BOUND = 0.95
const val SQUARE_ASPECT_RATIO_UPPER_BOUND = 1.05
class SetupNavLayoutter(
resources: Resources,
navButtonsView: NearestTouchFrame,
nearestTouchFrame: NearestTouchFrame,
navButtonContainer: LinearLayout,
endContextualContainer: ViewGroup,
startContextualContainer: ViewGroup,
@@ -51,17 +54,19 @@ class SetupNavLayoutter(
a11yButton,
space,
) {
private val mNavButtonsView = navButtonsView
// mNearestTouchFrame is a ViewGroup that contains start, end, nav button ViewGroups
private val mNearestTouchFrame = nearestTouchFrame
override fun layoutButtons(context: TaskbarActivityContext, isA11yButtonPersistent: Boolean) {
val SUWTheme = SystemProperties.get("setupwizard.theme", "")
if (SUWTheme == "glif_expressive" || SUWTheme == "glif_expressive_light") {
val SUWTheme = SystemProperties.get(SUW_THEME_SYSTEM_PROPERTY, "")
if (SUWTheme == GLIF_EXPRESSIVE_THEME || SUWTheme == GLIF_EXPRESSIVE_LIGHT_THEME) {
return
}
// 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
val navButtonsViewLayoutParams = mNavButtonsView.layoutParams as FrameLayout.LayoutParams
val navButtonsOverallViewGroupLayoutParams =
mNearestTouchFrame.layoutParams as FrameLayout.LayoutParams
val deviceProfile: DeviceProfile = context.deviceProfile
navButtonsLayoutParams.marginEnd = 0
@@ -77,18 +82,14 @@ class SetupNavLayoutter(
) {
navButtonsLayoutParams.marginStart =
resources.getDimensionPixelSize(R.dimen.taskbar_back_button_suw_start_margin)
navButtonsViewLayoutParams.bottomMargin =
navButtonsOverallViewGroupLayoutParams.bottomMargin =
resources.getDimensionPixelSize(R.dimen.taskbar_back_button_suw_bottom_margin)
navButtonsLayoutParams.height =
resources.getDimensionPixelSize(R.dimen.taskbar_back_button_suw_height)
} else {
adjustForSetupInPhoneMode(
navButtonsLayoutParams,
navButtonsViewLayoutParams,
deviceProfile,
)
adjustForSetupInPhoneMode(navButtonsOverallViewGroupLayoutParams, deviceProfile)
}
mNavButtonsView.layoutParams = navButtonsViewLayoutParams
mNearestTouchFrame.layoutParams = navButtonsOverallViewGroupLayoutParams
navButtonContainer.layoutParams = navButtonsLayoutParams
endContextualContainer.removeAllViews()