diff options
Diffstat (limited to 'src/main/java')
4 files changed, 60 insertions, 36 deletions
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<Message> 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<Message> 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<Message> 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<Message> 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<Message> 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<Message> 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; |