summaryrefslogtreecommitdiff
path: root/java/com/android/incallui/ThemeColorManager.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/com/android/incallui/ThemeColorManager.java')
-rw-r--r--java/com/android/incallui/ThemeColorManager.java52
1 files changed, 50 insertions, 2 deletions
diff --git a/java/com/android/incallui/ThemeColorManager.java b/java/com/android/incallui/ThemeColorManager.java
index 967fae9ff..1d4c287be 100644
--- a/java/com/android/incallui/ThemeColorManager.java
+++ b/java/com/android/incallui/ThemeColorManager.java
@@ -17,8 +17,10 @@
package com.android.incallui;
import android.content.Context;
+import android.graphics.Color;
import android.support.annotation.ColorInt;
import android.support.annotation.Nullable;
+import android.support.v4.graphics.ColorUtils;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
import android.telecom.TelecomManager;
@@ -34,6 +36,10 @@ public class ThemeColorManager {
private final MaterialColorMapUtils colorMap;
@ColorInt private int primaryColor;
@ColorInt private int secondaryColor;
+ @ColorInt private int backgroundColorTop;
+ @ColorInt private int backgroundColorMiddle;
+ @ColorInt private int backgroundColorBottom;
+ @ColorInt private int backgroundColorSolid;
/**
* If there is no actual call currently in the call list, this will be used as a fallback to
@@ -51,21 +57,38 @@ public class ThemeColorManager {
public void onForegroundCallChanged(Context context, @Nullable DialerCall newForegroundCall) {
if (newForegroundCall == null) {
- updateThemeColors(getHighlightColor(context, pendingPhoneAccountHandle), false);
+ updateThemeColors(context, getHighlightColor(context, pendingPhoneAccountHandle), false);
} else {
updateThemeColors(
+ context,
getHighlightColor(context, newForegroundCall.getAccountHandle()),
newForegroundCall.isSpam());
}
}
- private void updateThemeColors(@ColorInt int highlightColor, boolean isSpam) {
+ private void updateThemeColors(Context context, @ColorInt int highlightColor, boolean isSpam) {
MaterialPalette palette;
if (isSpam) {
palette =
colorMap.calculatePrimaryAndSecondaryColor(R.color.incall_call_spam_background_color);
+ backgroundColorTop = context.getColor(R.color.incall_background_gradient_spam_top);
+ backgroundColorMiddle = context.getColor(R.color.incall_background_gradient_spam_middle);
+ backgroundColorBottom = context.getColor(R.color.incall_background_gradient_spam_bottom);
+ backgroundColorSolid = context.getColor(R.color.incall_background_multiwindow_spam);
} else {
palette = colorMap.calculatePrimaryAndSecondaryColor(highlightColor);
+ backgroundColorTop = context.getColor(R.color.incall_background_gradient_top);
+ backgroundColorMiddle = context.getColor(R.color.incall_background_gradient_middle);
+ backgroundColorBottom = context.getColor(R.color.incall_background_gradient_bottom);
+ backgroundColorSolid = context.getColor(R.color.incall_background_multiwindow);
+ if (highlightColor != PhoneAccount.NO_HIGHLIGHT_COLOR) {
+ // The default background gradient has a subtle alpha. We grab that alpha and apply it to
+ // the phone account color.
+ backgroundColorTop = applyAlpha(palette.mPrimaryColor, backgroundColorTop);
+ backgroundColorMiddle = applyAlpha(palette.mPrimaryColor, backgroundColorMiddle);
+ backgroundColorBottom = applyAlpha(palette.mPrimaryColor, backgroundColorBottom);
+ backgroundColorSolid = applyAlpha(palette.mPrimaryColor, backgroundColorSolid);
+ }
}
primaryColor = palette.mPrimaryColor;
@@ -92,4 +115,29 @@ public class ThemeColorManager {
public int getSecondaryColor() {
return secondaryColor;
}
+
+ @ColorInt
+ public int getBackgroundColorTop() {
+ return backgroundColorTop;
+ }
+
+ @ColorInt
+ public int getBackgroundColorMiddle() {
+ return backgroundColorMiddle;
+ }
+
+ @ColorInt
+ public int getBackgroundColorBottom() {
+ return backgroundColorBottom;
+ }
+
+ @ColorInt
+ public int getBackgroundColorSolid() {
+ return backgroundColorSolid;
+ }
+
+ @ColorInt
+ private static int applyAlpha(@ColorInt int color, @ColorInt int sourceColorWithAlpha) {
+ return ColorUtils.setAlphaComponent(color, Color.alpha(sourceColorWithAlpha));
+ }
}