Fix UserAvatarView.setDisabled method.
Currently, we grey out the icon only when setDisabled method is called
and the icon is not already disabled. This would be a problem, if the
drawable is updated again. Updated to change the disabled state of the
icon in onDraw.
Bug: 26737161
Change-Id: Id166c05c3be3b1ebd9320b8f75f25a5a5cd12210
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/UserAvatarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/UserAvatarView.java
index 4f33d82..fd3c96e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/UserAvatarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/UserAvatarView.java
@@ -174,6 +174,7 @@
float halfW = getWidth() / 2f;
float halfH = getHeight() / 2f;
float halfSW = Math.min(halfH, halfW);
+ updateDrawableIfDisabled();
if (mBitmap != null && mScale > 0) {
int saveCount = canvas.getSaveCount();
canvas.save();
@@ -249,22 +250,25 @@
return;
}
mIsDisabled = disabled;
+ invalidate();
+ }
+
+ private void updateDrawableIfDisabled() {
int disabledColor = getContext().getColor(R.color.qs_tile_disabled_color);
PorterDuffColorFilter filter = new PorterDuffColorFilter(disabledColor,
PorterDuff.Mode.SRC_ATOP);
if (mBitmap != null) {
- if (disabled) {
+ if (mIsDisabled) {
mBitmapPaint.setColorFilter(filter);
} else {
mBitmapPaint.setColorFilter(null);
}
} else if (mDrawable != null) {
- if (disabled) {
+ if (mIsDisabled) {
mDrawable.setColorFilter(filter);
} else {
mDrawable.setColorFilter(null);
}
}
- invalidate();
}
}