Switch the conversation color back to incoming messages.

This commit is contained in:
Greyson Parrelli
2018-10-09 12:52:32 -07:00
parent b1d653a230
commit 710fa4a6f0
12 changed files with 49 additions and 44 deletions

View File

@@ -2246,14 +2246,12 @@ 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,8 @@ 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 +314,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_grey_60), defaultBubbleColor);
} else {
audioViewStub.get().setTint(Color.WHITE, defaultBubbleColor);
}
} else {
audioViewStub.get().setTint(Color.WHITE, recipient.getColor().toConversationColor(context));
}
}
@@ -599,7 +598,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), conversationRecipient, quote.getText(), quote.isOriginalMissing(), quote.getAttachment());
quoteView.setQuote(glideRequests, quote.getId(), Recipient.from(context, quote.getAuthor(), true), quote.getText(), quote.isOriginalMissing(), quote.getAttachment());
quoteView.setVisibility(View.VISIBLE);
quoteView.getLayoutParams().width = ViewGroup.LayoutParams.WRAP_CONTENT;

View File

@@ -82,17 +82,29 @@ public enum MaterialColor {
public @ColorRes int toQuoteBarColorResource(@NonNull Context context, boolean outgoing) {
if (outgoing) {
return isDarkTheme(context) ? R.color.core_black : R.color.core_white;
return isDarkTheme(context) ? tintColor : shadeColor ;
}
return isDarkTheme(context) ? tintColor : shadeColor;
return R.color.core_white;
}
public @ColorInt int toQuoteBackgroundColor(@NonNull Context context, boolean outgoing) {
return context.getResources().getColor(isDarkTheme(context) ? shadeColor : tintColor);
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 toQuoteFooterColor(@NonNull Context context, boolean outgoing) {
return context.getResources().getColor(isDarkTheme(context) ? tintColor : shadeColor);
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 boolean represents(Context context, int colorValue) {

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 Recipient conversation, @NonNull String body, @NonNull SlideDeck attachments) {
this.quoteView.setQuote(glideRequests, id, author, conversation, body, false, attachments);
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);
this.quoteView.setVisibility(View.VISIBLE);
}

View File

@@ -54,7 +54,6 @@ 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;
@@ -155,24 +154,22 @@ 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.conversation = conversation;
this.body = body;
this.attachments = attachments;
this.id = id;
this.author = author;
this.body = body;
this.attachments = attachments;
author.addListener(this);
setQuoteAuthor(author, conversation);
setQuoteAuthor(author);
setQuoteText(body, attachments);
setQuoteAttachment(glideRequests, attachments);
setQuoteMissingFooter(originalMissing, conversation);
setQuoteMissingFooter(originalMissing);
}
public void setTopCornerSizes(boolean topLeftLarge, boolean topRightLarge) {
@@ -194,21 +191,21 @@ public class QuoteView extends FrameLayout implements RecipientModifiedListener
public void onModified(Recipient recipient) {
Util.runOnMain(() -> {
if (recipient == author) {
setQuoteAuthor(recipient, conversation);
setQuoteAuthor(recipient);
}
});
}
private void setQuoteAuthor(@NonNull Recipient author, @NonNull Recipient conversation) {
boolean outgoing = messageType == MESSAGE_TYPE_OUTGOING;
private void setQuoteAuthor(@NonNull Recipient author) {
boolean outgoing = messageType != MESSAGE_TYPE_INCOMING;
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(conversation.getColor().toQuoteBarColorResource(getContext(), outgoing));
mainView.setBackgroundColor(conversation.getColor().toQuoteBackgroundColor(getContext(), outgoing));
quoteBarView.setImageResource(author.getColor().toQuoteBarColorResource(getContext(), outgoing));
mainView.setBackgroundColor(author.getColor().toQuoteBackgroundColor(getContext(), outgoing));
}
private void setQuoteText(@Nullable String body, @NonNull SlideDeck attachments) {
@@ -271,9 +268,9 @@ public class QuoteView extends FrameLayout implements RecipientModifiedListener
}
}
private void setQuoteMissingFooter(boolean missing, @NonNull Recipient conversation) {
private void setQuoteMissingFooter(boolean missing) {
footerView.setVisibility(missing ? VISIBLE : GONE);
footerView.setBackgroundColor(conversation.getColor().toQuoteFooterColor(getContext(), messageType == MESSAGE_TYPE_OUTGOING));
footerView.setBackgroundColor(author.getColor().toQuoteFooterColor(getContext(), messageType != MESSAGE_TYPE_INCOMING));
}
public long getQuoteId() {