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 --- .../theme/base/res/values/theme_dialer_dark.xml | 2 +- .../dialer/theme/common/res/values/colors.xml | 2 +- .../android/incallui/AnswerScreenPresenter.java | 9 +++ .../incallui/AnswerScreenPresenterStub.java | 4 ++ java/com/android/incallui/InCallActivity.java | 64 ++++++++++++++++++++++ java/com/android/incallui/ThemeColorManager.java | 52 +++++++++++++++++- .../incallui/answer/impl/AnswerFragment.java | 13 +++++ .../answer/impl/answermethod/res/values/styles.xml | 7 +++ .../answer/impl/res/layout/fragment_avatar.xml | 3 +- .../answer/protocol/AnswerScreenDelegate.java | 11 ++++ .../incallui/commontheme/res/values/styles.xml | 15 ++--- .../res/layout/incall_contactgrid_top_row.xml | 49 ++++++++--------- .../res/drawable/incall_background_gradient.xml | 23 ++++++++ .../android/incallui/theme/res/values/colors.xml | 12 ++++ .../android/incallui/theme/res/values/styles.xml | 26 ++++++++- 15 files changed, 251 insertions(+), 41 deletions(-) create mode 100644 java/com/android/incallui/answer/impl/answermethod/res/values/styles.xml create mode 100644 java/com/android/incallui/theme/res/drawable/incall_background_gradient.xml diff --git a/java/com/android/dialer/theme/base/res/values/theme_dialer_dark.xml b/java/com/android/dialer/theme/base/res/values/theme_dialer_dark.xml index 4b5034023..142bb897b 100644 --- a/java/com/android/dialer/theme/base/res/values/theme_dialer_dark.xml +++ b/java/com/android/dialer/theme/base/res/values/theme_dialer_dark.xml @@ -56,7 +56,7 @@ ?android:attr/colorPrimary - @color/google_grey_400 + ?android:attr/textColorSecondary ?android:attr/textColorSecondary @android:color/white @android:color/white diff --git a/java/com/android/dialer/theme/common/res/values/colors.xml b/java/com/android/dialer/theme/common/res/values/colors.xml index 6fea43665..1831862b1 100644 --- a/java/com/android/dialer/theme/common/res/values/colors.xml +++ b/java/com/android/dialer/theme/common/res/values/colors.xml @@ -16,7 +16,7 @@ --> - #34A853 + #00C853 #BD2A2A #D8D8D8 #2A56C6 diff --git a/java/com/android/incallui/AnswerScreenPresenter.java b/java/com/android/incallui/AnswerScreenPresenter.java index 35290dee9..8b789f317 100644 --- a/java/com/android/incallui/AnswerScreenPresenter.java +++ b/java/com/android/incallui/AnswerScreenPresenter.java @@ -18,6 +18,7 @@ package com.android.incallui; import android.content.Context; import android.os.SystemClock; +import android.support.annotation.FloatRange; import android.support.annotation.NonNull; import android.support.v4.os.UserManagerCompat; import android.telecom.VideoProfile; @@ -215,6 +216,14 @@ public class AnswerScreenPresenter } } + @Override + public void updateWindowBackgroundColor(@FloatRange(from = -1f, to = 1.0f) float progress) { + InCallActivity activity = (InCallActivity) answerScreen.getAnswerScreenFragment().getActivity(); + if (activity != null) { + activity.updateWindowBackgroundColor(progress); + } + } + private class AnswerOnDisconnected implements DialerCallListener { private final DialerCall disconnectingCall; diff --git a/java/com/android/incallui/AnswerScreenPresenterStub.java b/java/com/android/incallui/AnswerScreenPresenterStub.java index a96fee392..e85fdaa37 100644 --- a/java/com/android/incallui/AnswerScreenPresenterStub.java +++ b/java/com/android/incallui/AnswerScreenPresenterStub.java @@ -16,6 +16,7 @@ package com.android.incallui; +import android.support.annotation.FloatRange; import com.android.incallui.answer.protocol.AnswerScreenDelegate; import com.android.incallui.incalluilock.InCallUiLock; @@ -48,6 +49,9 @@ public class AnswerScreenPresenterStub implements AnswerScreenDelegate { @Override public void onAnswerAndReleaseButtonDisabled() {} + @Override + public void updateWindowBackgroundColor(@FloatRange(from = -1f, to = 1.0f) float progress) {} + @Override public boolean isActionTimeout() { return false; diff --git a/java/com/android/incallui/InCallActivity.java b/java/com/android/incallui/InCallActivity.java index fa4a06ecf..3ff1d269d 100644 --- a/java/com/android/incallui/InCallActivity.java +++ b/java/com/android/incallui/InCallActivity.java @@ -25,8 +25,12 @@ import android.app.KeyguardManager; import android.content.Context; import android.content.Intent; import android.content.res.Configuration; +import android.graphics.drawable.GradientDrawable; +import android.graphics.drawable.GradientDrawable.Orientation; import android.os.Bundle; import android.os.Trace; +import android.support.annotation.ColorInt; +import android.support.annotation.FloatRange; import android.support.annotation.IntDef; import android.support.annotation.NonNull; import android.support.annotation.Nullable; @@ -36,6 +40,7 @@ import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction; import android.support.v4.content.res.ResourcesCompat; +import android.support.v4.graphics.ColorUtils; import android.telecom.Call; import android.telecom.CallAudioState; import android.telecom.PhoneAccountHandle; @@ -132,6 +137,7 @@ public class InCallActivity extends TransactionSafeFragmentActivity private Animation dialpadSlideInAnimation; private Animation dialpadSlideOutAnimation; private Dialog errorDialog; + private GradientDrawable backgroundDrawable; private InCallOrientationEventListener inCallOrientationEventListener; private View pseudoBlackScreenOverlay; private SelectPhoneAccountDialogFragment selectPhoneAccountDialogFragment; @@ -150,6 +156,7 @@ public class InCallActivity extends TransactionSafeFragmentActivity private boolean isVisible; private boolean needDismissPendingDialogs; private boolean touchDownWhenPseudoScreenOff; + private int[] backgroundDrawableColors; @DialpadRequestType private int showDialpadRequest = DIALPAD_REQUEST_NONE; private SpeakEasyCallManager speakEasyCallManager; private DialogFragment rttRequestDialogFragment; @@ -867,6 +874,11 @@ public class InCallActivity extends TransactionSafeFragmentActivity public void onForegroundCallChanged(DialerCall newForegroundCall) { updateTaskDescription(); + + if (newForegroundCall == null || !didShowAnswerScreen) { + LogUtil.v("InCallActivity.onForegroundCallChanged", "resetting background color"); + updateWindowBackgroundColor(0 /* progress */); + } } private void updateTaskDescription() { @@ -880,6 +892,58 @@ public class InCallActivity extends TransactionSafeFragmentActivity getResources().getString(R.string.notification_ongoing_call), null /* icon */, color)); } + public void updateWindowBackgroundColor(@FloatRange(from = -1f, to = 1.0f) float progress) { + ThemeColorManager themeColorManager = InCallPresenter.getInstance().getThemeColorManager(); + @ColorInt int top; + @ColorInt int middle; + @ColorInt int bottom; + @ColorInt int gray = 0x66000000; + + if (isInMultiWindowMode()) { + top = themeColorManager.getBackgroundColorSolid(); + middle = themeColorManager.getBackgroundColorSolid(); + bottom = themeColorManager.getBackgroundColorSolid(); + } else { + top = themeColorManager.getBackgroundColorTop(); + middle = themeColorManager.getBackgroundColorMiddle(); + bottom = themeColorManager.getBackgroundColorBottom(); + } + + if (progress < 0) { + float correctedProgress = Math.abs(progress); + top = ColorUtils.blendARGB(top, gray, correctedProgress); + middle = ColorUtils.blendARGB(middle, gray, correctedProgress); + bottom = ColorUtils.blendARGB(bottom, gray, correctedProgress); + } + + boolean backgroundDirty = false; + if (backgroundDrawable == null) { + backgroundDrawableColors = new int[] {top, middle, bottom}; + backgroundDrawable = new GradientDrawable(Orientation.TOP_BOTTOM, backgroundDrawableColors); + backgroundDirty = true; + } else { + if (backgroundDrawableColors[0] != top) { + backgroundDrawableColors[0] = top; + backgroundDirty = true; + } + if (backgroundDrawableColors[1] != middle) { + backgroundDrawableColors[1] = middle; + backgroundDirty = true; + } + if (backgroundDrawableColors[2] != bottom) { + backgroundDrawableColors[2] = bottom; + backgroundDirty = true; + } + if (backgroundDirty) { + backgroundDrawable.setColors(backgroundDrawableColors); + } + } + + if (backgroundDirty) { + getWindow().setBackgroundDrawable(backgroundDrawable); + } + } + public boolean isVisible() { return isVisible; } 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)); + } } diff --git a/java/com/android/incallui/answer/impl/AnswerFragment.java b/java/com/android/incallui/answer/impl/AnswerFragment.java index f5da3effd..8d8b08791 100644 --- a/java/com/android/incallui/answer/impl/AnswerFragment.java +++ b/java/com/android/incallui/answer/impl/AnswerFragment.java @@ -880,6 +880,8 @@ public class AnswerFragment extends Fragment if (primaryCallState != null) { contactGridManager.setCallState(primaryCallState); } + + restoreBackgroundMaskColor(); } @Override @@ -898,6 +900,12 @@ public class AnswerFragment extends Fragment @Override public void onAnswerProgressUpdate(@FloatRange(from = -1f, to = 1f) float answerProgress) { + // Don't fade the window background for call waiting or video upgrades. Fading the background + // shows the system wallpaper which looks bad because on reject we switch to another call. + if (primaryCallState.state() == DialerCallState.INCOMING && !isVideoCall()) { + answerScreenDelegate.updateWindowBackgroundColor(answerProgress); + } + // Fade and scale contact name and video call text float startDelay = .25f; // Header progress is zero over positiveAdjustedProgress = [0, startDelay], @@ -926,6 +934,7 @@ public class AnswerFragment extends Fragment @Override public void resetAnswerProgress() { affordanceHolderLayout.reset(true); + restoreBackgroundMaskColor(); } private void animateEntry(@NonNull View rootView) { @@ -994,6 +1003,10 @@ public class AnswerFragment extends Fragment } } + private void restoreBackgroundMaskColor() { + answerScreenDelegate.updateWindowBackgroundColor(0); + } + private void restoreSwipeHintTexts() { if (getAnswerMethod() != null) { if (allowAnswerAndRelease()) { diff --git a/java/com/android/incallui/answer/impl/answermethod/res/values/styles.xml b/java/com/android/incallui/answer/impl/answermethod/res/values/styles.xml new file mode 100644 index 000000000..fd3ca7ca0 --- /dev/null +++ b/java/com/android/incallui/answer/impl/answermethod/res/values/styles.xml @@ -0,0 +1,7 @@ + + + + diff --git a/java/com/android/incallui/answer/impl/res/layout/fragment_avatar.xml b/java/com/android/incallui/answer/impl/res/layout/fragment_avatar.xml index 246abc577..f8e48942c 100644 --- a/java/com/android/incallui/answer/impl/res/layout/fragment_avatar.xml +++ b/java/com/android/incallui/answer/impl/res/layout/fragment_avatar.xml @@ -21,4 +21,5 @@ android:id="@id/contactgrid_avatar" android:layout_width="@dimen/answer_avatar_size" android:layout_height="@dimen/answer_avatar_size" - android:layout_gravity="center"/> + android:layout_gravity="center" + android:elevation="@dimen/answer_data_elevation"/> diff --git a/java/com/android/incallui/answer/protocol/AnswerScreenDelegate.java b/java/com/android/incallui/answer/protocol/AnswerScreenDelegate.java index db2af9bbb..172d9646a 100644 --- a/java/com/android/incallui/answer/protocol/AnswerScreenDelegate.java +++ b/java/com/android/incallui/answer/protocol/AnswerScreenDelegate.java @@ -16,6 +16,7 @@ package com.android.incallui.answer.protocol; +import android.support.annotation.FloatRange; import com.android.incallui.incalluilock.InCallUiLock; /** Callbacks implemented by the container app for this module. */ @@ -36,6 +37,16 @@ public interface AnswerScreenDelegate { void onAnswerAndReleaseButtonEnabled(); void onAnswerAndReleaseButtonDisabled(); + /** + * Sets the window background color based on foreground call's theme and the given progress. This + * is called from the answer UI to animate the accept and reject action. + * + *

When the user is rejecting we animate the background color to a mostly transparent gray. The + * end effect is that the home screen shows through. + * + * @param progress float from -1 to 1. -1 is fully rejected, 1 is fully accepted, and 0 is neutral + */ + void updateWindowBackgroundColor(@FloatRange(from = -1f, to = 1.0f) float progress); /** Returns true if any answer/reject action timed out. */ boolean isActionTimeout(); diff --git a/java/com/android/incallui/commontheme/res/values/styles.xml b/java/com/android/incallui/commontheme/res/values/styles.xml index f2ec2ccc3..464eda5bb 100644 --- a/java/com/android/incallui/commontheme/res/values/styles.xml +++ b/java/com/android/incallui/commontheme/res/values/styles.xml @@ -17,12 +17,15 @@ - - - - + + -- cgit v1.2.3