From 0e0e92153b8c195238550d91957496f1935129ae Mon Sep 17 00:00:00 2001 From: Aarthi Balachander Date: Thu, 19 Apr 2018 19:25:33 -0700 Subject: [PATCH] Refactoring the User Switcher layout files to use dimensions in dimens_car.xml and colors_car.xml so that overlays will be easier. Also, added a dialog when adding a user. Fixed the issue where coming back to the user picker makes the buttons unresponsive Test: tested on Mojave Bug: 78244241, 78309816, 78297334, Change-Id: Iec44eb93ec4456be6d39d08940bb6ba2050eac7a --- .../res/drawable/car_add_circle_round.xml | 6 +-- .../res/drawable/car_ic_add_white.xml | 2 +- .../res/layout/car_fullscreen_user_pod.xml | 23 ++++---- .../layout/car_fullscreen_user_switcher.xml | 21 ++++---- packages/SystemUI/res/layout/car_qs_panel.xml | 11 ++-- packages/SystemUI/res/values/colors_car.xml | 13 ++--- packages/SystemUI/res/values/dimens_car.xml | 12 ++--- packages/SystemUI/res/values/strings_car.xml | 4 ++ .../statusbar/car/UserGridRecyclerView.java | 54 +++++++++++++++---- 9 files changed, 86 insertions(+), 60 deletions(-) diff --git a/packages/SystemUI/res/drawable/car_add_circle_round.xml b/packages/SystemUI/res/drawable/car_add_circle_round.xml index cb9515c9693f6..5cf0c31384f96 100644 --- a/packages/SystemUI/res/drawable/car_add_circle_round.xml +++ b/packages/SystemUI/res/drawable/car_add_circle_round.xml @@ -3,10 +3,10 @@ + android:color="@color/car_user_switcher_add_user_background_color"/> + android:width="@dimen/car_user_switcher_image_avatar_size" + android:height="@dimen/car_user_switcher_image_avatar_size"/> \ No newline at end of file diff --git a/packages/SystemUI/res/layout/car_fullscreen_user_pod.xml b/packages/SystemUI/res/layout/car_fullscreen_user_pod.xml index 324216508dfc4..f34811eb53f86 100644 --- a/packages/SystemUI/res/layout/car_fullscreen_user_pod.xml +++ b/packages/SystemUI/res/layout/car_fullscreen_user_pod.xml @@ -16,30 +16,31 @@ --> - + android:orientation="vertical" + android:gravity="center" + > + android:gravity="center"/> - + diff --git a/packages/SystemUI/res/layout/car_fullscreen_user_switcher.xml b/packages/SystemUI/res/layout/car_fullscreen_user_switcher.xml index d8b52fc69f8bd..bf5f188b25faa 100644 --- a/packages/SystemUI/res/layout/car_fullscreen_user_switcher.xml +++ b/packages/SystemUI/res/layout/car_fullscreen_user_switcher.xml @@ -19,32 +19,29 @@ android:fitsSystemWindows="true" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="@color/car_card_dark" + android:background="@color/car_user_switcher_background_color" android:visibility="gone"> - + android:layout_height="match_parent" + android:orientation="vertical"> - + app:itemSpacing="@dimen/car_user_switcher_vertical_spacing_between_users"/> - + diff --git a/packages/SystemUI/res/layout/car_qs_panel.xml b/packages/SystemUI/res/layout/car_qs_panel.xml index 9c2b95b44aafe..0e8db77db588c 100644 --- a/packages/SystemUI/res/layout/car_qs_panel.xml +++ b/packages/SystemUI/res/layout/car_qs_panel.xml @@ -31,23 +31,18 @@ xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/user_switcher_container" - android:layout_marginStart="@dimen/car_margin" - android:layout_marginEnd="@dimen/car_margin" android:clipChildren="false" android:layout_width="match_parent" android:layout_height="@dimen/car_user_switcher_container_height"> + app:itemSpacing="@dimen/car_user_switcher_vertical_spacing_between_users"/> diff --git a/packages/SystemUI/res/values/colors_car.xml b/packages/SystemUI/res/values/colors_car.xml index 710b3e03ccf74..cb3abb957f0cd 100644 --- a/packages/SystemUI/res/values/colors_car.xml +++ b/packages/SystemUI/res/values/colors_car.xml @@ -18,14 +18,11 @@ --> #263238 - #00000000 - #80CBC4 - @color/car_grey_50 - @color/car_grey_900 - @color/car_grey_50 - @color/car_grey_900 @color/car_grey_50 - #FAFAFA - #212121 + + @color/car_card_dark + @color/car_body1_light + @color/car_dark_blue_grey_600 + @color/car_body1_light diff --git a/packages/SystemUI/res/values/dimens_car.xml b/packages/SystemUI/res/values/dimens_car.xml index 6bc8e26047fe2..8e17b52e61801 100644 --- a/packages/SystemUI/res/values/dimens_car.xml +++ b/packages/SystemUI/res/values/dimens_car.xml @@ -16,12 +16,11 @@ */ --> - - 64sp - 243dp - 356dp - 96dp - 96dp + + @dimen/car_body1_size + @dimen/car_large_avatar_size + @dimen/car_padding_5 + @dimen/car_padding_4 64dp 760dp @@ -43,5 +42,4 @@ -420dp - 26sp diff --git a/packages/SystemUI/res/values/strings_car.xml b/packages/SystemUI/res/values/strings_car.xml index 0b57ff895d052..61d734fc0e824 100644 --- a/packages/SystemUI/res/values/strings_car.xml +++ b/packages/SystemUI/res/values/strings_car.xml @@ -23,4 +23,8 @@ Add User New User + + When you add a new user, that person needs to set up their space. + + Any user can update apps for all other users. diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/car/UserGridRecyclerView.java b/packages/SystemUI/src/com/android/systemui/statusbar/car/UserGridRecyclerView.java index f1e2302ceda24..1148fad90dde7 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/car/UserGridRecyclerView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/car/UserGridRecyclerView.java @@ -16,9 +16,14 @@ package com.android.systemui.statusbar.car; +import static android.content.DialogInterface.BUTTON_POSITIVE; + +import android.app.AlertDialog; +import android.app.AlertDialog.Builder; +import android.app.Dialog; import android.content.Context; +import android.content.DialogInterface; import android.content.pm.UserInfo; -import android.content.res.ColorStateList; import android.content.res.Resources; import android.graphics.Bitmap; import android.os.AsyncTask; @@ -37,6 +42,7 @@ import com.android.internal.util.UserIcons; import com.android.settingslib.users.UserManagerHelper; import com.android.systemui.R; +import com.android.systemui.statusbar.phone.SystemUIDialog; import java.util.ArrayList; import java.util.List; @@ -147,13 +153,17 @@ public class UserGridRecyclerView extends PagedListView implements /** * Adapter to populate the grid layout with the available user profiles */ - public final class UserAdapter extends RecyclerView.Adapter { + public final class UserAdapter extends RecyclerView.Adapter + implements Dialog.OnClickListener { private final Context mContext; private List mUsers; private final Resources mRes; private final String mGuestName; private final String mNewUserName; + private AlertDialog mDialog; + // View that holds the add user button. Used to enable/disable the view + private View mAddUserView; public UserAdapter(Context context, List users) { mRes = context.getResources(); @@ -190,9 +200,6 @@ public class UserGridRecyclerView extends PagedListView implements return; } - // Disable button so it cannot be clicked multiple times - holder.mView.setEnabled(false); - // Notify the listener which user was selected if (mUserSelectionListener != null) { mUserSelectionListener.onUserSelected(userRecord); @@ -204,12 +211,28 @@ public class UserGridRecyclerView extends PagedListView implements return; } - // If the user wants to add a user, start task to add new user + // If the user wants to add a user, show dialog to confirm adding a user if (userRecord.mIsAddUser) { - new AddNewUserTask().execute(mNewUserName); + // Disable button so it cannot be clicked multiple times + mAddUserView = holder.mView; + mAddUserView.setEnabled(false); + + String message = mRes.getString(R.string.user_add_user_message_setup) + .concat(System.getProperty("line.separator")) + .concat(System.getProperty("line.separator")) + .concat(mRes.getString(R.string.user_add_user_message_update)); + + mDialog = new Builder(mContext, R.style.Theme_Car_Dark_Dialog_Alert) + .setTitle(R.string.user_add_user_title) + .setMessage(message) + .setNegativeButton(android.R.string.cancel, this) + .setPositiveButton(android.R.string.ok, this) + .create(); + // Sets window flags for the SysUI dialog + SystemUIDialog.applyFlags(mDialog); + mDialog.show(); return; } - // If the user doesn't want to be a guest or add a user, switch to the user selected mUserManagerHelper.switchToUser(userRecord.mInfo); }); @@ -219,17 +242,28 @@ public class UserGridRecyclerView extends PagedListView implements private Bitmap getUserRecordIcon(UserRecord userRecord) { if (userRecord.mIsStartGuestSession) { return UserIcons.convertToBitmap(UserIcons.getDefaultUserIcon( - mContext.getResources(), UserHandle.USER_NULL, false)); + mContext.getResources(), UserHandle.USER_NULL, false)); } if (userRecord.mIsAddUser) { return UserIcons.convertToBitmap(mContext - .getDrawable(R.drawable.car_add_circle_round)); + .getDrawable(R.drawable.car_add_circle_round)); } return mUserManagerHelper.getUserIcon(userRecord.mInfo); } + @Override + public void onClick(DialogInterface dialog, int which) { + // Enable the add button + if (mAddUserView != null) { + mAddUserView.setEnabled(true); + } + if (which == BUTTON_POSITIVE) { + new AddNewUserTask().execute(mNewUserName); + } + } + private class AddNewUserTask extends AsyncTask { @Override