aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationFragment.java28
-rw-r--r--src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java20
-rw-r--r--src/main/java/de/pixart/messenger/ui/util/MucDetailsContextMenuHelper.java25
3 files changed, 61 insertions, 12 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
index 296b1b215..ac88e2870 100644
--- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
+++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
@@ -3078,7 +3078,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
final User user = userByRealJid != null ? userByRealJid : conversation.getMucOptions().findUserByFullJid(cp);
popupMenu.inflate(R.menu.muc_details_context);
final Menu menu = popupMenu.getMenu();
- MucDetailsContextMenuHelper.configureMucDetailsContextMenu(activity, menu, conversation, user);
+ MucDetailsContextMenuHelper.configureMucDetailsContextMenu(activity, menu, conversation, user, true, getUsername(message));
popupMenu.setOnMenuItemClickListener(menuItem -> MucDetailsContextMenuHelper.onContextItemSelected(menuItem, user, activity, fingerprint));
} else {
popupMenu.inflate(R.menu.one_on_one_context);
@@ -3112,6 +3112,32 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
popupMenu.show();
}
+ private String getUsername(Message message) {
+ String user;
+ try {
+ final Contact contact = message.getContact();
+ if (conversation.getMode() == Conversation.MODE_MULTI) {
+ if (contact != null) {
+ user = contact.getDisplayName();
+ } else {
+ user = UIHelper.getDisplayedMucCounterpart(message.getCounterpart());
+ }
+ } else {
+ user = contact != null ? contact.getDisplayName() : null;
+ }
+ if (message.getStatus() == Message.STATUS_SEND
+ || message.getStatus() == Message.STATUS_SEND_FAILED
+ || message.getStatus() == Message.STATUS_SEND_RECEIVED
+ || message.getStatus() == Message.STATUS_SEND_DISPLAYED) {
+ user = getString(R.string.me);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ user = null;
+ }
+ return user;
+ }
+
@Override
public void onContactPictureClicked(Message message) {
String fingerprint;
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 5e7c5962f..6cff1aebd 100644
--- a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java
+++ b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java
@@ -9,8 +9,10 @@ import android.graphics.Rect;
import android.graphics.Typeface;
import android.net.Uri;
import android.preference.PreferenceManager;
+
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
+
import android.text.Editable;
import android.text.Spannable;
import android.text.SpannableString;
@@ -1039,16 +1041,14 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
}
});
- viewHolder.contact_picture
- .setOnLongClickListener(v -> {
- if (MessageAdapter.this.mOnContactPictureLongClickedListener != null) {
- MessageAdapter.this.mOnContactPictureLongClickedListener
- .onContactPictureLongClicked(v, message);
- return true;
- } else {
- return false;
- }
- });
+ viewHolder.contact_picture.setOnLongClickListener(v -> {
+ if (MessageAdapter.this.mOnContactPictureLongClickedListener != null) {
+ MessageAdapter.this.mOnContactPictureLongClickedListener.onContactPictureLongClicked(v, message);
+ return true;
+ } else {
+ return false;
+ }
+ });
final Transferable transferable = message.getTransferable();
if (message.isFileDeleted() || (transferable != null && transferable.getStatus() != Transferable.STATUS_UPLOADING)) {
diff --git a/src/main/java/de/pixart/messenger/ui/util/MucDetailsContextMenuHelper.java b/src/main/java/de/pixart/messenger/ui/util/MucDetailsContextMenuHelper.java
index 2abff6973..5a6415d75 100644
--- a/src/main/java/de/pixart/messenger/ui/util/MucDetailsContextMenuHelper.java
+++ b/src/main/java/de/pixart/messenger/ui/util/MucDetailsContextMenuHelper.java
@@ -1,16 +1,22 @@
package de.pixart.messenger.ui.util;
import android.app.Activity;
+import android.graphics.Typeface;
import android.preference.PreferenceManager;
-import androidx.appcompat.app.AlertDialog;
import android.text.SpannableString;
+import android.text.SpannableStringBuilder;
import android.text.Spanned;
+import android.text.style.ForegroundColorSpan;
+import android.text.style.RelativeSizeSpan;
+import android.text.style.StyleSpan;
import android.text.style.TypefaceSpan;
import android.view.ContextMenu;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
+import androidx.appcompat.app.AlertDialog;
+
import de.pixart.messenger.Config;
import de.pixart.messenger.R;
import de.pixart.messenger.entities.Contact;
@@ -27,6 +33,8 @@ import rocks.xmpp.addr.Jid;
public final class MucDetailsContextMenuHelper {
+ private static int titleColor = 0xff0091ea;
+
public static void onCreateContextMenu(ContextMenu menu, View v) {
final XmppActivity activity = XmppActivity.find(v);
final Object tag = v.getTag();
@@ -48,9 +56,24 @@ public final class MucDetailsContextMenuHelper {
}
public static void configureMucDetailsContextMenu(Activity activity, Menu menu, Conversation conversation, User user) {
+ configureMucDetailsContextMenu(activity, menu, conversation, user, false, null);
+ }
+
+ public static void configureMucDetailsContextMenu(Activity activity, Menu menu, Conversation conversation, User user, boolean forceContextMenu, String username) {
final boolean advancedMode = PreferenceManager.getDefaultSharedPreferences(activity).getBoolean("advanced_muc_mode", false);
final MucOptions mucOptions = conversation.getMucOptions();
final boolean isGroupChat = mucOptions.isPrivateAndNonAnonymous();
+ MenuItem title = menu.findItem(R.id.title);
+ if (forceContextMenu && username != null) {
+ SpannableStringBuilder menuTitle = new SpannableStringBuilder(username);
+ menuTitle.setSpan(new ForegroundColorSpan(titleColor), 0, menuTitle.length(), 0);
+ menuTitle.setSpan(new StyleSpan(Typeface.BOLD), 0, menuTitle.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+ menuTitle.setSpan(new RelativeSizeSpan(0.875f), 0, menuTitle.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+ title.setTitle(menuTitle);
+ title.setVisible(true);
+ } else {
+ title.setVisible(false);
+ }
MenuItem sendPrivateMessage = menu.findItem(R.id.send_private_message);
if (user != null && user.getRealJid() != null) {
MenuItem showContactDetails = menu.findItem(R.id.action_contact_details);