Implement new color palette.

This commit is contained in:
Greyson Parrelli
2018-09-21 15:16:52 -07:00
parent cfd20d23e8
commit 127505af0b
28 changed files with 215 additions and 218 deletions

View File

@@ -2246,12 +2246,14 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
inputPanel.setQuote(GlideApp.with(this),
messageRecord.getDateSent(),
author,
recipient,
body,
slideDeck);
} else {
inputPanel.setQuote(GlideApp.with(this),
messageRecord.getDateSent(),
author,
recipient,
messageRecord.getBody(),
messageRecord.isMms() ? ((MmsMessageRecord) messageRecord).getSlideDeck() : new SlideDeck());
}

View File

@@ -303,9 +303,9 @@ public class ConversationItem extends LinearLayout
private void setBubbleState(MessageRecord messageRecord) {
if (messageRecord.isOutgoing()) {
bodyBubble.getBackground().setColorFilter(defaultBubbleColor, PorterDuff.Mode.MULTIPLY);
bodyBubble.getBackground().setColorFilter(messageRecord.getRecipient().getColor().toConversationColor(context), PorterDuff.Mode.MULTIPLY);
} else {
bodyBubble.getBackground().setColorFilter(defaultBubbleColor, PorterDuff.Mode.MULTIPLY);
bodyBubble.getBackground().setColorFilter(messageRecord.getRecipient().getColor().toConversationColor(context), PorterDuff.Mode.MULTIPLY);
}
if (audioViewStub.resolved()) {
@@ -315,13 +315,13 @@ public class ConversationItem extends LinearLayout
private void setAudioViewTint(MessageRecord messageRecord, Recipient recipient) {
if (messageRecord.isOutgoing()) {
audioViewStub.get().setTint(Color.WHITE, recipient.getColor().toConversationColor(context));
} else {
if (DynamicTheme.LIGHT.equals(TextSecurePreferences.getTheme(context))) {
audioViewStub.get().setTint(getContext().getResources().getColor(R.color.core_light_60), defaultBubbleColor);
audioViewStub.get().setTint(getContext().getResources().getColor(R.color.core_grey_60), defaultBubbleColor);
} else {
audioViewStub.get().setTint(Color.WHITE, defaultBubbleColor);
}
} else {
audioViewStub.get().setTint(Color.WHITE, recipient.getColor().toConversationColor(context));
}
}
@@ -599,7 +599,7 @@ public class ConversationItem extends LinearLayout
if (current.isMms() && !current.isMmsNotification() && ((MediaMmsMessageRecord)current).getQuote() != null) {
Quote quote = ((MediaMmsMessageRecord)current).getQuote();
assert quote != null;
quoteView.setQuote(glideRequests, quote.getId(), Recipient.from(context, quote.getAuthor(), true), quote.getText(), quote.isOriginalMissing(), quote.getAttachment());
quoteView.setQuote(glideRequests, quote.getId(), Recipient.from(context, quote.getAuthor(), true), conversationRecipient, quote.getText(), quote.isOriginalMissing(), quote.getAttachment());
quoteView.setVisibility(View.VISIBLE);
quoteView.getLayoutParams().width = ViewGroup.LayoutParams.WRAP_CONTENT;

View File

@@ -2,6 +2,8 @@ package org.thoughtcrime.securesms.color;
import android.content.Context;
import android.graphics.Color;
import android.support.annotation.ColorInt;
import android.support.annotation.ColorRes;
import android.support.annotation.NonNull;
import org.thoughtcrime.securesms.R;
@@ -12,119 +14,87 @@ import java.util.Map;
import static org.thoughtcrime.securesms.util.ThemeUtil.isDarkTheme;
public enum MaterialColor {
RED (R.color.conversation_red, R.color.conversation_red_shade, "red"),
PINK (R.color.conversation_pink, R.color.conversation_pink_shade, "pink"),
PURPLE (R.color.conversation_purple, R.color.conversation_purple_shade, "purple"),
INDIGO (R.color.conversation_indigo, R.color.conversation_indigo_shade, "indigo"),
BLUE (R.color.conversation_blue, R.color.conversation_blue_shade, "blue"),
CYAN (R.color.conversation_cyan, R.color.conversation_cyan_shade, "cyan"),
TEAL (R.color.conversation_teal, R.color.conversation_teal_shade, "teal"),
GREEN (R.color.conversation_green, R.color.conversation_green_shade, "green"),
ORANGE (R.color.conversation_orange, R.color.conversation_orange_shade, "orange"),
GREY (R.color.conversation_grey, R.color.conversation_grey_shade, "grey");
CRIMSON (R.color.conversation_crimson, R.color.conversation_crimson_tint, R.color.conversation_crimson_shade, "red"),
VERMILLION (R.color.conversation_vermillion, R.color.conversation_vermillion_tint, R.color.conversation_vermillion_shade, "orange"),
BURLAP (R.color.conversation_burlap, R.color.conversation_burlap_tint, R.color.conversation_burlap_shade, "brown"),
FOREST (R.color.conversation_forest, R.color.conversation_forest_tint, R.color.conversation_forest_shade, "green"),
WINTERGREEN(R.color.conversation_wintergreen, R.color.conversation_wintergreen_tint, R.color.conversation_wintergreen_shade, "light_green"),
TEAL (R.color.conversation_teal, R.color.conversation_teal_tint, R.color.conversation_teal_shade, "teal"),
BLUE (R.color.conversation_blue, R.color.conversation_blue_tint, R.color.conversation_blue_shade, "blue"),
INDIGO (R.color.conversation_indigo, R.color.conversation_indigo_tint, R.color.conversation_indigo_shade, "indigo"),
VIOLET (R.color.conversation_violet, R.color.conversation_violet_tint, R.color.conversation_violet_shade, "purple"),
PLUM (R.color.conversation_plumb, R.color.conversation_plumb_tint, R.color.conversation_plumb_shade, "pink"),
TAUPE (R.color.conversation_taupe, R.color.conversation_taupe_tint, R.color.conversation_taupe_shade, "blue_grey"),
STEEL (R.color.conversation_steel, R.color.conversation_steel_tint, R.color.conversation_steel_shade, "grey");
private static final Map<String, MaterialColor> COLOR_MATCHES = new HashMap<String, MaterialColor>() {{
put("red", RED);
put("brown", RED);
put("pink", PINK);
put("purple", PURPLE);
put("deep_purple", PURPLE);
put("indigo", INDIGO);
put("blue", BLUE);
put("light_blue", BLUE);
put("cyan", CYAN);
put("blue_grey", CYAN);
put("teal", TEAL);
put("green", GREEN);
put("light_green", GREEN);
put("lime", GREEN);
put("orange", ORANGE);
put("amber", ORANGE);
put("deep_orange", ORANGE);
put("yellow", ORANGE);
put("grey", GREY);
put("red", CRIMSON);
put("deep_orange", VERMILLION);
put("orange", VERMILLION);
put("amber", VERMILLION);
put("brown", BURLAP);
put("yellow", BURLAP);
put("pink", PLUM);
put("purple", VIOLET);
put("deep_purple", VIOLET);
put("indigo", INDIGO);
put("blue", BLUE);
put("light_blue", BLUE);
put("cyan", TEAL);
put("teal", TEAL);
put("green", FOREST);
put("light_green", WINTERGREEN);
put("lime", WINTERGREEN);
put("blue_grey", TAUPE);
put("grey", STEEL);
put("group_color", BLUE);
}};
private final int conversationColorLight;
private final int actionBarColorLight;
private final int statusBarColorLight;
private final int conversationColorDark;
private final int actionBarColorDark;
private final int statusBarColorDark;
private final @ColorRes int mainColor;
private final @ColorRes int tintColor;
private final @ColorRes int shadeColor;
private final String serialized;
MaterialColor(int conversationColorLight, int actionBarColorLight,
int statusBarColorLight, int conversationColorDark,
int actionBarColorDark, int statusBarColorDark,
String serialized)
{
this.conversationColorLight = conversationColorLight;
this.actionBarColorLight = actionBarColorLight;
this.statusBarColorLight = statusBarColorLight;
this.conversationColorDark = conversationColorDark;
this.actionBarColorDark = actionBarColorDark;
this.statusBarColorDark = statusBarColorDark;
this.serialized = serialized;
MaterialColor(@ColorRes int mainColor, @ColorRes int tintColor, @ColorRes int shadeColor, String serialized) {
this.mainColor = mainColor;
this.tintColor = tintColor;
this.shadeColor = shadeColor;
this.serialized = serialized;
}
MaterialColor(int conversationColor, int statusBarColor, String serialized)
{
this(conversationColor, conversationColor, statusBarColor,
conversationColor, conversationColor, statusBarColor, serialized);
public @ColorInt int toConversationColor(@NonNull Context context) {
return context.getResources().getColor(mainColor);
}
public int toConversationColor(@NonNull Context context) {
return context.getResources().getColor(isDarkTheme(context) ? conversationColorDark
: conversationColorLight);
public @ColorInt int toActionBarColor(@NonNull Context context) {
return context.getResources().getColor(mainColor);
}
public int toActionBarColor(@NonNull Context context) {
return context.getResources().getColor(isDarkTheme(context) ? actionBarColorDark
: actionBarColorLight);
public @ColorInt int toStatusBarColor(@NonNull Context context) {
return context.getResources().getColor(shadeColor);
}
public int toStatusBarColor(@NonNull Context context) {
return context.getResources().getColor(isDarkTheme(context) ? statusBarColorDark
: statusBarColorLight);
}
public int toQuoteBarColorResource(@NonNull Context context, boolean outgoing) {
public @ColorRes int toQuoteBarColorResource(@NonNull Context context, boolean outgoing) {
if (outgoing) {
return conversationColorDark;
return isDarkTheme(context) ? R.color.core_black : R.color.core_white;
}
return R.color.white;
return isDarkTheme(context) ? tintColor : shadeColor;
}
public int toQuoteBackgroundColor(@NonNull Context context, boolean outgoing) {
if (outgoing) {
int color = toConversationColor(context);
int alpha = isDarkTheme(context) ? (int) (0.2 * 255) : (int) (0.4 * 255);
return Color.argb(alpha, Color.red(color), Color.green(color), Color.blue(color));
}
return context.getResources().getColor(isDarkTheme(context) ? R.color.transparent_black_70
: R.color.transparent_white_aa);
public @ColorInt int toQuoteBackgroundColor(@NonNull Context context, boolean outgoing) {
return context.getResources().getColor(isDarkTheme(context) ? shadeColor : tintColor);
}
public int toQuoteFooterColor(@NonNull Context context, boolean outgoing) {
if (outgoing) {
int color = toConversationColor(context);
int alpha = isDarkTheme(context) ? (int) (0.4 * 255) : (int) (0.6 * 255);
return Color.argb(alpha, Color.red(color), Color.green(color), Color.blue(color));
}
return context.getResources().getColor(isDarkTheme(context) ? R.color.transparent_black_90
: R.color.transparent_white_bb);
public @ColorInt int toQuoteFooterColor(@NonNull Context context, boolean outgoing) {
return context.getResources().getColor(isDarkTheme(context) ? tintColor : shadeColor);
}
public boolean represents(Context context, int colorValue) {
return context.getResources().getColor(conversationColorDark) == colorValue ||
context.getResources().getColor(conversationColorLight) == colorValue ||
context.getResources().getColor(actionBarColorDark) == colorValue ||
context.getResources().getColor(actionBarColorLight) == colorValue ||
context.getResources().getColor(statusBarColorLight) == colorValue ||
context.getResources().getColor(statusBarColorDark) == colorValue;
return context.getResources().getColor(mainColor) == colorValue ||
context.getResources().getColor(tintColor) == colorValue ||
context.getResources().getColor(shadeColor) == colorValue;
}
public String serialize() {
@@ -144,5 +114,4 @@ public enum MaterialColor {
super(message);
}
}
}

View File

@@ -11,15 +11,18 @@ import java.util.List;
public class MaterialColors {
public static final MaterialColorList CONVERSATION_PALETTE = new MaterialColorList(new ArrayList<>(Arrays.asList(
MaterialColor.ORANGE,
MaterialColor.RED,
MaterialColor.PINK,
MaterialColor.PURPLE,
MaterialColor.INDIGO,
MaterialColor.PLUM,
MaterialColor.CRIMSON,
MaterialColor.VERMILLION,
MaterialColor.VIOLET,
MaterialColor.BLUE,
MaterialColor.GREEN,
MaterialColor.INDIGO,
MaterialColor.FOREST,
MaterialColor.WINTERGREEN,
MaterialColor.TEAL,
MaterialColor.CYAN
MaterialColor.BURLAP,
MaterialColor.TAUPE,
MaterialColor.STEEL
)));
public static class MaterialColorList {

View File

@@ -120,8 +120,8 @@ public class InputPanel extends LinearLayout
composeText.setMediaListener(listener);
}
public void setQuote(@NonNull GlideRequests glideRequests, long id, @NonNull Recipient author, @NonNull String body, @NonNull SlideDeck attachments) {
this.quoteView.setQuote(glideRequests, id, author, body, false, attachments);
public void setQuote(@NonNull GlideRequests glideRequests, long id, @NonNull Recipient author, @NonNull Recipient conversation, @NonNull String body, @NonNull SlideDeck attachments) {
this.quoteView.setQuote(glideRequests, id, author, conversation, body, false, attachments);
this.quoteView.setVisibility(View.VISIBLE);
}

View File

@@ -54,6 +54,7 @@ public class QuoteView extends FrameLayout implements RecipientModifiedListener
private long id;
private Recipient author;
private Recipient conversation;
private String body;
private TextView mediaDescriptionText;
private TextView missingLinkText;
@@ -154,22 +155,24 @@ public class QuoteView extends FrameLayout implements RecipientModifiedListener
public void setQuote(GlideRequests glideRequests,
long id,
@NonNull Recipient author,
@NonNull Recipient conversation,
@Nullable String body,
boolean originalMissing,
@NonNull SlideDeck attachments)
{
if (this.author != null) this.author.removeListener(this);
this.id = id;
this.author = author;
this.body = body;
this.attachments = attachments;
this.id = id;
this.author = author;
this.conversation = conversation;
this.body = body;
this.attachments = attachments;
author.addListener(this);
setQuoteAuthor(author);
setQuoteAuthor(author, conversation);
setQuoteText(body, attachments);
setQuoteAttachment(glideRequests, attachments);
setQuoteMissingFooter(originalMissing);
setQuoteMissingFooter(originalMissing, conversation);
}
public void setTopCornerSizes(boolean topLeftLarge, boolean topRightLarge) {
@@ -191,21 +194,21 @@ public class QuoteView extends FrameLayout implements RecipientModifiedListener
public void onModified(Recipient recipient) {
Util.runOnMain(() -> {
if (recipient == author) {
setQuoteAuthor(recipient);
setQuoteAuthor(recipient, conversation);
}
});
}
private void setQuoteAuthor(@NonNull Recipient author) {
boolean outgoing = messageType != MESSAGE_TYPE_INCOMING;
private void setQuoteAuthor(@NonNull Recipient author, @NonNull Recipient conversation) {
boolean outgoing = messageType == MESSAGE_TYPE_OUTGOING;
boolean isOwnNumber = Util.isOwnNumber(getContext(), author.getAddress());
authorView.setText(isOwnNumber ? getContext().getString(R.string.QuoteView_you)
: author.toShortString());
// We use the raw color resource because Android 4.x was struggling with tints here
quoteBarView.setImageResource(author.getColor().toQuoteBarColorResource(getContext(), outgoing));
mainView.setBackgroundColor(author.getColor().toQuoteBackgroundColor(getContext(), outgoing));
quoteBarView.setImageResource(conversation.getColor().toQuoteBarColorResource(getContext(), outgoing));
mainView.setBackgroundColor(conversation.getColor().toQuoteBackgroundColor(getContext(), outgoing));
}
private void setQuoteText(@Nullable String body, @NonNull SlideDeck attachments) {
@@ -268,9 +271,9 @@ public class QuoteView extends FrameLayout implements RecipientModifiedListener
}
}
private void setQuoteMissingFooter(boolean missing) {
private void setQuoteMissingFooter(boolean missing, @NonNull Recipient conversation) {
footerView.setVisibility(missing ? VISIBLE : GONE);
footerView.setBackgroundColor(author.getColor().toQuoteFooterColor(getContext(), messageType != MESSAGE_TYPE_INCOMING));
footerView.setBackgroundColor(conversation.getColor().toQuoteFooterColor(getContext(), messageType == MESSAGE_TYPE_OUTGOING));
}
public long getQuoteId() {

View File

@@ -7,7 +7,7 @@ import org.thoughtcrime.securesms.color.MaterialColors;
public class ContactColors {
public static final MaterialColor UNKNOWN_COLOR = MaterialColor.GREY;
public static final MaterialColor UNKNOWN_COLOR = MaterialColor.STEEL;
private static final String[] LEGACY_PALETTE = new String[] {
"red",