Merge "Reduce user icon RAM usage" into lmp-mr1-dev

This commit is contained in:
Adrian Roos
2014-11-17 16:43:49 +00:00
committed by Android (Google) Code Review
7 changed files with 38 additions and 19 deletions

View File

@@ -38,8 +38,8 @@
android:layout_alignParentEnd="true"
android:background="@drawable/ripple_drawable" >
<ImageView android:id="@+id/multi_user_avatar"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_width="@dimen/multi_user_avatar_expanded_size"
android:layout_height="@dimen/multi_user_avatar_expanded_size"
android:layout_gravity="center"
android:scaleType="centerInside"/>
</com.android.systemui.statusbar.phone.MultiUserSwitch>

View File

@@ -405,6 +405,9 @@
<!-- The width of user avatar when on Keyguard -->
<dimen name="multi_user_avatar_keyguard_size">22dp</dimen>
<!-- The width of user avatar when expanded -->
<dimen name="multi_user_avatar_expanded_size">24dp</dimen>
<!-- The font size of the time when collapsed in QS -->
<dimen name="qs_time_collapsed_size">14sp</dimen>

View File

@@ -67,15 +67,18 @@ public class MultiUserSwitch extends FrameLayout implements View.OnClickListener
@Override
public void onClick(View v) {
if (opensUserSwitcherWhenClicked()) {
if (UserSwitcherController.isUserSwitcherAvailable(mUserManager)) {
if (mKeyguardMode) {
if (mKeyguardUserSwitcher != null) {
mKeyguardUserSwitcher.show(true /* animate */);
}
} else {
if (mQsPanel != null) {
mQsPanel.showDetailAdapter(true,
mQsPanel.getHost().getUserSwitcherController().userDetailAdapter);
UserSwitcherController userSwitcherController =
mQsPanel.getHost().getUserSwitcherController();
if (userSwitcherController != null) {
mQsPanel.showDetailAdapter(true, userSwitcherController.userDetailAdapter);
}
}
}
} else {
@@ -92,12 +95,14 @@ public class MultiUserSwitch extends FrameLayout implements View.OnClickListener
if (isClickable()) {
String text;
if (opensUserSwitcherWhenClicked()) {
if (UserSwitcherController.isUserSwitcherAvailable(mUserManager)) {
String currentUser = null;
if (mQsPanel != null) {
UserSwitcherController controller = mQsPanel.getHost()
.getUserSwitcherController();
currentUser = controller.getCurrentUserName(mContext);
if (controller != null) {
currentUser = controller.getCurrentUserName(mContext);
}
}
if (TextUtils.isEmpty(currentUser)) {
text = mContext.getString(R.string.accessibility_multi_user_switch_switcher);
@@ -121,8 +126,4 @@ public class MultiUserSwitch extends FrameLayout implements View.OnClickListener
return false;
}
private boolean opensUserSwitcherWhenClicked() {
UserManager um = UserManager.get(getContext());
return UserManager.supportsMultipleUsers() && um.isUserSwitcherEnabled();
}
}

View File

@@ -74,6 +74,7 @@ import android.os.PowerManager;
import android.os.RemoteException;
import android.os.SystemClock;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Settings;
import android.service.notification.NotificationListenerService;
import android.service.notification.NotificationListenerService.RankingMap;
@@ -853,8 +854,9 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
mKeyguardBottomArea.setAccessibilityController(mAccessibilityController);
mNextAlarmController = new NextAlarmController(mContext);
mKeyguardMonitor = new KeyguardMonitor();
mUserSwitcherController = new UserSwitcherController(mContext, mKeyguardMonitor);
if (UserSwitcherController.isUserSwitcherAvailable(UserManager.get(mContext))) {
mUserSwitcherController = new UserSwitcherController(mContext, mKeyguardMonitor);
}
mKeyguardUserSwitcher = new KeyguardUserSwitcher(mContext,
(ViewStub) mStatusBarWindow.findViewById(R.id.keyguard_user_switcher),
mKeyguardStatusBar, mNotificationPanel, mUserSwitcherController);
@@ -1510,7 +1512,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
// If the user switcher is simple then disable QS during setup because
// the user intends to use the lock screen user switcher, QS in not needed.
mNotificationPanel.setQsExpansionEnabled(isDeviceProvisioned()
&& (!mUserSwitcherController.isSimpleUserSwitcher() || mUserSetup));
&& (mUserSetup || mUserSwitcherController == null
|| !mUserSwitcherController.isSimpleUserSwitcher()));
mShadeUpdates.check();
}

View File

@@ -58,7 +58,9 @@ public class KeyguardUserSwitcher {
public KeyguardUserSwitcher(Context context, ViewStub userSwitcher,
KeyguardStatusBarView statusBarView, NotificationPanelView panelView,
UserSwitcherController userSwitcherController) {
if (context.getResources().getBoolean(R.bool.config_keyguardUserSwitcher) || ALWAYS_ON) {
boolean keyguardUserSwitcherEnabled =
context.getResources().getBoolean(R.bool.config_keyguardUserSwitcher) || ALWAYS_ON;
if (userSwitcherController != null && keyguardUserSwitcherEnabled) {
mUserSwitcherContainer = (Container) userSwitcher.inflate();
mUserSwitcher = (ViewGroup)
mUserSwitcherContainer.findViewById(R.id.keyguard_user_switcher_inner);

View File

@@ -23,6 +23,7 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.content.pm.UserInfo;
import android.content.res.Resources;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
@@ -131,8 +132,11 @@ public final class UserInfoController {
final int userId = userInfo.id;
final boolean isGuest = userInfo.isGuest();
final String userName = userInfo.name;
final int avatarSize
= mContext.getResources().getDimensionPixelSize(R.dimen.max_avatar_size);
final Resources res = mContext.getResources();
final int avatarSize = Math.max(
res.getDimensionPixelSize(R.dimen.multi_user_avatar_expanded_size),
res.getDimensionPixelSize(R.dimen.multi_user_avatar_keyguard_size));
final Context context = currentUserContext;
mUserInfoTask = new AsyncTask<Void, Void, Pair<String, Drawable>>() {
@@ -160,8 +164,9 @@ public final class UserInfoController {
// Try and read the display name from the local profile
final Cursor cursor = context.getContentResolver().query(
ContactsContract.Profile.CONTENT_URI, new String[] {
ContactsContract.CommonDataKinds.Phone._ID, ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME},
null, null, null);
ContactsContract.CommonDataKinds.Phone._ID,
ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME
}, null, null, null);
if (cursor != null) {
try {
if (cursor.moveToFirst()) {

View File

@@ -589,4 +589,9 @@ public class UserSwitcherController {
}
}
}
public static boolean isUserSwitcherAvailable(UserManager um) {
return UserManager.supportsMultipleUsers() && um.isUserSwitcherEnabled();
}
}