Full-screen user switcher is now scrollable.

When the user increases the font and item size through accessibility
settings, our picker gets its items cut off. This CL fixes it, following
guidance from UX and making the picker scrollable while elevating the
bottom add and cancel buttons to a button bar that extends along the
bottom of the screen, following the figma spec.

Fix: 254788900
Test: verified that the user switcher is scrollable when adding the
maximum number of users to the device. Verified that selecting them
still works. Checked on tablet with landscape and portrait mode as well
with maximum font and UI size and with normal sizes as well.

Change-Id: I2be56e624ac53a87e2c51f91bae1571d6559b3cf
This commit is contained in:
Alejandro Nijamkin
2022-10-27 15:10:36 -07:00
parent fac53656ed
commit 9c04df4f1e
2 changed files with 78 additions and 51 deletions

View File

@@ -14,58 +14,84 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<com.android.systemui.user.UserSwitcherRootView
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
android:id="@+id/user_switcher_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginVertical="40dp"
android:layout_marginHorizontal="60dp">
android:orientation="vertical">
<androidx.constraintlayout.helper.widget.Flow
android:id="@+id/flow"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:flow_horizontalBias="0.5"
app:flow_verticalAlign="center"
app:flow_wrapMode="chain"
app:flow_horizontalGap="@dimen/user_switcher_fullscreen_horizontal_gap"
app:flow_verticalGap="44dp"
app:flow_horizontalStyle="packed"/>
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:fillViewport="true">
<TextView
android:id="@+id/cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
app:layout_constraintHeight_min="48dp"
app:layout_constraintEnd_toStartOf="@+id/add"
app:layout_constraintBottom_toBottomOf="parent"
android:paddingHorizontal="@dimen/user_switcher_fullscreen_button_padding"
android:textSize="@dimen/user_switcher_fullscreen_button_text_size"
android:textColor="?androidprv:attr/colorAccentPrimary"
android:text="@string/cancel" />
<com.android.systemui.user.UserSwitcherRootView
android:id="@+id/user_switcher_grid_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="40dp"
android:paddingHorizontal="60dp">
<TextView
android:id="@+id/add"
style="@style/Widget.Dialog.Button.BorderButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:paddingHorizontal="@dimen/user_switcher_fullscreen_button_padding"
android:text="@string/add"
android:textColor="?androidprv:attr/colorAccentPrimary"
android:textSize="@dimen/user_switcher_fullscreen_button_text_size"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_min="48dp" />
</com.android.systemui.user.UserSwitcherRootView>
<androidx.constraintlayout.helper.widget.Flow
android:id="@+id/flow"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:flow_horizontalBias="0.5"
app:flow_verticalAlign="center"
app:flow_wrapMode="chain"
app:flow_horizontalGap="@dimen/user_switcher_fullscreen_horizontal_gap"
app:flow_verticalGap="44dp"
app:flow_horizontalStyle="packed"/>
</com.android.systemui.user.UserSwitcherRootView>
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="96dp"
android:orientation="horizontal"
android:gravity="center_vertical|end"
android:paddingEnd="48dp">
<TextView
android:id="@+id/cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:minHeight="48dp"
android:paddingHorizontal="@dimen/user_switcher_fullscreen_button_padding"
android:textSize="@dimen/user_switcher_fullscreen_button_text_size"
android:textColor="?androidprv:attr/colorAccentPrimary"
android:text="@string/cancel" />
<Space
android:layout_width="24dp"
android:layout_height="0dp"
/>
<TextView
android:id="@+id/add"
style="@style/Widget.Dialog.Button.BorderButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:paddingHorizontal="@dimen/user_switcher_fullscreen_button_padding"
android:text="@string/add"
android:textColor="?androidprv:attr/colorAccentPrimary"
android:textSize="@dimen/user_switcher_fullscreen_button_text_size"
android:visibility="gone"
android:minHeight="48dp" />
</LinearLayout>
</LinearLayout>

View File

@@ -61,14 +61,15 @@ object UserSwitcherViewBinder {
falsingCollector: FalsingCollector,
onFinish: () -> Unit,
) {
val rootView: UserSwitcherRootView = view.requireViewById(R.id.user_switcher_root)
val flowWidget: FlowWidget = view.requireViewById(R.id.flow)
val gridContainerView: UserSwitcherRootView =
view.requireViewById(R.id.user_switcher_grid_container)
val flowWidget: FlowWidget = gridContainerView.requireViewById(R.id.flow)
val addButton: View = view.requireViewById(R.id.add)
val cancelButton: View = view.requireViewById(R.id.cancel)
val popupMenuAdapter = MenuAdapter(layoutInflater)
var popupMenu: UserSwitcherPopupMenu? = null
rootView.touchHandler =
gridContainerView.touchHandler =
object : Gefingerpoken {
override fun onTouchEvent(ev: MotionEvent?): Boolean {
falsingCollector.onTouchEvent(ev)
@@ -134,7 +135,7 @@ object UserSwitcherViewBinder {
val viewPool =
view.children.filter { it.tag == USER_VIEW_TAG }.toMutableList()
viewPool.forEach {
view.removeView(it)
gridContainerView.removeView(it)
flowWidget.removeView(it)
}
users.forEach { userViewModel ->
@@ -152,7 +153,7 @@ object UserSwitcherViewBinder {
inflatedView
}
userView.id = View.generateViewId()
view.addView(userView)
gridContainerView.addView(userView)
flowWidget.addView(userView)
UserViewBinder.bind(
view = userView,