Merge "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" into pi-dev
diff --git a/packages/SystemUI/res/drawable/car_add_circle_round.xml b/packages/SystemUI/res/drawable/car_add_circle_round.xml
index cb9515c..5cf0c31 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 @@
     <item>
         <shape android:shape="oval">
             <solid
-                android:color="@color/car_dark_blue_grey_600"/>
+                android:color="@color/car_user_switcher_add_user_background_color"/>
             <size
-                android:width="@dimen/car_fullscreen_user_pod_image_avatar_width"
-                android:height="@dimen/car_fullscreen_user_pod_image_avatar_height"/>
+                android:width="@dimen/car_user_switcher_image_avatar_size"
+                android:height="@dimen/car_user_switcher_image_avatar_size"/>
         </shape>
     </item>
     <item
diff --git a/packages/SystemUI/res/drawable/car_ic_add_white.xml b/packages/SystemUI/res/drawable/car_ic_add_white.xml
index 98b37bf..f24771d 100644
--- a/packages/SystemUI/res/drawable/car_ic_add_white.xml
+++ b/packages/SystemUI/res/drawable/car_ic_add_white.xml
@@ -4,6 +4,6 @@
     android:viewportWidth="24.0"
     android:viewportHeight="24.0">
   <path
-      android:fillColor="@color/car_body1_light"
+      android:fillColor="@color/car_user_switcher_add_user_add_sign_color"
       android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/>
 </vector>
\ 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 3242165..f34811e 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 @@
 -->
 
 
-<RelativeLayout
+<LinearLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:clipChildren="false"
     android:alpha="0"
     android:layout_height="wrap_content"
     android:layout_width="match_parent"
-    android:gravity="fill_horizontal">
+    android:orientation="vertical"
+    android:gravity="center"
+    >
 
     <ImageView android:id="@+id/user_avatar"
-        android:layout_centerHorizontal="true"
-        android:layout_width="@dimen/car_fullscreen_user_pod_image_avatar_width"
-        android:layout_height="@dimen/car_fullscreen_user_pod_image_avatar_height"
+        android:layout_width="@dimen/car_user_switcher_image_avatar_size"
+        android:layout_height="@dimen/car_user_switcher_image_avatar_size"
         android:background="@drawable/car_button_ripple_background_inverse"
+        android:gravity="center"
         />
 
     <TextView android:id="@+id/user_name"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:layout_marginTop="@dimen/car_padding_4"
-        android:textSize="@dimen/car_body1_size"
-        android:textColor="@color/car_body1_light"
+        android:layout_marginTop="@dimen/car_user_switcher_vertical_spacing_between_name_and_avatar"
+        android:textSize="@dimen/car_user_switcher_name_text_size"
+        android:textColor="@color/car_user_switcher_name_text_color"
         android:ellipsize="end"
         android:singleLine="true"
-        android:gravity="center"
-        android:layout_below="@id/user_avatar"/>
+        android:gravity="center"/>
 
-</RelativeLayout>
+</LinearLayout>
diff --git a/packages/SystemUI/res/layout/car_fullscreen_user_switcher.xml b/packages/SystemUI/res/layout/car_fullscreen_user_switcher.xml
index d8b52fc..bf5f188 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">
 
-    <RelativeLayout
+    <LinearLayout
         android:id="@+id/container"
-        android:background="@color/car_card_dark"
+        android:background="@color/car_user_switcher_background_color"
         android:layout_width="match_parent"
-        android:layout_height="match_parent">
+        android:layout_height="match_parent"
+        android:orientation="vertical">
 
         <include layout="@layout/car_status_bar_header"
             android:theme="@android:style/Theme"
             android:layout_alignParentTop="true"/>
 
-        <!-- TODO: add app:verticallyCenterListContent="true" when car support lib is updated -->
         <com.android.systemui.statusbar.car.UserGridRecyclerView
             android:id="@+id/user_grid"
-            android:layout_width="wrap_content"
+            android:layout_width="match_parent"
             android:layout_height="match_parent"
-            android:layout_below="@+id/header"
-            android:layout_centerHorizontal="true"
-            android:layout_centerVertical="true"
-            android:layout_alignParentRight="true"
+            app:verticallyCenterListContent="true"
             app:dayNightStyle="force_night"
             app:showPagedListViewDivider="false"
             app:gutter="both"
-            app:itemSpacing="@dimen/car_padding_5"/>
+            app:itemSpacing="@dimen/car_user_switcher_vertical_spacing_between_users"/>
 
-    </RelativeLayout>
+    </LinearLayout>
 </FrameLayout>
diff --git a/packages/SystemUI/res/layout/car_qs_panel.xml b/packages/SystemUI/res/layout/car_qs_panel.xml
index 9c2b95b..0e8db77 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">
 
         <com.android.systemui.statusbar.car.UserGridRecyclerView
             android:id="@+id/user_grid"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_centerHorizontal="true"
-            android:layout_centerVertical="true"
-            android:layout_alignParentRight="true"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
             app:dayNightStyle="force_night"
             app:showPagedListViewDivider="false"
             app:gutter="both"
-            app:itemSpacing="@dimen/car_padding_4"/>
+            app:itemSpacing="@dimen/car_user_switcher_vertical_spacing_between_users"/>
 
     </RelativeLayout>
 
diff --git a/packages/SystemUI/res/values/colors_car.xml b/packages/SystemUI/res/values/colors_car.xml
index 710b3e0..cb3abb9 100644
--- a/packages/SystemUI/res/values/colors_car.xml
+++ b/packages/SystemUI/res/values/colors_car.xml
@@ -18,14 +18,11 @@
 -->
 <resources>
     <color name="car_qs_background_primary">#263238</color> <!-- Blue Gray 900 -->
-    <color name="car_user_switcher_progress_bgcolor">#00000000</color> <!-- Transparent -->
-    <color name="car_user_switcher_progress_fgcolor">#80CBC4</color> <!-- Teal 200 -->
-    <color name="car_user_switcher_no_user_image_bgcolor">@color/car_grey_50</color>
-    <color name="car_user_switcher_no_user_image_fgcolor">@color/car_grey_900</color>
-    <color name="car_start_driving_background">@color/car_grey_50</color>
-    <color name="car_start_driving_text">@color/car_grey_900</color>
     <color name="car_qs_footer_user_name_color">@color/car_grey_50</color>
 
-    <color name="car_grey_50">#FAFAFA</color>
-    <color name="car_grey_900">#212121</color>
+    <!-- colors for user switcher -->
+    <color name="car_user_switcher_background_color">@color/car_card_dark</color>
+    <color name="car_user_switcher_name_text_color">@color/car_body1_light</color>
+    <color name="car_user_switcher_add_user_background_color">@color/car_dark_blue_grey_600</color>
+    <color name="car_user_switcher_add_user_add_sign_color">@color/car_body1_light</color>
 </resources>
diff --git a/packages/SystemUI/res/values/dimens_car.xml b/packages/SystemUI/res/values/dimens_car.xml
index 6bc8e26..8e17b52 100644
--- a/packages/SystemUI/res/values/dimens_car.xml
+++ b/packages/SystemUI/res/values/dimens_car.xml
@@ -16,12 +16,11 @@
 */
 -->
 <resources>
-    <!-- TODO replace with car support lib sizes when available -->
-    <dimen name="car_fullscreen_user_pod_icon_text_size">64sp</dimen>
-    <dimen name="car_fullscreen_user_pod_width">243dp</dimen>
-    <dimen name="car_fullscreen_user_pod_height">356dp</dimen>
-    <dimen name="car_fullscreen_user_pod_image_avatar_width">96dp</dimen>
-    <dimen name="car_fullscreen_user_pod_image_avatar_height">96dp</dimen>
+    <!-- dimensions for the car user switcher -->
+    <dimen name="car_user_switcher_name_text_size">@dimen/car_body1_size</dimen>
+    <dimen name="car_user_switcher_image_avatar_size">@dimen/car_large_avatar_size</dimen>
+    <dimen name="car_user_switcher_vertical_spacing_between_users">@dimen/car_padding_5</dimen>
+    <dimen name="car_user_switcher_vertical_spacing_between_name_and_avatar">@dimen/car_padding_4</dimen>
 
     <dimen name="car_navigation_button_width">64dp</dimen>
     <dimen name="car_navigation_bar_width">760dp</dimen>
@@ -43,5 +42,4 @@
     <!-- This must be the negative of car_user_switcher_container_height for the animation. -->
     <dimen name="car_user_switcher_container_anim_height">-420dp</dimen>
 
-    <dimen name="car_body2_size">26sp</dimen>
 </resources>
diff --git a/packages/SystemUI/res/values/strings_car.xml b/packages/SystemUI/res/values/strings_car.xml
index 0b57ff8..61d734f 100644
--- a/packages/SystemUI/res/values/strings_car.xml
+++ b/packages/SystemUI/res/values/strings_car.xml
@@ -23,4 +23,8 @@
     <string name="car_add_user">Add User</string>
     <!-- Default name of the new user created. [CHAR LIMIT=30] -->
     <string name="car_new_user">New User</string>
+    <!-- Message to inform user that creation of new user requires that user to set up their space. [CHAR LIMIT=100] -->
+    <string name="user_add_user_message_setup">When you add a new user, that person needs to set up their space.</string>
+    <!-- Message to inform user that the newly created user will have permissions to update apps for all other users. [CHAR LIMIT=100] -->
+    <string name="user_add_user_message_update">Any user can update apps for all other users.</string>
 </resources>
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 f1e2302..1148fad 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.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 @@
     /**
      * Adapter to populate the grid layout with the available user profiles
      */
-    public final class UserAdapter extends RecyclerView.Adapter<UserAdapter.UserAdapterViewHolder> {
+    public final class UserAdapter extends RecyclerView.Adapter<UserAdapter.UserAdapterViewHolder>
+            implements Dialog.OnClickListener {
 
         private final Context mContext;
         private List<UserRecord> 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<UserRecord> users) {
             mRes = context.getResources();
@@ -190,9 +200,6 @@
                     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 @@
                     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 @@
         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<String, Void, UserInfo> {
 
             @Override