summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
authorAmith Yamasani <yamasani@google.com>2013-04-22 13:37:58 -0700
committerAmith Yamasani <yamasani@google.com>2013-04-22 17:03:30 -0700
commit1bad7141b4c602399beaddde49ac295ae1a89afc (patch)
tree4a237224e63795143ff4839cb112bd5af76639e7 /src/com/android
parentbf3391f19b6f1733825de07d9c602545f8818c64 (diff)
downloadpackages_apps_Settings-1bad7141b4c602399beaddde49ac295ae1a89afc.zip
packages_apps_Settings-1bad7141b4c602399beaddde49ac295ae1a89afc.tar.gz
packages_apps_Settings-1bad7141b4c602399beaddde49ac295ae1a89afc.tar.bz2
Fix repeating apps on pause/resume
Preference list was getting duplicated on pausing and resuming the activity. Pull the user info out of the preference list and make it a static header so that it stays fixed. Can now remove all entries before re-adding. Disable location by default and disable ability to change Unknown sources toggle. Bug: 8685561 Bug: 8688400 Change-Id: I64ce728d5369e03ddaba562bcd66bb0720a037d2
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/settings/SecuritySettings.java4
-rw-r--r--src/com/android/settings/users/AppRestrictionsFragment.java61
-rw-r--r--src/com/android/settings/users/RestrictionUtils.java6
-rw-r--r--src/com/android/settings/users/UserSettings.java5
4 files changed, 44 insertions, 32 deletions
diff --git a/src/com/android/settings/SecuritySettings.java b/src/com/android/settings/SecuritySettings.java
index c324dd8..38e4cda 100644
--- a/src/com/android/settings/SecuritySettings.java
+++ b/src/com/android/settings/SecuritySettings.java
@@ -257,10 +257,8 @@ public class SecuritySettings extends SettingsPreferenceFragment
KEY_TOGGLE_INSTALL_APPLICATIONS);
mToggleAppInstallation.setChecked(isNonMarketAppsAllowed());
- boolean isSideloadingAllowed =
- !um.hasUserRestriction(UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES);
// Side loading of apps.
- mToggleAppInstallation.setEnabled(isSideloadingAllowed);
+ mToggleAppInstallation.setEnabled(mIsPrimary);
// Package verification, only visible to primary user and if enabled
mToggleVerifyApps = (CheckBoxPreference) findPreference(KEY_TOGGLE_VERIFY_APPLICATIONS);
diff --git a/src/com/android/settings/users/AppRestrictionsFragment.java b/src/com/android/settings/users/AppRestrictionsFragment.java
index a7540cc..9f64b71 100644
--- a/src/com/android/settings/users/AppRestrictionsFragment.java
+++ b/src/com/android/settings/users/AppRestrictionsFragment.java
@@ -74,6 +74,7 @@ import android.widget.ImageView;
import android.widget.ListAdapter;
import android.widget.ListPopupWindow;
import android.widget.Switch;
+import android.widget.TextView;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
@@ -104,7 +105,6 @@ public class AppRestrictionsFragment extends SettingsPreferenceFragment implemen
private UserManager mUserManager;
private UserHandle mUser;
- private Preference mUserPreference;
private PreferenceGroup mAppList;
private static final int MAX_APP_RESTRICTIONS = 100;
@@ -125,6 +125,9 @@ public class AppRestrictionsFragment extends SettingsPreferenceFragment implemen
private int mCustomRequestCode;
private HashMap<Integer, AppRestrictionsPreference> mCustomRequestMap =
new HashMap<Integer,AppRestrictionsPreference>();
+ private View mHeaderView;
+ private ImageView mUserIconView;
+ private TextView mUserNameView;
private List<SelectableAppInfo> mVisibleApps;
private List<ApplicationInfo> mUserApps;
@@ -262,14 +265,25 @@ public class AppRestrictionsFragment extends SettingsPreferenceFragment implemen
mUserManager = (UserManager) getActivity().getSystemService(Context.USER_SERVICE);
addPreferencesFromResource(R.xml.app_restrictions);
mAppList = getPreferenceScreen();
- mUserPreference = findPreference(KEY_USER_INFO);
-
- mUserPreference.setOnPreferenceClickListener(this);
-
setHasOptionsMenu(true);
}
@Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ if (mHeaderView == null) {
+ mHeaderView = LayoutInflater.from(getActivity()).inflate(
+ R.layout.user_info_header, null);
+ ((ViewGroup) getListView().getParent()).addView(mHeaderView, 0);
+ mHeaderView.setOnClickListener(this);
+ mUserIconView = (ImageView) mHeaderView.findViewById(android.R.id.icon);
+ mUserNameView = (TextView) mHeaderView.findViewById(android.R.id.title);
+ getListView().setFastScrollEnabled(true);
+ }
+ // This is going to bind the preferences.
+ super.onActivityCreated(savedInstanceState);
+ }
+
+ @Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putBoolean(EXTRA_NEW_USER, mNewUser);
@@ -282,12 +296,11 @@ public class AppRestrictionsFragment extends SettingsPreferenceFragment implemen
new AppLoadingTask().execute((Void[]) null);
UserInfo info = mUserManager.getUserInfo(mUser.getIdentifier());
- mUserPreference.setTitle(info.name);
Bitmap userIcon = mUserManager.getUserIcon(mUser.getIdentifier());
CircleFramedDrawable circularIcon =
CircleFramedDrawable.getInstance(this.getActivity(), userIcon);
- mUserPreference.setIcon(circularIcon);
- mUserPreference.setTitle(info.name);
+ ((TextView) mHeaderView.findViewById(android.R.id.title)).setText(info.name);
+ ((ImageView) mHeaderView.findViewById(android.R.id.icon)).setImageDrawable(circularIcon);
}
public void onPause() {
@@ -335,6 +348,7 @@ public class AppRestrictionsFragment extends SettingsPreferenceFragment implemen
}
private void addSystemApps(List<SelectableAppInfo> visibleApps, Intent intent) {
+ if (getActivity() == null) return;
final PackageManager pm = getActivity().getPackageManager();
List<ResolveInfo> launchableApps = pm.queryIntentActivities(intent, 0);
for (ResolveInfo app : launchableApps) {
@@ -377,6 +391,7 @@ public class AppRestrictionsFragment extends SettingsPreferenceFragment implemen
mAppList.setOrderingAsAdded(false);
mVisibleApps = new ArrayList<SelectableAppInfo>();
final Context context = getActivity();
+ if (context == null) return;
PackageManager pm = context.getPackageManager();
IPackageManager ipm = AppGlobals.getPackageManager();
@@ -450,13 +465,14 @@ public class AppRestrictionsFragment extends SettingsPreferenceFragment implemen
packageMap.put(info.packageName, info);
}
}
-
}
private void populateApps() {
final Context context = getActivity();
+ if (context == null) return;
PackageManager pm = context.getPackageManager();
IPackageManager ipm = AppGlobals.getPackageManager();
+ mAppList.removeAll();
Intent restrictionsIntent = new Intent(Intent.ACTION_GET_RESTRICTION_ENTRIES);
final List<ResolveInfo> receivers = pm.queryBroadcastReceivers(restrictionsIntent, 0);
int i = 0;
@@ -464,14 +480,14 @@ public class AppRestrictionsFragment extends SettingsPreferenceFragment implemen
for (SelectableAppInfo app : mVisibleApps) {
String packageName = app.packageName;
if (packageName == null) continue;
- final boolean isSettingsApp = packageName.equals(getActivity().getPackageName());
+ final boolean isSettingsApp = packageName.equals(context.getPackageName());
AppRestrictionsPreference p = new AppRestrictionsPreference(context, this);
final boolean hasSettings = resolveInfoListHasPackage(receivers, packageName);
p.setIcon(app.icon);
p.setChecked(false);
p.setTitle(app.activityName);
if (app.masterEntry != null) {
- p.setSummary(getActivity().getString(R.string.user_restrictions_controlled_by,
+ p.setSummary(context.getString(R.string.user_restrictions_controlled_by,
app.masterEntry.activityName));
}
p.setKey(PKG_PREFIX + packageName);
@@ -563,7 +579,9 @@ public class AppRestrictionsFragment extends SettingsPreferenceFragment implemen
@Override
public void onClick(View v) {
- if (v.getTag() instanceof AppRestrictionsPreference) {
+ if (v == mHeaderView) {
+ showDialog(DIALOG_ID_EDIT_USER_INFO);
+ } else if (v.getTag() instanceof AppRestrictionsPreference) {
AppRestrictionsPreference pref = (AppRestrictionsPreference) v.getTag();
if (v.getId() == R.id.app_restrictions_settings) {
toggleAppPanel(pref);
@@ -624,12 +642,6 @@ public class AppRestrictionsFragment extends SettingsPreferenceFragment implemen
}
}
}
- } else if (preference == mUserPreference) {
- String userName = ((CharSequence) newValue).toString();
- if (!TextUtils.isEmpty(userName)) {
- mUserManager.setUserName(mUser.getIdentifier(), userName);
- mUserPreference.setTitle(userName);
- }
}
return true;
}
@@ -840,8 +852,6 @@ public class AppRestrictionsFragment extends SettingsPreferenceFragment implemen
mAppListChanged = true;
}
return true;
- } else if (preference == mUserPreference) {
- showDialog(DIALOG_ID_EDIT_USER_INFO);
}
return false;
}
@@ -862,7 +872,7 @@ public class AppRestrictionsFragment extends SettingsPreferenceFragment implemen
userNameView.setText(info.name);
final ImageView userPhotoView = (ImageView) content.findViewById(R.id.user_photo);
- userPhotoView.setImageDrawable(mUserPreference.getIcon());
+ userPhotoView.setImageDrawable(mUserIconView.getDrawable());
mEditUserPhotoController = new EditUserPhotoController(this, userPhotoView);
@@ -878,10 +888,11 @@ public class AppRestrictionsFragment extends SettingsPreferenceFragment implemen
// Update the name if changed.
CharSequence userName = userNameView.getText();
if (!TextUtils.isEmpty(userName)) {
- CharSequence oldUserName = mUserPreference.getTitle();
+ CharSequence oldUserName = mUserNameView.getText();
if (oldUserName == null
|| !userName.toString().equals(oldUserName.toString())) {
- mUserPreference.setTitle(userName);
+ ((TextView) mHeaderView.findViewById(android.R.id.title))
+ .setText(userName.toString());
mUserManager.setUserName(mUser.getIdentifier(),
userName.toString());
}
@@ -889,8 +900,8 @@ public class AppRestrictionsFragment extends SettingsPreferenceFragment implemen
// Update the photo if changed.
Drawable userPhoto = mEditUserPhotoController.getNewUserPhotoDrawable();
if (userPhoto != null
- && !userPhoto.equals(mUserPreference.getIcon())) {
- mUserPreference.setIcon(userPhoto);
+ && !userPhoto.equals(mUserIconView.getDrawable())) {
+ mUserIconView.setImageDrawable(userPhoto);
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
diff --git a/src/com/android/settings/users/RestrictionUtils.java b/src/com/android/settings/users/RestrictionUtils.java
index be62b3b..3ee6d51 100644
--- a/src/com/android/settings/users/RestrictionUtils.java
+++ b/src/com/android/settings/users/RestrictionUtils.java
@@ -34,21 +34,21 @@ public class RestrictionUtils {
// UserManager.DISALLOW_CONFIG_WIFI,
// UserManager.DISALLOW_CONFIG_BLUETOOTH,
UserManager.DISALLOW_SHARE_LOCATION,
- UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES
+// UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES
};
public static final int [] sRestrictionTitles = {
// R.string.restriction_wifi_config_title,
// R.string.restriction_bluetooth_config_title,
R.string.restriction_location_enable_title,
- R.string.install_applications
+// R.string.install_applications
};
public static final int [] sRestrictionDescriptions = {
// R.string.restriction_wifi_config_summary,
// R.string.restriction_bluetooth_config_summary,
R.string.restriction_location_enable_summary,
- R.string.install_unknown_applications
+// R.string.install_unknown_applications
};
/**
diff --git a/src/com/android/settings/users/UserSettings.java b/src/com/android/settings/users/UserSettings.java
index 676951e..605daa5 100644
--- a/src/com/android/settings/users/UserSettings.java
+++ b/src/com/android/settings/users/UserSettings.java
@@ -45,6 +45,7 @@ import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceGroup;
import android.provider.ContactsContract;
import android.provider.ContactsContract.Contacts;
+import android.provider.Settings.Secure;
import android.util.Log;
import android.util.SparseArray;
import android.view.Menu;
@@ -305,7 +306,9 @@ public class UserSettings extends SettingsPreferenceFragment
int userId = newUserInfo.id;
UserHandle user = new UserHandle(userId);
mUserManager.setUserRestriction(UserManager.DISALLOW_MODIFY_ACCOUNTS, true, user);
-
+ mUserManager.setUserRestriction(UserManager.DISALLOW_SHARE_LOCATION, true, user);
+ Secure.putStringForUser(getContentResolver(),
+ Secure.LOCATION_PROVIDERS_ALLOWED, "", userId);
Bitmap bitmap = BitmapFactory.decodeResource(getResources(),
UserSettings.USER_DRAWABLES[
userId % UserSettings.USER_DRAWABLES.length]);