From 9ae0475413334b33b713dae6b84a070c890d1d76 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Wed, 14 Sep 2022 10:13:17 -0500 Subject: [PATCH] Show the name of the sender in search results (#4379) Just like a MUC, search results lack the context to be sure who sent a message, so show the name in the result item. --- .../java/eu/siacs/conversations/ui/SearchActivity.java | 2 +- .../eu/siacs/conversations/ui/adapter/MessageAdapter.java | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/SearchActivity.java b/src/main/java/eu/siacs/conversations/ui/SearchActivity.java index f5f4eb175..ec279f58e 100644 --- a/src/main/java/eu/siacs/conversations/ui/SearchActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/SearchActivity.java @@ -97,7 +97,7 @@ public class SearchActivity extends XmppActivity implements TextWatcher, OnSearc this.binding = DataBindingUtil.setContentView(this, R.layout.activity_search); setSupportActionBar(this.binding.toolbar); configureActionBar(getSupportActionBar()); - this.messageListAdapter = new MessageAdapter(this, this.messages); + this.messageListAdapter = new MessageAdapter(this, this.messages, uuid == null); this.messageListAdapter.setOnContactPictureClicked(this); this.binding.searchResults.setAdapter(messageListAdapter); registerForContextMenu(this.binding.searchResults); diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java index a5ba05819..bb954f45e 100644 --- a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java +++ b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java @@ -87,6 +87,7 @@ public class MessageAdapter extends ArrayAdapter { private OnContactPictureClicked mOnContactPictureClickedListener; private OnContactPictureLongClicked mOnContactPictureLongClickedListener; private boolean mUseGreenBackground = false; + private boolean mForceNames = false; public MessageAdapter(XmppActivity activity, List messages) { super(activity, 0, messages); @@ -96,6 +97,10 @@ public class MessageAdapter extends ArrayAdapter { updatePreferences(); } + public MessageAdapter(XmppActivity activity, List messages, boolean forceNames) { + this(activity, messages); + mForceNames = forceNames; + } private static void resetClickListener(View... views) { for (View view : views) { @@ -233,7 +238,7 @@ public class MessageAdapter extends ArrayAdapter { error = true; break; default: - if (multiReceived) { + if (mForceNames || multiReceived) { info = UIHelper.getMessageDisplayName(message); } break;