More User Settings improvements
Add a menu checkbox to allow creation of users from lockscreen. Add a delete icon in restricted profiles settings. Other little fixes to icons. Update some strings based on feedback. Bug: 15761405 Bug: 16550371 Bug: 16298824 Change-Id: Ib876bd57f15c6ce2d71856f72571c6b8b0e3102d
This commit is contained in:
@@ -446,7 +446,7 @@ public class ApnEditor extends PreferenceActivity
|
||||
// If it's a new APN, then cancel will delete the new entry in onPause
|
||||
if (!mNewApn) {
|
||||
menu.add(0, MENU_DELETE, 0, R.string.menu_delete)
|
||||
.setIcon(R.drawable.ic_menu_delete_holo_dark);
|
||||
.setIcon(R.drawable.ic_menu_delete);
|
||||
}
|
||||
menu.add(0, MENU_SAVE, 0, R.string.menu_save)
|
||||
.setIcon(android.R.drawable.ic_menu_save);
|
||||
|
@@ -242,7 +242,7 @@ public class AccountSyncSettings extends AccountPreferenceBase {
|
||||
if (!um.hasUserRestriction(UserManager.DISALLOW_MODIFY_ACCOUNTS, mUserHandle)) {
|
||||
MenuItem removeAccount = menu.add(0, MENU_REMOVE_ACCOUNT_ID, 0,
|
||||
getString(R.string.remove_account_label))
|
||||
.setIcon(R.drawable.ic_menu_delete_holo_dark);
|
||||
.setIcon(R.drawable.ic_menu_delete);
|
||||
removeAccount.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER |
|
||||
MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
||||
}
|
||||
|
@@ -988,6 +988,7 @@ public class AppRestrictionsFragment extends SettingsPreferenceFragment implemen
|
||||
+ entry.getKey());
|
||||
mAppList.addPreference(p);
|
||||
p.setOnPreferenceChangeListener(AppRestrictionsFragment.this);
|
||||
p.setIcon(R.drawable.empty_icon);
|
||||
preference.mChildren.add(p);
|
||||
count++;
|
||||
}
|
||||
|
@@ -38,7 +38,14 @@ import android.widget.ImageView;
|
||||
|
||||
import com.android.settings.R;
|
||||
|
||||
/**
|
||||
* This class encapsulates a Dialog for editing the user nickname and photo.
|
||||
*/
|
||||
public class EditUserInfoController {
|
||||
|
||||
private static final String KEY_AWAITING_RESULT = "awaiting_result";
|
||||
private static final String KEY_SAVED_PHOTO = "pending_photo";
|
||||
|
||||
private Dialog mEditUserInfoDialog;
|
||||
private Bitmap mSavedPhoto;
|
||||
private EditUserPhotoController mEditUserPhotoController;
|
||||
@@ -48,7 +55,6 @@ public class EditUserInfoController {
|
||||
|
||||
public interface OnContentChangedCallback {
|
||||
public void onPhotoChanged(Drawable photo);
|
||||
|
||||
public void onLabelChanged(CharSequence label);
|
||||
}
|
||||
|
||||
@@ -62,17 +68,18 @@ public class EditUserInfoController {
|
||||
}
|
||||
|
||||
public void onRestoreInstanceState(Bundle icicle) {
|
||||
mSavedPhoto = (Bitmap) icicle.getParcelable(RestrictedProfileSettings.KEY_SAVED_PHOTO);
|
||||
mSavedPhoto = (Bitmap) icicle.getParcelable(KEY_SAVED_PHOTO);
|
||||
mWaitingForActivityResult = icicle.getBoolean(KEY_AWAITING_RESULT, false);
|
||||
}
|
||||
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
if (mEditUserInfoDialog != null && mEditUserInfoDialog.isShowing()
|
||||
&& mEditUserPhotoController != null) {
|
||||
outState.putParcelable(RestrictedProfileSettings.KEY_SAVED_PHOTO,
|
||||
outState.putParcelable(KEY_SAVED_PHOTO,
|
||||
mEditUserPhotoController.getNewUserPhotoBitmap());
|
||||
}
|
||||
if (mWaitingForActivityResult) {
|
||||
outState.putBoolean(RestrictedProfileSettings.KEY_AWAITING_RESULT,
|
||||
outState.putBoolean(KEY_AWAITING_RESULT,
|
||||
mWaitingForActivityResult);
|
||||
}
|
||||
}
|
||||
|
@@ -17,6 +17,7 @@
|
||||
package com.android.settings.users;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.graphics.drawable.Drawable;
|
||||
@@ -28,24 +29,24 @@ import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RestrictedProfileSettings extends AppRestrictionsFragment
|
||||
implements EditUserInfoController.OnContentChangedCallback {
|
||||
|
||||
static final String KEY_SAVED_PHOTO = "pending_photo";
|
||||
static final String KEY_AWAITING_RESULT = "awaiting_result";
|
||||
static final int DIALOG_ID_EDIT_USER_INFO = 1;
|
||||
public static final String FILE_PROVIDER_AUTHORITY = "com.android.settings.files";
|
||||
static final int DIALOG_ID_EDIT_USER_INFO = 1;
|
||||
private static final int DIALOG_CONFIRM_REMOVE = 2;
|
||||
|
||||
private View mHeaderView;
|
||||
private ImageView mUserIconView;
|
||||
private TextView mUserNameView;
|
||||
private ImageView mDeleteButton;
|
||||
|
||||
private EditUserInfoController mEditUserInfoController =
|
||||
new EditUserInfoController();
|
||||
private boolean mWaitingForActivityResult;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
@@ -53,7 +54,6 @@ public class RestrictedProfileSettings extends AppRestrictionsFragment
|
||||
|
||||
if (icicle != null) {
|
||||
mEditUserInfoController.onRestoreInstanceState(icicle);
|
||||
mWaitingForActivityResult = icicle.getBoolean(KEY_AWAITING_RESULT, false);
|
||||
}
|
||||
|
||||
init(icicle);
|
||||
@@ -68,6 +68,8 @@ public class RestrictedProfileSettings extends AppRestrictionsFragment
|
||||
mHeaderView.setOnClickListener(this);
|
||||
mUserIconView = (ImageView) mHeaderView.findViewById(android.R.id.icon);
|
||||
mUserNameView = (TextView) mHeaderView.findViewById(android.R.id.title);
|
||||
mDeleteButton = (ImageView) mHeaderView.findViewById(R.id.delete);
|
||||
mDeleteButton.setOnClickListener(this);
|
||||
getListView().setFastScrollEnabled(true);
|
||||
}
|
||||
// This is going to bind the preferences.
|
||||
@@ -122,6 +124,8 @@ public class RestrictedProfileSettings extends AppRestrictionsFragment
|
||||
public void onClick(View view) {
|
||||
if (view == mHeaderView) {
|
||||
showDialog(DIALOG_ID_EDIT_USER_INFO);
|
||||
} else if (view == mDeleteButton) {
|
||||
showDialog(DIALOG_CONFIRM_REMOVE);
|
||||
} else {
|
||||
super.onClick(view); // in AppRestrictionsFragment
|
||||
}
|
||||
@@ -133,11 +137,30 @@ public class RestrictedProfileSettings extends AppRestrictionsFragment
|
||||
return mEditUserInfoController.createDialog(this, mUserIconView.getDrawable(),
|
||||
mUserNameView.getText(), R.string.profile_info_settings_title,
|
||||
this, mUser);
|
||||
} else if (dialogId == DIALOG_CONFIRM_REMOVE) {
|
||||
Dialog dlg =
|
||||
Utils.createRemoveConfirmationDialog(getActivity(), mUser.getIdentifier(),
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
removeUser();
|
||||
}
|
||||
}
|
||||
);
|
||||
return dlg;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void removeUser() {
|
||||
getView().post(new Runnable() {
|
||||
public void run() {
|
||||
mUserManager.removeUser(mUser.getIdentifier());
|
||||
finishFragment();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPhotoChanged(Drawable photo) {
|
||||
mUserIconView.setImageDrawable(photo);
|
||||
|
@@ -50,6 +50,7 @@ import android.os.UserManager;
|
||||
import android.preference.Preference;
|
||||
import android.preference.Preference.OnPreferenceClickListener;
|
||||
import android.preference.PreferenceGroup;
|
||||
import android.provider.Settings;
|
||||
import android.provider.Settings.Secure;
|
||||
import android.util.Log;
|
||||
import android.util.SparseArray;
|
||||
@@ -94,6 +95,7 @@ public class UserSettings extends SettingsPreferenceFragment
|
||||
private static final String KEY_ADD_USER = "user_add";
|
||||
|
||||
private static final int MENU_REMOVE_USER = Menu.FIRST;
|
||||
private static final int MENU_ADD_ON_LOCKSCREEN = Menu.FIRST + 1;
|
||||
|
||||
private static final int DIALOG_CONFIRM_REMOVE = 1;
|
||||
private static final int DIALOG_ADD_USER = 2;
|
||||
@@ -282,13 +284,21 @@ public class UserSettings extends SettingsPreferenceFragment
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
int pos = 0;
|
||||
UserManager um = (UserManager) getActivity().getSystemService(Context.USER_SERVICE);
|
||||
if (!mIsOwner && !um.hasUserRestriction(UserManager.DISALLOW_REMOVE_USER)) {
|
||||
String nickname = mUserManager.getUserName();
|
||||
MenuItem removeThisUser = menu.add(0, MENU_REMOVE_USER, 0,
|
||||
MenuItem removeThisUser = menu.add(0, MENU_REMOVE_USER, pos++,
|
||||
getResources().getString(R.string.user_remove_user_menu, nickname));
|
||||
removeThisUser.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
|
||||
}
|
||||
if (mIsOwner && !um.hasUserRestriction(UserManager.DISALLOW_ADD_USER)) {
|
||||
MenuItem allowAddOnLockscreen = menu.add(0, MENU_ADD_ON_LOCKSCREEN, pos++,
|
||||
R.string.user_add_on_lockscreen_menu);
|
||||
allowAddOnLockscreen.setCheckable(true);
|
||||
allowAddOnLockscreen.setChecked(Settings.Global.getInt(getContentResolver(),
|
||||
Settings.Global.ADD_USERS_WHEN_LOCKED, 0) == 1);
|
||||
}
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
}
|
||||
|
||||
@@ -298,6 +308,12 @@ public class UserSettings extends SettingsPreferenceFragment
|
||||
if (itemId == MENU_REMOVE_USER) {
|
||||
onRemoveUserClicked(UserHandle.myUserId());
|
||||
return true;
|
||||
} else if (itemId == MENU_ADD_ON_LOCKSCREEN) {
|
||||
final boolean isChecked = item.isChecked();
|
||||
Settings.Global.putInt(getContentResolver(), Settings.Global.ADD_USERS_WHEN_LOCKED,
|
||||
isChecked ? 0 : 1);
|
||||
item.setChecked(!isChecked);
|
||||
return true;
|
||||
} else {
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
@@ -780,6 +796,7 @@ public class UserSettings extends SettingsPreferenceFragment
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add a temporary entry for the user being created
|
||||
if (mAddingUser) {
|
||||
Preference pref = new UserPreference(getActivity(), null, UserPreference.USERID_UNKNOWN,
|
||||
@@ -793,7 +810,9 @@ public class UserSettings extends SettingsPreferenceFragment
|
||||
if (!mIsGuest) {
|
||||
// Add a virtual Guest user for guest defaults
|
||||
Preference pref = new UserPreference(getActivity(), null,
|
||||
UserPreference.USERID_GUEST_DEFAULTS, mIsOwner ? this : null, null);
|
||||
UserPreference.USERID_GUEST_DEFAULTS,
|
||||
mIsOwner && voiceCapable? this : null /* settings icon handler */,
|
||||
null /* delete icon handler */);
|
||||
pref.setTitle(R.string.user_guest);
|
||||
pref.setIcon(getEncircledGuestDrawable());
|
||||
pref.setOnPreferenceClickListener(this);
|
||||
@@ -928,11 +947,6 @@ public class UserSettings extends SettingsPreferenceFragment
|
||||
return (user.flags & UserInfo.FLAG_INITIALIZED) != 0;
|
||||
}
|
||||
|
||||
private Drawable encircle(int iconResId) {
|
||||
Bitmap icon = BitmapFactory.decodeResource(getResources(), iconResId);
|
||||
return encircle(icon);
|
||||
}
|
||||
|
||||
private Drawable encircle(Bitmap icon) {
|
||||
Drawable circled = CircleFramedDrawable.getInstance(getActivity(), icon);
|
||||
return circled;
|
||||
|
Reference in New Issue
Block a user