Messaging: Contact Colors
Adds the option to use individual colors for contacts. Matches the colors used in Contacts. Change-Id: I9f222308a900c5d47ec16f83232bd7f6d9af6cd7
This commit is contained in:
@@ -17,6 +17,7 @@ package com.android.messaging.ui;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
import com.android.messaging.Factory;
|
||||
@@ -52,6 +53,7 @@ public class ConversationDrawables {
|
||||
private int mIncomingAudioButtonColor;
|
||||
private int mSelectedBubbleColor;
|
||||
private int mThemeColor;
|
||||
private TypedArray mColors;
|
||||
|
||||
public static ConversationDrawables get() {
|
||||
if (sInstance == null) {
|
||||
@@ -102,10 +104,11 @@ public class ConversationDrawables {
|
||||
resources.getColor(R.color.message_audio_button_color_incoming);
|
||||
mSelectedBubbleColor = resources.getColor(R.color.message_bubble_color_selected);
|
||||
mThemeColor = resources.getColor(R.color.primary_color);
|
||||
mColors = resources.obtainTypedArray(R.array.letter_tile_colors);
|
||||
}
|
||||
|
||||
public Drawable getBubbleDrawable(final boolean selected, final boolean incoming,
|
||||
final boolean needArrow, final boolean isError) {
|
||||
final boolean needArrow, final boolean isError, final String identifier) {
|
||||
final Drawable protoDrawable;
|
||||
if (needArrow) {
|
||||
if (incoming) {
|
||||
@@ -127,7 +130,13 @@ public class ConversationDrawables {
|
||||
if (isError) {
|
||||
color = mIncomingErrorBubbleColor;
|
||||
} else {
|
||||
color = mThemeColor;
|
||||
if (identifier != null &&
|
||||
mContext.getResources().getBoolean(R.bool.contact_colors)) {
|
||||
int idcolor = Math.abs(identifier.hashCode()) % mColors.length();
|
||||
color = mColors.getColor(idcolor, mThemeColor);
|
||||
} else {
|
||||
color = mThemeColor;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
color = mOutgoingBubbleColor;
|
||||
|
||||
@@ -701,7 +701,8 @@ public class ConversationMessageView extends FrameLayout implements View.OnClick
|
||||
isSelected(),
|
||||
incoming,
|
||||
false /* needArrow */,
|
||||
mData.hasIncomingErrorStatus());
|
||||
mData.hasIncomingErrorStatus(),
|
||||
mData.getSenderContactLookupKey());
|
||||
textMinHeight = messageTextMinHeightDefault;
|
||||
textTopMargin = messageTopPaddingClustered;
|
||||
textTopPadding = textTopPaddingDefault;
|
||||
@@ -729,7 +730,8 @@ public class ConversationMessageView extends FrameLayout implements View.OnClick
|
||||
isSelected(),
|
||||
incoming,
|
||||
shouldShowMessageBubbleArrow(),
|
||||
mData.hasIncomingErrorStatus());
|
||||
mData.hasIncomingErrorStatus(),
|
||||
mData.getSenderContactLookupKey());
|
||||
textMinHeight = messageTextMinHeightDefault;
|
||||
textTopMargin = 0;
|
||||
textTopPadding = textTopPaddingDefault;
|
||||
@@ -1121,7 +1123,7 @@ public class ConversationMessageView extends FrameLayout implements View.OnClick
|
||||
audioView.bindMessagePartData(attachment, mData.getIsIncoming(), isSelected());
|
||||
audioView.setBackground(ConversationDrawables.get().getBubbleDrawable(
|
||||
isSelected(), mData.getIsIncoming(), false /* needArrow */,
|
||||
mData.hasIncomingErrorStatus()));
|
||||
mData.hasIncomingErrorStatus(), mData.getSenderContactLookupKey()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1138,7 +1140,7 @@ public class ConversationMessageView extends FrameLayout implements View.OnClick
|
||||
attachment));
|
||||
personView.setBackground(ConversationDrawables.get().getBubbleDrawable(
|
||||
isSelected(), mData.getIsIncoming(), false /* needArrow */,
|
||||
mData.hasIncomingErrorStatus()));
|
||||
mData.hasIncomingErrorStatus(), mData.getSenderContactLookupKey()));
|
||||
final int nameTextColorRes;
|
||||
final int detailsTextColorRes;
|
||||
if (isSelected()) {
|
||||
|
||||
Reference in New Issue
Block a user