From 8e79d3ec8092a69c2d79130e5dc7d81611620188 Mon Sep 17 00:00:00 2001 From: Amith Yamasani Date: Wed, 22 Aug 2012 18:43:54 -0700 Subject: [PATCH] Simplify User management settings to bare minimum No need to restrictions or account association at this time. Change-Id: Ic4ae43d5bb9d4308e67499495d44c12de9e61777 --- res/xml/user_details.xml | 37 -------- .../settings/users/UserDetailsSettings.java | 90 +------------------ 2 files changed, 1 insertion(+), 126 deletions(-) diff --git a/res/xml/user_details.xml b/res/xml/user_details.xml index 616c6286369..f36fd4584f7 100644 --- a/res/xml/user_details.xml +++ b/res/xml/user_details.xml @@ -33,41 +33,4 @@ /> - - - - - - - - - - - - - - diff --git a/src/com/android/settings/users/UserDetailsSettings.java b/src/com/android/settings/users/UserDetailsSettings.java index 1f4f39bc750..aa7f9b2481c 100644 --- a/src/com/android/settings/users/UserDetailsSettings.java +++ b/src/com/android/settings/users/UserDetailsSettings.java @@ -65,31 +65,14 @@ public class UserDetailsSettings extends SettingsPreferenceFragment private static final String KEY_USER_NAME = "user_name"; private static final String KEY_USER_PICTURE = "user_picture"; - private static final String KEY_INSTALLED_APPS = "market_apps_category"; - private static final String KEY_SYSTEM_APPS = "system_apps_category"; - private static final String KEY_ACCOUNT = "associated_account"; - private static final String KEY_RESTRICTIONS = "restrictions_category"; public static final String EXTRA_USER_ID = "user_id"; private static final int RESULT_PICK_IMAGE = 1; private static final int RESULT_CROP_IMAGE = 2; - static class AppState { - boolean dirty; - boolean enabled; - - AppState(boolean enabled) { - this.enabled = enabled; - } - } - - private HashMap mAppStates = new HashMap(); - private PreferenceGroup mSystemAppGroup; - private PreferenceGroup mInstalledAppGroup; private EditTextPreference mNamePref; private Preference mPicturePref; - private Preference mAccountPref; private IPackageManager mIPm; private PackageManager mPm; @@ -110,20 +93,10 @@ public class UserDetailsSettings extends SettingsPreferenceFragment if (mUserId == -1) { mUserId = mUm.createUser(getString(R.string.user_new_user_name), 0).id; } - mSystemAppGroup = (PreferenceGroup) findPreference(KEY_SYSTEM_APPS); - mInstalledAppGroup = (PreferenceGroup) findPreference(KEY_INSTALLED_APPS); mNamePref = (EditTextPreference) findPreference(KEY_USER_NAME); mNamePref.setOnPreferenceChangeListener(this); mPicturePref = findPreference(KEY_USER_PICTURE); mPicturePref.setOnPreferenceClickListener(this); - mAccountPref = findPreference(KEY_ACCOUNT); - mAccountPref.setOnPreferenceClickListener(this); - - if (mUserId == 0) { - getPreferenceScreen().removePreference(mSystemAppGroup); - getPreferenceScreen().removePreference(mInstalledAppGroup); - getPreferenceScreen().removePreference(findPreference(KEY_RESTRICTIONS)); - } setHasOptionsMenu(true); } @@ -136,7 +109,6 @@ public class UserDetailsSettings extends SettingsPreferenceFragment } else { initNewUser(); } - refreshApps(); } @Override @@ -198,63 +170,6 @@ public class UserDetailsSettings extends SettingsPreferenceFragment finish(); } - private void insertAppInfo(PreferenceGroup group, HashMap appStateMap, - PackageInfo info, boolean defaultState) { - if (info != null) { - String pkgName = info.packageName; - String name = info.applicationInfo.loadLabel(mPm).toString(); - Drawable icon = info.applicationInfo.loadIcon(mPm); - AppState appState = appStateMap.get(info.packageName); - boolean enabled = appState == null ? defaultState : appState.enabled; - CheckBoxPreference appPref = new CheckBoxPreference(getActivity()); - appPref.setTitle(name != null ? name : pkgName); - appPref.setIcon(icon); - appPref.setChecked(enabled); - appPref.setKey(pkgName); - appPref.setPersistent(false); - appPref.setOnPreferenceChangeListener(this); - group.addPreference(appPref); - } - } - - private void refreshApps() { - if (mUserId == 0) return; - mSystemAppGroup.removeAll(); - mInstalledAppGroup.removeAll(); - - boolean firstTime = mAppStates.isEmpty(); - - final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); - mainIntent.addCategory(Intent.CATEGORY_LAUNCHER); - List apps = mPm.queryIntentActivities(mainIntent, 0); - - for (ResolveInfo resolveInfo : apps) { - PackageInfo info; - try { - info = mIPm.getPackageInfo(resolveInfo.activityInfo.packageName, - 0 /* flags */, - mUserId < 0 ? 0 : mUserId); - } catch (RemoteException re) { - continue; - } - if (firstTime) { - mAppStates.put(resolveInfo.activityInfo.packageName, - new AppState(info.applicationInfo.enabled)); - } - if ((info.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) { - if (mSystemAppGroup.findPreference(info.packageName) != null) { - continue; - } - insertAppInfo(mSystemAppGroup, mAppStates, info, false); - } else { - if (mInstalledAppGroup.findPreference(info.packageName) != null) { - continue; - } - insertAppInfo(mInstalledAppGroup, mAppStates, info, false); - } - } - } - @Override public boolean onPreferenceChange(Preference preference, Object newValue) { if (preference instanceof CheckBoxPreference) { @@ -300,10 +215,7 @@ public class UserDetailsSettings extends SettingsPreferenceFragment @Override public boolean onPreferenceClick(Preference preference) { - if (preference == mAccountPref) { -// Intent launch = AccountManager.newChooseAccountsIntent(null, null, new String[]{"com.google"}, false, null, -// null, null, null); - } else if (preference == mPicturePref) { + if (preference == mPicturePref) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT);