summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorLucas Dupin <dupin@google.com>2020-11-19 03:18:10 +0000
committerLucas Dupin <dupin@google.com>2020-12-01 14:23:16 -0800
commit7b8636fdb0dfc5ef727365cdf42a2fb56bdffeb2 (patch)
tree35429253346bc7c59558a354d760026f13869499 /core/java
parent60797526531ad856bc3428ebc1af14a472c998ed (diff)
1/N The road to Material NEXT (bouncer and shade)
Styling bouncer and shade so they have solid backgrounds and read colors from themes instead of named resources. Scrim now fetches colorBackgroundFloating, and views get their background from colorBackground. Switching from light to dark theme will make bouncer colors update without re-inflating any views. Bug: 173561906 Bug: 173561901 Test: atest ScrimControllerTest Test: atest KeyguardSecurityContainerControllerTest Test: manual, switching to dark theme annd showing notif guts Change-Id: I372e8b688d7bbddd698381accd074b7655788cd0
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/app/Notification.java24
-rw-r--r--core/java/com/android/internal/widget/LockPatternView.java14
2 files changed, 32 insertions, 6 deletions
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index d5977e7711fd..a1135809fd4c 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -5932,8 +5932,7 @@ public class Notification implements Parcelable
}
int color;
- int background = mContext.getColor(
- com.android.internal.R.color.notification_material_background_color);
+ int background = obtainBackgroundColor();
if (rawColor == COLOR_DEFAULT) {
ensureColors(p);
color = ContrastColorUtil.resolveDefaultColor(mContext, background, mInNightMode);
@@ -5966,8 +5965,7 @@ public class Notification implements Parcelable
if (mNeutralColor != COLOR_INVALID) {
return mNeutralColor;
}
- int background = mContext.getColor(
- com.android.internal.R.color.notification_material_background_color);
+ int background = obtainBackgroundColor();
mNeutralColor = ContrastColorUtil.resolveDefaultColor(mContext, background,
mInNightMode);
if (Color.alpha(mNeutralColor) < 255) {
@@ -6118,6 +6116,21 @@ public class Notification implements Parcelable
return mN;
}
+ private @ColorInt int obtainBackgroundColor() {
+ int defaultColor = mInNightMode ? Color.BLACK : Color.WHITE;
+ Resources.Theme theme = mContext.getTheme();
+ if (theme == null) {
+ return defaultColor;
+ }
+ TypedArray ta = theme.obtainStyledAttributes(new int[]{R.attr.colorBackground});
+ if (ta == null) {
+ return defaultColor;
+ }
+ int background = ta.getColor(0, defaultColor);
+ ta.recycle();
+ return background;
+ }
+
/**
* Apply this Builder to an existing {@link Notification} object.
*
@@ -6251,8 +6264,7 @@ public class Notification implements Parcelable
private int resolveBackgroundColor(StandardTemplateParams p) {
int backgroundColor = getBackgroundColor(p);
if (backgroundColor == COLOR_DEFAULT) {
- backgroundColor = mContext.getColor(
- com.android.internal.R.color.notification_material_background_color);
+ backgroundColor = obtainBackgroundColor();
}
return backgroundColor;
}
diff --git a/core/java/com/android/internal/widget/LockPatternView.java b/core/java/com/android/internal/widget/LockPatternView.java
index 4ddc782aacb4..bad21d28416b 100644
--- a/core/java/com/android/internal/widget/LockPatternView.java
+++ b/core/java/com/android/internal/widget/LockPatternView.java
@@ -1090,6 +1090,20 @@ public class LockPatternView extends View {
}
}
+ /**
+ * Change theme colors
+ * @param regularColor The dot color
+ * @param successColor Color used when pattern is correct
+ * @param errorColor Color used when authentication fails
+ */
+ public void setColors(int regularColor, int successColor, int errorColor) {
+ mRegularColor = regularColor;
+ mErrorColor = errorColor;
+ mSuccessColor = successColor;
+ mPathPaint.setColor(regularColor);
+ invalidate();
+ }
+
private float getCenterXForColumn(int column) {
return mPaddingLeft + column * mSquareWidth + mSquareWidth / 2f;
}