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.
This commit is contained in:
Stephen Paul Weber 2022-09-14 10:13:17 -05:00 committed by GitHub
parent c1abca35da
commit 9ae0475413
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View file

@ -97,7 +97,7 @@ public class SearchActivity extends XmppActivity implements TextWatcher, OnSearc
this.binding = DataBindingUtil.setContentView(this, R.layout.activity_search); this.binding = DataBindingUtil.setContentView(this, R.layout.activity_search);
setSupportActionBar(this.binding.toolbar); setSupportActionBar(this.binding.toolbar);
configureActionBar(getSupportActionBar()); configureActionBar(getSupportActionBar());
this.messageListAdapter = new MessageAdapter(this, this.messages); this.messageListAdapter = new MessageAdapter(this, this.messages, uuid == null);
this.messageListAdapter.setOnContactPictureClicked(this); this.messageListAdapter.setOnContactPictureClicked(this);
this.binding.searchResults.setAdapter(messageListAdapter); this.binding.searchResults.setAdapter(messageListAdapter);
registerForContextMenu(this.binding.searchResults); registerForContextMenu(this.binding.searchResults);

View file

@ -87,6 +87,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
private OnContactPictureClicked mOnContactPictureClickedListener; private OnContactPictureClicked mOnContactPictureClickedListener;
private OnContactPictureLongClicked mOnContactPictureLongClickedListener; private OnContactPictureLongClicked mOnContactPictureLongClickedListener;
private boolean mUseGreenBackground = false; private boolean mUseGreenBackground = false;
private boolean mForceNames = false;
public MessageAdapter(XmppActivity activity, List<Message> messages) { public MessageAdapter(XmppActivity activity, List<Message> messages) {
super(activity, 0, messages); super(activity, 0, messages);
@ -96,6 +97,10 @@ public class MessageAdapter extends ArrayAdapter<Message> {
updatePreferences(); updatePreferences();
} }
public MessageAdapter(XmppActivity activity, List<Message> messages, boolean forceNames) {
this(activity, messages);
mForceNames = forceNames;
}
private static void resetClickListener(View... views) { private static void resetClickListener(View... views) {
for (View view : views) { for (View view : views) {
@ -233,7 +238,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
error = true; error = true;
break; break;
default: default:
if (multiReceived) { if (mForceNames || multiReceived) {
info = UIHelper.getMessageDisplayName(message); info = UIHelper.getMessageDisplayName(message);
} }
break; break;