diff options
author | Jason Monk <jmonk@google.com> | 2016-02-23 15:31:09 -0500 |
---|---|---|
committer | Jason Monk <jmonk@google.com> | 2016-02-24 08:55:01 -0500 |
commit | 91e2f89b0f8b440728fe395ee02a71ae59e21ffc (patch) | |
tree | cf180063ed69b2e70a6d838d865c926f027288a9 /src/com/android/settings/AppListPreference.java | |
parent | e57f7cbc8c80d298bbbd63b7536acd67c7f95df4 (diff) | |
download | packages_apps_Settings-91e2f89b0f8b440728fe395ee02a71ae59e21ffc.tar.gz packages_apps_Settings-91e2f89b0f8b440728fe395ee02a71ae59e21ffc.tar.bz2 packages_apps_Settings-91e2f89b0f8b440728fe395ee02a71ae59e21ffc.zip |
Rearrange configure/default apps
Bug: 27276982
Bug: 27279305
Change-Id: I443e9d2bc0c3fd9bcc13ee86716c14fbb55af0ba
Diffstat (limited to 'src/com/android/settings/AppListPreference.java')
-rw-r--r-- | src/com/android/settings/AppListPreference.java | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/src/com/android/settings/AppListPreference.java b/src/com/android/settings/AppListPreference.java index 1c1ccd7447..8dee7b8f53 100644 --- a/src/com/android/settings/AppListPreference.java +++ b/src/com/android/settings/AppListPreference.java @@ -23,9 +23,12 @@ import android.content.DialogInterface; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; +import android.content.res.TypedArray; import android.graphics.drawable.Drawable; import android.os.Parcel; import android.os.Parcelable; +import android.os.UserHandle; +import android.os.UserManager; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; @@ -47,6 +50,9 @@ public class AppListPreference extends CustomListPreference { public static final String ITEM_NONE_VALUE = ""; + protected final boolean mForWork; + protected final int mUserId; + private Drawable[] mEntryDrawables; private boolean mShowItemNone = false; private CharSequence[] mSummaries; @@ -91,13 +97,24 @@ public class AppListPreference extends CustomListPreference { } } - public AppListPreference(Context context, AttributeSet attrs, - int defStyleAttr, int defStyleRes) { - super(context, attrs, defStyleAttr, defStyleRes); + public AppListPreference(Context context, AttributeSet attrs, int defStyle, int defAttrs) { + super(context, attrs, defStyle, defAttrs); + + TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.WorkPreference, 0, 0); + mForWork = a.getBoolean(R.styleable.WorkPreference_forWork, false); + final UserHandle managedProfile = Utils.getManagedProfile(UserManager.get(context)); + mUserId = mForWork && managedProfile != null ? managedProfile.getIdentifier() + : UserHandle.myUserId(); } public AppListPreference(Context context, AttributeSet attrs) { super(context, attrs); + + TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.WorkPreference, 0, 0); + mForWork = a.getBoolean(R.styleable.WorkPreference_forWork, false); + final UserHandle managedProfile = Utils.getManagedProfile(UserManager.get(context)); + mUserId = mForWork && managedProfile != null ? managedProfile.getIdentifier() + : UserHandle.myUserId(); } public void setShowItemNone(boolean showItemNone) { @@ -114,7 +131,8 @@ public class AppListPreference extends CustomListPreference { int selectedIndex = -1; for (int i = 0; i < packageNames.length; i++) { try { - ApplicationInfo appInfo = pm.getApplicationInfo(packageNames[i].toString(), 0); + ApplicationInfo appInfo = pm.getApplicationInfoAsUser(packageNames[i].toString(), 0, + mUserId); applicationNames.add(appInfo.loadLabel(pm)); validatedPackageNames.add(appInfo.packageName); entryDrawables.add(appInfo.loadIcon(pm)); @@ -162,8 +180,8 @@ public class AppListPreference extends CustomListPreference { int selectedIndex = -1; for (int i = 0; i < componentNames.length; i++) { try { - ApplicationInfo appInfo = pm.getApplicationInfo( - componentNames[i].getPackageName().toString(), 0); + ApplicationInfo appInfo = pm.getApplicationInfoAsUser( + componentNames[i].getPackageName().toString(), 0, mUserId); applicationNames.add(appInfo.loadLabel(pm)); validatedComponentNames.add(componentNames[i].flattenToString()); entryDrawables.add(appInfo.loadIcon(pm)); |