From 991acb8d1b00d68e2be118cae5e9396d1127d5bb Mon Sep 17 00:00:00 2001 From: Nancy Chen Date: Fri, 24 Oct 2014 16:00:55 -0700 Subject: In Multi-SIM cases use the color of the SIM icon for InCallUI. Set the color of the InCallUI to be the color of the SIM icon. In the single SIM case, the background should be the default background. * Added id to all call button backgrounds for color change * Initialize color onResume for InCallActivity * CallCardFragment/CallButtonFragment/DialpadFragment update their colors * Added InCallUIMaterialColorMapUtils to extract color Bug: 17971273 Change-Id: Ia247b153b57ffc8a5277d521c433ab0be6696cf6 --- InCallUI/res/drawable/btn_add.xml | 5 +- InCallUI/res/drawable/btn_change_to_video.xml | 3 +- InCallUI/res/drawable/btn_change_to_voice.xml | 3 +- InCallUI/res/drawable/btn_compound_background.xml | 2 +- InCallUI/res/drawable/btn_compound_dialpad.xml | 3 +- InCallUI/res/drawable/btn_compound_hold.xml | 3 +- InCallUI/res/drawable/btn_compound_mute.xml | 3 +- InCallUI/res/drawable/btn_compound_video_off.xml | 3 +- .../res/drawable/btn_compound_video_switch.xml | 3 +- InCallUI/res/drawable/btn_merge.xml | 3 +- InCallUI/res/drawable/btn_overflow.xml | 3 +- InCallUI/res/drawable/btn_swap.xml | 3 +- InCallUI/res/layout/call_button_fragment.xml | 2 +- InCallUI/res/values/colors.xml | 27 +++++ .../com/android/incallui/CallButtonFragment.java | 113 ++++++++++++++++++++- .../src/com/android/incallui/CallCardFragment.java | 27 ++++- .../src/com/android/incallui/DialpadFragment.java | 39 +++++-- .../src/com/android/incallui/InCallActivity.java | 9 ++ .../src/com/android/incallui/InCallPresenter.java | 55 ++++++++++ .../incallui/InCallUIMaterialColorMapUtils.java | 52 ++++++++++ 20 files changed, 336 insertions(+), 25 deletions(-) create mode 100644 InCallUI/src/com/android/incallui/InCallUIMaterialColorMapUtils.java diff --git a/InCallUI/res/drawable/btn_add.xml b/InCallUI/res/drawable/btn_add.xml index 515d65b00..7d5e90f71 100644 --- a/InCallUI/res/drawable/btn_add.xml +++ b/InCallUI/res/drawable/btn_add.xml @@ -18,12 +18,13 @@ - + - + \ No newline at end of file diff --git a/InCallUI/res/drawable/btn_change_to_video.xml b/InCallUI/res/drawable/btn_change_to_video.xml index 962539e4f..a26cee3e9 100644 --- a/InCallUI/res/drawable/btn_change_to_video.xml +++ b/InCallUI/res/drawable/btn_change_to_video.xml @@ -18,7 +18,8 @@ - + - + cd + android:drawable="@drawable/btn_unselected_focused" /> diff --git a/InCallUI/res/drawable/btn_compound_dialpad.xml b/InCallUI/res/drawable/btn_compound_dialpad.xml index fcd9a3c0f..1b78ead44 100644 --- a/InCallUI/res/drawable/btn_compound_dialpad.xml +++ b/InCallUI/res/drawable/btn_compound_dialpad.xml @@ -18,7 +18,8 @@ - + diff --git a/InCallUI/res/drawable/btn_compound_hold.xml b/InCallUI/res/drawable/btn_compound_hold.xml index dcf95073a..7974efae5 100644 --- a/InCallUI/res/drawable/btn_compound_hold.xml +++ b/InCallUI/res/drawable/btn_compound_hold.xml @@ -18,7 +18,8 @@ - + diff --git a/InCallUI/res/drawable/btn_compound_mute.xml b/InCallUI/res/drawable/btn_compound_mute.xml index 68a8c9b34..86708fb0c 100644 --- a/InCallUI/res/drawable/btn_compound_mute.xml +++ b/InCallUI/res/drawable/btn_compound_mute.xml @@ -18,7 +18,8 @@ - + diff --git a/InCallUI/res/drawable/btn_compound_video_off.xml b/InCallUI/res/drawable/btn_compound_video_off.xml index 8af4209d3..b942cd0c3 100644 --- a/InCallUI/res/drawable/btn_compound_video_off.xml +++ b/InCallUI/res/drawable/btn_compound_video_off.xml @@ -19,7 +19,8 @@ - + diff --git a/InCallUI/res/drawable/btn_compound_video_switch.xml b/InCallUI/res/drawable/btn_compound_video_switch.xml index ef171ab9c..f8111866e 100644 --- a/InCallUI/res/drawable/btn_compound_video_switch.xml +++ b/InCallUI/res/drawable/btn_compound_video_switch.xml @@ -19,7 +19,8 @@ - + diff --git a/InCallUI/res/drawable/btn_merge.xml b/InCallUI/res/drawable/btn_merge.xml index 78e19749f..2b4818a47 100644 --- a/InCallUI/res/drawable/btn_merge.xml +++ b/InCallUI/res/drawable/btn_merge.xml @@ -18,7 +18,8 @@ - + - + - + #330288d1 + + + + #00796B + #3367D6 + #303F9F + #7B1FA2 + #C2185B + #C53929 + + + + + #004D40 + #1C3AA9 + #1A237E + #4A148C + #880E4F + #A52714 + diff --git a/InCallUI/src/com/android/incallui/CallButtonFragment.java b/InCallUI/src/com/android/incallui/CallButtonFragment.java index 3324c91e5..261378235 100644 --- a/InCallUI/src/com/android/incallui/CallButtonFragment.java +++ b/InCallUI/src/com/android/incallui/CallButtonFragment.java @@ -17,7 +17,11 @@ package com.android.incallui; import android.content.Context; +import android.content.res.Resources; +import android.graphics.drawable.Drawable; import android.graphics.drawable.LayerDrawable; +import android.graphics.drawable.GradientDrawable; +import android.graphics.drawable.StateListDrawable; import android.os.Bundle; import android.telecom.AudioState; import android.view.ContextThemeWrapper; @@ -34,6 +38,9 @@ import android.widget.PopupMenu; import android.widget.PopupMenu.OnDismissListener; import android.widget.PopupMenu.OnMenuItemClickListener; +import com.android.contacts.common.util.MaterialColorMapUtils; +import com.android.contacts.common.util.MaterialColorMapUtils.MaterialPalette; + /** * Fragment for call control buttons */ @@ -41,7 +48,6 @@ public class CallButtonFragment extends BaseFragment implements CallButtonPresenter.CallButtonUi, OnMenuItemClickListener, OnDismissListener, View.OnClickListener, CompoundButton.OnCheckedChangeListener { - private ImageButton mAudioButton; private ImageButton mChangeToVoiceButton; private ImageButton mMuteButton; @@ -66,6 +72,7 @@ public class CallButtonFragment private static final int VISIBLE = 255; private boolean mIsEnabled; + private MaterialPalette mCurrentThemeColors; @Override CallButtonPresenter createPresenter() { @@ -130,6 +137,8 @@ public class CallButtonFragment getPresenter().refreshMuteState(); } super.onResume(); + + updateColors(); } @Override @@ -190,6 +199,108 @@ public class CallButtonFragment } } + public void updateColors() { + MaterialPalette themeColors = InCallPresenter.getInstance().getThemeColors(); + + if (mCurrentThemeColors != null && mCurrentThemeColors.equals(themeColors)) { + return; + } + + Resources res = getActivity().getResources(); + ImageButton[] compoundButtons = { + mAudioButton, + mMuteButton, + mShowDialpadButton, + mHoldButton, + mSwitchCameraButton, + mPauseVideoButton + }; + + for (ImageButton button : compoundButtons) { + final LayerDrawable layers = (LayerDrawable) button.getBackground(); + final StateListDrawable btnCompoundDrawable = compoundBackgroundDrawable(themeColors); + layers.setDrawableByLayerId(R.id.compoundBackgroundItem, btnCompoundDrawable); + } + + ImageButton[] normalButtons = { + mChangeToVoiceButton, + mSwapButton, + mChangeToVideoButton, + mAddCallButton, + mMergeButton, + mOverflowButton + }; + + for (ImageButton button : normalButtons) { + final LayerDrawable layers = (LayerDrawable) button.getBackground(); + final StateListDrawable btnCompoundDrawable = backgroundDrawable(themeColors); + layers.setDrawableByLayerId(R.id.backgroundItem, btnCompoundDrawable); + } + + mCurrentThemeColors = themeColors; + } + + /** + * Generate a StateListDrawable which will be the background for a compound button, i.e. + * a button with pressed and unpressed states. The unpressed state will be the same color + * as the rest of the call card, the pressed state will be the dark version of that color. + */ + private StateListDrawable compoundBackgroundDrawable(MaterialPalette palette) { + Resources res = getResources(); + StateListDrawable stateListDrawable = new StateListDrawable(); + + addSelectedAndFocused(res, stateListDrawable); + addFocused(res, stateListDrawable); + addSelected(res, stateListDrawable, palette); + addUnselected(res, stateListDrawable, palette); + + return stateListDrawable; + } + + /** + * Generate a StateListDrawable which will be the background of a button to ensure it + * is the same color as the rest of the call card. + */ + private StateListDrawable backgroundDrawable(MaterialPalette palette) { + Resources res = getResources(); + StateListDrawable stateListDrawable = new StateListDrawable(); + + addFocused(res, stateListDrawable); + addUnselected(res, stateListDrawable, palette); + + return stateListDrawable; + } + + // state_selected and state_focused + private void addSelectedAndFocused(Resources res, StateListDrawable drawable) { + int[] selectedAndFocused = {android.R.attr.state_selected, android.R.attr.state_focused}; + Drawable selectedAndFocusedDrawable = res.getDrawable(R.drawable.btn_selected_focused); + drawable.addState(selectedAndFocused, selectedAndFocusedDrawable); + } + + // state_focused + private void addFocused(Resources res, StateListDrawable drawable) { + int[] focused = {android.R.attr.state_focused}; + Drawable focusedDrawable = res.getDrawable(R.drawable.btn_unselected_focused); + drawable.addState(focused, focusedDrawable); + } + + // state_selected + private void addSelected(Resources res, StateListDrawable drawable, MaterialPalette palette) { + int[] selected = {android.R.attr.state_selected}; + LayerDrawable selectedDrawable = (LayerDrawable) res.getDrawable(R.drawable.btn_selected); + ((GradientDrawable) selectedDrawable.getDrawable(0)).setColor(palette.mSecondaryColor); + drawable.addState(selected, selectedDrawable); + } + + // default + private void addUnselected(Resources res, StateListDrawable drawable, MaterialPalette palette) { + LayerDrawable unselectedDrawable = + (LayerDrawable) res.getDrawable(R.drawable.btn_unselected); + ((GradientDrawable) unselectedDrawable.getDrawable(0)).setColor(palette.mPrimaryColor); + drawable.addState(new int[0], unselectedDrawable); + } + @Override public void setEnabled(boolean isEnabled) { mIsEnabled = isEnabled; diff --git a/InCallUI/src/com/android/incallui/CallCardFragment.java b/InCallUI/src/com/android/incallui/CallCardFragment.java index 6643128b3..a3804b15d 100644 --- a/InCallUI/src/com/android/incallui/CallCardFragment.java +++ b/InCallUI/src/com/android/incallui/CallCardFragment.java @@ -46,7 +46,7 @@ import android.view.animation.AnimationUtils; import android.widget.ImageButton; import android.widget.ImageView; import android.widget.TextView; - +import com.android.contacts.common.util.MaterialColorMapUtils.MaterialPalette; import com.android.contacts.common.widget.FloatingActionButtonController; import com.android.phone.common.animation.AnimUtils; @@ -112,6 +112,8 @@ public class CallCardFragment extends BaseFragment eventText = event.getText(); @@ -802,9 +820,8 @@ public class CallCardFragment extends BaseFragment