Merge "Apply predefined icon and label to managed profiles" into lmp-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
d47f15a474
@@ -5181,8 +5181,6 @@
|
||||
<string name="user_add_user_menu">Add user</string>
|
||||
<!-- User settings summary for a restricted profile [CHAR LIMIT=50] -->
|
||||
<string name="user_summary_restricted_profile">Restricted profile</string>
|
||||
<!-- User settings summary for a work profile [CHAR LIMIT=50] -->
|
||||
<string name="user_summary_managed_profile">Work profile</string>
|
||||
<!-- User settings warning that restricted profile needs a screen lock [CHAR LIMIT=NONE] -->
|
||||
<string name="user_need_lock_message">Before you can create a restricted profile, you\'ll need to set up a screen lock to protect your apps and personal data.</string>
|
||||
<!-- User settings dialog button to set screen lock [CHAR LIMIT=25] -->
|
||||
|
@@ -61,8 +61,6 @@ import android.provider.ContactsContract.Profile;
|
||||
import android.provider.ContactsContract.RawContacts;
|
||||
import android.service.persistentdata.PersistentDataBlockManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.text.BidiFormatter;
|
||||
import android.text.TextDirectionHeuristics;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
@@ -70,10 +68,8 @@ import android.view.ViewGroup;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TabWidget;
|
||||
|
||||
import com.android.internal.util.ImageUtils;
|
||||
import com.android.internal.util.UserIcons;
|
||||
import com.android.settings.UserSpinnerAdapter.UserDetails;
|
||||
import com.android.settings.dashboard.DashboardCategory;
|
||||
import com.android.settings.dashboard.DashboardTile;
|
||||
import com.android.settings.drawable.CircleFramedDrawable;
|
||||
|
||||
@@ -858,6 +854,12 @@ public final class Utils {
|
||||
* Returns a circular icon for a user.
|
||||
*/
|
||||
public static Drawable getUserIcon(Context context, UserManager um, UserInfo user) {
|
||||
if (user.isManagedProfile()) {
|
||||
// We use predefined values for managed profiles
|
||||
Bitmap b = BitmapFactory.decodeResource(context.getResources(),
|
||||
com.android.internal.R.drawable.ic_corp_icon);
|
||||
return CircleFramedDrawable.getInstance(context, b);
|
||||
}
|
||||
if (user.iconPath != null) {
|
||||
Bitmap icon = um.getUserIcon(user.id);
|
||||
if (icon != null) {
|
||||
@@ -867,6 +869,23 @@ public final class Utils {
|
||||
return UserIcons.getDefaultUserIcon(user.id, /* light= */ false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a label for the user, in the form of "User: user name" or "Work profile".
|
||||
*/
|
||||
public static String getUserLabel(Context context, UserInfo info) {
|
||||
if (info.isManagedProfile()) {
|
||||
// We use predefined values for managed profiles
|
||||
return context.getString(R.string.managed_user_title);
|
||||
}
|
||||
String name = info != null ? info.name : null;
|
||||
if (name == null && info != null) {
|
||||
name = Integer.toString(info.id);
|
||||
} else if (info == null) {
|
||||
name = context.getString(R.string.unknown);
|
||||
}
|
||||
return context.getResources().getString(R.string.running_process_item_user_label, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether or not the user should have a SIM Cards option in Settings.
|
||||
* TODO: Change back to returning true if count is greater than one after testing.
|
||||
|
@@ -16,9 +16,6 @@
|
||||
|
||||
package com.android.settings.applications;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.app.ActivityManagerNative;
|
||||
import android.app.ActivityThread;
|
||||
@@ -31,6 +28,8 @@ import android.content.pm.PackageManager;
|
||||
import android.content.pm.ServiceInfo;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.Drawable.ConstantState;
|
||||
import android.os.Handler;
|
||||
@@ -44,6 +43,10 @@ import android.text.format.Formatter;
|
||||
import android.util.Log;
|
||||
import android.util.SparseArray;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.drawable.CircleFramedDrawable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
@@ -836,17 +839,8 @@ public class RunningState {
|
||||
userItem.mUser = new UserState();
|
||||
UserInfo info = mUm.getUserInfo(newItem.mUserId);
|
||||
userItem.mUser.mInfo = info;
|
||||
if (info != null) {
|
||||
userItem.mUser.mIcon = Utils.getUserIcon(context, mUm, info);
|
||||
}
|
||||
String name = info != null ? info.name : null;
|
||||
if (name == null && info != null) {
|
||||
name = Integer.toString(info.id);
|
||||
} else if (info == null) {
|
||||
name = context.getString(R.string.unknown);
|
||||
}
|
||||
userItem.mUser.mLabel = context.getResources().getString(
|
||||
R.string.running_process_item_user_label, name);
|
||||
userItem.mUser.mIcon = Utils.getUserIcon(context, mUm, info);
|
||||
userItem.mUser.mLabel = Utils.getUserLabel(context, info);
|
||||
}
|
||||
newMergedItems.add(userItem);
|
||||
}
|
||||
|
@@ -167,12 +167,7 @@ public class BatteryEntry {
|
||||
UserInfo info = um.getUserInfo(sipper.userId);
|
||||
if (info != null) {
|
||||
icon = Utils.getUserIcon(context, um, info);
|
||||
name = info != null ? info.name : null;
|
||||
if (name == null) {
|
||||
name = Integer.toString(info.id);
|
||||
}
|
||||
name = context.getResources().getString(
|
||||
R.string.running_process_item_user_label, name);
|
||||
name = Utils.getUserLabel(context, info);
|
||||
} else {
|
||||
icon = null;
|
||||
name = context.getResources().getString(
|
||||
|
@@ -136,15 +136,8 @@ public class UidDetailProvider {
|
||||
final int userHandle = getUserIdForKey(uid);
|
||||
final UserInfo info = um.getUserInfo(userHandle);
|
||||
if (info != null) {
|
||||
if (info.isManagedProfile()) {
|
||||
detail.label = res.getString(R.string.managed_user_title);
|
||||
detail.icon = mContext.getDrawable(
|
||||
com.android.internal.R.drawable.ic_corp_icon);
|
||||
} else {
|
||||
detail.label = res.getString(R.string.running_process_item_user_label,
|
||||
info.name);
|
||||
detail.icon = Utils.getUserIcon(mContext, um, info);
|
||||
}
|
||||
detail.label = Utils.getUserLabel(mContext, info);
|
||||
detail.icon = Utils.getUserIcon(mContext, um, info);
|
||||
return detail;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user