diff --git a/src/main/java/com/b44t/messenger/DcMsg.java b/src/main/java/com/b44t/messenger/DcMsg.java index 1292e80d1..45d2ed51f 100644 --- a/src/main/java/com/b44t/messenger/DcMsg.java +++ b/src/main/java/com/b44t/messenger/DcMsg.java @@ -166,10 +166,10 @@ public JSONObject getWebxdcInfo () { public native String getError (); public native String getOverrideSenderName(); - public String getSenderName(DcContact dcContact, boolean markOverride) { + public String getSenderName(DcContact dcContact) { String overrideName = getOverrideSenderName(); if (overrideName != null) { - return (markOverride ? "~" : "") + overrideName; + return "~" + overrideName; } else { return dcContact.getDisplayName(); } diff --git a/src/main/java/org/thoughtcrime/securesms/ConversationFragment.java b/src/main/java/org/thoughtcrime/securesms/ConversationFragment.java index 737967b21..d8845094f 100644 --- a/src/main/java/org/thoughtcrime/securesms/ConversationFragment.java +++ b/src/main/java/org/thoughtcrime/securesms/ConversationFragment.java @@ -24,7 +24,6 @@ import android.content.Context; import android.content.Intent; import android.content.res.Configuration; -import android.os.Build; import android.os.Bundle; import android.text.Editable; import android.text.TextWatcher; @@ -427,7 +426,7 @@ private void handleCopyMessage(final Set dcMsgsSet) { if (msg.getFromId() != prevMsg.getFromId() && !singleMsg) { DcContact contact = dcContext.getContact(msg.getFromId()); - result.append(msg.getSenderName(contact, false)).append(":\n"); + result.append(msg.getSenderName(contact)).append(":\n"); } if (msg.getType() == DcMsg.DC_MSG_TEXT || (singleMsg && !msg.getText().isEmpty())) { result.append(msg.getText()); diff --git a/src/main/java/org/thoughtcrime/securesms/ConversationItem.java b/src/main/java/org/thoughtcrime/securesms/ConversationItem.java index 5be0c7408..2a7bfd62a 100644 --- a/src/main/java/org/thoughtcrime/securesms/ConversationItem.java +++ b/src/main/java/org/thoughtcrime/securesms/ConversationItem.java @@ -22,12 +22,10 @@ import android.graphics.Color; import android.graphics.PorterDuff; import android.graphics.Rect; -import android.os.Build; import android.text.SpannableString; import android.text.TextUtils; import android.util.AttributeSet; import android.util.Log; -import android.util.TypedValue; import android.view.View; import android.view.ViewGroup; import android.widget.Button; @@ -791,14 +789,14 @@ private void setGroupMessageStatus() { if (messageRecord.isForwarded()) { if (showSender && dcContact !=null) { - this.groupSender.setText(context.getString(R.string.forwarded_by, messageRecord.getSenderName(dcContact, false))); + this.groupSender.setText(context.getString(R.string.forwarded_by, messageRecord.getSenderName(dcContact))); } else { this.groupSender.setText(context.getString(R.string.forwarded_message)); } this.groupSender.setTextColor(context.getResources().getColor(R.color.unknown_sender)); } else if (showSender && dcContact !=null) { - this.groupSender.setText(messageRecord.getSenderName(dcContact, true)); + this.groupSender.setText(messageRecord.getSenderName(dcContact)); this.groupSender.setTextColor(Util.rgbToArgbColor(dcContact.getColor())); } } diff --git a/src/main/java/org/thoughtcrime/securesms/components/QuoteView.java b/src/main/java/org/thoughtcrime/securesms/components/QuoteView.java index af7b5a835..7a30e32b9 100644 --- a/src/main/java/org/thoughtcrime/securesms/components/QuoteView.java +++ b/src/main/java/org/thoughtcrime/securesms/components/QuoteView.java @@ -4,7 +4,6 @@ import android.content.Context; import android.content.res.TypedArray; import android.net.Uri; -import android.os.Build; import android.text.TextUtils; import android.util.AttributeSet; import android.util.Log; @@ -16,7 +15,6 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import androidx.annotation.RequiresApi; import com.annimon.stream.Stream; import com.b44t.messenger.DcContact; @@ -155,7 +153,7 @@ private void setQuoteAuthor(@Nullable Recipient author) { if (contact == null) { authorView.setText(getContext().getString(R.string.forwarded_message)); } else { - authorView.setText(getContext().getString(R.string.forwarded_by, quotedMsg.getSenderName(contact, false))); + authorView.setText(getContext().getString(R.string.forwarded_by, quotedMsg.getSenderName(contact))); } authorView.setTextColor(getForwardedColor()); quoteBarView.setBackgroundColor(getForwardedColor()); @@ -166,7 +164,7 @@ private void setQuoteAuthor(@Nullable Recipient author) { quoteBarView.setBackgroundColor(getForwardedColor()); } else { authorView.setVisibility(VISIBLE); - authorView.setText(quotedMsg.getSenderName(contact, true)); + authorView.setText(quotedMsg.getSenderName(contact)); if (hasSticker) { authorView.setTextColor(getResources().getColor(R.color.core_dark_05)); quoteBarView.setBackgroundColor(getResources().getColor(R.color.core_dark_05)); diff --git a/src/main/java/org/thoughtcrime/securesms/notifications/NotificationCenter.java b/src/main/java/org/thoughtcrime/securesms/notifications/NotificationCenter.java index f32c04a0e..5a162ee2a 100644 --- a/src/main/java/org/thoughtcrime/securesms/notifications/NotificationCenter.java +++ b/src/main/java/org/thoughtcrime/securesms/notifications/NotificationCenter.java @@ -345,11 +345,17 @@ public void notifyMessage(int accountId, int chatId, int msgId) { String shortLine = privacy.isDisplayMessage()? dcMsg.getSummarytext(2000) : context.getString(R.string.notify_new_message); if (dcChat.isMultiUser() && privacy.isDisplayContact()) { - shortLine = dcMsg.getSenderName(dcContext.getContact(dcMsg.getFromId()), false) + ": " + shortLine; + shortLine = dcMsg.getSenderName(dcContext.getContact(dcMsg.getFromId())) + ": " + shortLine; } String tickerLine = shortLine; if (!dcChat.isMultiUser() && privacy.isDisplayContact()) { - tickerLine = dcMsg.getSenderName(dcContext.getContact(dcMsg.getFromId()), false) + ": " + tickerLine; + tickerLine = dcMsg.getSenderName(dcContext.getContact(dcMsg.getFromId())) + ": " + tickerLine; + + if (dcMsg.getOverrideSenderName() != null) { + // There is an "overridden" display name on the message, so, we need to prepend the display name to the message, + // i.e. set the shortLine to be the same as the tickerLine. + shortLine = tickerLine; + } } maybeAddNotification(accountId, dcChat, msgId, shortLine, tickerLine, true); @@ -549,7 +555,7 @@ private void maybeAddNotification(int accountId, DcChat dcChat, int msgId, Strin lines = new ArrayList<>(); accountInbox.put(chatId, lines); } - lines.add(tickerLine); + lines.add(shortLine); for (int l = 0; l < lines.size(); l++) { inboxStyle.addLine(lines.get(l));