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;
|
||||
|
||||
Reference in New Issue
Block a user