Merge "Disable apps that require an account on a limited user" into jb-mr2-dev

This commit is contained in:
Amith Yamasani
2013-04-13 22:54:18 +00:00
committed by Android (Google) Code Review
2 changed files with 39 additions and 1 deletions

View File

@@ -4464,6 +4464,8 @@
<string name="app_restrictions_custom_label">Set application limits</string> <string name="app_restrictions_custom_label">Set application limits</string>
<!-- Summary for app entries that are controlled by another entry [CHAR LIMIT=none] --> <!-- Summary for app entries that are controlled by another entry [CHAR LIMIT=none] -->
<string name="user_restrictions_controlled_by">Controlled by <xliff:g id="app">%1$s</xliff:g></string> <string name="user_restrictions_controlled_by">Controlled by <xliff:g id="app">%1$s</xliff:g></string>
<!-- Summary for apps that aren't supported in limited users [CHAR LIMIT=none] -->
<string name="app_not_supported_in_limited">This app is not supported in limited users</string>
<!-- Restrictions title for configuring wifi and mobile [CHAR LIMIT=35] --> <!-- Restrictions title for configuring wifi and mobile [CHAR LIMIT=35] -->
<string name="restriction_wifi_config_title">Wi\u2011Fi and Mobile</string> <string name="restriction_wifi_config_title">Wi\u2011Fi and Mobile</string>

View File

@@ -32,6 +32,9 @@ import android.content.pm.ResolveInfo;
import android.content.pm.UserInfo; import android.content.pm.UserInfo;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Color; 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.BitmapDrawable;
import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
@@ -135,17 +138,35 @@ public class AppRestrictionsFragment extends SettingsPreferenceFragment implemen
boolean panelOpen; boolean panelOpen;
private boolean immutable; private boolean immutable;
List<Preference> childPreferences = new ArrayList<Preference>(); List<Preference> childPreferences = new ArrayList<Preference>();
private SelectableAppInfo appInfo;
private final ColorFilter grayscaleFilter;
AppRestrictionsPreference(Context context, OnClickListener listener) { AppRestrictionsPreference(Context context, OnClickListener listener) {
super(context); super(context);
setLayoutResource(R.layout.preference_app_restrictions); setLayoutResource(R.layout.preference_app_restrictions);
this.listener = listener; 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) { private void setSettingsEnabled(boolean enable) {
hasSettings = 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) { void setRestrictions(ArrayList<RestrictionEntry> restrictions) {
this.restrictions = restrictions; this.restrictions = restrictions;
} }
@@ -158,6 +179,10 @@ public class AppRestrictionsFragment extends SettingsPreferenceFragment implemen
return immutable; return immutable;
} }
void setSelectableAppInfo(SelectableAppInfo appInfo) {
this.appInfo = appInfo;
}
RestrictionEntry getRestriction(String key) { RestrictionEntry getRestriction(String key) {
if (restrictions == null) return null; if (restrictions == null) return null;
for (RestrictionEntry entry : restrictions) { for (RestrictionEntry entry : restrictions) {
@@ -256,8 +281,12 @@ public class AppRestrictionsFragment extends SettingsPreferenceFragment implemen
public void onPause() { public void onPause() {
super.onPause(); super.onPause();
if (mAppListChanged) { if (mAppListChanged) {
new Thread() {
public void run() {
updateUserAppList(); updateUserAppList();
} }
}.start();
}
} }
private void updateUserAppList() { private void updateUserAppList() {
@@ -388,6 +417,7 @@ public class AppRestrictionsFragment extends SettingsPreferenceFragment implemen
AppRestrictionsPreference p = new AppRestrictionsPreference(context, this); AppRestrictionsPreference p = new AppRestrictionsPreference(context, this);
final boolean hasSettings = resolveInfoListHasPackage(receivers, packageName); final boolean hasSettings = resolveInfoListHasPackage(receivers, packageName);
p.setIcon(app.icon); p.setIcon(app.icon);
p.setChecked(false);
p.setTitle(app.activityName); p.setTitle(app.activityName);
if (app.masterEntry != null) { if (app.masterEntry != null) {
p.setSummary(getActivity().getString(R.string.user_restrictions_controlled_by, 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)) { } else if (!mNewUser && appInfoListHasPackage(userApps, packageName)) {
p.setChecked(true); 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) { if (app.masterEntry != null) {
p.setImmutable(true); p.setImmutable(true);
p.setChecked(mSelectedPackages.get(packageName)); p.setChecked(mSelectedPackages.get(packageName));
@@ -425,6 +460,7 @@ public class AppRestrictionsFragment extends SettingsPreferenceFragment implemen
} else { } else {
p.setOrder(MAX_APP_RESTRICTIONS * (i + 2)); p.setOrder(MAX_APP_RESTRICTIONS * (i + 2));
} }
p.setSelectableAppInfo(app);
mSelectedPackages.put(packageName, p.isChecked()); mSelectedPackages.put(packageName, p.isChecked());
mAppListChanged = true; mAppListChanged = true;
i++; i++;