From 4ca9e8da3d5c1469e9b203874c9c4e7d4db3eb92 Mon Sep 17 00:00:00 2001 From: Eric Erfanian Date: Tue, 10 Jul 2018 18:37:03 +0000 Subject: Revert "UI refresh for ringing screen." This reverts commit 36d5b93da4f93e50deb496daa5ad820c48aa7b01. Change-Id: I533bc3f7d592a6e257d184f0d3730b4be95f2af2 --- java/com/android/incallui/ThemeColorManager.java | 52 +++++++++++++++++++++++- 1 file changed, 50 insertions(+), 2 deletions(-) (limited to 'java/com/android/incallui/ThemeColorManager.java') 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)); + } } -- cgit v1.2.3