diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java index 0858c7c03..4c5cfddad 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java @@ -1164,7 +1164,6 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke binding.textinput.addTextChangedListener(new StylingHelper.MessageEditorStyler(binding.textinput)); binding.textinput.setOnEditorActionListener(mEditorActionListener); binding.textinput.setRichContentListener(new String[]{"image/*"}, mEditorContentListener); - binding.messageInputBox.setBackgroundResource(messageInputBubble(false)); binding.textSendButton.setOnClickListener(this.mSendButtonListener); binding.textSendButton.setOnLongClickListener(this.mSendButtonLongListener); @@ -2638,7 +2637,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke public void updateSendButton() { updateChatMsgHint(); - binding.messageInputBox.setBackgroundResource(messageInputBubble(isPrivateMessage())); + messageListAdapter.setBubbleBackgroundColor(binding.messageInputBox, activity.getThemeColor(), 0, isPrivateMessage(), true); boolean hasAttachments = mediaPreviewAdapter != null && mediaPreviewAdapter.hasAttachments(); boolean useSendButtonToIndicateStatus = activity != null && PreferenceManager.getDefaultSharedPreferences(activity).getBoolean("send_button_status", getResources().getBoolean(R.bool.send_button_status)); final Conversation c = this.conversation; @@ -3094,10 +3093,6 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke } } - private int messageInputBubble(final boolean isPrivate) { - return isPrivate ? activity.isOrangeTheme() ? activity.isDarkTheme() ? R.drawable.message_bubble_sent_dark_orange_private : R.drawable.message_bubble_sent_orange_private : activity.isDarkTheme() ? R.drawable.message_bubble_sent_dark_private : R.drawable.message_bubble_sent_private : activity.isOrangeTheme() ? activity.isDarkTheme() ? R.drawable.message_bubble_sent_dark_orange : R.drawable.message_bubble_sent_orange : activity.isDarkTheme() ? R.drawable.message_bubble_sent_dark : R.drawable.message_bubble_sent; - } - public Conversation getConversation() { return conversation; } diff --git a/src/main/java/de/pixart/messenger/ui/XmppActivity.java b/src/main/java/de/pixart/messenger/ui/XmppActivity.java index 18604d4e5..23b2120e3 100644 --- a/src/main/java/de/pixart/messenger/ui/XmppActivity.java +++ b/src/main/java/de/pixart/messenger/ui/XmppActivity.java @@ -25,6 +25,7 @@ import android.graphics.Color; import android.graphics.Point; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; +import android.graphics.drawable.GradientDrawable; import android.media.AudioManager; import android.net.ConnectivityManager; import android.net.Uri; @@ -50,6 +51,7 @@ import android.widget.Toast; import androidx.annotation.BoolRes; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.annotation.StringRes; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatDelegate; @@ -426,6 +428,19 @@ public abstract class XmppActivity extends ActionBarActivity { return getStringPreference("theme_color", R.string.theme_color).equals("orange"); } + public String getThemeColor() { + return getStringPreference("theme_color", R.string.theme_color); + } + + public void setBubbleColor(final View v, final int backgroundColor, final int borderColor) { + GradientDrawable shape = (GradientDrawable)v.getBackground(); + shape.setColor(backgroundColor); + if (borderColor != -1) { + shape.setStroke(2, borderColor); + } + v.setBackground(shape); + } + public int getThemeResource(int r_attr_name, int r_drawable_def) { int[] attrs = {r_attr_name}; TypedArray ta = this.getTheme().obtainStyledAttributes(attrs); diff --git a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java index 6e277f0f2..8e7577f6f 100644 --- a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java +++ b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java @@ -7,6 +7,7 @@ import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.graphics.Rect; import android.graphics.Typeface; +import android.graphics.drawable.GradientDrawable; import android.net.Uri; import android.preference.PreferenceManager; import android.text.Editable; @@ -82,6 +83,7 @@ import de.pixart.messenger.utils.Emoticons; import de.pixart.messenger.utils.GeoHelper; import de.pixart.messenger.utils.RichPreview; import de.pixart.messenger.utils.StylingHelper; +import de.pixart.messenger.utils.ThemeHelper; import de.pixart.messenger.utils.UIHelper; import de.pixart.messenger.xmpp.mam.MamReference; import pl.droidsonroids.gif.GifImageView; @@ -726,7 +728,7 @@ public class MessageAdapter extends ArrayAdapter implements CopyTextVie viewHolder.richlinkview.setLayoutParams(layoutParams); final String url = body.toString(); String weburl; - final String lcUrl = url.toLowerCase(Locale.US); + final String lcUrl = url.toLowerCase(Locale.US).trim(); if (lcUrl.startsWith("http://") || lcUrl.startsWith("https://")) { weburl = removeTrailingBracket(url); } else { @@ -872,6 +874,11 @@ public class MessageAdapter extends ArrayAdapter implements CopyTextVie private void toggleWhisperInfo(ViewHolder viewHolder, final Message message, final boolean includeBody, final boolean darkBackground) { SpannableStringBuilder messageBody = new SpannableStringBuilder(replaceYoutube(activity.getApplicationContext(), message.getBody())); Editable body; + if (darkBackground) { + viewHolder.messageBody.setTextAppearance(getContext(), R.style.TextAppearance_Conversations_Body1_OnDark); + } else { + viewHolder.messageBody.setTextAppearance(getContext(), R.style.TextAppearance_Conversations_Body1); + } if (message.isPrivateMessage()) { final String privateMarker; if (message.getStatus() <= Message.STATUS_RECEIVED) { @@ -1000,7 +1007,6 @@ public class MessageAdapter extends ArrayAdapter implements CopyTextVie } boolean darkBackground = activity.isDarkTheme(); - boolean isOrange = activity.isOrangeTheme(); if (type == DATE_SEPARATOR) { if (UIHelper.today(message.getTimeSent())) { @@ -1140,23 +1146,11 @@ public class MessageAdapter extends ArrayAdapter implements CopyTextVie if (type == RECEIVED) { if (isInValidSession) { - if (message.isPrivateMessage()) { - if (activity.isOrangeTheme()) { - viewHolder.message_box.setBackgroundResource(darkBackground ? R.drawable.message_bubble_received_light_orange_dark_private : R.drawable.message_bubble_received_light_orange_private); - } else { - viewHolder.message_box.setBackgroundResource(darkBackground ? R.drawable.message_bubble_received_light_dark_private : R.drawable.message_bubble_received_light_private); - } - } else { - viewHolder.message_box.setBackgroundResource(darkBackground ? R.drawable.message_bubble_received_light_dark : R.drawable.message_bubble_received_light); - } + setBubbleBackgroundColor(viewHolder.message_box, activity.getThemeColor(), type, message.isPrivateMessage(), isInValidSession); viewHolder.encryption.setVisibility(View.GONE); viewHolder.encryption.setTextColor(this.getMessageTextColor(darkBackground, false)); } else { - if (message.isPrivateMessage()) { - viewHolder.message_box.setBackgroundResource(darkBackground ? R.drawable.message_bubble_received_warning_dark : R.drawable.message_bubble_received_warning); - } else { - viewHolder.message_box.setBackgroundResource(darkBackground ? R.drawable.message_bubble_received_warning_dark : R.drawable.message_bubble_received_warning); - } + setBubbleBackgroundColor(viewHolder.message_box, activity.getThemeColor(), type, message.isPrivateMessage(), isInValidSession); viewHolder.encryption.setVisibility(View.VISIBLE); viewHolder.encryption.setTextColor(this.getWarningTextColor(darkBackground)); if (omemoEncryption && !message.isTrusted()) { @@ -1168,19 +1162,7 @@ public class MessageAdapter extends ArrayAdapter implements CopyTextVie } if (type == SENT) { - if (message.isPrivateMessage()) { - if (activity.isOrangeTheme()) { - viewHolder.message_box.setBackgroundResource(activity.isDarkTheme() ? R.drawable.message_bubble_sent_dark_orange_private : R.drawable.message_bubble_sent_orange_private); - } else { - viewHolder.message_box.setBackgroundResource(activity.isDarkTheme() ? R.drawable.message_bubble_sent_dark_private : R.drawable.message_bubble_sent_private); - } - } else { - if (activity.isOrangeTheme()) { - viewHolder.message_box.setBackgroundResource(activity.isDarkTheme() ? R.drawable.message_bubble_sent_dark_orange : R.drawable.message_bubble_sent_orange ); - } else { - viewHolder.message_box.setBackgroundResource(activity.isDarkTheme() ? R.drawable.message_bubble_sent_dark : R.drawable.message_bubble_sent); - } - } + setBubbleBackgroundColor(viewHolder.message_box, activity.getThemeColor(), type, message.isPrivateMessage(), isInValidSession); } displayStatus(viewHolder, message, type, darkBackground); return view; @@ -1374,4 +1356,36 @@ public class MessageAdapter extends ArrayAdapter implements CopyTextVie public void onDestroyActionMode(ActionMode mode) { } } + + public void setBubbleBackgroundColor(final View viewHolder, final String themeColor, final int type, final boolean isPrivateMessage, final boolean isInValidSession) { + if (type == RECEIVED) { + if (isInValidSession) { + if (isPrivateMessage) { + viewHolder.setBackgroundResource(R.drawable.message_bubble_received_light_private); + activity.setBubbleColor(viewHolder, StyledAttributes.getColor(activity, R.attr.color_bubble_light), StyledAttributes.getColor(activity, R.attr.colorAccent)); + } else { + viewHolder.setBackgroundResource(R.drawable.message_bubble_received_light); + activity.setBubbleColor(viewHolder, StyledAttributes.getColor(activity, R.attr.color_bubble_light), -1); + } + } else { + if (isPrivateMessage) { + viewHolder.setBackgroundResource(R.drawable.message_bubble_received_warning_private); + activity.setBubbleColor(viewHolder, StyledAttributes.getColor(activity, R.attr.color_bubble_warning), StyledAttributes.getColor(activity, R.attr.colorAccent)); + } else { + viewHolder.setBackgroundResource(R.drawable.message_bubble_received_warning); + activity.setBubbleColor(viewHolder, StyledAttributes.getColor(activity, R.attr.color_bubble_warning), -1); + } + } + } + + if (type == SENT) { + if (isPrivateMessage) { + viewHolder.setBackgroundResource(R.drawable.message_bubble_sent_private); + activity.setBubbleColor(viewHolder, StyledAttributes.getColor(activity, R.attr.color_bubble_dark), StyledAttributes.getColor(activity, R.attr.colorAccent)); + } else { + viewHolder.setBackgroundResource(R.drawable.message_bubble_sent); + activity.setBubbleColor(viewHolder, StyledAttributes.getColor(activity, R.attr.color_bubble_dark), -1); + } + } + } } \ No newline at end of file diff --git a/src/main/java/de/pixart/messenger/utils/ThemeHelper.java b/src/main/java/de/pixart/messenger/utils/ThemeHelper.java index 738d2d685..9a326b638 100644 --- a/src/main/java/de/pixart/messenger/utils/ThemeHelper.java +++ b/src/main/java/de/pixart/messenger/utils/ThemeHelper.java @@ -61,7 +61,7 @@ public class ThemeHelper { final String themeColor = sharedPreferences.getString("theme_color", resources.getString(R.string.theme_color)); final String fontSize = sharedPreferences.getString("font_size", resources.getString(R.string.default_font_size)); switch (themeColor) { - case "c": + case "blue": switch (fontSize) { case "medium": return dark ? R.style.ConversationsTheme_Dark_Medium : R.style.ConversationsTheme_Medium; diff --git a/src/main/res/drawable/message_bubble_received_light.xml b/src/main/res/drawable/message_bubble_received_light.xml index c1a8b456b..a895b4bda 100644 --- a/src/main/res/drawable/message_bubble_received_light.xml +++ b/src/main/res/drawable/message_bubble_received_light.xml @@ -10,5 +10,5 @@ android:left="6dp" android:right="6dp" android:top="2dp" /> - + \ No newline at end of file diff --git a/src/main/res/drawable/message_bubble_received_light_dark.xml b/src/main/res/drawable/message_bubble_received_light_dark.xml deleted file mode 100644 index 301f634bc..000000000 --- a/src/main/res/drawable/message_bubble_received_light_dark.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/main/res/drawable/message_bubble_received_light_dark_private.xml b/src/main/res/drawable/message_bubble_received_light_dark_private.xml deleted file mode 100644 index 28bdb9b15..000000000 --- a/src/main/res/drawable/message_bubble_received_light_dark_private.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/src/main/res/drawable/message_bubble_received_light_orange_dark_private.xml b/src/main/res/drawable/message_bubble_received_light_orange_dark_private.xml deleted file mode 100644 index cf7d44c87..000000000 --- a/src/main/res/drawable/message_bubble_received_light_orange_dark_private.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/src/main/res/drawable/message_bubble_received_light_orange_private.xml b/src/main/res/drawable/message_bubble_received_light_orange_private.xml deleted file mode 100644 index e22a46996..000000000 --- a/src/main/res/drawable/message_bubble_received_light_orange_private.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/src/main/res/drawable/message_bubble_received_light_private.xml b/src/main/res/drawable/message_bubble_received_light_private.xml index 6752d9393..657f8dad0 100644 --- a/src/main/res/drawable/message_bubble_received_light_private.xml +++ b/src/main/res/drawable/message_bubble_received_light_private.xml @@ -11,5 +11,5 @@ android:left="6dp" android:right="6dp" android:top="2dp" /> - + \ No newline at end of file diff --git a/src/main/res/drawable/message_bubble_received_warning.xml b/src/main/res/drawable/message_bubble_received_warning.xml index cd47cf948..42e7e8f71 100644 --- a/src/main/res/drawable/message_bubble_received_warning.xml +++ b/src/main/res/drawable/message_bubble_received_warning.xml @@ -10,5 +10,5 @@ android:left="6dp" android:right="6dp" android:top="4dp" /> - + \ No newline at end of file diff --git a/src/main/res/drawable/message_bubble_received_warning_dark.xml b/src/main/res/drawable/message_bubble_received_warning_dark.xml deleted file mode 100644 index e25ef23a2..000000000 --- a/src/main/res/drawable/message_bubble_received_warning_dark.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/main/res/drawable/message_bubble_received_warning_dark_private.xml b/src/main/res/drawable/message_bubble_received_warning_dark_private.xml deleted file mode 100644 index 758d6d2e8..000000000 --- a/src/main/res/drawable/message_bubble_received_warning_dark_private.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/src/main/res/drawable/message_bubble_received_warning_orange_dark_private.xml b/src/main/res/drawable/message_bubble_received_warning_orange_dark_private.xml deleted file mode 100644 index 5f0525113..000000000 --- a/src/main/res/drawable/message_bubble_received_warning_orange_dark_private.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/src/main/res/drawable/message_bubble_received_warning_orange_private.xml b/src/main/res/drawable/message_bubble_received_warning_orange_private.xml deleted file mode 100644 index 08bd30406..000000000 --- a/src/main/res/drawable/message_bubble_received_warning_orange_private.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/src/main/res/drawable/message_bubble_received_warning_private.xml b/src/main/res/drawable/message_bubble_received_warning_private.xml index 6aef6105e..c5c4ce4ac 100644 --- a/src/main/res/drawable/message_bubble_received_warning_private.xml +++ b/src/main/res/drawable/message_bubble_received_warning_private.xml @@ -1,6 +1,6 @@ - + - + \ No newline at end of file diff --git a/src/main/res/drawable/message_bubble_sent.xml b/src/main/res/drawable/message_bubble_sent.xml index 677c1fe43..3cbe163ec 100644 --- a/src/main/res/drawable/message_bubble_sent.xml +++ b/src/main/res/drawable/message_bubble_sent.xml @@ -10,5 +10,5 @@ android:left="6dp" android:right="6dp" android:top="4dp" /> - + \ No newline at end of file diff --git a/src/main/res/drawable/message_bubble_sent_dark.xml b/src/main/res/drawable/message_bubble_sent_dark.xml deleted file mode 100644 index 3cbe163ec..000000000 --- a/src/main/res/drawable/message_bubble_sent_dark.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/main/res/drawable/message_bubble_sent_dark_orange.xml b/src/main/res/drawable/message_bubble_sent_dark_orange.xml deleted file mode 100644 index 6e81cabe7..000000000 --- a/src/main/res/drawable/message_bubble_sent_dark_orange.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/main/res/drawable/message_bubble_sent_dark_orange_private.xml b/src/main/res/drawable/message_bubble_sent_dark_orange_private.xml deleted file mode 100644 index 33b726220..000000000 --- a/src/main/res/drawable/message_bubble_sent_dark_orange_private.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/src/main/res/drawable/message_bubble_sent_dark_private.xml b/src/main/res/drawable/message_bubble_sent_dark_private.xml deleted file mode 100644 index e37c43ad3..000000000 --- a/src/main/res/drawable/message_bubble_sent_dark_private.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/src/main/res/drawable/message_bubble_sent_orange.xml b/src/main/res/drawable/message_bubble_sent_orange.xml deleted file mode 100644 index a6ab35a46..000000000 --- a/src/main/res/drawable/message_bubble_sent_orange.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/main/res/drawable/message_bubble_sent_orange_private.xml b/src/main/res/drawable/message_bubble_sent_orange_private.xml deleted file mode 100644 index fca639dfd..000000000 --- a/src/main/res/drawable/message_bubble_sent_orange_private.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/src/main/res/drawable/message_bubble_sent_private.xml b/src/main/res/drawable/message_bubble_sent_private.xml index e83ded310..e37c43ad3 100644 --- a/src/main/res/drawable/message_bubble_sent_private.xml +++ b/src/main/res/drawable/message_bubble_sent_private.xml @@ -11,5 +11,5 @@ android:left="6dp" android:right="6dp" android:top="4dp" /> - + \ No newline at end of file diff --git a/src/main/res/values/attrs.xml b/src/main/res/values/attrs.xml index d51172093..16a35eb2b 100644 --- a/src/main/res/values/attrs.xml +++ b/src/main/res/values/attrs.xml @@ -113,7 +113,7 @@ - + diff --git a/src/main/res/values/colors.xml b/src/main/res/values/colors.xml index e8f3b0d79..67ffc3423 100644 --- a/src/main/res/values/colors.xml +++ b/src/main/res/values/colors.xml @@ -8,7 +8,7 @@ #ffB27300 #ffce8500 #ffa06700 - #ffffa500 + #ffffa500 #ff0091ea #ff000000 @@ -51,7 +51,9 @@ #ffb71c1c #ff1b5e20 - #fffff6e5 + #ffffb732 + #ffcc8400 + #ff996300 #ff4c3100 #ff388e3c diff --git a/src/main/res/values/themes.xml b/src/main/res/values/themes.xml index de539df44..ea5230cef 100644 --- a/src/main/res/values/themes.xml +++ b/src/main/res/values/themes.xml @@ -26,7 +26,7 @@ @color/realblack @color/lightwhite - @color/lightblue + @color/lightblue @color/lightgreen @color/lightred @@ -185,7 +185,7 @@ @color/realwhite @color/darkwhite - @color/darkblue + @color/darkblue @color/darkgreen @color/darkred @@ -325,6 +325,11 @@ @color/accent_orange @color/accent_orange @color/accent_orange + + @color/lightorange + @color/lightorange2 + @color/darkred + @color/darkgreen