diff options
author | Amith Yamasani <yamasani@google.com> | 2013-04-12 17:56:34 -0700 |
---|---|---|
committer | Amith Yamasani <yamasani@google.com> | 2013-04-12 17:56:34 -0700 |
commit | 9517b02d4314a181cb09b33521fc2b81754baedb (patch) | |
tree | 5f16dd0f5d3c2e128924f9b5b4943bade68daa96 /src | |
parent | 8c32c28f1909393bd01a34fb966b23caba9e69da (diff) | |
download | packages_apps_Settings-9517b02d4314a181cb09b33521fc2b81754baedb.zip packages_apps_Settings-9517b02d4314a181cb09b33521fc2b81754baedb.tar.gz packages_apps_Settings-9517b02d4314a181cb09b33521fc2b81754baedb.tar.bz2 |
Disable apps that require an account on a limited user
If an app is marked as requiring an account to work, disable that app
and show a message in the summary.
Also, implement graying out of icons for deselected apps.
Bug: 8600261
Change-Id: I9cf48832675c24257e09addad4316249082c30fb
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/settings/users/AppRestrictionsFragment.java | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/src/com/android/settings/users/AppRestrictionsFragment.java b/src/com/android/settings/users/AppRestrictionsFragment.java index 5e2868e..4e6e5de 100644 --- a/src/com/android/settings/users/AppRestrictionsFragment.java +++ b/src/com/android/settings/users/AppRestrictionsFragment.java @@ -32,6 +32,9 @@ import android.content.pm.ResolveInfo; import android.content.pm.UserInfo; import android.graphics.Bitmap; import android.graphics.Color; +import android.graphics.ColorFilter; +import android.graphics.ColorMatrix; +import android.graphics.ColorMatrixColorFilter; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; @@ -135,17 +138,35 @@ public class AppRestrictionsFragment extends SettingsPreferenceFragment implemen boolean panelOpen; private boolean immutable; List<Preference> childPreferences = new ArrayList<Preference>(); + private SelectableAppInfo appInfo; + private final ColorFilter grayscaleFilter; AppRestrictionsPreference(Context context, OnClickListener listener) { super(context); setLayoutResource(R.layout.preference_app_restrictions); this.listener = listener; + + ColorMatrix colorMatrix = new ColorMatrix(); + colorMatrix.setSaturation(0f); + float[] matrix = colorMatrix.getArray(); + matrix[18] = 0.5f; + grayscaleFilter = new ColorMatrixColorFilter(colorMatrix); } private void setSettingsEnabled(boolean enable) { hasSettings = enable; } + @Override + public void setChecked(boolean checked) { + if (checked) { + getIcon().setColorFilter(null); + } else { + getIcon().setColorFilter(grayscaleFilter); + } + super.setChecked(checked); + } + void setRestrictions(ArrayList<RestrictionEntry> restrictions) { this.restrictions = restrictions; } @@ -158,6 +179,10 @@ public class AppRestrictionsFragment extends SettingsPreferenceFragment implemen return immutable; } + void setSelectableAppInfo(SelectableAppInfo appInfo) { + this.appInfo = appInfo; + } + RestrictionEntry getRestriction(String key) { if (restrictions == null) return null; for (RestrictionEntry entry : restrictions) { @@ -256,7 +281,11 @@ public class AppRestrictionsFragment extends SettingsPreferenceFragment implemen public void onPause() { super.onPause(); if (mAppListChanged) { - updateUserAppList(); + new Thread() { + public void run() { + updateUserAppList(); + } + }.start(); } } @@ -388,6 +417,7 @@ public class AppRestrictionsFragment extends SettingsPreferenceFragment implemen 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, @@ -415,6 +445,11 @@ public class AppRestrictionsFragment extends SettingsPreferenceFragment implemen } else if (!mNewUser && appInfoListHasPackage(userApps, packageName)) { p.setChecked(true); } + if (pi.requiredAccountType != null && pi.restrictedAccountType == null) { + p.setChecked(false); + p.setImmutable(true); + p.setSummary(R.string.app_not_supported_in_limited); + } if (app.masterEntry != null) { p.setImmutable(true); p.setChecked(mSelectedPackages.get(packageName)); @@ -425,6 +460,7 @@ public class AppRestrictionsFragment extends SettingsPreferenceFragment implemen } else { p.setOrder(MAX_APP_RESTRICTIONS * (i + 2)); } + p.setSelectableAppInfo(app); mSelectedPackages.put(packageName, p.isChecked()); mAppListChanged = true; i++; |