aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/ui/adapter
diff options
context:
space:
mode:
authorChristian Schneppe <christian.schneppe@pix-art.de>2020-02-11 20:16:03 +0100
committerChristian Schneppe <christian.schneppe@pix-art.de>2020-02-11 20:16:03 +0100
commit898218e7402bdb22d0a439dea376665a28729a49 (patch)
tree3282d594ffc1e640b6ac682f6db1402b078c2df1 /src/main/java/de/pixart/messenger/ui/adapter
parent71780abb89b56e976bccecea721581794df0f62b (diff)
make colored muc names configurable
* default = off
Diffstat (limited to 'src/main/java/de/pixart/messenger/ui/adapter')
-rw-r--r--src/main/java/de/pixart/messenger/ui/adapter/ConversationAdapter.java12
-rw-r--r--src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java39
2 files changed, 13 insertions, 38 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/adapter/ConversationAdapter.java b/src/main/java/de/pixart/messenger/ui/adapter/ConversationAdapter.java
index cf4a72bee..7ce7573a3 100644
--- a/src/main/java/de/pixart/messenger/ui/adapter/ConversationAdapter.java
+++ b/src/main/java/de/pixart/messenger/ui/adapter/ConversationAdapter.java
@@ -3,7 +3,10 @@ package de.pixart.messenger.ui.adapter;
import android.content.SharedPreferences;
import android.graphics.Typeface;
import android.preference.PreferenceManager;
+import android.text.Spannable;
+import android.text.SpannableString;
import android.text.SpannableStringBuilder;
+import android.text.style.StyleSpan;
import android.util.Pair;
import android.view.LayoutInflater;
import android.view.View;
@@ -183,13 +186,18 @@ public class ConversationAdapter extends RecyclerView.Adapter<ConversationAdapte
if (message.getStatus() == Message.STATUS_RECEIVED) {
if (conversation.getMode() == Conversation.MODE_MULTI) {
viewHolder.binding.senderName.setVisibility(View.VISIBLE);
- viewHolder.binding.senderName.setText(UIHelper.getColoredUsername(message));
+ viewHolder.binding.senderName.setText(UIHelper.getColoredUsername(activity.xmppConnectionService, message));
+ viewHolder.binding.senderName.append(":");
} else {
viewHolder.binding.senderName.setVisibility(View.GONE);
}
} else if (message.getType() != Message.TYPE_STATUS) {
viewHolder.binding.senderName.setVisibility(View.VISIBLE);
- viewHolder.binding.senderName.setText(activity.getString(R.string.me) + ':');
+ final SpannableString me;
+ me = SpannableString.valueOf(activity.getString(R.string.me));
+ me.setSpan(new StyleSpan(Typeface.BOLD), 0, me.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+ viewHolder.binding.senderName.setText(me);
+ viewHolder.binding.senderName.append(":");
} else {
viewHolder.binding.senderName.setVisibility(View.GONE);
}
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 d66b5cf5a..0593869ca 100644
--- a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java
+++ b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java
@@ -306,7 +306,7 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
default:
if (multiReceived) {
viewHolder.username.setVisibility(View.VISIBLE);
- viewHolder.username.setText(UIHelper.getColoredUsername(message));
+ viewHolder.username.setText(UIHelper.getColoredUsername(activity.xmppConnectionService, message));
}
if (singleReceived) {
viewHolder.username.setVisibility(View.GONE);
@@ -584,7 +584,7 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
viewHolder.messageBody.setHighlightColor(darkBackground ? type == SENT ? StyledAttributes.getColor(activity, R.attr.colorAccent) : StyledAttributes.getColor(activity, R.attr.colorAccent) : StyledAttributes.getColor(activity, R.attr.colorAccent));
viewHolder.messageBody.setTypeface(null, Typeface.NORMAL);
if (message.getBody() != null) {
- final SpannableString nick = UIHelper.getColoredUsername(message);
+ final SpannableString nick = UIHelper.getColoredUsername(activity.xmppConnectionService, message);
SpannableStringBuilder body = new SpannableStringBuilder(replaceYoutube(activity.getApplicationContext(), message.getMergedBody().toString()));
if (message.getBody().equals(DELETED_MESSAGE_BODY)) {
body = body.replace(0, DELETED_MESSAGE_BODY.length(), activity.getString(R.string.message_deleted));
@@ -682,14 +682,7 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
private void displayOpenableMessage(ViewHolder viewHolder, final Message message, final boolean darkBackground) {
toggleWhisperInfo(viewHolder, message, false, darkBackground);
final String mimeType = message.getMimeType();
- if (mimeType != null && message.getMimeType().contains("pdf")) {
- try {
- showPDF(message, viewHolder, false);
- } catch (Exception e) {
- e.printStackTrace();
- showPDF(message, viewHolder, true);
- }
- } else if (mimeType != null && message.getMimeType().contains("vcard")) {
+ if (mimeType != null && message.getMimeType().contains("vcard")) {
try {
showVCard(message, viewHolder);
} catch (Exception e) {
@@ -735,32 +728,6 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
viewHolder.download_button.setOnClickListener(v -> openDownloadable(message));
}
- private void showPDF(final Message message, final ViewHolder viewHolder, boolean compat) {
- if (runsTwentyOne() && !compat) {
- viewHolder.audioPlayer.setVisibility(View.GONE);
- viewHolder.image.setVisibility(View.VISIBLE);
- viewHolder.gifImage.setVisibility(View.GONE);
- viewHolder.richlinkview.setVisibility(View.GONE);
- viewHolder.progressBar.setVisibility(View.GONE);
- viewHolder.download_button.setVisibility(View.GONE);
- activity.loadBitmap(message, viewHolder.image);
- viewHolder.image.setOnClickListener(v -> openDownloadable(message));
- } else {
- viewHolder.audioPlayer.setVisibility(View.GONE);
- viewHolder.image.setVisibility(View.GONE);
- viewHolder.gifImage.setVisibility(View.GONE);
- viewHolder.richlinkview.setVisibility(View.GONE);
- viewHolder.progressBar.setVisibility(View.GONE);
- viewHolder.download_button.setVisibility(View.VISIBLE);
- final Drawable icon = activity.getResources().getDrawable(R.drawable.ic_file_pdf_grey600_48dp);
- final Drawable drawable = DrawableCompat.wrap(icon);
- DrawableCompat.setTint(drawable, StyledAttributes.getColor(getContext(), R.attr.colorAccent));
- viewHolder.download_button.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null);
- viewHolder.download_button.setText(activity.getString(R.string.open_x_file, UIHelper.getFileDescriptionString(activity, message)));
- viewHolder.download_button.setOnClickListener(v -> openDownloadable(message));
- }
- }
-
private void showAPK(final Message message, final ViewHolder viewHolder) {
String APKName = "";
if (message.getFileParams().subject.length() != 0) {