Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4a0371bb authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "DO NOT MERGE Fix bug when pressing the add user cancel button results...

Merge "DO NOT MERGE Fix bug when pressing the add user cancel button results in a black screen Test: Tested on Mojave Bug: 80187163 Change-Id: Ie46c228dea9de71b97a276f7e4f2d60fe98649b6" into pi-dev
parents 3116918b 47fe2d28
Loading
Loading
Loading
Loading
+2 −4
Original line number Original line Diff line number Diff line
@@ -23,15 +23,13 @@
    android:layout_height="wrap_content"
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    android:layout_width="match_parent"
    android:orientation="vertical"
    android:orientation="vertical"
    android:gravity="center"
    android:gravity="center">
    >


    <ImageView android:id="@+id/user_avatar"
    <ImageView android:id="@+id/user_avatar"
        android:layout_width="@dimen/car_user_switcher_image_avatar_size"
        android:layout_width="@dimen/car_user_switcher_image_avatar_size"
        android:layout_height="@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:background="@drawable/car_button_ripple_background_inverse"
        android:gravity="center"
        android:gravity="center"/>
        />


    <TextView android:id="@+id/user_name"
    <TextView android:id="@+id/user_name"
        android:layout_width="match_parent"
        android:layout_width="match_parent"
+1 −0
Original line number Original line Diff line number Diff line
@@ -37,6 +37,7 @@
            android:id="@+id/user_grid"
            android:id="@+id/user_grid"
            android:layout_width="match_parent"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_height="match_parent"
            android:layout_marginTop="@dimen/car_user_switcher_margin_top"
            app:verticallyCenterListContent="true"
            app:verticallyCenterListContent="true"
            app:dayNightStyle="force_night"
            app:dayNightStyle="force_night"
            app:showPagedListViewDivider="false"
            app:showPagedListViewDivider="false"
+1 −0
Original line number Original line Diff line number Diff line
@@ -21,6 +21,7 @@
    <dimen name="car_user_switcher_image_avatar_size">@dimen/car_large_avatar_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_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_user_switcher_vertical_spacing_between_name_and_avatar">@dimen/car_padding_4</dimen>
    <dimen name="car_user_switcher_margin_top">@dimen/car_padding_4</dimen>


    <dimen name="car_navigation_button_width">64dp</dimen>
    <dimen name="car_navigation_button_width">64dp</dimen>
    <dimen name="car_navigation_bar_width">760dp</dimen>
    <dimen name="car_navigation_bar_width">760dp</dimen>
+21 −9
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@


package com.android.systemui.statusbar.car;
package com.android.systemui.statusbar.car;


import static android.content.DialogInterface.BUTTON_NEGATIVE;
import static android.content.DialogInterface.BUTTON_POSITIVE;
import static android.content.DialogInterface.BUTTON_POSITIVE;


import android.app.AlertDialog;
import android.app.AlertDialog;
@@ -27,7 +28,6 @@ import android.content.pm.UserInfo;
import android.content.res.Resources;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Bitmap;
import android.os.AsyncTask;
import android.os.AsyncTask;
import android.os.UserHandle;
import android.support.v4.graphics.drawable.RoundedBitmapDrawable;
import android.support.v4.graphics.drawable.RoundedBitmapDrawable;
import android.support.v4.graphics.drawable.RoundedBitmapDrawableFactory;
import android.support.v4.graphics.drawable.RoundedBitmapDrawableFactory;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView;
@@ -167,6 +167,9 @@ public class UserGridRecyclerView extends PagedListView implements
        private AlertDialog mDialog;
        private AlertDialog mDialog;
        // View that holds the add user button.  Used to enable/disable the view
        // View that holds the add user button.  Used to enable/disable the view
        private View mAddUserView;
        private View mAddUserView;
        // User record for the add user.  Need to call notifyUserSelected only if the user
        // confirms adding a user
        private UserRecord mAddUserRecord;


        public UserAdapter(Context context, List<UserRecord> users) {
        public UserAdapter(Context context, List<UserRecord> users) {
            mRes = context.getResources();
            mRes = context.getResources();
@@ -201,18 +204,16 @@ public class UserGridRecyclerView extends PagedListView implements
            circleIcon.setCircular(true);
            circleIcon.setCircular(true);
            holder.mUserAvatarImageView.setImageDrawable(circleIcon);
            holder.mUserAvatarImageView.setImageDrawable(circleIcon);
            holder.mUserNameTextView.setText(userRecord.mInfo.name);
            holder.mUserNameTextView.setText(userRecord.mInfo.name);

            holder.mView.setOnClickListener(v -> {
            holder.mView.setOnClickListener(v -> {
                if (userRecord == null) {
                if (userRecord == null) {
                    return;
                    return;
                }
                }


                // Notify the listener which user was selected
                if (mUserSelectionListener != null) {
                    mUserSelectionListener.onUserSelected(userRecord);
                }


                // If the user selects Guest, start the guest session.
                // If the user selects Guest, start the guest session.
                if (userRecord.mIsStartGuestSession) {
                if (userRecord.mIsStartGuestSession) {
                    notifyUserSelected(userRecord);
                    mUserManagerHelper.startNewGuestSession(mGuestName);
                    mUserManagerHelper.startNewGuestSession(mGuestName);
                    return;
                    return;
                }
                }
@@ -228,6 +229,7 @@ public class UserGridRecyclerView extends PagedListView implements
                        .concat(System.getProperty("line.separator"))
                        .concat(System.getProperty("line.separator"))
                        .concat(mRes.getString(R.string.user_add_user_message_update));
                        .concat(mRes.getString(R.string.user_add_user_message_update));


                    mAddUserRecord = userRecord;
                    mDialog = new Builder(mContext, R.style.Theme_Car_Dark_Dialog_Alert)
                    mDialog = new Builder(mContext, R.style.Theme_Car_Dark_Dialog_Alert)
                        .setTitle(R.string.user_add_user_title)
                        .setTitle(R.string.user_add_user_title)
                        .setMessage(message)
                        .setMessage(message)
@@ -240,11 +242,19 @@ public class UserGridRecyclerView extends PagedListView implements
                    return;
                    return;
                }
                }
                // If the user doesn't want to be a guest or add a user, switch to the user selected
                // If the user doesn't want to be a guest or add a user, switch to the user selected
                notifyUserSelected(userRecord);
                mUserManagerHelper.switchToUser(userRecord.mInfo);
                mUserManagerHelper.switchToUser(userRecord.mInfo);
            });
            });


        }
        }


        private void notifyUserSelected(UserRecord userRecord) {
            // Notify the listener which user was selected
            if (mUserSelectionListener != null) {
                mUserSelectionListener.onUserSelected(userRecord);
            }
        }

        private Bitmap getUserRecordIcon(UserRecord userRecord) {
        private Bitmap getUserRecordIcon(UserRecord userRecord) {
            if (userRecord.mIsStartGuestSession) {
            if (userRecord.mIsStartGuestSession) {
                return mUserManagerHelper.getGuestDefaultIcon();
                return mUserManagerHelper.getGuestDefaultIcon();
@@ -260,12 +270,14 @@ public class UserGridRecyclerView extends PagedListView implements


        @Override
        @Override
        public void onClick(DialogInterface dialog, int which) {
        public void onClick(DialogInterface dialog, int which) {
            // Enable the add button
            if (which == BUTTON_POSITIVE) {
                notifyUserSelected(mAddUserRecord);
                new AddNewUserTask().execute(mNewUserName);
            } else if (which == BUTTON_NEGATIVE) {
                // Enable the add button only if cancel
                if (mAddUserView != null) {
                if (mAddUserView != null) {
                    mAddUserView.setEnabled(true);
                    mAddUserView.setEnabled(true);
                }
                }
            if (which == BUTTON_POSITIVE) {
                new AddNewUserTask().execute(mNewUserName);
            }
            }
        }
        }