show context menu when long pressing own account picture
This commit is contained in:
parent
2f3ccb5f90
commit
20e731c956
|
@ -83,6 +83,7 @@ import eu.siacs.conversations.entities.TransferablePlaceholder;
|
|||
import eu.siacs.conversations.http.HttpDownloadConnection;
|
||||
import eu.siacs.conversations.persistance.FileBackend;
|
||||
import eu.siacs.conversations.services.MessageArchiveService;
|
||||
import eu.siacs.conversations.services.QuickConversationsService;
|
||||
import eu.siacs.conversations.services.XmppConnectionService;
|
||||
import eu.siacs.conversations.ui.adapter.MediaPreviewAdapter;
|
||||
import eu.siacs.conversations.ui.adapter.MessageAdapter;
|
||||
|
@ -102,6 +103,7 @@ import eu.siacs.conversations.ui.util.SendButtonTool;
|
|||
import eu.siacs.conversations.ui.util.ShareUtil;
|
||||
import eu.siacs.conversations.ui.util.ViewUtil;
|
||||
import eu.siacs.conversations.ui.widget.EditMessage;
|
||||
import eu.siacs.conversations.utils.AccountUtils;
|
||||
import eu.siacs.conversations.utils.Compatibility;
|
||||
import eu.siacs.conversations.utils.GeoHelper;
|
||||
import eu.siacs.conversations.utils.MessageUtils;
|
||||
|
@ -2727,36 +2729,32 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
|||
|
||||
@Override
|
||||
public void onContactPictureLongClicked(View v, final Message message) {
|
||||
if (message.getStatus() <= Message.STATUS_RECEIVED) {
|
||||
final PopupMenu popupMenu = new PopupMenu(getActivity(), v);
|
||||
final String fingerprint;
|
||||
if (message.getEncryption() == Message.ENCRYPTION_PGP || message.getEncryption() == Message.ENCRYPTION_DECRYPTED) {
|
||||
fingerprint = "pgp";
|
||||
} else {
|
||||
fingerprint = message.getFingerprint();
|
||||
}
|
||||
final PopupMenu popupMenu = new PopupMenu(getActivity(), v);
|
||||
final Contact contact = message.getContact();
|
||||
if (message.getStatus() <= Message.STATUS_RECEIVED || (contact != null && contact.isSelf())) {
|
||||
if (message.getConversation().getMode() == Conversation.MODE_MULTI) {
|
||||
final Jid cp = message.getCounterpart();
|
||||
if (cp == null || cp.isBareJid()) {
|
||||
return;
|
||||
}
|
||||
Jid tcp = message.getTrueCounterpart();
|
||||
User userByRealJid = tcp != null ? conversation.getMucOptions().findOrCreateUserByRealJid(tcp, cp) : null;
|
||||
final Jid tcp = message.getTrueCounterpart();
|
||||
final User userByRealJid = tcp != null ? conversation.getMucOptions().findOrCreateUserByRealJid(tcp, cp) : null;
|
||||
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);
|
||||
popupMenu.setOnMenuItemClickListener(menuItem -> MucDetailsContextMenuHelper.onContextItemSelected(menuItem, user, activity));
|
||||
popupMenu.setOnMenuItemClickListener(menuItem -> MucDetailsContextMenuHelper.onContextItemSelected(menuItem, user, activity, fingerprint));
|
||||
} else {
|
||||
final Contact contact = message.getContact();
|
||||
if (contact.isSelf()) {
|
||||
activity.showQrCode(conversation.getAccount().getShareableUri());
|
||||
return;
|
||||
}
|
||||
popupMenu.inflate(R.menu.one_on_one_context);
|
||||
popupMenu.setOnMenuItemClickListener(item -> {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_contact_details:
|
||||
String fingerprint;
|
||||
if (message.getEncryption() == Message.ENCRYPTION_PGP || message.getEncryption() == Message.ENCRYPTION_DECRYPTED) {
|
||||
fingerprint = "pgp";
|
||||
} else {
|
||||
fingerprint = message.getFingerprint();
|
||||
}
|
||||
activity.switchToContactDetails(message.getContact(), fingerprint);
|
||||
break;
|
||||
case R.id.action_show_qr_code:
|
||||
|
@ -2766,10 +2764,26 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
|||
return true;
|
||||
});
|
||||
}
|
||||
popupMenu.show();
|
||||
} else {
|
||||
activity.showQrCode(conversation.getAccount().getShareableUri());
|
||||
popupMenu.inflate(R.menu.account_context);
|
||||
final Menu menu = popupMenu.getMenu();
|
||||
menu.findItem(R.id.action_manage_accounts).setVisible(QuickConversationsService.isConversations());
|
||||
popupMenu.setOnMenuItemClickListener(item -> {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_show_qr_code:
|
||||
activity.showQrCode(conversation.getAccount().getShareableUri());
|
||||
break;
|
||||
case R.id.action_account_details:
|
||||
activity.switchToAccount(message.getConversation().getAccount(), fingerprint);
|
||||
break;
|
||||
case R.id.action_manage_accounts:
|
||||
AccountUtils.launchManageAccounts(activity);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
popupMenu.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,6 +3,7 @@ package eu.siacs.conversations.ui;
|
|||
import android.app.Activity;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentSender;
|
||||
import android.content.SharedPreferences;
|
||||
|
|
|
@ -102,6 +102,10 @@ public final class MucDetailsContextMenuHelper {
|
|||
}
|
||||
|
||||
public static boolean onContextItemSelected(MenuItem item, User user, XmppActivity activity) {
|
||||
return onContextItemSelected(item, user, activity, null);
|
||||
}
|
||||
|
||||
public static boolean onContextItemSelected(MenuItem item, User user, XmppActivity activity, final String fingerprint) {
|
||||
final Conversation conversation = user.getConversation();
|
||||
final XmppConnectionService.OnAffiliationChanged onAffiliationChanged = activity instanceof XmppConnectionService.OnAffiliationChanged ? (XmppConnectionService.OnAffiliationChanged) activity : null;
|
||||
final XmppConnectionService.OnRoleChanged onRoleChanged = activity instanceof XmppConnectionService.OnRoleChanged ? (XmppConnectionService.OnRoleChanged) activity : null;
|
||||
|
@ -110,7 +114,7 @@ public final class MucDetailsContextMenuHelper {
|
|||
case R.id.action_contact_details:
|
||||
Contact contact = user.getContact();
|
||||
if (contact != null) {
|
||||
activity.switchToContactDetails(contact);
|
||||
activity.switchToContactDetails(contact, fingerprint);
|
||||
}
|
||||
return true;
|
||||
case R.id.start_conversation:
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:id="@+id/action_account_details"
|
||||
android:title="@string/account_details"/>
|
||||
<item
|
||||
android:id="@+id/action_manage_accounts"
|
||||
android:title="@string/action_accounts"/>
|
||||
<item
|
||||
android:id="@+id/action_show_qr_code"
|
||||
android:title="@string/show_qr_code"/>
|
||||
</menu>
|
Loading…
Reference in New Issue