diff options
author | wangqi <wangqi@google.com> | 2017-10-26 11:27:19 -0700 |
---|---|---|
committer | Eric Erfanian <erfanian@google.com> | 2017-10-26 15:31:05 -0700 |
commit | 8d662cae2c05b5e256e7bb826abf05fb9ace133d (patch) | |
tree | 47eefa3a9b9b172df2db32e2f1b6246bad885a57 /java | |
parent | 9b99b22391a92fe20a74076bf5e47d36eb9b4ab4 (diff) |
Set incall button color to match sim color.
This change also add a handy adb command script run before UI integration test.
Bug: 67429956
Test: IncallActivityTest
PiperOrigin-RevId: 173565382
Change-Id: I9b8b957f00a0b7d11dbb7f40e8c9f1dbdb8c3928
Diffstat (limited to 'java')
9 files changed, 46 insertions, 14 deletions
diff --git a/java/com/android/incallui/CallButtonPresenter.java b/java/com/android/incallui/CallButtonPresenter.java index aa96c4fe5..cc95f7b84 100644 --- a/java/com/android/incallui/CallButtonPresenter.java +++ b/java/com/android/incallui/CallButtonPresenter.java @@ -412,7 +412,8 @@ public class CallButtonPresenter } if (call != null) { - mInCallButtonUi.updateInCallButtonUiColors(); + mInCallButtonUi.updateInCallButtonUiColors( + InCallPresenter.getInstance().getThemeColorManager().getSecondaryColor()); } final boolean isEnabled = @@ -559,5 +560,4 @@ public class CallButtonPresenter } return null; } - } diff --git a/java/com/android/incallui/InCallPresenter.java b/java/com/android/incallui/InCallPresenter.java index 8535cbc3e..ed7b2c290 100644 --- a/java/com/android/incallui/InCallPresenter.java +++ b/java/com/android/incallui/InCallPresenter.java @@ -357,8 +357,10 @@ public class InCallPresenter implements CallList.Listener { mProximitySensor = proximitySensor; addListener(mProximitySensor); - mThemeColorManager = - new ThemeColorManager(new InCallUIMaterialColorMapUtils(mContext.getResources())); + if (mThemeColorManager == null) { + mThemeColorManager = + new ThemeColorManager(new InCallUIMaterialColorMapUtils(mContext.getResources())); + } mCallList = callList; mExternalCallList = externalCallList; @@ -1651,6 +1653,11 @@ public class InCallPresenter implements CallList.Listener { return mThemeColorManager; } + @VisibleForTesting + public void setThemeColorManager(ThemeColorManager themeColorManager) { + mThemeColorManager = themeColorManager; + } + /** Called when the foreground call changes. */ public void onForegroundCallChanged(DialerCall newForegroundCall) { mThemeColorManager.onForegroundCallChanged(mContext, newForegroundCall); diff --git a/java/com/android/incallui/ThemeColorManager.java b/java/com/android/incallui/ThemeColorManager.java index a88ae33cd..1d4c287be 100644 --- a/java/com/android/incallui/ThemeColorManager.java +++ b/java/com/android/incallui/ThemeColorManager.java @@ -57,14 +57,16 @@ public class ThemeColorManager { public void onForegroundCallChanged(Context context, @Nullable DialerCall newForegroundCall) { if (newForegroundCall == null) { - updateThemeColors(context, pendingPhoneAccountHandle, false); + updateThemeColors(context, getHighlightColor(context, pendingPhoneAccountHandle), false); } else { - updateThemeColors(context, newForegroundCall.getAccountHandle(), newForegroundCall.isSpam()); + updateThemeColors( + context, + getHighlightColor(context, newForegroundCall.getAccountHandle()), + newForegroundCall.isSpam()); } } - private void updateThemeColors( - Context context, @Nullable PhoneAccountHandle handle, boolean isSpam) { + private void updateThemeColors(Context context, @ColorInt int highlightColor, boolean isSpam) { MaterialPalette palette; if (isSpam) { palette = @@ -74,7 +76,6 @@ public class ThemeColorManager { backgroundColorBottom = context.getColor(R.color.incall_background_gradient_spam_bottom); backgroundColorSolid = context.getColor(R.color.incall_background_multiwindow_spam); } else { - @ColorInt int highlightColor = getHighlightColor(context, handle); palette = colorMap.calculatePrimaryAndSecondaryColor(highlightColor); backgroundColorTop = context.getColor(R.color.incall_background_gradient_top); backgroundColorMiddle = context.getColor(R.color.incall_background_gradient_middle); @@ -95,7 +96,7 @@ public class ThemeColorManager { } @ColorInt - private static int getHighlightColor(Context context, @Nullable PhoneAccountHandle handle) { + private int getHighlightColor(Context context, @Nullable PhoneAccountHandle handle) { if (handle != null) { PhoneAccount account = context.getSystemService(TelecomManager.class).getPhoneAccount(handle); if (account != null) { diff --git a/java/com/android/incallui/incall/impl/CheckableLabeledButton.java b/java/com/android/incallui/incall/impl/CheckableLabeledButton.java index a681adcb4..325c3a92a 100644 --- a/java/com/android/incallui/incall/impl/CheckableLabeledButton.java +++ b/java/com/android/incallui/incall/impl/CheckableLabeledButton.java @@ -18,11 +18,14 @@ package com.android.incallui.incall.impl; import android.animation.AnimatorInflater; import android.content.Context; +import android.content.res.ColorStateList; import android.content.res.TypedArray; +import android.graphics.Color; import android.graphics.PorterDuff.Mode; import android.graphics.drawable.Drawable; import android.os.Parcel; import android.os.Parcelable; +import android.support.annotation.ColorInt; import android.support.annotation.DrawableRes; import android.support.annotation.StringRes; import android.text.TextUtils.TruncateAt; @@ -88,6 +91,7 @@ public class CheckableLabeledButton extends LinearLayout implements Checkable { iconView.setImageDrawable(icon); iconView.setImageTintMode(Mode.SRC_IN); iconView.setImageTintList(getResources().getColorStateList(R.color.incall_button_icon, null)); + iconView.setBackground(getResources().getDrawable(R.drawable.incall_button_background, null)); iconView.setDuplicateParentStateEnabled(true); iconView.setElevation(getResources().getDimension(R.dimen.incall_button_elevation)); @@ -124,6 +128,13 @@ public class CheckableLabeledButton extends LinearLayout implements Checkable { labelView.setAlpha(isEnabled() ? 1f : DISABLED_STATE_OPACITY); } + public void setCheckedColor(@ColorInt int color) { + iconView.setImageTintList( + new ColorStateList( + new int[][] {new int[] {android.R.attr.state_checked}, new int[] {}}, + new int[] {color, Color.WHITE})); + } + public void setIconDrawable(@DrawableRes int drawableRes) { iconView.setImageResource(drawableRes); } diff --git a/java/com/android/incallui/incall/impl/InCallButtonGridFragment.java b/java/com/android/incallui/incall/impl/InCallButtonGridFragment.java index db0b5b9b8..a0eead128 100644 --- a/java/com/android/incallui/incall/impl/InCallButtonGridFragment.java +++ b/java/com/android/incallui/incall/impl/InCallButtonGridFragment.java @@ -17,6 +17,7 @@ package com.android.incallui.incall.impl; import android.os.Bundle; +import android.support.annotation.ColorInt; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.util.ArraySet; @@ -127,6 +128,12 @@ public class InCallButtonGridFragment extends Fragment { return numVisibleButtons; } + public void updateButtonColor(@ColorInt int color) { + for (CheckableLabeledButton button : buttons) { + button.setCheckedColor(color); + } + } + /** Interface to let the listener know the status of the button grid. */ public interface OnButtonGridCreatedListener { void onButtonGridCreated(InCallButtonGridFragment inCallButtonGridFragment); diff --git a/java/com/android/incallui/incall/impl/InCallFragment.java b/java/com/android/incallui/incall/impl/InCallFragment.java index e96060c06..ddad61d27 100644 --- a/java/com/android/incallui/incall/impl/InCallFragment.java +++ b/java/com/android/incallui/incall/impl/InCallFragment.java @@ -23,6 +23,7 @@ import android.os.Build.VERSION; import android.os.Build.VERSION_CODES; import android.os.Bundle; import android.os.Handler; +import android.support.annotation.ColorInt; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; @@ -476,7 +477,9 @@ public class InCallFragment extends Fragment } @Override - public void updateInCallButtonUiColors() {} + public void updateInCallButtonUiColors(@ColorInt int color) { + inCallButtonGridFragment.updateButtonColor(color); + } @Override public Fragment getInCallButtonUiFragment() { diff --git a/java/com/android/incallui/incall/protocol/InCallButtonUi.java b/java/com/android/incallui/incall/protocol/InCallButtonUi.java index 96d741af3..28dd84c42 100644 --- a/java/com/android/incallui/incall/protocol/InCallButtonUi.java +++ b/java/com/android/incallui/incall/protocol/InCallButtonUi.java @@ -16,6 +16,7 @@ package com.android.incallui.incall.protocol; +import android.support.annotation.ColorInt; import android.support.v4.app.Fragment; import android.telecom.CallAudioState; @@ -42,7 +43,7 @@ public interface InCallButtonUi { */ void updateButtonStates(); - void updateInCallButtonUiColors(); + void updateInCallButtonUiColors(@ColorInt int color); Fragment getInCallButtonUiFragment(); diff --git a/java/com/android/incallui/video/impl/SurfaceViewVideoCallFragment.java b/java/com/android/incallui/video/impl/SurfaceViewVideoCallFragment.java index 95bdd6b78..631cc1d68 100644 --- a/java/com/android/incallui/video/impl/SurfaceViewVideoCallFragment.java +++ b/java/com/android/incallui/video/impl/SurfaceViewVideoCallFragment.java @@ -22,6 +22,7 @@ import android.content.pm.PackageManager; import android.graphics.Point; import android.graphics.drawable.Animatable; import android.os.Bundle; +import android.support.annotation.ColorInt; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.VisibleForTesting; @@ -804,7 +805,7 @@ public class SurfaceViewVideoCallFragment extends Fragment } @Override - public void updateInCallButtonUiColors() {} + public void updateInCallButtonUiColors(@ColorInt int color) {} @Override public Fragment getInCallButtonUiFragment() { diff --git a/java/com/android/incallui/video/impl/VideoCallFragment.java b/java/com/android/incallui/video/impl/VideoCallFragment.java index a3614c09c..0793d1830 100644 --- a/java/com/android/incallui/video/impl/VideoCallFragment.java +++ b/java/com/android/incallui/video/impl/VideoCallFragment.java @@ -30,6 +30,7 @@ import android.renderscript.Allocation; import android.renderscript.Element; import android.renderscript.RenderScript; import android.renderscript.ScriptIntrinsicBlur; +import android.support.annotation.ColorInt; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.VisibleForTesting; @@ -845,7 +846,7 @@ public class VideoCallFragment extends Fragment } @Override - public void updateInCallButtonUiColors() {} + public void updateInCallButtonUiColors(@ColorInt int color) {} @Override public Fragment getInCallButtonUiFragment() { |