Merge "DO NOT MERGE - Defer migration to CarUserManagerHelper, until CarSysUI" into pi-dev
am: 330713b381
Change-Id: I16ae2912f0650a9712bd6e0dd8dd1986537c9050
This commit is contained in:
@@ -18,13 +18,13 @@ package com.android.systemui.statusbar.car;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.car.user.CarUserManagerHelper;
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.view.ViewStub;
|
||||
|
||||
import android.support.v7.widget.GridLayoutManager;
|
||||
|
||||
import com.android.settingslib.users.UserManagerHelper;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.statusbar.phone.StatusBar;
|
||||
|
||||
@@ -37,7 +37,7 @@ public class FullscreenUserSwitcher {
|
||||
private final UserGridRecyclerView mUserGridView;
|
||||
private final int mShortAnimDuration;
|
||||
private final StatusBar mStatusBar;
|
||||
private final CarUserManagerHelper mCarUserManagerHelper;
|
||||
private final UserManagerHelper mUserManagerHelper;
|
||||
private int mCurrentForegroundUserId;
|
||||
private boolean mShowing;
|
||||
|
||||
@@ -52,7 +52,7 @@ public class FullscreenUserSwitcher {
|
||||
mUserGridView.buildAdapter();
|
||||
mUserGridView.setUserSelectionListener(this::onUserSelected);
|
||||
|
||||
mCarUserManagerHelper = new CarUserManagerHelper(context);
|
||||
mUserManagerHelper = new UserManagerHelper(context);
|
||||
updateCurrentForegroundUser();
|
||||
|
||||
mShortAnimDuration = mContainer.getResources()
|
||||
@@ -84,11 +84,11 @@ public class FullscreenUserSwitcher {
|
||||
}
|
||||
|
||||
private boolean foregroundUserChanged() {
|
||||
return mCurrentForegroundUserId != mCarUserManagerHelper.getCurrentForegroundUserId();
|
||||
return mCurrentForegroundUserId != mUserManagerHelper.getForegroundUserId();
|
||||
}
|
||||
|
||||
private void updateCurrentForegroundUser() {
|
||||
mCurrentForegroundUserId = mCarUserManagerHelper.getCurrentForegroundUserId();
|
||||
mCurrentForegroundUserId = mUserManagerHelper.getForegroundUserId();
|
||||
}
|
||||
|
||||
private void onUserSelected(UserGridRecyclerView.UserRecord record) {
|
||||
|
||||
@@ -21,7 +21,6 @@ import static android.content.DialogInterface.BUTTON_POSITIVE;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.AlertDialog.Builder;
|
||||
import android.app.Dialog;
|
||||
import android.car.user.CarUserManagerHelper;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.pm.UserInfo;
|
||||
@@ -42,6 +41,7 @@ import android.widget.TextView;
|
||||
import androidx.car.widget.PagedListView;
|
||||
|
||||
import com.android.internal.util.UserIcons;
|
||||
import com.android.settingslib.users.UserManagerHelper;
|
||||
import com.android.systemui.R;
|
||||
|
||||
import com.android.systemui.statusbar.phone.SystemUIDialog;
|
||||
@@ -53,16 +53,16 @@ import java.util.List;
|
||||
* One of the uses of this is for the lock screen in auto.
|
||||
*/
|
||||
public class UserGridRecyclerView extends PagedListView implements
|
||||
CarUserManagerHelper.OnUsersUpdateListener {
|
||||
UserManagerHelper.OnUsersUpdateListener {
|
||||
private UserSelectionListener mUserSelectionListener;
|
||||
private UserAdapter mAdapter;
|
||||
private CarUserManagerHelper mCarUserManagerHelper;
|
||||
private UserManagerHelper mUserManagerHelper;
|
||||
private Context mContext;
|
||||
|
||||
public UserGridRecyclerView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
mContext = context;
|
||||
mCarUserManagerHelper = new CarUserManagerHelper(mContext);
|
||||
mUserManagerHelper = new UserManagerHelper(mContext);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,7 +71,7 @@ public class UserGridRecyclerView extends PagedListView implements
|
||||
@Override
|
||||
public void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
mCarUserManagerHelper.registerOnUsersUpdateListener(this);
|
||||
mUserManagerHelper.registerOnUsersUpdateListener(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,7 +80,7 @@ public class UserGridRecyclerView extends PagedListView implements
|
||||
@Override
|
||||
public void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
mCarUserManagerHelper.unregisterOnUsersUpdateListener();
|
||||
mUserManagerHelper.unregisterOnUsersUpdateListener();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -89,8 +89,8 @@ public class UserGridRecyclerView extends PagedListView implements
|
||||
* @return the adapter
|
||||
*/
|
||||
public void buildAdapter() {
|
||||
List<UserRecord> userRecords = createUserRecords(mCarUserManagerHelper
|
||||
.getAllUsers());
|
||||
List<UserRecord> userRecords = createUserRecords(mUserManagerHelper
|
||||
.getAllUsersExcludesSystemUser());
|
||||
mAdapter = new UserAdapter(mContext, userRecords);
|
||||
super.setAdapter(mAdapter);
|
||||
}
|
||||
@@ -103,19 +103,19 @@ public class UserGridRecyclerView extends PagedListView implements
|
||||
continue;
|
||||
}
|
||||
boolean isForeground =
|
||||
mCarUserManagerHelper.getCurrentForegroundUserId() == userInfo.id;
|
||||
mUserManagerHelper.getForegroundUserId() == userInfo.id;
|
||||
UserRecord record = new UserRecord(userInfo, false /* isStartGuestSession */,
|
||||
false /* isAddUser */, isForeground);
|
||||
userRecords.add(record);
|
||||
}
|
||||
|
||||
// Add guest user record if the foreground user is not a guest
|
||||
if (!mCarUserManagerHelper.isForegroundUserGuest()) {
|
||||
if (!mUserManagerHelper.foregroundUserIsGuestUser()) {
|
||||
userRecords.add(addGuestUserRecord());
|
||||
}
|
||||
|
||||
// Add add user record if the foreground user can add users
|
||||
if (mCarUserManagerHelper.canForegroundUserAddUsers()) {
|
||||
if (mUserManagerHelper.foregroundUserCanAddUsers()) {
|
||||
userRecords.add(addUserRecord());
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ public class UserGridRecyclerView extends PagedListView implements
|
||||
@Override
|
||||
public void onUsersUpdate() {
|
||||
mAdapter.clearUsers();
|
||||
mAdapter.updateUsers(createUserRecords(mCarUserManagerHelper.getAllUsers()));
|
||||
mAdapter.updateUsers(createUserRecords(mUserManagerHelper.getAllUsersExcludesSystemUser()));
|
||||
mAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@@ -213,7 +213,7 @@ public class UserGridRecyclerView extends PagedListView implements
|
||||
|
||||
// If the user selects Guest, start the guest session.
|
||||
if (userRecord.mIsStartGuestSession) {
|
||||
mCarUserManagerHelper.startNewGuestSession(mGuestName);
|
||||
mUserManagerHelper.startNewGuestSession(mGuestName);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -240,14 +240,14 @@ public class UserGridRecyclerView extends PagedListView implements
|
||||
return;
|
||||
}
|
||||
// If the user doesn't want to be a guest or add a user, switch to the user selected
|
||||
mCarUserManagerHelper.switchToUser(userRecord.mInfo);
|
||||
mUserManagerHelper.switchToUser(userRecord.mInfo);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private Bitmap getUserRecordIcon(UserRecord userRecord) {
|
||||
if (userRecord.mIsStartGuestSession) {
|
||||
return mCarUserManagerHelper.getGuestDefaultIcon();
|
||||
return mUserManagerHelper.getGuestDefaultIcon();
|
||||
}
|
||||
|
||||
if (userRecord.mIsAddUser) {
|
||||
@@ -255,7 +255,7 @@ public class UserGridRecyclerView extends PagedListView implements
|
||||
.getDrawable(R.drawable.car_add_circle_round));
|
||||
}
|
||||
|
||||
return mCarUserManagerHelper.getUserIcon(userRecord.mInfo);
|
||||
return mUserManagerHelper.getUserIcon(userRecord.mInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -273,10 +273,7 @@ public class UserGridRecyclerView extends PagedListView implements
|
||||
|
||||
@Override
|
||||
protected UserInfo doInBackground(String... userNames) {
|
||||
// Default to create a non admin user for now. Need to add logic
|
||||
// for user to choose whether they want to create an admin or non-admin
|
||||
// user later.
|
||||
return mCarUserManagerHelper.createNewNonAdminUser(userNames[0]);
|
||||
return mUserManagerHelper.createNewUser(userNames[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -286,7 +283,7 @@ public class UserGridRecyclerView extends PagedListView implements
|
||||
@Override
|
||||
protected void onPostExecute(UserInfo user) {
|
||||
if (user != null) {
|
||||
mCarUserManagerHelper.switchToUser(user);
|
||||
mUserManagerHelper.switchToUser(user);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user