From 710fa4a6f08d1b3f974ccbfe3477351c42c0b9a0 Mon Sep 17 00:00:00 2001 From: Greyson Parrelli Date: Tue, 9 Oct 2018 12:52:32 -0700 Subject: [PATCH] Switch the conversation color back to incoming messages. --- ...sation_activity_attachment_editor_stub.xml | 4 +-- res/layout/conversation_input_panel.xml | 4 +-- res/layout/conversation_item_sent.xml | 1 - res/layout/transfer_controls_view.xml | 2 +- res/values/core_colors.xml | 2 +- res/values/styles.xml | 2 +- res/values/themes.xml | 14 ++++----- .../securesms/ConversationActivity.java | 2 -- .../securesms/ConversationItem.java | 9 +++--- .../securesms/color/MaterialColor.java | 20 ++++++++++--- .../securesms/components/InputPanel.java | 4 +-- .../securesms/components/QuoteView.java | 29 +++++++++---------- 12 files changed, 49 insertions(+), 44 deletions(-) diff --git a/res/layout/conversation_activity_attachment_editor_stub.xml b/res/layout/conversation_activity_attachment_editor_stub.xml index ec466caecc..61fb384620 100644 --- a/res/layout/conversation_activity_attachment_editor_stub.xml +++ b/res/layout/conversation_activity_attachment_editor_stub.xml @@ -53,8 +53,8 @@ android:paddingLeft="@dimen/message_bubble_horizontal_padding" android:paddingRight="@dimen/message_bubble_horizontal_padding" android:background="@drawable/message_bubble_background_sent_alone" - app:doc_titleColor="?attr/conversation_item_received_text_primary_color" - app:doc_captionColor="?attr/conversation_item_received_text_secondary_color"/> + app:doc_titleColor="?attr/conversation_item_sent_text_primary_color" + app:doc_captionColor="?attr/conversation_item_sent_text_secondary_color"/> diff --git a/res/layout/conversation_input_panel.xml b/res/layout/conversation_input_panel.xml index b113ea42f3..82d8565e48 100644 --- a/res/layout/conversation_input_panel.xml +++ b/res/layout/conversation_input_panel.xml @@ -41,8 +41,8 @@ android:layout_marginTop="6dp" android:visibility="gone" app:message_type="preview" - app:quote_colorPrimary="?attr/conversation_item_received_text_primary_color" - app:quote_colorSecondary="?attr/conversation_item_received_text_primary_color" + app:quote_colorPrimary="?attr/conversation_item_sent_text_primary_color" + app:quote_colorSecondary="?attr/conversation_item_sent_text_primary_color" tools:visibility="visible"/> diff --git a/res/layout/transfer_controls_view.xml b/res/layout/transfer_controls_view.xml index 8a4c1b4d8b..8fb943b7a7 100644 --- a/res/layout/transfer_controls_view.xml +++ b/res/layout/transfer_controls_view.xml @@ -18,7 +18,7 @@ android:padding="15dp" android:gravity="center" android:longClickable="false" - android:textColor="?conversation_item_sent_text_primary_color" + android:textColor="?conversation_item_received_text_primary_color" android:drawableLeft="@drawable/ic_file_download_white_36dp" android:textSize="16dp" android:visibility="gone" diff --git a/res/values/core_colors.xml b/res/values/core_colors.xml index 0ec14c534b..abd6bb39dc 100644 --- a/res/values/core_colors.xml +++ b/res/values/core_colors.xml @@ -13,7 +13,7 @@ #d5d6d6 #bbbdbe #898a8c - #636467 + #6b6d70 #3d3e44 #23252a #17191d diff --git a/res/values/styles.xml b/res/values/styles.xml index c466d85a19..6ce601c61c 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -174,7 +174,7 @@ @null 4 2000 - ?conversation_item_received_text_primary_color + ?conversation_item_sent_text_primary_color sentences true center_vertical diff --git a/res/values/themes.xml b/res/values/themes.xml index 5391d57ac1..9d96ef3bd3 100644 --- a/res/values/themes.xml +++ b/res/values/themes.xml @@ -188,12 +188,12 @@ @color/core_grey_05 - @color/core_white - @color/core_white - @color/core_white + @color/core_grey_90 + @color/core_grey_60 + @color/core_grey_60 #99000000 - @color/core_grey_90 - @color/core_grey_60 + @color/core_white + @color/core_white @color/core_grey_60 @color/core_grey_90 @color/core_grey_60 @@ -293,8 +293,8 @@ @color/core_grey_75 @color/core_grey_05 - @color/core_grey_05 - @color/core_grey_05 + @color/core_grey_25 + @color/core_grey_25 #99ffffff @color/core_grey_05 @color/core_grey_25 diff --git a/src/org/thoughtcrime/securesms/ConversationActivity.java b/src/org/thoughtcrime/securesms/ConversationActivity.java index 4f08d232aa..7fc4128fbf 100644 --- a/src/org/thoughtcrime/securesms/ConversationActivity.java +++ b/src/org/thoughtcrime/securesms/ConversationActivity.java @@ -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()); } diff --git a/src/org/thoughtcrime/securesms/ConversationItem.java b/src/org/thoughtcrime/securesms/ConversationItem.java index f6b00a118d..319fbb29ed 100644 --- a/src/org/thoughtcrime/securesms/ConversationItem.java +++ b/src/org/thoughtcrime/securesms/ConversationItem.java @@ -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; diff --git a/src/org/thoughtcrime/securesms/color/MaterialColor.java b/src/org/thoughtcrime/securesms/color/MaterialColor.java index 3066302f84..ea5047b646 100644 --- a/src/org/thoughtcrime/securesms/color/MaterialColor.java +++ b/src/org/thoughtcrime/securesms/color/MaterialColor.java @@ -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) { diff --git a/src/org/thoughtcrime/securesms/components/InputPanel.java b/src/org/thoughtcrime/securesms/components/InputPanel.java index 1211fb1c05..031acc46b0 100644 --- a/src/org/thoughtcrime/securesms/components/InputPanel.java +++ b/src/org/thoughtcrime/securesms/components/InputPanel.java @@ -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); } diff --git a/src/org/thoughtcrime/securesms/components/QuoteView.java b/src/org/thoughtcrime/securesms/components/QuoteView.java index 47541fc920..dc6eba85fc 100644 --- a/src/org/thoughtcrime/securesms/components/QuoteView.java +++ b/src/org/thoughtcrime/securesms/components/QuoteView.java @@ -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() {