Merge "Full-screen user switcher is now scrollable." into tm-qpr-dev

This commit is contained in:
Ale Nijamkin
2022-10-31 23:11:22 +00:00
committed by Android (Google) Code Review
2 changed files with 78 additions and 51 deletions

View File

@@ -14,15 +14,27 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
--> -->
<com.android.systemui.user.UserSwitcherRootView <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android" xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
android:id="@+id/user_switcher_root" android:id="@+id/user_switcher_root"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginVertical="40dp" android:orientation="vertical">
android:layout_marginHorizontal="60dp">
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:fillViewport="true">
<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">
<androidx.constraintlayout.helper.widget.Flow <androidx.constraintlayout.helper.widget.Flow
android:id="@+id/flow" android:id="@+id/flow"
@@ -38,6 +50,16 @@
app:flow_horizontalGap="@dimen/user_switcher_fullscreen_horizontal_gap" app:flow_horizontalGap="@dimen/user_switcher_fullscreen_horizontal_gap"
app:flow_verticalGap="44dp" app:flow_verticalGap="44dp"
app:flow_horizontalStyle="packed"/> 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 <TextView
android:id="@+id/cancel" android:id="@+id/cancel"
@@ -45,14 +67,17 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:gravity="center" android:gravity="center"
app:layout_constraintHeight_min="48dp" android:minHeight="48dp"
app:layout_constraintEnd_toStartOf="@+id/add"
app:layout_constraintBottom_toBottomOf="parent"
android:paddingHorizontal="@dimen/user_switcher_fullscreen_button_padding" android:paddingHorizontal="@dimen/user_switcher_fullscreen_button_padding"
android:textSize="@dimen/user_switcher_fullscreen_button_text_size" android:textSize="@dimen/user_switcher_fullscreen_button_text_size"
android:textColor="?androidprv:attr/colorAccentPrimary" android:textColor="?androidprv:attr/colorAccentPrimary"
android:text="@string/cancel" /> android:text="@string/cancel" />
<Space
android:layout_width="24dp"
android:layout_height="0dp"
/>
<TextView <TextView
android:id="@+id/add" android:id="@+id/add"
style="@style/Widget.Dialog.Button.BorderButton" style="@style/Widget.Dialog.Button.BorderButton"
@@ -65,7 +90,8 @@
android:textColor="?androidprv:attr/colorAccentPrimary" android:textColor="?androidprv:attr/colorAccentPrimary"
android:textSize="@dimen/user_switcher_fullscreen_button_text_size" android:textSize="@dimen/user_switcher_fullscreen_button_text_size"
android:visibility="gone" android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent" android:minHeight="48dp" />
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_min="48dp" /> </LinearLayout>
</com.android.systemui.user.UserSwitcherRootView>
</LinearLayout>

View File

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