Loading packages/CarSystemUI/src/com/android/systemui/statusbar/car/UserGridRecyclerView.java +35 −6 Original line number Diff line number Diff line Loading @@ -23,13 +23,17 @@ import android.app.AlertDialog; import android.app.AlertDialog.Builder; import android.app.Dialog; import android.car.userlib.CarUserManagerHelper; import android.content.BroadcastReceiver; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.IntentFilter; import android.content.pm.UserInfo; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.Rect; import android.os.AsyncTask; import android.os.UserHandle; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; Loading @@ -53,13 +57,19 @@ import java.util.List; * Displays a GridLayout with icons for the users in the system to allow switching between users. * One of the uses of this is for the lock screen in auto. */ public class UserGridRecyclerView extends RecyclerView implements CarUserManagerHelper.OnUsersUpdateListener { public class UserGridRecyclerView extends RecyclerView { private UserSelectionListener mUserSelectionListener; private UserAdapter mAdapter; private CarUserManagerHelper mCarUserManagerHelper; private Context mContext; private final BroadcastReceiver mUserUpdateReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { onUsersUpdate(); } }; public UserGridRecyclerView(Context context, AttributeSet attrs) { super(context, attrs); mContext = context; Loading @@ -75,7 +85,7 @@ public class UserGridRecyclerView extends RecyclerView implements @Override public void onFinishInflate() { super.onFinishInflate(); mCarUserManagerHelper.registerOnUsersUpdateListener(this); registerForUserEvents(); } /** Loading @@ -84,7 +94,7 @@ public class UserGridRecyclerView extends RecyclerView implements @Override public void onDetachedFromWindow() { super.onDetachedFromWindow(); mCarUserManagerHelper.unregisterOnUsersUpdateListener(this); unregisterForUserEvents(); } /** Loading Loading @@ -161,13 +171,32 @@ public class UserGridRecyclerView extends RecyclerView implements mUserSelectionListener = userSelectionListener; } @Override public void onUsersUpdate() { private void onUsersUpdate() { mAdapter.clearUsers(); mAdapter.updateUsers(createUserRecords(mCarUserManagerHelper.getAllUsers())); mAdapter.notifyDataSetChanged(); } private void registerForUserEvents() { IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_USER_REMOVED); filter.addAction(Intent.ACTION_USER_ADDED); filter.addAction(Intent.ACTION_USER_INFO_CHANGED); filter.addAction(Intent.ACTION_USER_SWITCHED); filter.addAction(Intent.ACTION_USER_STOPPED); filter.addAction(Intent.ACTION_USER_UNLOCKED); mContext.registerReceiverAsUser( mUserUpdateReceiver, UserHandle.ALL, filter, /* broadcastPermission= */ null, /* scheduler= */ null); } private void unregisterForUserEvents() { mContext.unregisterReceiver(mUserUpdateReceiver); } /** * Adapter to populate the grid layout with the available user profiles */ Loading Loading
packages/CarSystemUI/src/com/android/systemui/statusbar/car/UserGridRecyclerView.java +35 −6 Original line number Diff line number Diff line Loading @@ -23,13 +23,17 @@ import android.app.AlertDialog; import android.app.AlertDialog.Builder; import android.app.Dialog; import android.car.userlib.CarUserManagerHelper; import android.content.BroadcastReceiver; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.IntentFilter; import android.content.pm.UserInfo; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.Rect; import android.os.AsyncTask; import android.os.UserHandle; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; Loading @@ -53,13 +57,19 @@ import java.util.List; * Displays a GridLayout with icons for the users in the system to allow switching between users. * One of the uses of this is for the lock screen in auto. */ public class UserGridRecyclerView extends RecyclerView implements CarUserManagerHelper.OnUsersUpdateListener { public class UserGridRecyclerView extends RecyclerView { private UserSelectionListener mUserSelectionListener; private UserAdapter mAdapter; private CarUserManagerHelper mCarUserManagerHelper; private Context mContext; private final BroadcastReceiver mUserUpdateReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { onUsersUpdate(); } }; public UserGridRecyclerView(Context context, AttributeSet attrs) { super(context, attrs); mContext = context; Loading @@ -75,7 +85,7 @@ public class UserGridRecyclerView extends RecyclerView implements @Override public void onFinishInflate() { super.onFinishInflate(); mCarUserManagerHelper.registerOnUsersUpdateListener(this); registerForUserEvents(); } /** Loading @@ -84,7 +94,7 @@ public class UserGridRecyclerView extends RecyclerView implements @Override public void onDetachedFromWindow() { super.onDetachedFromWindow(); mCarUserManagerHelper.unregisterOnUsersUpdateListener(this); unregisterForUserEvents(); } /** Loading Loading @@ -161,13 +171,32 @@ public class UserGridRecyclerView extends RecyclerView implements mUserSelectionListener = userSelectionListener; } @Override public void onUsersUpdate() { private void onUsersUpdate() { mAdapter.clearUsers(); mAdapter.updateUsers(createUserRecords(mCarUserManagerHelper.getAllUsers())); mAdapter.notifyDataSetChanged(); } private void registerForUserEvents() { IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_USER_REMOVED); filter.addAction(Intent.ACTION_USER_ADDED); filter.addAction(Intent.ACTION_USER_INFO_CHANGED); filter.addAction(Intent.ACTION_USER_SWITCHED); filter.addAction(Intent.ACTION_USER_STOPPED); filter.addAction(Intent.ACTION_USER_UNLOCKED); mContext.registerReceiverAsUser( mUserUpdateReceiver, UserHandle.ALL, filter, /* broadcastPermission= */ null, /* scheduler= */ null); } private void unregisterForUserEvents() { mContext.unregisterReceiver(mUserUpdateReceiver); } /** * Adapter to populate the grid layout with the available user profiles */ Loading