Loading res/layout/preference_user_delete_widget.xml +4 −4 Original line number Diff line number Diff line Loading @@ -31,8 +31,8 @@ android:id="@+id/manage_user" android:layout_width="wrap_content" android:layout_height="fill_parent" android:paddingStart="12dip" android:paddingEnd="12dip" android:paddingStart="16dip" android:paddingEnd="16dip" android:src="@drawable/ic_sysbar_quicksettings" android:contentDescription="@string/user_delete_user_description" android:layout_gravity="center" Loading @@ -48,8 +48,8 @@ android:id="@+id/trash_user" android:layout_width="wrap_content" android:layout_height="fill_parent" android:paddingStart="12dip" android:paddingEnd="12dip" android:paddingStart="16dip" android:paddingEnd="16dip" android:src="@drawable/ic_menu_delete_holo_dark" android:contentDescription="@string/user_delete_user_description" android:layout_gravity="center" Loading res/layout/two_line_list_item.xml 0 → 100644 +41 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2013 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="?android:attr/listPreferredItemHeight" android:paddingStart="16dip" android:paddingEnd="16dip" android:paddingTop="8dip" android:paddingBottom="8dip"> <TextView android:id="@+id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:singleLine="true" android:textAppearance="?android:attr/textAppearanceMedium" android:ellipsize="marquee" android:fadingEdge="horizontal"/> <TextView android:id="@+id/summary" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/title" android:layout_alignStart="@id/title" android:textAppearance="?android:attr/textAppearanceSmall" android:textColor="?android:attr/textColorSecondary" android:maxLines="4" /> </RelativeLayout> res/values/strings.xml +23 −24 Original line number Diff line number Diff line Loading @@ -4322,37 +4322,32 @@ <!-- User settings screen title [CHAR LIMIT=25] --> <string name="user_settings_title">Users</string> <!-- User settings section title for details about you [CHAR LIMIT=25] --> <string name="user_you_section">You</string> <!-- User settings trusted user list section header [CHAR LIMIT=40] --> <string name="user_trusted_list_title">Users</string> <!-- User settings limited user list section header [CHAR LIMIT=40] --> <string name="user_limited_list_title">Limited users</string> <!-- User settings header for list of users and profiles [CHAR LIMIT=40] --> <string name="user_list_title">Users & profiles</string> <!-- User settings add user menu [CHAR LIMIT=35] --> <string name="user_add_user_menu">Add user</string> <!-- User settings add restricted user label [CHAR LIMIT=35] --> <string name="user_add_restricted">Add limited user</string> <!-- User settings summary for add restricted user [CHAR LIMIT=100] --> <string name="user_add_restricted_summary">Limited users can only access the apps and content you select</string> <!-- User settings add user label [CHAR LIMIT=35] --> <string name="user_add_trusted">Add standard user</string> <!-- User settings summary for add trusted user [CHAR LIMIT=100] --> <string name="user_add_trusted_summary">Standard users have their own apps and content</string> <!-- User summary to indicate that user is currently active in the background [CHAR LIMIT=100] --> <string name="user_summary_active">Active</string> <!-- User summary to indicate that user is currently inactive in the background [CHAR LIMIT=100] --> <string name="user_summary_inactive">Not active</string> <string name="user_add_user_menu">Add user or profile</string> <!-- User settings summary for a restricted profile [CHAR LIMIT=50] --> <string name="user_summary_restricted_profile">Restricted profile</string> <!-- User summary to indicate that user is currently not set up [CHAR LIMIT=100] --> <string name="user_summary_not_set_up">Not set up</string> <!-- Summary text for a trusted user [CHAR LIMIT=50] --> <string name="user_trusted">Trusted</string> <!-- Summary text for a limited user [CHAR LIMIT=50] --> <string name="user_limited">Limited</string> <!-- User summary to indicate that restricted profile is currently not set up [CHAR LIMIT=100] --> <string name="user_summary_restricted_not_set_up">Not set up - Restricted profile</string> <!-- User information string to represent the owner of the device [CHAR LIMIT=25] --> <string name="user_owner">Owner</string> <!-- User settings title for current user entry "You" user. [CHAR LIMIT=30] --> <string name="user_you">You (<xliff:g id="name" example="Name">%s</xliff:g>)</string> <!-- Title for the preference to enter the nickname of the userto display in the user switcher [CHAR LIMIT=25]--> <string name="user_nickname">Nickname</string> <!-- Title for add user type dialog [CHAR LIMIT=45] --> <string name="user_add_user_type_title">Add</string> <!-- Summary for add user entry in the choice dialog [CHAR LIMIT=none] --> <string name="user_add_user_item_summary">Users have their own apps and content</string> <!-- Summary for add restricted profile entry in the choice dialog [CHAR LIMIT=none] --> <string name="user_add_profile_item_summary">Restricted profiles can only access the apps and content from your accounts</string> <!-- Button text for adding a regular user [CHAR LIMIT=25] --> <string name="user_add_user_item_title">User</string> <!-- Button text for adding a restricted profile [CHAR LIMIT=25] --> <string name="user_add_profile_item_title">Restricted profile</string> <!-- Title for add user confirmation dialog [CHAR LIMIT=30] --> <string name="user_add_user_title">Add new user</string> <!-- Message for add user confirmation dialog - long version. [CHAR LIMIT=none] --> Loading @@ -4363,6 +4358,8 @@ <string name="user_setup_dialog_title">Set up user now?</string> <!-- Message in dialog to setup a new user after creation [CHAR LIMIT=none] --> <string name="user_setup_dialog_message">Make sure the person is available to take the tablet and set up their space</string> <!-- Message in dialog to setup a new restricted profile after creation [CHAR LIMIT=none] --> <string name="user_setup_profile_dialog_message">Set up profile now?</string> <!-- Button text to setup the new user now [CHAR LIMIT=25] --> <string name="user_setup_button_setup_now">Set up now</string> <!-- Button text to setup the new user later [CHAR LIMIT=25] --> Loading @@ -4378,6 +4375,8 @@ <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 details new restricted profile name [CHAR LIMIT=30] --> <string name="user_new_profile_name">New profile</string> <!-- User (self) removal confirmation title [CHAR LIMIT=30] --> <string name="user_confirm_remove_self_title">Delete yourself?</string> <!-- User removal confirmation title [CHAR LIMIT=25] --> Loading res/xml/user_settings.xml +4 −16 Original line number Diff line number Diff line Loading @@ -19,25 +19,13 @@ android:title="@string/user_settings_title"> <PreferenceCategory android:key="trusted_user_list" android:title="@string/user_trusted_list_title"> android:key="user_list" android:title="@string/user_list_title"> </PreferenceCategory> <Preference android:key="user_add_trusted" android:title="@string/user_add_trusted" android:summary="@string/user_add_trusted_summary" android:icon="@drawable/ic_menu_add" /> <PreferenceCategory android:key="limited_user_list" android:title="@string/user_limited_list_title"> </PreferenceCategory> <Preference android:key="user_add_restricted" android:title="@string/user_add_restricted" android:summary="@string/user_add_restricted_summary" android:key="user_add" android:title="@string/user_add_user_menu" android:icon="@drawable/ic_menu_add" /> </PreferenceScreen> src/com/android/settings/users/UserSettings.java +119 −88 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.widget.SimpleAdapter; import com.android.settings.OwnerInfoSettings; import com.android.settings.R; Loading @@ -61,7 +62,9 @@ import com.android.settings.SettingsPreferenceFragment; import com.android.settings.Utils; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; public class UserSettings extends SettingsPreferenceFragment implements OnPreferenceClickListener, OnClickListener, DialogInterface.OnDismissListener, Loading @@ -74,26 +77,25 @@ public class UserSettings extends SettingsPreferenceFragment /** UserId of the user that was just added */ private static final String SAVE_ADDING_USER = "adding_user"; private static final String KEY_TRUSTED_USER_LIST = "trusted_user_list"; private static final String KEY_LIMITED_USER_LIST = "limited_user_list"; private static final String KEY_USER_LIST = "user_list"; private static final String KEY_USER_ME = "user_me"; private static final String KEY_ADD_RESTRICTED_USER = "user_add_restricted"; private static final String KEY_ADD_TRUSTED_USER = "user_add_trusted"; private static final String KEY_ADD_USER = "user_add"; private static final int MENU_REMOVE_USER = Menu.FIRST; private static final int DIALOG_CONFIRM_REMOVE = 1; private static final int DIALOG_ADD_USER_TRUSTED = 2; private static final int DIALOG_ADD_USER_LIMITED = 3; private static final int DIALOG_SETUP_USER = 4; private static final int DIALOG_ADD_USER = 2; private static final int DIALOG_SETUP_USER = 3; private static final int DIALOG_SETUP_PROFILE = 4; private static final int DIALOG_USER_CANNOT_MANAGE = 5; private static final int DIALOG_CHOOSE_USER_TYPE = 6; private static final int MESSAGE_UPDATE_LIST = 1; private static final int MESSAGE_SETUP_USER = 2; private static final int MESSAGE_CONFIG_USER = 3; private static final int USER_TYPE_TRUSTED = 1; private static final int USER_TYPE_LIMITED = 2; private static final int USER_TYPE_USER = 1; private static final int USER_TYPE_RESTRICTED_PROFILE = 2; private static final String KEY_ADD_USER_LONG_MESSAGE_DISPLAYED = "key_add_user_long_message_displayed"; Loading @@ -109,12 +111,13 @@ public class UserSettings extends SettingsPreferenceFragment R.drawable.avatar_default_8 }; private PreferenceGroup mTrustedUserListCategory; private PreferenceGroup mLimitedUserListCategory; private static final String KEY_TITLE = "title"; private static final String KEY_SUMMARY = "summary"; private PreferenceGroup mUserListCategory; private Preference mMePreference; private SelectableEditTextPreference mNicknamePreference; private Preference mAddRestrictedUser; private Preference mAddTrustedUser; private Preference mAddUser; private int mRemovingUserId = -1; private int mAddedUserId = 0; private boolean mAddingUser; Loading Loading @@ -173,8 +176,7 @@ public class UserSettings extends SettingsPreferenceFragment mUserManager = (UserManager) getActivity().getSystemService(Context.USER_SERVICE); addPreferencesFromResource(R.xml.user_settings); mTrustedUserListCategory = (PreferenceGroup) findPreference(KEY_TRUSTED_USER_LIST); mLimitedUserListCategory = (PreferenceGroup) findPreference(KEY_LIMITED_USER_LIST); mUserListCategory = (PreferenceGroup) findPreference(KEY_USER_LIST); mMePreference = new UserPreference(getActivity(), null, UserHandle.myUserId(), mUserManager.isLinkedUser() ? null : this, null); mMePreference.setKey(KEY_USER_ME); Loading @@ -182,13 +184,10 @@ public class UserSettings extends SettingsPreferenceFragment if (mIsOwner) { mMePreference.setSummary(R.string.user_owner); } mAddRestrictedUser = findPreference(KEY_ADD_RESTRICTED_USER); mAddTrustedUser = findPreference(KEY_ADD_TRUSTED_USER); mAddRestrictedUser.setOnPreferenceClickListener(this); mAddTrustedUser.setOnPreferenceClickListener(this); mAddUser = findPreference(KEY_ADD_USER); mAddUser.setOnPreferenceClickListener(this); if (!mIsOwner || UserManager.getMaxSupportedUsers() < 2) { removePreference(KEY_ADD_RESTRICTED_USER); removePreference(KEY_ADD_TRUSTED_USER); removePreference(KEY_ADD_USER); } loadProfile(); setHasOptionsMenu(true); Loading Loading @@ -266,7 +265,8 @@ public class UserSettings extends SettingsPreferenceFragment } private void finishLoadProfile(String profileName) { mMePreference.setTitle(profileName); if (getActivity() == null) return; mMePreference.setTitle(getString(R.string.user_you, profileName)); int myUserId = UserHandle.myUserId(); Bitmap b = mUserManager.getUserIcon(myUserId); if (b != null) { Loading @@ -279,11 +279,11 @@ public class UserSettings extends SettingsPreferenceFragment synchronized (mUserLock) { if (mRemovingUserId == -1 && !mAddingUser) { switch (userType) { case USER_TYPE_TRUSTED: showDialog(DIALOG_ADD_USER_TRUSTED); case USER_TYPE_USER: showDialog(DIALOG_ADD_USER); break; case USER_TYPE_LIMITED: showDialog(DIALOG_ADD_USER_LIMITED); case USER_TYPE_RESTRICTED_PROFILE: addUserNow(USER_TYPE_RESTRICTED_PROFILE); break; } } Loading @@ -301,7 +301,7 @@ public class UserSettings extends SettingsPreferenceFragment private UserInfo createLimitedUser() { UserInfo newUserInfo = mUserManager.createUser( getResources().getString(R.string.user_new_user_name), getResources().getString(R.string.user_new_profile_name), UserInfo.FLAG_RESTRICTED); int userId = newUserInfo.id; UserHandle user = new UserHandle(userId); Loading @@ -326,7 +326,7 @@ public class UserSettings extends SettingsPreferenceFragment private UserInfo createTrustedUser() { UserInfo newUserInfo = mUserManager.createUser( getActivity().getResources().getString(R.string.user_new_user_name), 0); getResources().getString(R.string.user_new_user_name), 0); if (newUserInfo != null) { assignDefaultPhoto(newUserInfo); } Loading Loading @@ -360,8 +360,12 @@ public class UserSettings extends SettingsPreferenceFragment private void onUserCreated(int userId) { mAddedUserId = userId; if (mUserManager.getUserInfo(userId).isRestricted()) { showDialog(DIALOG_SETUP_PROFILE); } else { showDialog(DIALOG_SETUP_USER); } } @Override public void onDialogShowing() { Loading @@ -372,6 +376,8 @@ public class UserSettings extends SettingsPreferenceFragment @Override public Dialog onCreateDialog(int dialogId) { Context context = getActivity(); if (context == null) return null; switch (dialogId) { case DIALOG_CONFIRM_REMOVE: { Dialog dlg = new AlertDialog.Builder(getActivity()) Loading @@ -392,12 +398,11 @@ public class UserSettings extends SettingsPreferenceFragment return dlg; } case DIALOG_USER_CANNOT_MANAGE: return new AlertDialog.Builder(getActivity()) return new AlertDialog.Builder(context) .setMessage(R.string.user_cannot_manage_message) .setPositiveButton(android.R.string.ok, null) .create(); case DIALOG_ADD_USER_TRUSTED: case DIALOG_ADD_USER_LIMITED: { case DIALOG_ADD_USER: { final SharedPreferences preferences = getActivity().getPreferences( Context.MODE_PRIVATE); final boolean longMessageDisplayed = preferences.getBoolean( Loading @@ -405,9 +410,9 @@ public class UserSettings extends SettingsPreferenceFragment final int messageResId = longMessageDisplayed ? R.string.user_add_user_message_short : R.string.user_add_user_message_long; final int userType = dialogId == DIALOG_ADD_USER_TRUSTED ? USER_TYPE_TRUSTED : USER_TYPE_LIMITED; Dialog dlg = new AlertDialog.Builder(getActivity()) final int userType = dialogId == DIALOG_ADD_USER ? USER_TYPE_USER : USER_TYPE_RESTRICTED_PROFILE; Dialog dlg = new AlertDialog.Builder(context) .setTitle(R.string.user_add_user_title) .setMessage(messageResId) .setPositiveButton(android.R.string.ok, Loading @@ -415,8 +420,8 @@ public class UserSettings extends SettingsPreferenceFragment public void onClick(DialogInterface dialog, int which) { addUserNow(userType); if (!longMessageDisplayed) { preferences.edit().putBoolean(KEY_ADD_USER_LONG_MESSAGE_DISPLAYED, true).commit(); preferences.edit().putBoolean( KEY_ADD_USER_LONG_MESSAGE_DISPLAYED, true).apply(); } } }) Loading @@ -425,7 +430,7 @@ public class UserSettings extends SettingsPreferenceFragment return dlg; } case DIALOG_SETUP_USER: { Dialog dlg = new AlertDialog.Builder(getActivity()) Dialog dlg = new AlertDialog.Builder(context) .setTitle(R.string.user_setup_dialog_title) .setMessage(R.string.user_setup_dialog_message) .setPositiveButton(R.string.user_setup_button_setup_now, Loading @@ -438,6 +443,44 @@ public class UserSettings extends SettingsPreferenceFragment .create(); return dlg; } case DIALOG_SETUP_PROFILE: { Dialog dlg = new AlertDialog.Builder(context) .setMessage(R.string.user_setup_profile_dialog_message) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { switchUserNow(mAddedUserId); } }) .setNegativeButton(android.R.string.cancel, null) .create(); return dlg; } case DIALOG_CHOOSE_USER_TYPE: { List<HashMap<String, String>> data = new ArrayList<HashMap<String,String>>(); HashMap<String,String> addUserItem = new HashMap<String,String>(); addUserItem.put(KEY_TITLE, getString(R.string.user_add_user_item_title)); addUserItem.put(KEY_SUMMARY, getString(R.string.user_add_user_item_summary)); HashMap<String,String> addProfileItem = new HashMap<String,String>(); addProfileItem.put(KEY_TITLE, getString(R.string.user_add_profile_item_title)); addProfileItem.put(KEY_SUMMARY, getString(R.string.user_add_profile_item_summary)); data.add(addUserItem); data.add(addProfileItem); Dialog dlg = new AlertDialog.Builder(context) .setTitle(R.string.user_add_user_type_title) .setAdapter(new SimpleAdapter(context, data, R.layout.two_line_list_item, new String[] {KEY_TITLE, KEY_SUMMARY}, new int[] {R.id.title, R.id.summary}), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { onAddUserClicked(which == 0 ? USER_TYPE_USER : USER_TYPE_RESTRICTED_PROFILE); } }) .create(); return dlg; } default: return null; } Loading Loading @@ -476,14 +519,14 @@ public class UserSettings extends SettingsPreferenceFragment public void run() { UserInfo user = null; // Could take a few seconds if (userType == USER_TYPE_TRUSTED) { if (userType == USER_TYPE_USER) { user = createTrustedUser(); } else { user = createLimitedUser(); } synchronized (mUserLock) { mAddingUser = false; if (userType == USER_TYPE_TRUSTED) { if (userType == USER_TYPE_USER) { mHandler.sendEmptyMessage(MESSAGE_UPDATE_LIST); mHandler.sendMessage(mHandler.obtainMessage( MESSAGE_SETUP_USER, user.id, user.serialNumber)); Loading @@ -509,12 +552,9 @@ public class UserSettings extends SettingsPreferenceFragment if (getActivity() == null) return; List<UserInfo> users = mUserManager.getUsers(true); mTrustedUserListCategory.removeAll(); mTrustedUserListCategory.setOrderingAsAdded(false); mLimitedUserListCategory.removeAll(); mLimitedUserListCategory.setOrderingAsAdded(false); mTrustedUserListCategory.addPreference(mMePreference); mUserListCategory.removeAll(); mUserListCategory.setOrderingAsAdded(false); mUserListCategory.addPreference(mMePreference); final ArrayList<Integer> missingIcons = new ArrayList<Integer>(); for (UserInfo user : users) { Loading @@ -527,18 +567,18 @@ public class UserSettings extends SettingsPreferenceFragment mIsOwner ? this : null); pref.setOnPreferenceClickListener(this); pref.setKey("id=" + user.id); if (user.isRestricted()) { mLimitedUserListCategory.addPreference(pref); } else { mTrustedUserListCategory.addPreference(pref); } mUserListCategory.addPreference(pref); if (user.id == UserHandle.USER_OWNER) { pref.setSummary(R.string.user_owner); } pref.setTitle(user.name); if (!isInitialized(user)) { pref.setSummary(R.string.user_summary_not_set_up); } if (!isInitialized(user)) { pref.setSummary(user.isRestricted() ? R.string.user_summary_restricted_not_set_up : R.string.user_summary_not_set_up); } else if (user.isRestricted()) { pref.setSummary(R.string.user_summary_restricted_profile); } if (user.iconPath != null) { if (mUserIcons.get(user.id) == null) { Loading @@ -556,7 +596,7 @@ public class UserSettings extends SettingsPreferenceFragment pref.setEnabled(false); pref.setTitle(R.string.user_new_user_name); pref.setIcon(encircle(R.drawable.avatar_default_1)); mTrustedUserListCategory.addPreference(pref); mUserListCategory.addPreference(pref); } getActivity().invalidateOptionsMenu(); Loading @@ -565,14 +605,7 @@ public class UserSettings extends SettingsPreferenceFragment loadIconsAsync(missingIcons); } boolean moreUsers = mUserManager.getMaxSupportedUsers() > users.size(); mAddRestrictedUser.setEnabled(moreUsers); mAddTrustedUser.setEnabled(moreUsers); // Remove the limited users category if there aren't other limited users. if (!mIsOwner) { if (mLimitedUserListCategory.getPreferenceCount() == 0) { removePreference(KEY_LIMITED_USER_LIST); } } mAddUser.setEnabled(moreUsers); } private void loadIconsAsync(List<Integer> missingIcons) { Loading Loading @@ -662,10 +695,8 @@ public class UserSettings extends SettingsPreferenceFragment onManageUserClicked(user.id, false); } } } else if (pref == mAddTrustedUser) { onAddUserClicked(USER_TYPE_TRUSTED); } else if (pref == mAddRestrictedUser) { onAddUserClicked(USER_TYPE_LIMITED); } else if (pref == mAddUser) { showDialog(DIALOG_CHOOSE_USER_TYPE); } return false; } Loading Loading
res/layout/preference_user_delete_widget.xml +4 −4 Original line number Diff line number Diff line Loading @@ -31,8 +31,8 @@ android:id="@+id/manage_user" android:layout_width="wrap_content" android:layout_height="fill_parent" android:paddingStart="12dip" android:paddingEnd="12dip" android:paddingStart="16dip" android:paddingEnd="16dip" android:src="@drawable/ic_sysbar_quicksettings" android:contentDescription="@string/user_delete_user_description" android:layout_gravity="center" Loading @@ -48,8 +48,8 @@ android:id="@+id/trash_user" android:layout_width="wrap_content" android:layout_height="fill_parent" android:paddingStart="12dip" android:paddingEnd="12dip" android:paddingStart="16dip" android:paddingEnd="16dip" android:src="@drawable/ic_menu_delete_holo_dark" android:contentDescription="@string/user_delete_user_description" android:layout_gravity="center" Loading
res/layout/two_line_list_item.xml 0 → 100644 +41 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2013 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="?android:attr/listPreferredItemHeight" android:paddingStart="16dip" android:paddingEnd="16dip" android:paddingTop="8dip" android:paddingBottom="8dip"> <TextView android:id="@+id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:singleLine="true" android:textAppearance="?android:attr/textAppearanceMedium" android:ellipsize="marquee" android:fadingEdge="horizontal"/> <TextView android:id="@+id/summary" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/title" android:layout_alignStart="@id/title" android:textAppearance="?android:attr/textAppearanceSmall" android:textColor="?android:attr/textColorSecondary" android:maxLines="4" /> </RelativeLayout>
res/values/strings.xml +23 −24 Original line number Diff line number Diff line Loading @@ -4322,37 +4322,32 @@ <!-- User settings screen title [CHAR LIMIT=25] --> <string name="user_settings_title">Users</string> <!-- User settings section title for details about you [CHAR LIMIT=25] --> <string name="user_you_section">You</string> <!-- User settings trusted user list section header [CHAR LIMIT=40] --> <string name="user_trusted_list_title">Users</string> <!-- User settings limited user list section header [CHAR LIMIT=40] --> <string name="user_limited_list_title">Limited users</string> <!-- User settings header for list of users and profiles [CHAR LIMIT=40] --> <string name="user_list_title">Users & profiles</string> <!-- User settings add user menu [CHAR LIMIT=35] --> <string name="user_add_user_menu">Add user</string> <!-- User settings add restricted user label [CHAR LIMIT=35] --> <string name="user_add_restricted">Add limited user</string> <!-- User settings summary for add restricted user [CHAR LIMIT=100] --> <string name="user_add_restricted_summary">Limited users can only access the apps and content you select</string> <!-- User settings add user label [CHAR LIMIT=35] --> <string name="user_add_trusted">Add standard user</string> <!-- User settings summary for add trusted user [CHAR LIMIT=100] --> <string name="user_add_trusted_summary">Standard users have their own apps and content</string> <!-- User summary to indicate that user is currently active in the background [CHAR LIMIT=100] --> <string name="user_summary_active">Active</string> <!-- User summary to indicate that user is currently inactive in the background [CHAR LIMIT=100] --> <string name="user_summary_inactive">Not active</string> <string name="user_add_user_menu">Add user or profile</string> <!-- User settings summary for a restricted profile [CHAR LIMIT=50] --> <string name="user_summary_restricted_profile">Restricted profile</string> <!-- User summary to indicate that user is currently not set up [CHAR LIMIT=100] --> <string name="user_summary_not_set_up">Not set up</string> <!-- Summary text for a trusted user [CHAR LIMIT=50] --> <string name="user_trusted">Trusted</string> <!-- Summary text for a limited user [CHAR LIMIT=50] --> <string name="user_limited">Limited</string> <!-- User summary to indicate that restricted profile is currently not set up [CHAR LIMIT=100] --> <string name="user_summary_restricted_not_set_up">Not set up - Restricted profile</string> <!-- User information string to represent the owner of the device [CHAR LIMIT=25] --> <string name="user_owner">Owner</string> <!-- User settings title for current user entry "You" user. [CHAR LIMIT=30] --> <string name="user_you">You (<xliff:g id="name" example="Name">%s</xliff:g>)</string> <!-- Title for the preference to enter the nickname of the userto display in the user switcher [CHAR LIMIT=25]--> <string name="user_nickname">Nickname</string> <!-- Title for add user type dialog [CHAR LIMIT=45] --> <string name="user_add_user_type_title">Add</string> <!-- Summary for add user entry in the choice dialog [CHAR LIMIT=none] --> <string name="user_add_user_item_summary">Users have their own apps and content</string> <!-- Summary for add restricted profile entry in the choice dialog [CHAR LIMIT=none] --> <string name="user_add_profile_item_summary">Restricted profiles can only access the apps and content from your accounts</string> <!-- Button text for adding a regular user [CHAR LIMIT=25] --> <string name="user_add_user_item_title">User</string> <!-- Button text for adding a restricted profile [CHAR LIMIT=25] --> <string name="user_add_profile_item_title">Restricted profile</string> <!-- Title for add user confirmation dialog [CHAR LIMIT=30] --> <string name="user_add_user_title">Add new user</string> <!-- Message for add user confirmation dialog - long version. [CHAR LIMIT=none] --> Loading @@ -4363,6 +4358,8 @@ <string name="user_setup_dialog_title">Set up user now?</string> <!-- Message in dialog to setup a new user after creation [CHAR LIMIT=none] --> <string name="user_setup_dialog_message">Make sure the person is available to take the tablet and set up their space</string> <!-- Message in dialog to setup a new restricted profile after creation [CHAR LIMIT=none] --> <string name="user_setup_profile_dialog_message">Set up profile now?</string> <!-- Button text to setup the new user now [CHAR LIMIT=25] --> <string name="user_setup_button_setup_now">Set up now</string> <!-- Button text to setup the new user later [CHAR LIMIT=25] --> Loading @@ -4378,6 +4375,8 @@ <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 details new restricted profile name [CHAR LIMIT=30] --> <string name="user_new_profile_name">New profile</string> <!-- User (self) removal confirmation title [CHAR LIMIT=30] --> <string name="user_confirm_remove_self_title">Delete yourself?</string> <!-- User removal confirmation title [CHAR LIMIT=25] --> Loading
res/xml/user_settings.xml +4 −16 Original line number Diff line number Diff line Loading @@ -19,25 +19,13 @@ android:title="@string/user_settings_title"> <PreferenceCategory android:key="trusted_user_list" android:title="@string/user_trusted_list_title"> android:key="user_list" android:title="@string/user_list_title"> </PreferenceCategory> <Preference android:key="user_add_trusted" android:title="@string/user_add_trusted" android:summary="@string/user_add_trusted_summary" android:icon="@drawable/ic_menu_add" /> <PreferenceCategory android:key="limited_user_list" android:title="@string/user_limited_list_title"> </PreferenceCategory> <Preference android:key="user_add_restricted" android:title="@string/user_add_restricted" android:summary="@string/user_add_restricted_summary" android:key="user_add" android:title="@string/user_add_user_menu" android:icon="@drawable/ic_menu_add" /> </PreferenceScreen>
src/com/android/settings/users/UserSettings.java +119 −88 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.widget.SimpleAdapter; import com.android.settings.OwnerInfoSettings; import com.android.settings.R; Loading @@ -61,7 +62,9 @@ import com.android.settings.SettingsPreferenceFragment; import com.android.settings.Utils; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; public class UserSettings extends SettingsPreferenceFragment implements OnPreferenceClickListener, OnClickListener, DialogInterface.OnDismissListener, Loading @@ -74,26 +77,25 @@ public class UserSettings extends SettingsPreferenceFragment /** UserId of the user that was just added */ private static final String SAVE_ADDING_USER = "adding_user"; private static final String KEY_TRUSTED_USER_LIST = "trusted_user_list"; private static final String KEY_LIMITED_USER_LIST = "limited_user_list"; private static final String KEY_USER_LIST = "user_list"; private static final String KEY_USER_ME = "user_me"; private static final String KEY_ADD_RESTRICTED_USER = "user_add_restricted"; private static final String KEY_ADD_TRUSTED_USER = "user_add_trusted"; private static final String KEY_ADD_USER = "user_add"; private static final int MENU_REMOVE_USER = Menu.FIRST; private static final int DIALOG_CONFIRM_REMOVE = 1; private static final int DIALOG_ADD_USER_TRUSTED = 2; private static final int DIALOG_ADD_USER_LIMITED = 3; private static final int DIALOG_SETUP_USER = 4; private static final int DIALOG_ADD_USER = 2; private static final int DIALOG_SETUP_USER = 3; private static final int DIALOG_SETUP_PROFILE = 4; private static final int DIALOG_USER_CANNOT_MANAGE = 5; private static final int DIALOG_CHOOSE_USER_TYPE = 6; private static final int MESSAGE_UPDATE_LIST = 1; private static final int MESSAGE_SETUP_USER = 2; private static final int MESSAGE_CONFIG_USER = 3; private static final int USER_TYPE_TRUSTED = 1; private static final int USER_TYPE_LIMITED = 2; private static final int USER_TYPE_USER = 1; private static final int USER_TYPE_RESTRICTED_PROFILE = 2; private static final String KEY_ADD_USER_LONG_MESSAGE_DISPLAYED = "key_add_user_long_message_displayed"; Loading @@ -109,12 +111,13 @@ public class UserSettings extends SettingsPreferenceFragment R.drawable.avatar_default_8 }; private PreferenceGroup mTrustedUserListCategory; private PreferenceGroup mLimitedUserListCategory; private static final String KEY_TITLE = "title"; private static final String KEY_SUMMARY = "summary"; private PreferenceGroup mUserListCategory; private Preference mMePreference; private SelectableEditTextPreference mNicknamePreference; private Preference mAddRestrictedUser; private Preference mAddTrustedUser; private Preference mAddUser; private int mRemovingUserId = -1; private int mAddedUserId = 0; private boolean mAddingUser; Loading Loading @@ -173,8 +176,7 @@ public class UserSettings extends SettingsPreferenceFragment mUserManager = (UserManager) getActivity().getSystemService(Context.USER_SERVICE); addPreferencesFromResource(R.xml.user_settings); mTrustedUserListCategory = (PreferenceGroup) findPreference(KEY_TRUSTED_USER_LIST); mLimitedUserListCategory = (PreferenceGroup) findPreference(KEY_LIMITED_USER_LIST); mUserListCategory = (PreferenceGroup) findPreference(KEY_USER_LIST); mMePreference = new UserPreference(getActivity(), null, UserHandle.myUserId(), mUserManager.isLinkedUser() ? null : this, null); mMePreference.setKey(KEY_USER_ME); Loading @@ -182,13 +184,10 @@ public class UserSettings extends SettingsPreferenceFragment if (mIsOwner) { mMePreference.setSummary(R.string.user_owner); } mAddRestrictedUser = findPreference(KEY_ADD_RESTRICTED_USER); mAddTrustedUser = findPreference(KEY_ADD_TRUSTED_USER); mAddRestrictedUser.setOnPreferenceClickListener(this); mAddTrustedUser.setOnPreferenceClickListener(this); mAddUser = findPreference(KEY_ADD_USER); mAddUser.setOnPreferenceClickListener(this); if (!mIsOwner || UserManager.getMaxSupportedUsers() < 2) { removePreference(KEY_ADD_RESTRICTED_USER); removePreference(KEY_ADD_TRUSTED_USER); removePreference(KEY_ADD_USER); } loadProfile(); setHasOptionsMenu(true); Loading Loading @@ -266,7 +265,8 @@ public class UserSettings extends SettingsPreferenceFragment } private void finishLoadProfile(String profileName) { mMePreference.setTitle(profileName); if (getActivity() == null) return; mMePreference.setTitle(getString(R.string.user_you, profileName)); int myUserId = UserHandle.myUserId(); Bitmap b = mUserManager.getUserIcon(myUserId); if (b != null) { Loading @@ -279,11 +279,11 @@ public class UserSettings extends SettingsPreferenceFragment synchronized (mUserLock) { if (mRemovingUserId == -1 && !mAddingUser) { switch (userType) { case USER_TYPE_TRUSTED: showDialog(DIALOG_ADD_USER_TRUSTED); case USER_TYPE_USER: showDialog(DIALOG_ADD_USER); break; case USER_TYPE_LIMITED: showDialog(DIALOG_ADD_USER_LIMITED); case USER_TYPE_RESTRICTED_PROFILE: addUserNow(USER_TYPE_RESTRICTED_PROFILE); break; } } Loading @@ -301,7 +301,7 @@ public class UserSettings extends SettingsPreferenceFragment private UserInfo createLimitedUser() { UserInfo newUserInfo = mUserManager.createUser( getResources().getString(R.string.user_new_user_name), getResources().getString(R.string.user_new_profile_name), UserInfo.FLAG_RESTRICTED); int userId = newUserInfo.id; UserHandle user = new UserHandle(userId); Loading @@ -326,7 +326,7 @@ public class UserSettings extends SettingsPreferenceFragment private UserInfo createTrustedUser() { UserInfo newUserInfo = mUserManager.createUser( getActivity().getResources().getString(R.string.user_new_user_name), 0); getResources().getString(R.string.user_new_user_name), 0); if (newUserInfo != null) { assignDefaultPhoto(newUserInfo); } Loading Loading @@ -360,8 +360,12 @@ public class UserSettings extends SettingsPreferenceFragment private void onUserCreated(int userId) { mAddedUserId = userId; if (mUserManager.getUserInfo(userId).isRestricted()) { showDialog(DIALOG_SETUP_PROFILE); } else { showDialog(DIALOG_SETUP_USER); } } @Override public void onDialogShowing() { Loading @@ -372,6 +376,8 @@ public class UserSettings extends SettingsPreferenceFragment @Override public Dialog onCreateDialog(int dialogId) { Context context = getActivity(); if (context == null) return null; switch (dialogId) { case DIALOG_CONFIRM_REMOVE: { Dialog dlg = new AlertDialog.Builder(getActivity()) Loading @@ -392,12 +398,11 @@ public class UserSettings extends SettingsPreferenceFragment return dlg; } case DIALOG_USER_CANNOT_MANAGE: return new AlertDialog.Builder(getActivity()) return new AlertDialog.Builder(context) .setMessage(R.string.user_cannot_manage_message) .setPositiveButton(android.R.string.ok, null) .create(); case DIALOG_ADD_USER_TRUSTED: case DIALOG_ADD_USER_LIMITED: { case DIALOG_ADD_USER: { final SharedPreferences preferences = getActivity().getPreferences( Context.MODE_PRIVATE); final boolean longMessageDisplayed = preferences.getBoolean( Loading @@ -405,9 +410,9 @@ public class UserSettings extends SettingsPreferenceFragment final int messageResId = longMessageDisplayed ? R.string.user_add_user_message_short : R.string.user_add_user_message_long; final int userType = dialogId == DIALOG_ADD_USER_TRUSTED ? USER_TYPE_TRUSTED : USER_TYPE_LIMITED; Dialog dlg = new AlertDialog.Builder(getActivity()) final int userType = dialogId == DIALOG_ADD_USER ? USER_TYPE_USER : USER_TYPE_RESTRICTED_PROFILE; Dialog dlg = new AlertDialog.Builder(context) .setTitle(R.string.user_add_user_title) .setMessage(messageResId) .setPositiveButton(android.R.string.ok, Loading @@ -415,8 +420,8 @@ public class UserSettings extends SettingsPreferenceFragment public void onClick(DialogInterface dialog, int which) { addUserNow(userType); if (!longMessageDisplayed) { preferences.edit().putBoolean(KEY_ADD_USER_LONG_MESSAGE_DISPLAYED, true).commit(); preferences.edit().putBoolean( KEY_ADD_USER_LONG_MESSAGE_DISPLAYED, true).apply(); } } }) Loading @@ -425,7 +430,7 @@ public class UserSettings extends SettingsPreferenceFragment return dlg; } case DIALOG_SETUP_USER: { Dialog dlg = new AlertDialog.Builder(getActivity()) Dialog dlg = new AlertDialog.Builder(context) .setTitle(R.string.user_setup_dialog_title) .setMessage(R.string.user_setup_dialog_message) .setPositiveButton(R.string.user_setup_button_setup_now, Loading @@ -438,6 +443,44 @@ public class UserSettings extends SettingsPreferenceFragment .create(); return dlg; } case DIALOG_SETUP_PROFILE: { Dialog dlg = new AlertDialog.Builder(context) .setMessage(R.string.user_setup_profile_dialog_message) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { switchUserNow(mAddedUserId); } }) .setNegativeButton(android.R.string.cancel, null) .create(); return dlg; } case DIALOG_CHOOSE_USER_TYPE: { List<HashMap<String, String>> data = new ArrayList<HashMap<String,String>>(); HashMap<String,String> addUserItem = new HashMap<String,String>(); addUserItem.put(KEY_TITLE, getString(R.string.user_add_user_item_title)); addUserItem.put(KEY_SUMMARY, getString(R.string.user_add_user_item_summary)); HashMap<String,String> addProfileItem = new HashMap<String,String>(); addProfileItem.put(KEY_TITLE, getString(R.string.user_add_profile_item_title)); addProfileItem.put(KEY_SUMMARY, getString(R.string.user_add_profile_item_summary)); data.add(addUserItem); data.add(addProfileItem); Dialog dlg = new AlertDialog.Builder(context) .setTitle(R.string.user_add_user_type_title) .setAdapter(new SimpleAdapter(context, data, R.layout.two_line_list_item, new String[] {KEY_TITLE, KEY_SUMMARY}, new int[] {R.id.title, R.id.summary}), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { onAddUserClicked(which == 0 ? USER_TYPE_USER : USER_TYPE_RESTRICTED_PROFILE); } }) .create(); return dlg; } default: return null; } Loading Loading @@ -476,14 +519,14 @@ public class UserSettings extends SettingsPreferenceFragment public void run() { UserInfo user = null; // Could take a few seconds if (userType == USER_TYPE_TRUSTED) { if (userType == USER_TYPE_USER) { user = createTrustedUser(); } else { user = createLimitedUser(); } synchronized (mUserLock) { mAddingUser = false; if (userType == USER_TYPE_TRUSTED) { if (userType == USER_TYPE_USER) { mHandler.sendEmptyMessage(MESSAGE_UPDATE_LIST); mHandler.sendMessage(mHandler.obtainMessage( MESSAGE_SETUP_USER, user.id, user.serialNumber)); Loading @@ -509,12 +552,9 @@ public class UserSettings extends SettingsPreferenceFragment if (getActivity() == null) return; List<UserInfo> users = mUserManager.getUsers(true); mTrustedUserListCategory.removeAll(); mTrustedUserListCategory.setOrderingAsAdded(false); mLimitedUserListCategory.removeAll(); mLimitedUserListCategory.setOrderingAsAdded(false); mTrustedUserListCategory.addPreference(mMePreference); mUserListCategory.removeAll(); mUserListCategory.setOrderingAsAdded(false); mUserListCategory.addPreference(mMePreference); final ArrayList<Integer> missingIcons = new ArrayList<Integer>(); for (UserInfo user : users) { Loading @@ -527,18 +567,18 @@ public class UserSettings extends SettingsPreferenceFragment mIsOwner ? this : null); pref.setOnPreferenceClickListener(this); pref.setKey("id=" + user.id); if (user.isRestricted()) { mLimitedUserListCategory.addPreference(pref); } else { mTrustedUserListCategory.addPreference(pref); } mUserListCategory.addPreference(pref); if (user.id == UserHandle.USER_OWNER) { pref.setSummary(R.string.user_owner); } pref.setTitle(user.name); if (!isInitialized(user)) { pref.setSummary(R.string.user_summary_not_set_up); } if (!isInitialized(user)) { pref.setSummary(user.isRestricted() ? R.string.user_summary_restricted_not_set_up : R.string.user_summary_not_set_up); } else if (user.isRestricted()) { pref.setSummary(R.string.user_summary_restricted_profile); } if (user.iconPath != null) { if (mUserIcons.get(user.id) == null) { Loading @@ -556,7 +596,7 @@ public class UserSettings extends SettingsPreferenceFragment pref.setEnabled(false); pref.setTitle(R.string.user_new_user_name); pref.setIcon(encircle(R.drawable.avatar_default_1)); mTrustedUserListCategory.addPreference(pref); mUserListCategory.addPreference(pref); } getActivity().invalidateOptionsMenu(); Loading @@ -565,14 +605,7 @@ public class UserSettings extends SettingsPreferenceFragment loadIconsAsync(missingIcons); } boolean moreUsers = mUserManager.getMaxSupportedUsers() > users.size(); mAddRestrictedUser.setEnabled(moreUsers); mAddTrustedUser.setEnabled(moreUsers); // Remove the limited users category if there aren't other limited users. if (!mIsOwner) { if (mLimitedUserListCategory.getPreferenceCount() == 0) { removePreference(KEY_LIMITED_USER_LIST); } } mAddUser.setEnabled(moreUsers); } private void loadIconsAsync(List<Integer> missingIcons) { Loading Loading @@ -662,10 +695,8 @@ public class UserSettings extends SettingsPreferenceFragment onManageUserClicked(user.id, false); } } } else if (pref == mAddTrustedUser) { onAddUserClicked(USER_TYPE_TRUSTED); } else if (pref == mAddRestrictedUser) { onAddUserClicked(USER_TYPE_LIMITED); } else if (pref == mAddUser) { showDialog(DIALOG_CHOOSE_USER_TYPE); } return false; } Loading