Merge "Fix density change bugs in SystemUI" into nyc-dev

This commit is contained in:
TreeHugger Robot
2016-05-10 22:38:25 +00:00
committed by Android (Google) Code Review
9 changed files with 85 additions and 32 deletions

View File

@@ -19,14 +19,5 @@
android:visibility="gone"
android:layout_height="match_parent"
android:layout_width="match_parent">
<com.android.keyguard.AlphaOptimizedLinearLayout
android:id="@+id/keyguard_user_switcher_inner"
android:orientation="vertical"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginTop="@dimen/status_bar_header_height_keyguard"
android:layout_gravity="end"
android:gravity="end"
android:paddingTop="4dp">
</com.android.keyguard.AlphaOptimizedLinearLayout>
<!-- KeyguardUserSwitcher loads keyguard_user_switcher_inner.xml here -->
</view>

View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2016 The Android Open Source Project
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License
-->
<com.android.keyguard.AlphaOptimizedLinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/keyguard_user_switcher_inner"
android:orientation="vertical"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginTop="@dimen/status_bar_header_height_keyguard"
android:layout_gravity="end"
android:gravity="end"
android:paddingTop="4dp">
</com.android.keyguard.AlphaOptimizedLinearLayout>

View File

@@ -16,6 +16,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:systemui="http://schemas.android.com/apk/res-auto"
android:layout_height="48dp"
android:layout_width="match_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp"
style="@style/BrightnessDialogContainer">

View File

@@ -85,6 +85,11 @@ public class KeyguardStatusBarView extends RelativeLayout
com.android.internal.R.dimen.text_size_small_material));
mBatteryLevel.setTextSize(TypedValue.COMPLEX_UNIT_PX,
getResources().getDimensionPixelSize(R.dimen.battery_level_text_size));
MarginLayoutParams lp = (MarginLayoutParams) mMultiUserAvatar.getLayoutParams();
lp.width = lp.height = getResources().getDimensionPixelSize(
R.dimen.multi_user_avatar_keyguard_size);
mMultiUserAvatar.setLayoutParams(lp);
}
private void loadDimens() {

View File

@@ -966,7 +966,9 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
super.onDensityOrFontScaleChanged();
mScrimController.onDensityOrFontScaleChanged();
mStatusBarView.onDensityOrFontScaleChanged();
mBrightnessMirrorController.onDensityOrFontScaleChanged();
if (mBrightnessMirrorController != null) {
mBrightnessMirrorController.onDensityOrFontScaleChanged();
}
inflateSignalClusters();
mIconController.onDensityOrFontScaleChanged();
inflateDismissView();
@@ -975,6 +977,13 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
updateEmptyShadeView();
inflateOverflowContainer();
mStatusBarKeyguardViewManager.onDensityOrFontScaleChanged();
mUserInfoController.onDensityOrFontScaleChanged();
if (mUserSwitcherController != null) {
mUserSwitcherController.onDensityOrFontScaleChanged();
}
if (mKeyguardUserSwitcher != null) {
mKeyguardUserSwitcher.onDensityOrFontScaleChanged();
}
}
private void inflateSignalClusters() {

View File

@@ -21,8 +21,6 @@ import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.database.DataSetObserver;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.MotionEvent;
@@ -47,11 +45,12 @@ public class KeyguardUserSwitcher {
private static final boolean ALWAYS_ON = false;
private final Container mUserSwitcherContainer;
private final ViewGroup mUserSwitcher;
private final KeyguardStatusBarView mStatusBarView;
private final Adapter mAdapter;
private final AppearAnimationUtils mAppearAnimationUtils;
private final KeyguardUserSwitcherScrim mBackground;
private ViewGroup mUserSwitcher;
private ObjectAnimator mBgAnimator;
private UserSwitcherController mUserSwitcherController;
private boolean mAnimating;
@@ -63,10 +62,8 @@ public class KeyguardUserSwitcher {
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);
mBackground = new KeyguardUserSwitcherScrim(mUserSwitcher);
mUserSwitcher.setBackground(mBackground);
mBackground = new KeyguardUserSwitcherScrim(context);
reinflateViews();
mStatusBarView = statusBarView;
mStatusBarView.setKeyguardUserSwitcher(this);
panelView.setKeyguardUserSwitcher(this);
@@ -78,7 +75,6 @@ public class KeyguardUserSwitcher {
mUserSwitcherContainer.setKeyguardUserSwitcher(this);
} else {
mUserSwitcherContainer = null;
mUserSwitcher = null;
mStatusBarView = null;
mAdapter = null;
mAppearAnimationUtils = null;
@@ -86,6 +82,22 @@ public class KeyguardUserSwitcher {
}
}
private void reinflateViews() {
if (mUserSwitcher != null) {
mUserSwitcher.setBackground(null);
mUserSwitcher.removeOnLayoutChangeListener(mBackground);
}
mUserSwitcherContainer.removeAllViews();
LayoutInflater.from(mUserSwitcherContainer.getContext())
.inflate(R.layout.keyguard_user_switcher_inner, mUserSwitcherContainer);
mUserSwitcher = (ViewGroup) mUserSwitcherContainer.findViewById(
R.id.keyguard_user_switcher_inner);
mUserSwitcher.addOnLayoutChangeListener(mBackground);
mUserSwitcher.setBackground(mBackground);
}
public void setKeyguard(boolean keyguard, boolean animate) {
if (mUserSwitcher != null) {
if (keyguard && shouldExpandByDefault()) {
@@ -228,6 +240,13 @@ public class KeyguardUserSwitcher {
}
};
public void onDensityOrFontScaleChanged() {
if (mUserSwitcherContainer != null) {
reinflateViews();
refresh();
}
}
public static class Adapter extends UserSwitcherController.BaseUserAdapter implements
View.OnClickListener {

View File

@@ -16,6 +16,7 @@
package com.android.systemui.statusbar.policy;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorFilter;
@@ -45,9 +46,8 @@ public class KeyguardUserSwitcherScrim extends Drawable
private Paint mRadialGradientPaint = new Paint();
private int mLayoutWidth;
public KeyguardUserSwitcherScrim(View host) {
host.addOnLayoutChangeListener(this);
mDarkColor = host.getContext().getColor(
public KeyguardUserSwitcherScrim(Context context) {
mDarkColor = context.getColor(
R.color.keyguard_user_switcher_background_gradient_color);
}

View File

@@ -50,7 +50,6 @@ public final class UserInfoController {
new ArrayList<OnUserInfoChangedListener>();
private AsyncTask<Void, Void, Pair<String, Drawable>> mUserInfoTask;
private boolean mUseDefaultAvatar;
private String mUserName;
private Drawable mUserDrawable;
@@ -58,7 +57,6 @@ public final class UserInfoController {
mContext = context;
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_USER_SWITCHED);
filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED);
mContext.registerReceiver(mReceiver, filter);
IntentFilter profileFilter = new IntentFilter();
@@ -83,10 +81,6 @@ public final class UserInfoController {
final String action = intent.getAction();
if (Intent.ACTION_USER_SWITCHED.equals(action)) {
reloadUserInfo();
} else if (Intent.ACTION_CONFIGURATION_CHANGED.equals(action)) {
if (mUseDefaultAvatar) {
reloadUserInfo();
}
}
}
};
@@ -159,7 +153,6 @@ public final class UserInfoController {
} else {
avatar = UserIcons.getDefaultUserIcon(isGuest? UserHandle.USER_NULL : userId,
/* light= */ true);
mUseDefaultAvatar = true;
}
// If it's a single-user device, get the profile name, since the nickname is not
@@ -202,6 +195,10 @@ public final class UserInfoController {
}
}
public void onDensityOrFontScaleChanged() {
reloadUserInfo();
}
public interface OnUserInfoChangedListener {
public void onUserInfoChanged(String name, Drawable picture);
}

View File

@@ -23,7 +23,6 @@ import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
@@ -169,12 +168,13 @@ public class UserSwitcherController {
return;
}
boolean forceAllUsers = mForcePictureLoadForUserId.get(UserHandle.USER_ALL);
SparseArray<Bitmap> bitmaps = new SparseArray<>(mUsers.size());
final int N = mUsers.size();
for (int i = 0; i < N; i++) {
UserRecord r = mUsers.get(i);
if (r == null || r.picture == null ||
r.info == null || mForcePictureLoadForUserId.get(r.info.id)) {
if (r == null || r.picture == null || r.info == null || forceAllUsers
|| mForcePictureLoadForUserId.get(r.info.id)) {
continue;
}
bitmaps.put(r.info.id, r.picture);
@@ -600,6 +600,10 @@ public class UserSwitcherController {
return item.info.name;
}
public void onDensityOrFontScaleChanged() {
refreshUsers(UserHandle.USER_ALL);
}
public static abstract class BaseUserAdapter extends BaseAdapter {
final UserSwitcherController mController;