summaryrefslogtreecommitdiff
path: root/InCallUI
diff options
context:
space:
mode:
authorNancy Chen <nancychen@google.com>2014-10-24 16:00:55 -0700
committerNancy Chen <nancychen@google.com>2014-10-29 22:42:49 +0000
commit991acb8d1b00d68e2be118cae5e9396d1127d5bb (patch)
tree831436338bb29e872f0d7eaf66024f411aa53f35 /InCallUI
parente05642ba64551c6fc96dee79e65d223f9326a749 (diff)
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
Diffstat (limited to 'InCallUI')
-rw-r--r--InCallUI/res/drawable/btn_add.xml5
-rw-r--r--InCallUI/res/drawable/btn_change_to_video.xml3
-rw-r--r--InCallUI/res/drawable/btn_change_to_voice.xml3
-rw-r--r--InCallUI/res/drawable/btn_compound_background.xml2
-rw-r--r--InCallUI/res/drawable/btn_compound_dialpad.xml3
-rw-r--r--InCallUI/res/drawable/btn_compound_hold.xml3
-rw-r--r--InCallUI/res/drawable/btn_compound_mute.xml3
-rw-r--r--InCallUI/res/drawable/btn_compound_video_off.xml3
-rw-r--r--InCallUI/res/drawable/btn_compound_video_switch.xml3
-rw-r--r--InCallUI/res/drawable/btn_merge.xml3
-rw-r--r--InCallUI/res/drawable/btn_overflow.xml3
-rw-r--r--InCallUI/res/drawable/btn_swap.xml3
-rw-r--r--InCallUI/res/layout/call_button_fragment.xml2
-rw-r--r--InCallUI/res/values/colors.xml27
-rw-r--r--InCallUI/src/com/android/incallui/CallButtonFragment.java113
-rw-r--r--InCallUI/src/com/android/incallui/CallCardFragment.java27
-rw-r--r--InCallUI/src/com/android/incallui/DialpadFragment.java39
-rw-r--r--InCallUI/src/com/android/incallui/InCallActivity.java9
-rw-r--r--InCallUI/src/com/android/incallui/InCallPresenter.java55
-rw-r--r--InCallUI/src/com/android/incallui/InCallUIMaterialColorMapUtils.java52
20 files changed, 336 insertions, 25 deletions
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 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:drawable="@drawable/btn_background" />
+ <item android:id="@+id/backgroundItem"
+ android:drawable="@drawable/btn_background" />
<item>
<bitmap android:src="@drawable/ic_toolbar_add_call"
android:gravity="center"
android:tint="@color/selectable_icon_tint" />
</item>
-
+
</layer-list> \ 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 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:drawable="@drawable/btn_background" />
+ <item android:id="@+id/backgroundItem"
+ android:drawable="@drawable/btn_background" />
<item>
<bitmap android:src="@drawable/ic_toolbar_video"
diff --git a/InCallUI/res/drawable/btn_change_to_voice.xml b/InCallUI/res/drawable/btn_change_to_voice.xml
index fdeae071b..86a7f21d5 100644
--- a/InCallUI/res/drawable/btn_change_to_voice.xml
+++ b/InCallUI/res/drawable/btn_change_to_voice.xml
@@ -18,7 +18,8 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:drawable="@drawable/btn_background" />
+ <item android:id="@+id/backgroundItem"
+ android:drawable="@drawable/btn_background" />
<item>
<bitmap android:src="@drawable/ic_toolbar_audio_phone"
diff --git a/InCallUI/res/drawable/btn_compound_background.xml b/InCallUI/res/drawable/btn_compound_background.xml
index 93e6c311a..36aab0df7 100644
--- a/InCallUI/res/drawable/btn_compound_background.xml
+++ b/InCallUI/res/drawable/btn_compound_background.xml
@@ -24,7 +24,7 @@
android:drawable="@drawable/btn_selected_focused" />
<item android:state_focused="true"
- android:drawable="@drawable/btn_unselected_focused" />cd
+ android:drawable="@drawable/btn_unselected_focused" />
<item android:state_selected="true"
android:drawable="@drawable/btn_selected" />
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 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- The standard "compound button" background. -->
- <item android:drawable="@drawable/btn_compound_background" />
+ <item android:id="@+id/compoundBackgroundItem"
+ android:drawable="@drawable/btn_compound_background" />
<!-- ...and the actual icon on top. Use an explicit <bitmap> to avoid scaling
the icon up to the full size of the button. -->
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 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- The standard "compound button" background. -->
- <item android:drawable="@drawable/btn_compound_background" />
+ <item android:id="@+id/compoundBackgroundItem"
+ android:drawable="@drawable/btn_compound_background" />
<!-- ...and the actual icon on top. Use an explicit <bitmap> to avoid scaling
the icon up to the full size of the button. -->
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 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- The standard "compound button" background. -->
- <item android:drawable="@drawable/btn_compound_background" />
+ <item android:id="@+id/compoundBackgroundItem"
+ android:drawable="@drawable/btn_compound_background" />
<!-- Use an explicit <bitmap> to avoid scaling the icon up to the full size of the button. -->
<item>
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 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- The standard "compound button" background. -->
- <item android:drawable="@drawable/btn_compound_background" />
+ <item android:id="@+id/compoundBackgroundItem"
+ android:drawable="@drawable/btn_compound_background" />
<!-- Use an explicit <bitmap> to avoid scaling the icon up to the full size of the button. -->
<item>
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 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- The standard "compound button" background. -->
- <item android:drawable="@drawable/btn_compound_background" />
+ <item android:id="@+id/compoundBackgroundItem"
+ android:drawable="@drawable/btn_compound_background" />
<!-- Use an explicit <bitmap> to avoid scaling the icon up to the full size of the button. -->
<item>
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 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:drawable="@drawable/btn_background" />
+ <item android:id="@+id/backgroundItem"
+ android:drawable="@drawable/btn_background" />
<item>
<bitmap android:src="@drawable/ic_toolbar_merge"
diff --git a/InCallUI/res/drawable/btn_overflow.xml b/InCallUI/res/drawable/btn_overflow.xml
index e851eceb4..2eb26cc14 100644
--- a/InCallUI/res/drawable/btn_overflow.xml
+++ b/InCallUI/res/drawable/btn_overflow.xml
@@ -18,7 +18,8 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:drawable="@drawable/btn_background" />
+ <item android:id="@+id/backgroundItem"
+ android:drawable="@drawable/btn_background" />
<item>
<bitmap android:src="@drawable/ic_overflow_menu"
diff --git a/InCallUI/res/drawable/btn_swap.xml b/InCallUI/res/drawable/btn_swap.xml
index 7a8241123..5d6c8ecaf 100644
--- a/InCallUI/res/drawable/btn_swap.xml
+++ b/InCallUI/res/drawable/btn_swap.xml
@@ -18,7 +18,8 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:drawable="@drawable/btn_background" />
+ <item android:id="@+id/backgroundItem"
+ android:drawable="@drawable/btn_background" />
<item>
<bitmap android:src="@drawable/ic_toolbar_swap"
diff --git a/InCallUI/res/layout/call_button_fragment.xml b/InCallUI/res/layout/call_button_fragment.xml
index aa87d0c1a..56d65b07f 100644
--- a/InCallUI/res/layout/call_button_fragment.xml
+++ b/InCallUI/res/layout/call_button_fragment.xml
@@ -35,6 +35,7 @@
android:layout_width="match_parent"
android:layout_margin="0dp"
android:padding="0dp"
+ android:background="@color/button_background_color"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:animateLayoutChanges="true"
@@ -46,7 +47,6 @@
android:layout_height="wrap_content"
android:paddingStart="@dimen/button_cluster_horizontal_padding"
android:paddingEnd="@dimen/button_cluster_horizontal_padding"
- android:background="@color/button_background_color"
android:gravity="bottom|center_horizontal">
<!-- This row only ever shows either 4 or 5 buttons. This may depend on whether the device
diff --git a/InCallUI/res/values/colors.xml b/InCallUI/res/values/colors.xml
index f691fe2d0..05c2cf139 100644
--- a/InCallUI/res/values/colors.xml
+++ b/InCallUI/res/values/colors.xml
@@ -76,4 +76,31 @@
<!-- 20% opacity, theme color. -->
<color name="incall_dialpad_touch_tint">#330288d1</color>
+
+ <!-- Background colors for InCallUI. This set of colors is a subset of
+ https://spec.googleplex.com/quantumpalette#extended which pass WCAG AA and all have a
+ contrast ratio over 5:1.
+
+ These colors are also used by InCallUIMaterialColorMapUtils to generate primary
+ activity colors.
+ -->
+ <array name="background_colors">
+ <item>#00796B</item>
+ <item>#3367D6</item>
+ <item>#303F9F</item>
+ <item>#7B1FA2</item>
+ <item>#C2185B</item>
+ <item>#C53929</item>
+ </array>
+
+ <!-- Darker versions of background_colors, two shades darker. These colors are used for the
+ status bar. -->
+ <array name="background_colors_dark">
+ <item>#004D40</item>
+ <item>#1C3AA9</item>
+ <item>#1A237E</item>
+ <item>#4A148C</item>
+ <item>#880E4F</item>
+ <item>#A52714</item>
+ </array>
</resources>
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<CallButtonPresenter, CallButtonPresenter.CallButtonUi>
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<CallCardPresenter, CallCardPr
private int mVideoAnimationDuration;
+ private MaterialPalette mCurrentThemeColors;
+
@Override
CallCardPresenter.CallCardUi getUi() {
return this;
@@ -791,6 +793,22 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr
mManageConferenceCallButton.setVisibility(visible ? View.VISIBLE : View.GONE);
}
+ /**
+ * Get the overall InCallUI background colors and apply to call card.
+ */
+ public void updateColors() {
+ MaterialPalette themeColors = InCallPresenter.getInstance().getThemeColors();
+
+ if (mCurrentThemeColors != null && mCurrentThemeColors.equals(themeColors)) {
+ return;
+ }
+
+ mPrimaryCallCardContainer.setBackgroundColor(themeColors.mPrimaryColor);
+ mCallButtonsContainer.setBackgroundColor(themeColors.mPrimaryColor);
+
+ mCurrentThemeColors = themeColors;
+ }
+
private void dispatchPopulateAccessibilityEvent(AccessibilityEvent event, View view) {
if (view == null) return;
final List<CharSequence> eventText = event.getText();
@@ -802,9 +820,8 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr
}
}
- public void animateForNewOutgoingCall(Point touchPoint) {
+ public void animateForNewOutgoingCall(final Point touchPoint) {
final ViewGroup parent = (ViewGroup) mPrimaryCallCardContainer.getParent();
- final Point startPoint = touchPoint;
final ViewTreeObserver observer = getView().getViewTreeObserver();
@@ -835,7 +852,7 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr
mCallTypeLabel.setAlpha(0);
mCallNumberAndLabel.setAlpha(0);
- final Animator revealAnimator = getRevealAnimator(startPoint);
+ final Animator revealAnimator = getRevealAnimator(touchPoint);
final Animator shrinkAnimator =
getShrinkAnimator(parent.getHeight(), originalHeight);
@@ -903,6 +920,8 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr
updateFabPosition();
}
});
+
+ updateColors();
}
/**
diff --git a/InCallUI/src/com/android/incallui/DialpadFragment.java b/InCallUI/src/com/android/incallui/DialpadFragment.java
index 6cb5d1f8f..63f6379fc 100644
--- a/InCallUI/src/com/android/incallui/DialpadFragment.java
+++ b/InCallUI/src/com/android/incallui/DialpadFragment.java
@@ -34,6 +34,7 @@ import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
+import com.android.contacts.common.util.MaterialColorMapUtils.MaterialPalette;
import com.android.phone.common.dialpad.DialpadKeyButton;
import com.android.phone.common.dialpad.DialpadView;
@@ -48,6 +49,10 @@ public class DialpadFragment extends BaseFragment<DialpadPresenter, DialpadPrese
private static final int ACCESSIBILITY_DTMF_STOP_DELAY_MILLIS = 50;
+ private final int[] mButtonIds = new int[] {R.id.zero, R.id.one, R.id.two, R.id.three,
+ R.id.four, R.id.five, R.id.six, R.id.seven, R.id.eight, R.id.nine, R.id.star,
+ R.id.pound};
+
/**
* LinearLayout with getter and setter methods for the translationY property using floats,
* for animation purposes.
@@ -132,6 +137,8 @@ public class DialpadFragment extends BaseFragment<DialpadPresenter, DialpadPrese
private DialpadView mDialpadView;
+ private int mCurrentTextColor;
+
/**
* Our own key listener, specialized for dealing with DTMF codes.
* 1. Ignore the backspace since it is irrelevant.
@@ -457,13 +464,35 @@ public class DialpadFragment extends BaseFragment<DialpadPresenter, DialpadPrese
// the edit (copy / paste / select) functions.
mDtmfDialerField.setLongClickable(false);
mDtmfDialerField.setElegantTextHeight(false);
- configureKeypadListeners(mDialpadView);
+ configureKeypadListeners();
}
return parent;
}
@Override
+ public void onResume() {
+ super.onResume();
+ updateColors();
+ }
+
+ public void updateColors() {
+ int textColor = InCallPresenter.getInstance().getThemeColors().mPrimaryColor;
+
+ if (mCurrentTextColor == textColor) {
+ return;
+ }
+
+ DialpadKeyButton dialpadKey;
+ for (int i = 0; i < mButtonIds.length; i++) {
+ dialpadKey = (DialpadKeyButton) mDialpadView.findViewById(mButtonIds[i]);
+ ((TextView) dialpadKey.findViewById(R.id.dialpad_key_number)).setTextColor(textColor);
+ }
+
+ mCurrentTextColor = textColor;
+ }
+
+ @Override
public void onDestroyView() {
mDialerKeyListener = null;
super.onDestroyView();
@@ -544,12 +573,10 @@ public class DialpadFragment extends BaseFragment<DialpadPresenter, DialpadPrese
}
}
- private void configureKeypadListeners(View fragmentView) {
- final int[] buttonIds = new int[] {R.id.zero, R.id.one, R.id.two, R.id.three, R.id.four,
- R.id.five, R.id.six, R.id.seven, R.id.eight, R.id.nine, R.id.star, R.id.pound};
+ private void configureKeypadListeners() {
DialpadKeyButton dialpadKey;
- for (int i = 0; i < buttonIds.length; i++) {
- dialpadKey = (DialpadKeyButton) fragmentView.findViewById(buttonIds[i]);
+ for (int i = 0; i < mButtonIds.length; i++) {
+ dialpadKey = (DialpadKeyButton) mDialpadView.findViewById(mButtonIds[i]);
dialpadKey.setOnTouchListener(this);
dialpadKey.setOnKeyListener(this);
dialpadKey.setOnHoverListener(this);
diff --git a/InCallUI/src/com/android/incallui/InCallActivity.java b/InCallUI/src/com/android/incallui/InCallActivity.java
index 27d17c4b5..5316b6dec 100644
--- a/InCallUI/src/com/android/incallui/InCallActivity.java
+++ b/InCallUI/src/com/android/incallui/InCallActivity.java
@@ -21,17 +21,20 @@ import android.app.Activity;
import android.app.AlertDialog;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
+import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.DialogInterface.OnCancelListener;
import android.content.Intent;
import android.content.res.Configuration;
+import android.content.res.Resources;
import android.graphics.Point;
import android.net.Uri;
import android.os.Bundle;
import android.telecom.DisconnectCause;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
+import android.telecom.TelecomManager;
import android.telephony.PhoneNumberUtils;
import android.text.TextUtils;
import android.view.MenuItem;
@@ -46,6 +49,8 @@ import android.view.accessibility.AccessibilityEvent;
import com.android.phone.common.animation.AnimUtils;
import com.android.phone.common.animation.AnimationListenerAdapter;
import com.android.contacts.common.interactions.TouchPointManager;
+import com.android.contacts.common.util.MaterialColorMapUtils;
+import com.android.contacts.common.util.MaterialColorMapUtils.MaterialPalette;
import com.android.contacts.common.widget.SelectPhoneAccountDialogFragment;
import com.android.contacts.common.widget.SelectPhoneAccountDialogFragment.SelectPhoneAccountListener;
import com.android.incallui.Call.State;
@@ -193,6 +198,9 @@ public class InCallActivity extends Activity {
super.onResume();
mIsForegroundActivity = true;
+
+ InCallPresenter.getInstance().setThemeColors();
+
InCallPresenter.getInstance().onUiShowing(true);
if (mShowDialpadRequested) {
@@ -493,6 +501,7 @@ public class InCallActivity extends Activity {
touchPoint = (Point) extras.getParcelable(TouchPointManager.TOUCH_POINT);
}
}
+
mCallCardFragment.animateForNewOutgoingCall(touchPoint);
/*
diff --git a/InCallUI/src/com/android/incallui/InCallPresenter.java b/InCallUI/src/com/android/incallui/InCallPresenter.java
index 1299dd32d..bd81f1036 100644
--- a/InCallUI/src/com/android/incallui/InCallPresenter.java
+++ b/InCallUI/src/com/android/incallui/InCallPresenter.java
@@ -27,6 +27,7 @@ import android.telecom.PhoneAccount;
import android.telecom.PhoneCapabilities;
import android.telecom.Phone;
import android.telecom.PhoneAccountHandle;
+import android.telecom.TelecomManager;
import android.telecom.VideoProfile;
import android.text.TextUtils;
import android.view.Surface;
@@ -34,6 +35,8 @@ import android.view.View;
import com.google.common.base.Preconditions;
+import com.android.contacts.common.util.MaterialColorMapUtils;
+import com.android.contacts.common.util.MaterialColorMapUtils.MaterialPalette;
import com.android.incalluibind.ObjectFactory;
import java.util.Collections;
@@ -143,6 +146,11 @@ public class InCallPresenter implements CallList.Listener, InCallPhoneListener {
private Phone mPhone;
+ /** Display colors for the UI. Consists of a primary color and secondary (darker) color */
+ private MaterialPalette mThemeColors;
+
+ private TelecomManager mTelecomManager;
+
public static synchronized InCallPresenter getInstance() {
if (sInCallPresenter == null) {
sInCallPresenter = new InCallPresenter();
@@ -1101,6 +1109,53 @@ public class InCallPresenter implements CallList.Listener, InCallPhoneListener {
}
/**
+ * Extract background color from call object. The theme colors will include a primary color
+ * and a secondary color.
+ */
+ public void setThemeColors() {
+ if (mInCallActivity == null) {
+ return;
+ }
+
+ Call call = CallList.getInstance().getFirstCall();
+ TelecomManager tm = getTelecomManager();
+
+ int color = PhoneAccount.NO_COLOR;
+
+ if (call != null && tm != null && tm.hasMultipleCallCapableAccounts()) {
+ PhoneAccount account = tm.getPhoneAccount(call.getAccountHandle());
+ if (account != null) {
+ color = account.getColor();
+ }
+ }
+
+ // This method will set the background to default if the color is PhoneAccount.NO_COLOR.
+ mThemeColors = new InCallUIMaterialColorMapUtils(mContext.getResources()).
+ calculatePrimaryAndSecondaryColor(color);
+
+ mInCallActivity.getWindow().setStatusBarColor(mThemeColors.mSecondaryColor);
+ }
+
+ /**
+ * @return A palette for colors to display in the UI.
+ */
+ public MaterialPalette getThemeColors() {
+ return mThemeColors;
+ }
+
+ /**
+ * @return An instance of TelecomManager.
+ */
+ private TelecomManager getTelecomManager() {
+ if (mTelecomManager == null) {
+ mTelecomManager = (TelecomManager)
+ mInCallActivity.getSystemService(Context.TELECOM_SERVICE);
+ }
+ return mTelecomManager;
+ }
+
+
+ /**
* Private constructor. Must use getInstance() to get this singleton.
*/
private InCallPresenter() {
diff --git a/InCallUI/src/com/android/incallui/InCallUIMaterialColorMapUtils.java b/InCallUI/src/com/android/incallui/InCallUIMaterialColorMapUtils.java
new file mode 100644
index 000000000..efab45f21
--- /dev/null
+++ b/InCallUI/src/com/android/incallui/InCallUIMaterialColorMapUtils.java
@@ -0,0 +1,52 @@
+package com.android.incallui;
+
+import android.content.res.Resources;
+import android.content.res.TypedArray;
+import android.telecom.PhoneAccount;
+
+import com.android.contacts.common.util.MaterialColorMapUtils;
+import com.android.contacts.common.util.MaterialColorMapUtils.MaterialPalette;
+
+public class InCallUIMaterialColorMapUtils extends MaterialColorMapUtils {
+ private final TypedArray sPrimaryColors;
+ private final TypedArray sSecondaryColors;
+ private final Resources mResources;
+
+ public InCallUIMaterialColorMapUtils(Resources resources) {
+ super(resources);
+ sPrimaryColors = resources.obtainTypedArray(
+ com.android.incallui.R.array.background_colors);
+ sSecondaryColors = resources.obtainTypedArray(
+ com.android.contacts.common.R.array.background_colors_dark);
+ mResources = resources;
+ }
+
+ /**
+ * Currently the InCallUI color will only vary by SIM color which is a list of colors
+ * defined in the background_colors array, so first search the list for the matching color and
+ * fall back to the closest matching color if an exact match does not exist.
+ */
+ @Override
+ public MaterialPalette calculatePrimaryAndSecondaryColor(int color) {
+ if (color == PhoneAccount.NO_COLOR) {
+ return getDefaultPrimaryAndSecondaryColors(mResources);
+ }
+
+ for (int i = 0; i < sPrimaryColors.length(); i++) {
+ if (sPrimaryColors.getColor(i, 0) == color) {
+ return new MaterialPalette(
+ sPrimaryColors.getColor(i, 0),
+ sSecondaryColors.getColor(i, 0));
+ }
+ }
+
+ // The color isn't in the list, so use the superclass to find an approximate color.
+ return super.calculatePrimaryAndSecondaryColor(color);
+ }
+
+ public static MaterialPalette getDefaultPrimaryAndSecondaryColors(Resources resources) {
+ final int primaryColor = resources.getColor(R.color.dialer_theme_color);
+ final int secondaryColor = resources.getColor(R.color.dialer_theme_color_dark);
+ return new MaterialPalette(primaryColor, secondaryColor);
+ }
+} \ No newline at end of file