diff options
author | wangqi <wangqi@google.com> | 2017-10-27 00:54:27 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-10-27 00:54:27 +0000 |
commit | 5f873da9542b888ffebe64f3953d784b2f91c3f7 (patch) | |
tree | 47eefa3a9b9b172df2db32e2f1b6246bad885a57 | |
parent | 499b6d1d2f2a7273a8e6f01a3f24d2b85da92f21 (diff) | |
parent | 4f6214ee55f6d286db36d970e2c60c9402c34d60 (diff) |
Merge "Set incall button color to match sim color."
am: 4f6214ee55
Change-Id: Ib9bde0c08610327be80680f108521190d77b3673
10 files changed, 50 insertions, 14 deletions
diff --git a/common_fixture_script.sh b/common_fixture_script.sh new file mode 100644 index 000000000..a7e527d4a --- /dev/null +++ b/common_fixture_script.sh @@ -0,0 +1,4 @@ +# This file runs before emulator integration tests . +# It utilizes adb shell commands to prepare test environment. + +setprop log.tag.Dialer VERBOSE 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() { |