change opacity on emoji only messages

This commit is contained in:
Daniel Gultsch 2018-04-11 09:04:16 +02:00
parent 58a5e67d43
commit 14f9a51b8b
5 changed files with 21 additions and 2 deletions

View File

@ -390,11 +390,16 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
viewHolder.messageBody.setTextIsSelectable(false); viewHolder.messageBody.setTextIsSelectable(false);
} }
private void displayEmojiMessage(final ViewHolder viewHolder, final String body) { private void displayEmojiMessage(final ViewHolder viewHolder, final String body, final boolean darkBackground) {
viewHolder.download_button.setVisibility(View.GONE); viewHolder.download_button.setVisibility(View.GONE);
viewHolder.audioPlayer.setVisibility(View.GONE); viewHolder.audioPlayer.setVisibility(View.GONE);
viewHolder.image.setVisibility(View.GONE); viewHolder.image.setVisibility(View.GONE);
viewHolder.messageBody.setVisibility(View.VISIBLE); viewHolder.messageBody.setVisibility(View.VISIBLE);
if (darkBackground) {
viewHolder.messageBody.setTextAppearance(getContext(), R.style.TextAppearance_Conversations_Body1_Emoji_OnDark);
} else {
viewHolder.messageBody.setTextAppearance(getContext(), R.style.TextAppearance_Conversations_Body1_Emoji);
}
Spannable span = new SpannableString(body); Spannable span = new SpannableString(body);
float size = Emoticons.isEmoji(body) ? 3.0f : 2.0f; float size = Emoticons.isEmoji(body) ? 3.0f : 2.0f;
span.setSpan(new RelativeSizeSpan(size), 0, body.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); span.setSpan(new RelativeSizeSpan(size), 0, body.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
@ -817,7 +822,7 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
if (message.isGeoUri()) { if (message.isGeoUri()) {
displayLocationMessage(viewHolder, message); displayLocationMessage(viewHolder, message);
} else if (message.bodyIsOnlyEmojis() && message.getType() != Message.TYPE_PRIVATE) { } else if (message.bodyIsOnlyEmojis() && message.getType() != Message.TYPE_PRIVATE) {
displayEmojiMessage(viewHolder, message.getBody().trim()); displayEmojiMessage(viewHolder, message.getBody().trim(), darkBackground);
} else if (message.treatAsDownloadable()) { } else if (message.treatAsDownloadable()) {
try { try {
URL url = new URL(message.getBody()); URL url = new URL(message.getBody());

View File

@ -14,6 +14,7 @@
<attr name="color_background_secondary" format="reference|color" /> <attr name="color_background_secondary" format="reference|color" />
<attr name="color_background_primary" format="reference|color" /> <attr name="color_background_primary" format="reference|color" />
<attr name="color_warning" format="reference|color"/> <attr name="color_warning" format="reference|color"/>
<attr name="EmojiColor" format="reference|color"/>
<attr name="ic_send_cancel_offline" format="reference"/> <attr name="ic_send_cancel_offline" format="reference"/>
<attr name="ic_send_location_offline" format="reference"/> <attr name="ic_send_location_offline" format="reference"/>

View File

@ -5,6 +5,7 @@
<color name="primary800">#ff026100</color> <color name="primary800">#ff026100</color>
<color name="primary900">#ff024500</color> <color name="primary900">#ff024500</color>
<color name="accent">#ff0091ea</color> <color name="accent">#ff0091ea</color>
<color name="black">#ff000000</color>
<color name="black87">#de000000</color> <color name="black87">#de000000</color>
<color name="black54">#8a000000</color> <color name="black54">#8a000000</color>
<color name="black26">#42000000</color> <color name="black26">#42000000</color>

View File

@ -99,6 +99,14 @@
<item name="android:textColorLink">@color/white</item> <item name="android:textColorLink">@color/white</item>
</style> </style>
<style name="TextAppearance.Conversations.Body1.Emoji.OnDark" parent="TextAppearance.Conversations.Body1">
<item name="android:textColor">@color/white</item>
</style>
<style name="TextAppearance.Conversations.Body1.Emoji" parent="TextAppearance.Conversations.Body1">
<item name="android:textColor">?EmojiColor</item>
</style>
<style name="TextAppearance.Conversations.Body1.Secondary.OnDark" parent="TextAppearance.Conversations.Body1"> <style name="TextAppearance.Conversations.Body1.Secondary.OnDark" parent="TextAppearance.Conversations.Body1">
<item name="android:textColor">@color/white70</item> <item name="android:textColor">@color/white70</item>
</style> </style>

View File

@ -11,6 +11,8 @@
<item name="color_background_secondary">@color/grey200</item> <item name="color_background_secondary">@color/grey200</item>
<item name="color_warning">@color/red_a700</item> <item name="color_warning">@color/red_a700</item>
<item name="EmojiColor">@color/black</item>
<item name="windowActionModeOverlay">true</item> <item name="windowActionModeOverlay">true</item>
<item name="android:actionModeBackground">@color/accent</item> <item name="android:actionModeBackground">@color/accent</item>
@ -94,6 +96,8 @@
<item name="color_background_secondary">@color/grey900</item> <item name="color_background_secondary">@color/grey900</item>
<item name="color_warning">@color/red_a100</item> <item name="color_warning">@color/red_a100</item>
<item name="EmojiColor">@color/white</item>
<item name="windowActionModeOverlay">true</item> <item name="windowActionModeOverlay">true</item>
<item name="android:actionModeBackground">@color/accent</item> <item name="android:actionModeBackground">@color/accent</item>