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

Commit 1a634d32 authored by Amith Yamasani's avatar Amith Yamasani
Browse files

Bring up new user setup dialog when tapping on new user

Bug: 7245796

Also fix a few strings that changed and other UI tweaks to conform
to spec document.

Change-Id: If4409459b20ec8c8ece69b6c23c8ab49b0ca0cac
parent bfb5fa9e
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -35,7 +35,5 @@
        android:src="@drawable/ic_menu_delete_holo_dark"
        android:contentDescription="@string/user_delete_user_description"
        android:layout_gravity="center"
        android:clickable="true"
        android:focusable="true"
        android:background="?android:attr/selectableItemBackground" />
</LinearLayout>
+13 −3
Original line number Diff line number Diff line
@@ -4283,9 +4283,13 @@
    <string name="user_setup_button_setup_now">Set up now</string>
    <!-- Button text to setup the new user later [CHAR LIMIT=25] -->
    <string name="user_setup_button_setup_later">Not now</string>
    <!-- Message to secondary users that only owner can manage users [CHAR LIMIT=none] -->
    <string name="user_cannot_manage_message" product="tablet">Only the tablet\'s owner can manage users.</string>
    <!-- Message to secondary users that only owner can manage users [CHAR LIMIT=none] -->
    <string name="user_cannot_manage_message" product="default">Only the phone\'s owner can manage users.</string>

    <!-- User details remove user menu [CHAR LIMIT=20] -->
    <string name="user_remove_user_menu">Remove user</string>
    <string name="user_remove_user_menu">Delete <xliff:g id="user_name">%1$s</xliff:g> from this device</string>
    <!-- User details new user name [CHAR LIMIT=30] -->
    <string name="user_new_user_name">New user</string>
    <!-- User (self) removal confirmation title [CHAR LIMIT=30] -->
@@ -4293,13 +4297,19 @@
    <!-- User removal confirmation title [CHAR LIMIT=25] -->
    <string name="user_confirm_remove_title">Remove user?</string>
    <!-- User (self) removal confirmation message [CHAR LIMIT=none] -->
    <string name="user_confirm_remove_self_message">You will lose your space and data on this delete. Are you sure you want to remove the user and all associated data from the device?</string>
    <string name="user_confirm_remove_self_message" product="tablet">You will lose your space and data on this tablet. You can\'t undo this action.</string>
    <!-- User (self) removal confirmation message [CHAR LIMIT=none] -->
    <string name="user_confirm_remove_self_message" product="default">You will lose your space and data on this phone. You can\'t undo this action.</string>
    <!-- User removal confirmation message [CHAR LIMIT=none] -->
    <string name="user_confirm_remove_message" product="tablet">This user\'s space and data will disappear from this tablet. You can\'t undo this action.</string>
    <!-- User removal confirmation message [CHAR LIMIT=none] -->
    <string name="user_confirm_remove_message">Are you sure you want to remove the user and all associated data from the device?</string>
    <string name="user_confirm_remove_message" product="default">This user\'s space and data will disappear from this phone. You can\'t undo this action.</string>
    <!-- Setting label to show that a new user is being added [CHAR LIMIT=30] -->
    <string name="user_adding_new_user">Adding new user\u2026</string>
    <!-- Spoken content description for delete icon beside a user [CHAR LIMIT=none] -->
    <string name="user_delete_user_description">Delete user</string>
    <!-- Delete button text [CHAR LIMIT=25] -->
    <string name="user_delete_button">Delete</string>

    <!-- Warning message when changing a global setting for a tablet.[CHAR LIMIT=none] -->
    <string name="global_change_warning" product="tablet">This setting affects all users on this tablet.</string>
+0 −2
Original line number Diff line number Diff line
@@ -50,8 +50,6 @@ public class UserPreference extends Preference {

    @Override
    protected void onBindView(View view) {
        view.setClickable(true);
        view.setFocusable(true);
        View deleteView = view.findViewById(R.id.trash_user);
        if (deleteView != null) {
            deleteView.setOnClickListener(mDeleteClickListener);
+33 −5
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import android.os.RemoteException;
import android.os.UserHandle;
import android.os.UserManager;
import android.preference.Preference;
import android.preference.PreferenceScreen;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceGroup;
import android.provider.ContactsContract;
@@ -75,6 +76,7 @@ public class UserSettings extends SettingsPreferenceFragment
    private static final int DIALOG_CONFIRM_REMOVE = 1;
    private static final int DIALOG_ADD_USER = 2;
    private static final int DIALOG_SETUP_USER = 3;
    private static final int DIALOG_USER_CANNOT_MANAGE = 4;

    private static final int MESSAGE_UPDATE_LIST = 1;
    private static final int MESSAGE_SETUP_USER = 2;
@@ -179,9 +181,10 @@ public class UserSettings extends SettingsPreferenceFragment
                        | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
            }
        } else {
            MenuItem removeThisUser = menu.add(0, MENU_REMOVE_USER, 0, R.string.user_remove_user_menu);
            removeThisUser.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM
                    | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
            String nickname = mUserManager.getUserName();
            MenuItem removeThisUser = menu.add(0, MENU_REMOVE_USER, 0,
                    getResources().getString(R.string.user_remove_user_menu, nickname));
            removeThisUser.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
        }
        super.onCreateOptionsMenu(menu, inflater);
    }
@@ -266,7 +269,7 @@ public class UserSettings extends SettingsPreferenceFragment
                    .setMessage(UserHandle.myUserId() == mRemovingUserId
                            ? R.string.user_confirm_remove_self_message
                            : R.string.user_confirm_remove_message)
                    .setPositiveButton(android.R.string.ok,
                    .setPositiveButton(R.string.user_delete_button,
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
                                removeUserNow();
@@ -274,6 +277,11 @@ public class UserSettings extends SettingsPreferenceFragment
                    })
                    .setNegativeButton(android.R.string.cancel, null)
                    .create();
            case DIALOG_USER_CANNOT_MANAGE:
                return new AlertDialog.Builder(getActivity())
                    .setMessage(R.string.user_cannot_manage_message)
                    .setPositiveButton(android.R.string.ok, null)
                    .create();
            case DIALOG_ADD_USER:
                final SharedPreferences preferences = getActivity().getPreferences(
                        Context.MODE_PRIVATE);
@@ -385,7 +393,7 @@ public class UserSettings extends SettingsPreferenceFragment
                continue;
            } else if (user.id == UserHandle.myUserId()) {
                pref = mMePreference;
                mNicknamePreference.getEditText().setText(user.name);
                mNicknamePreference.setText(user.name);
                mNicknamePreference.setSummary(user.name);
            } else {
                pref = new UserPreference(getActivity(), null, user.id,
@@ -397,6 +405,9 @@ public class UserSettings extends SettingsPreferenceFragment
                    pref.setSummary(R.string.user_owner);
                }
                pref.setTitle(user.name);
                if (!isInitialized(user)) {
                    pref.setSummary(R.string.user_summary_not_set_up);
                }
            }
            if (user.iconPath != null) {
                if (mUserIcons.get(user.id) == null) {
@@ -475,6 +486,7 @@ public class UserSettings extends SettingsPreferenceFragment
    private void setUserName(String name) {
        mUserManager.setUserName(UserHandle.myUserId(), name);
        mNicknamePreference.setSummary(name);
        getActivity().invalidateOptionsMenu();
    }

    @Override
@@ -492,10 +504,26 @@ public class UserSettings extends SettingsPreferenceFragment
            // TODO: Make this a proper API
            editProfile.putExtra("finishActivityOnSaveCompleted", true);
            startActivity(editProfile);
        } else if (pref instanceof UserPreference) {
            int userId = ((UserPreference) pref).getUserId();
            // Get the latest status of the user
            UserInfo user = mUserManager.getUserInfo(userId);
            if (UserHandle.myUserId() != UserHandle.USER_OWNER) {
                showDialog(DIALOG_USER_CANNOT_MANAGE);
            } else {
                if (!isInitialized(user)) {
                    mHandler.sendMessage(mHandler.obtainMessage(
                            MESSAGE_SETUP_USER, user.id, user.serialNumber));
                }
            }
        }
        return false;
    }

    private boolean isInitialized(UserInfo user) {
        return (user.flags & UserInfo.FLAG_INITIALIZED) != 0;
    }

    @Override
    public void onClick(View v) {
        if (v.getTag() instanceof UserPreference) {