Aarthi Balachander | d8bf249 | 2018-03-30 11:15:59 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License |
| 15 | */ |
| 16 | |
| 17 | package com.android.systemui.statusbar.car; |
| 18 | |
Aarthi Balachander | a709600 | 2018-05-21 18:12:25 -0700 | [diff] [blame] | 19 | import static android.content.DialogInterface.BUTTON_NEGATIVE; |
Aarthi Balachander | 0e0e921 | 2018-04-19 19:25:33 -0700 | [diff] [blame] | 20 | import static android.content.DialogInterface.BUTTON_POSITIVE; |
| 21 | |
| 22 | import android.app.AlertDialog; |
| 23 | import android.app.AlertDialog.Builder; |
| 24 | import android.app.Dialog; |
Aarthi Balachander | d8bf249 | 2018-03-30 11:15:59 -0700 | [diff] [blame] | 25 | import android.content.Context; |
Aarthi Balachander | 0e0e921 | 2018-04-19 19:25:33 -0700 | [diff] [blame] | 26 | import android.content.DialogInterface; |
Aarthi Balachander | d8bf249 | 2018-03-30 11:15:59 -0700 | [diff] [blame] | 27 | import android.content.pm.UserInfo; |
| 28 | import android.content.res.Resources; |
jovanak | e4ce3cc | 2018-04-19 12:17:12 -0700 | [diff] [blame] | 29 | import android.graphics.Bitmap; |
Aarthi Balachander | d8bf249 | 2018-03-30 11:15:59 -0700 | [diff] [blame] | 30 | import android.os.AsyncTask; |
jovanak | e4ce3cc | 2018-04-19 12:17:12 -0700 | [diff] [blame] | 31 | import android.os.UserHandle; |
Aarthi Balachander | d8bf249 | 2018-03-30 11:15:59 -0700 | [diff] [blame] | 32 | import android.util.AttributeSet; |
| 33 | import android.view.LayoutInflater; |
| 34 | import android.view.View; |
| 35 | import android.view.ViewGroup; |
| 36 | import android.widget.ImageView; |
| 37 | import android.widget.TextView; |
| 38 | |
Aarthi Balachander | 608b6e3 | 2018-04-11 18:41:52 -0700 | [diff] [blame] | 39 | import androidx.car.widget.PagedListView; |
Aarthi Balachander | e3110e4 | 2018-04-30 18:16:26 -0700 | [diff] [blame] | 40 | import androidx.core.graphics.drawable.RoundedBitmapDrawable; |
| 41 | import androidx.core.graphics.drawable.RoundedBitmapDrawableFactory; |
Aarthi Balachander | a709600 | 2018-05-21 18:12:25 -0700 | [diff] [blame] | 42 | import androidx.recyclerview.widget.RecyclerView; |
| 43 | |
jovanak | e4ce3cc | 2018-04-19 12:17:12 -0700 | [diff] [blame] | 44 | import com.android.internal.util.UserIcons; |
Colin Cross | f83b306 | 2018-08-15 07:06:05 +0000 | [diff] [blame^] | 45 | import com.android.settingslib.users.UserManagerHelper; |
Aarthi Balachander | d8bf249 | 2018-03-30 11:15:59 -0700 | [diff] [blame] | 46 | import com.android.systemui.R; |
Aarthi Balachander | d8bf249 | 2018-03-30 11:15:59 -0700 | [diff] [blame] | 47 | |
Aarthi Balachander | 0e0e921 | 2018-04-19 19:25:33 -0700 | [diff] [blame] | 48 | import com.android.systemui.statusbar.phone.SystemUIDialog; |
Aarthi Balachander | d8bf249 | 2018-03-30 11:15:59 -0700 | [diff] [blame] | 49 | import java.util.ArrayList; |
| 50 | import java.util.List; |
| 51 | |
| 52 | /** |
| 53 | * Displays a GridLayout with icons for the users in the system to allow switching between users. |
| 54 | * One of the uses of this is for the lock screen in auto. |
| 55 | */ |
Aarthi Balachander | 608b6e3 | 2018-04-11 18:41:52 -0700 | [diff] [blame] | 56 | public class UserGridRecyclerView extends PagedListView implements |
Colin Cross | f83b306 | 2018-08-15 07:06:05 +0000 | [diff] [blame^] | 57 | UserManagerHelper.OnUsersUpdateListener { |
Aarthi Balachander | d8bf249 | 2018-03-30 11:15:59 -0700 | [diff] [blame] | 58 | private UserSelectionListener mUserSelectionListener; |
| 59 | private UserAdapter mAdapter; |
Colin Cross | f83b306 | 2018-08-15 07:06:05 +0000 | [diff] [blame^] | 60 | private UserManagerHelper mUserManagerHelper; |
Aarthi Balachander | d8bf249 | 2018-03-30 11:15:59 -0700 | [diff] [blame] | 61 | private Context mContext; |
| 62 | |
| 63 | public UserGridRecyclerView(Context context, AttributeSet attrs) { |
| 64 | super(context, attrs); |
Aarthi Balachander | d8bf249 | 2018-03-30 11:15:59 -0700 | [diff] [blame] | 65 | mContext = context; |
Colin Cross | f83b306 | 2018-08-15 07:06:05 +0000 | [diff] [blame^] | 66 | mUserManagerHelper = new UserManagerHelper(mContext); |
Aarthi Balachander | d8bf249 | 2018-03-30 11:15:59 -0700 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | /** |
| 70 | * Register listener for any update to the users |
| 71 | */ |
| 72 | @Override |
| 73 | public void onFinishInflate() { |
Aarthi Balachander | 608b6e3 | 2018-04-11 18:41:52 -0700 | [diff] [blame] | 74 | super.onFinishInflate(); |
Colin Cross | f83b306 | 2018-08-15 07:06:05 +0000 | [diff] [blame^] | 75 | mUserManagerHelper.registerOnUsersUpdateListener(this); |
Aarthi Balachander | d8bf249 | 2018-03-30 11:15:59 -0700 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | /** |
| 79 | * Unregisters listener checking for any change to the users |
| 80 | */ |
| 81 | @Override |
| 82 | public void onDetachedFromWindow() { |
Aarthi Balachander | 608b6e3 | 2018-04-11 18:41:52 -0700 | [diff] [blame] | 83 | super.onDetachedFromWindow(); |
Colin Cross | f83b306 | 2018-08-15 07:06:05 +0000 | [diff] [blame^] | 84 | mUserManagerHelper.unregisterOnUsersUpdateListener(); |
Aarthi Balachander | d8bf249 | 2018-03-30 11:15:59 -0700 | [diff] [blame] | 85 | } |
| 86 | |
| 87 | /** |
| 88 | * Initializes the adapter that populates the grid layout |
| 89 | * |
| 90 | * @return the adapter |
| 91 | */ |
| 92 | public void buildAdapter() { |
Colin Cross | f83b306 | 2018-08-15 07:06:05 +0000 | [diff] [blame^] | 93 | List<UserRecord> userRecords = createUserRecords(mUserManagerHelper |
Aarthi Balachander | d8bf249 | 2018-03-30 11:15:59 -0700 | [diff] [blame] | 94 | .getAllUsers()); |
| 95 | mAdapter = new UserAdapter(mContext, userRecords); |
| 96 | super.setAdapter(mAdapter); |
| 97 | } |
| 98 | |
Aarthi Balachander | d8bf249 | 2018-03-30 11:15:59 -0700 | [diff] [blame] | 99 | private List<UserRecord> createUserRecords(List<UserInfo> userInfoList) { |
| 100 | List<UserRecord> userRecords = new ArrayList<>(); |
| 101 | for (UserInfo userInfo : userInfoList) { |
jovanak | 80b4859 | 2018-04-11 17:09:53 -0700 | [diff] [blame] | 102 | if (userInfo.isGuest()) { |
| 103 | // Don't display guests in the switcher. |
| 104 | continue; |
| 105 | } |
Colin Cross | f83b306 | 2018-08-15 07:06:05 +0000 | [diff] [blame^] | 106 | boolean isForeground = mUserManagerHelper.getForegroundUserId() == userInfo.id; |
jovanak | 80b4859 | 2018-04-11 17:09:53 -0700 | [diff] [blame] | 107 | UserRecord record = new UserRecord(userInfo, false /* isStartGuestSession */, |
jovanak | 0535abc | 2018-04-10 15:14:50 -0700 | [diff] [blame] | 108 | false /* isAddUser */, isForeground); |
Aarthi Balachander | d8bf249 | 2018-03-30 11:15:59 -0700 | [diff] [blame] | 109 | userRecords.add(record); |
| 110 | } |
| 111 | |
jovanak | 2d26ae3 | 2018-07-31 10:44:41 -0700 | [diff] [blame] | 112 | // Add button for starting guest session. |
| 113 | userRecords.add(createStartGuestUserRecord()); |
Aarthi Balachander | d8bf249 | 2018-03-30 11:15:59 -0700 | [diff] [blame] | 114 | |
jovanak | 0535abc | 2018-04-10 15:14:50 -0700 | [diff] [blame] | 115 | // Add add user record if the foreground user can add users |
Colin Cross | f83b306 | 2018-08-15 07:06:05 +0000 | [diff] [blame^] | 116 | if (mUserManagerHelper.foregroundUserCanAddUsers()) { |
jovanak | 2d26ae3 | 2018-07-31 10:44:41 -0700 | [diff] [blame] | 117 | userRecords.add(createAddUserRecord()); |
Aarthi Balachander | d8bf249 | 2018-03-30 11:15:59 -0700 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | return userRecords; |
| 121 | } |
| 122 | |
| 123 | /** |
| 124 | * Create guest user record |
| 125 | */ |
jovanak | 2d26ae3 | 2018-07-31 10:44:41 -0700 | [diff] [blame] | 126 | private UserRecord createStartGuestUserRecord() { |
Aarthi Balachander | d8bf249 | 2018-03-30 11:15:59 -0700 | [diff] [blame] | 127 | UserInfo userInfo = new UserInfo(); |
jovanak | 2d26ae3 | 2018-07-31 10:44:41 -0700 | [diff] [blame] | 128 | userInfo.name = mContext.getString(R.string.start_guest_session); |
| 129 | return new UserRecord(userInfo, true /* isStartGuestSession */, false /* isAddUser */, |
| 130 | false /* isForeground */); |
Aarthi Balachander | d8bf249 | 2018-03-30 11:15:59 -0700 | [diff] [blame] | 131 | } |
| 132 | |
| 133 | /** |
| 134 | * Create add user record |
| 135 | */ |
jovanak | 2d26ae3 | 2018-07-31 10:44:41 -0700 | [diff] [blame] | 136 | private UserRecord createAddUserRecord() { |
Aarthi Balachander | d8bf249 | 2018-03-30 11:15:59 -0700 | [diff] [blame] | 137 | UserInfo userInfo = new UserInfo(); |
| 138 | userInfo.name = mContext.getString(R.string.car_add_user); |
jovanak | 80b4859 | 2018-04-11 17:09:53 -0700 | [diff] [blame] | 139 | return new UserRecord(userInfo, false /* isStartGuestSession */, |
jovanak | 0535abc | 2018-04-10 15:14:50 -0700 | [diff] [blame] | 140 | true /* isAddUser */, false /* isForeground */); |
Aarthi Balachander | d8bf249 | 2018-03-30 11:15:59 -0700 | [diff] [blame] | 141 | } |
| 142 | |
| 143 | public void setUserSelectionListener(UserSelectionListener userSelectionListener) { |
| 144 | mUserSelectionListener = userSelectionListener; |
| 145 | } |
| 146 | |
Aarthi Balachander | d8bf249 | 2018-03-30 11:15:59 -0700 | [diff] [blame] | 147 | @Override |
| 148 | public void onUsersUpdate() { |
| 149 | mAdapter.clearUsers(); |
Colin Cross | f83b306 | 2018-08-15 07:06:05 +0000 | [diff] [blame^] | 150 | mAdapter.updateUsers(createUserRecords(mUserManagerHelper.getAllUsers())); |
Aarthi Balachander | d8bf249 | 2018-03-30 11:15:59 -0700 | [diff] [blame] | 151 | mAdapter.notifyDataSetChanged(); |
| 152 | } |
| 153 | |
| 154 | /** |
| 155 | * Adapter to populate the grid layout with the available user profiles |
| 156 | */ |
Aarthi Balachander | 0e0e921 | 2018-04-19 19:25:33 -0700 | [diff] [blame] | 157 | public final class UserAdapter extends RecyclerView.Adapter<UserAdapter.UserAdapterViewHolder> |
| 158 | implements Dialog.OnClickListener { |
Aarthi Balachander | d8bf249 | 2018-03-30 11:15:59 -0700 | [diff] [blame] | 159 | |
| 160 | private final Context mContext; |
| 161 | private List<UserRecord> mUsers; |
Aarthi Balachander | d8bf249 | 2018-03-30 11:15:59 -0700 | [diff] [blame] | 162 | private final Resources mRes; |
| 163 | private final String mGuestName; |
| 164 | private final String mNewUserName; |
Aarthi Balachander | 0e0e921 | 2018-04-19 19:25:33 -0700 | [diff] [blame] | 165 | private AlertDialog mDialog; |
| 166 | // View that holds the add user button. Used to enable/disable the view |
| 167 | private View mAddUserView; |
Aarthi Balachander | a709600 | 2018-05-21 18:12:25 -0700 | [diff] [blame] | 168 | // User record for the add user. Need to call notifyUserSelected only if the user |
| 169 | // confirms adding a user |
| 170 | private UserRecord mAddUserRecord; |
Aarthi Balachander | d8bf249 | 2018-03-30 11:15:59 -0700 | [diff] [blame] | 171 | |
| 172 | public UserAdapter(Context context, List<UserRecord> users) { |
| 173 | mRes = context.getResources(); |
| 174 | mContext = context; |
| 175 | updateUsers(users); |
Aarthi Balachander | d8bf249 | 2018-03-30 11:15:59 -0700 | [diff] [blame] | 176 | mGuestName = mRes.getString(R.string.car_guest); |
| 177 | mNewUserName = mRes.getString(R.string.car_new_user); |
| 178 | } |
| 179 | |
| 180 | public void clearUsers() { |
| 181 | mUsers.clear(); |
| 182 | } |
| 183 | |
| 184 | public void updateUsers(List<UserRecord> users) { |
| 185 | mUsers = users; |
| 186 | } |
| 187 | |
| 188 | @Override |
| 189 | public UserAdapterViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { |
| 190 | View view = LayoutInflater.from(mContext) |
| 191 | .inflate(R.layout.car_fullscreen_user_pod, parent, false); |
| 192 | view.setAlpha(1f); |
| 193 | view.bringToFront(); |
| 194 | return new UserAdapterViewHolder(view); |
| 195 | } |
| 196 | |
| 197 | @Override |
| 198 | public void onBindViewHolder(UserAdapterViewHolder holder, int position) { |
| 199 | UserRecord userRecord = mUsers.get(position); |
Aarthi Balachander | e3110e4 | 2018-04-30 18:16:26 -0700 | [diff] [blame] | 200 | RoundedBitmapDrawable circleIcon = RoundedBitmapDrawableFactory.create(mRes, |
| 201 | getUserRecordIcon(userRecord)); |
| 202 | circleIcon.setCircular(true); |
| 203 | holder.mUserAvatarImageView.setImageDrawable(circleIcon); |
Aarthi Balachander | d8bf249 | 2018-03-30 11:15:59 -0700 | [diff] [blame] | 204 | holder.mUserNameTextView.setText(userRecord.mInfo.name); |
Aarthi Balachander | a709600 | 2018-05-21 18:12:25 -0700 | [diff] [blame] | 205 | |
Aarthi Balachander | d8bf249 | 2018-03-30 11:15:59 -0700 | [diff] [blame] | 206 | holder.mView.setOnClickListener(v -> { |
| 207 | if (userRecord == null) { |
| 208 | return; |
| 209 | } |
| 210 | |
jovanak | 80b4859 | 2018-04-11 17:09:53 -0700 | [diff] [blame] | 211 | if (userRecord.mIsStartGuestSession) { |
Aarthi Balachander | a709600 | 2018-05-21 18:12:25 -0700 | [diff] [blame] | 212 | notifyUserSelected(userRecord); |
Colin Cross | f83b306 | 2018-08-15 07:06:05 +0000 | [diff] [blame^] | 213 | mUserManagerHelper.startNewGuestSession(mGuestName); |
Aarthi Balachander | d8bf249 | 2018-03-30 11:15:59 -0700 | [diff] [blame] | 214 | return; |
| 215 | } |
| 216 | |
Aarthi Balachander | 0e0e921 | 2018-04-19 19:25:33 -0700 | [diff] [blame] | 217 | // If the user wants to add a user, show dialog to confirm adding a user |
Aarthi Balachander | d8bf249 | 2018-03-30 11:15:59 -0700 | [diff] [blame] | 218 | if (userRecord.mIsAddUser) { |
Aarthi Balachander | 0e0e921 | 2018-04-19 19:25:33 -0700 | [diff] [blame] | 219 | // Disable button so it cannot be clicked multiple times |
| 220 | mAddUserView = holder.mView; |
| 221 | mAddUserView.setEnabled(false); |
| 222 | |
| 223 | String message = mRes.getString(R.string.user_add_user_message_setup) |
| 224 | .concat(System.getProperty("line.separator")) |
| 225 | .concat(System.getProperty("line.separator")) |
| 226 | .concat(mRes.getString(R.string.user_add_user_message_update)); |
| 227 | |
Aarthi Balachander | a709600 | 2018-05-21 18:12:25 -0700 | [diff] [blame] | 228 | mAddUserRecord = userRecord; |
Aarthi Balachander | 0e0e921 | 2018-04-19 19:25:33 -0700 | [diff] [blame] | 229 | mDialog = new Builder(mContext, R.style.Theme_Car_Dark_Dialog_Alert) |
| 230 | .setTitle(R.string.user_add_user_title) |
| 231 | .setMessage(message) |
| 232 | .setNegativeButton(android.R.string.cancel, this) |
| 233 | .setPositiveButton(android.R.string.ok, this) |
| 234 | .create(); |
| 235 | // Sets window flags for the SysUI dialog |
| 236 | SystemUIDialog.applyFlags(mDialog); |
| 237 | mDialog.show(); |
Aarthi Balachander | d8bf249 | 2018-03-30 11:15:59 -0700 | [diff] [blame] | 238 | return; |
| 239 | } |
Aarthi Balachander | d8bf249 | 2018-03-30 11:15:59 -0700 | [diff] [blame] | 240 | // If the user doesn't want to be a guest or add a user, switch to the user selected |
Aarthi Balachander | a709600 | 2018-05-21 18:12:25 -0700 | [diff] [blame] | 241 | notifyUserSelected(userRecord); |
Colin Cross | f83b306 | 2018-08-15 07:06:05 +0000 | [diff] [blame^] | 242 | mUserManagerHelper.switchToUser(userRecord.mInfo); |
Aarthi Balachander | d8bf249 | 2018-03-30 11:15:59 -0700 | [diff] [blame] | 243 | }); |
| 244 | |
| 245 | } |
| 246 | |
Aarthi Balachander | a709600 | 2018-05-21 18:12:25 -0700 | [diff] [blame] | 247 | private void notifyUserSelected(UserRecord userRecord) { |
| 248 | // Notify the listener which user was selected |
| 249 | if (mUserSelectionListener != null) { |
| 250 | mUserSelectionListener.onUserSelected(userRecord); |
| 251 | } |
| 252 | } |
| 253 | |
jovanak | e4ce3cc | 2018-04-19 12:17:12 -0700 | [diff] [blame] | 254 | private Bitmap getUserRecordIcon(UserRecord userRecord) { |
| 255 | if (userRecord.mIsStartGuestSession) { |
Colin Cross | f83b306 | 2018-08-15 07:06:05 +0000 | [diff] [blame^] | 256 | return mUserManagerHelper.getGuestDefaultIcon(); |
jovanak | e4ce3cc | 2018-04-19 12:17:12 -0700 | [diff] [blame] | 257 | } |
| 258 | |
| 259 | if (userRecord.mIsAddUser) { |
| 260 | return UserIcons.convertToBitmap(mContext |
Aarthi Balachander | 0e0e921 | 2018-04-19 19:25:33 -0700 | [diff] [blame] | 261 | .getDrawable(R.drawable.car_add_circle_round)); |
jovanak | e4ce3cc | 2018-04-19 12:17:12 -0700 | [diff] [blame] | 262 | } |
| 263 | |
Colin Cross | f83b306 | 2018-08-15 07:06:05 +0000 | [diff] [blame^] | 264 | return mUserManagerHelper.getUserIcon(userRecord.mInfo); |
jovanak | e4ce3cc | 2018-04-19 12:17:12 -0700 | [diff] [blame] | 265 | } |
| 266 | |
Aarthi Balachander | 0e0e921 | 2018-04-19 19:25:33 -0700 | [diff] [blame] | 267 | @Override |
| 268 | public void onClick(DialogInterface dialog, int which) { |
Aarthi Balachander | 0e0e921 | 2018-04-19 19:25:33 -0700 | [diff] [blame] | 269 | if (which == BUTTON_POSITIVE) { |
Aarthi Balachander | a709600 | 2018-05-21 18:12:25 -0700 | [diff] [blame] | 270 | notifyUserSelected(mAddUserRecord); |
Aarthi Balachander | 0e0e921 | 2018-04-19 19:25:33 -0700 | [diff] [blame] | 271 | new AddNewUserTask().execute(mNewUserName); |
Aarthi Balachander | a709600 | 2018-05-21 18:12:25 -0700 | [diff] [blame] | 272 | } else if (which == BUTTON_NEGATIVE) { |
| 273 | // Enable the add button only if cancel |
| 274 | if (mAddUserView != null) { |
| 275 | mAddUserView.setEnabled(true); |
| 276 | } |
Aarthi Balachander | 0e0e921 | 2018-04-19 19:25:33 -0700 | [diff] [blame] | 277 | } |
| 278 | } |
| 279 | |
Aarthi Balachander | d8bf249 | 2018-03-30 11:15:59 -0700 | [diff] [blame] | 280 | private class AddNewUserTask extends AsyncTask<String, Void, UserInfo> { |
| 281 | |
| 282 | @Override |
| 283 | protected UserInfo doInBackground(String... userNames) { |
Colin Cross | f83b306 | 2018-08-15 07:06:05 +0000 | [diff] [blame^] | 284 | return mUserManagerHelper.createNewUser(userNames[0]); |
Aarthi Balachander | d8bf249 | 2018-03-30 11:15:59 -0700 | [diff] [blame] | 285 | } |
| 286 | |
| 287 | @Override |
| 288 | protected void onPreExecute() { |
| 289 | } |
| 290 | |
| 291 | @Override |
| 292 | protected void onPostExecute(UserInfo user) { |
| 293 | if (user != null) { |
Colin Cross | f83b306 | 2018-08-15 07:06:05 +0000 | [diff] [blame^] | 294 | mUserManagerHelper.switchToUser(user); |
Aarthi Balachander | d8bf249 | 2018-03-30 11:15:59 -0700 | [diff] [blame] | 295 | } |
| 296 | } |
| 297 | } |
| 298 | |
| 299 | @Override |
| 300 | public int getItemCount() { |
| 301 | return mUsers.size(); |
| 302 | } |
| 303 | |
Aarthi Balachander | d8bf249 | 2018-03-30 11:15:59 -0700 | [diff] [blame] | 304 | public class UserAdapterViewHolder extends RecyclerView.ViewHolder { |
| 305 | |
| 306 | public ImageView mUserAvatarImageView; |
| 307 | public TextView mUserNameTextView; |
| 308 | public View mView; |
| 309 | |
| 310 | public UserAdapterViewHolder(View view) { |
| 311 | super(view); |
| 312 | mView = view; |
| 313 | mUserAvatarImageView = (ImageView) view.findViewById(R.id.user_avatar); |
| 314 | mUserNameTextView = (TextView) view.findViewById(R.id.user_name); |
| 315 | } |
| 316 | } |
| 317 | } |
| 318 | |
| 319 | /** |
| 320 | * Object wrapper class for the userInfo. Use it to distinguish if a profile is a |
jovanak | 0535abc | 2018-04-10 15:14:50 -0700 | [diff] [blame] | 321 | * guest profile, add user profile, or the foreground user. |
Aarthi Balachander | d8bf249 | 2018-03-30 11:15:59 -0700 | [diff] [blame] | 322 | */ |
| 323 | public static final class UserRecord { |
| 324 | |
| 325 | public final UserInfo mInfo; |
jovanak | 80b4859 | 2018-04-11 17:09:53 -0700 | [diff] [blame] | 326 | public final boolean mIsStartGuestSession; |
Aarthi Balachander | d8bf249 | 2018-03-30 11:15:59 -0700 | [diff] [blame] | 327 | public final boolean mIsAddUser; |
jovanak | 0535abc | 2018-04-10 15:14:50 -0700 | [diff] [blame] | 328 | public final boolean mIsForeground; |
Aarthi Balachander | d8bf249 | 2018-03-30 11:15:59 -0700 | [diff] [blame] | 329 | |
jovanak | 80b4859 | 2018-04-11 17:09:53 -0700 | [diff] [blame] | 330 | public UserRecord(UserInfo userInfo, boolean isStartGuestSession, boolean isAddUser, |
jovanak | 0535abc | 2018-04-10 15:14:50 -0700 | [diff] [blame] | 331 | boolean isForeground) { |
Aarthi Balachander | d8bf249 | 2018-03-30 11:15:59 -0700 | [diff] [blame] | 332 | mInfo = userInfo; |
jovanak | 80b4859 | 2018-04-11 17:09:53 -0700 | [diff] [blame] | 333 | mIsStartGuestSession = isStartGuestSession; |
Aarthi Balachander | d8bf249 | 2018-03-30 11:15:59 -0700 | [diff] [blame] | 334 | mIsAddUser = isAddUser; |
jovanak | 0535abc | 2018-04-10 15:14:50 -0700 | [diff] [blame] | 335 | mIsForeground = isForeground; |
Aarthi Balachander | d8bf249 | 2018-03-30 11:15:59 -0700 | [diff] [blame] | 336 | } |
| 337 | } |
| 338 | |
| 339 | /** |
| 340 | * Listener used to notify when a user has been selected |
| 341 | */ |
| 342 | interface UserSelectionListener { |
| 343 | |
| 344 | void onUserSelected(UserRecord record); |
| 345 | } |
| 346 | } |