Search in sources :

Example 1 with ConversationFragment

use of eu.siacs.conversations.ui.ConversationFragment in project Conversations by siacs.

the class MucDetailsContextMenuHelper method onContextItemSelected.

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;
    Jid jid = user.getRealJid();
    switch(item.getItemId()) {
        case R.id.action_contact_details:
            final Jid realJid = user.getRealJid();
            final Account account = conversation.getAccount();
            final Contact contact = realJid == null ? null : account.getRoster().getContact(realJid);
            if (contact != null) {
                activity.switchToContactDetails(contact, fingerprint);
            }
            return true;
        case R.id.start_conversation:
            startConversation(user, activity);
            return true;
        case R.id.give_admin_privileges:
            activity.xmppConnectionService.changeAffiliationInConference(conversation, jid, MucOptions.Affiliation.ADMIN, onAffiliationChanged);
            return true;
        case R.id.give_membership:
        case R.id.remove_admin_privileges:
        case R.id.revoke_owner_privileges:
            activity.xmppConnectionService.changeAffiliationInConference(conversation, jid, MucOptions.Affiliation.MEMBER, onAffiliationChanged);
            return true;
        case R.id.give_owner_privileges:
            activity.xmppConnectionService.changeAffiliationInConference(conversation, jid, MucOptions.Affiliation.OWNER, onAffiliationChanged);
            return true;
        case R.id.remove_membership:
            activity.xmppConnectionService.changeAffiliationInConference(conversation, jid, MucOptions.Affiliation.NONE, onAffiliationChanged);
            return true;
        case R.id.remove_from_room:
            removeFromRoom(user, activity, onAffiliationChanged);
            return true;
        case R.id.ban_from_conference:
            activity.xmppConnectionService.changeAffiliationInConference(conversation, jid, MucOptions.Affiliation.OUTCAST, onAffiliationChanged);
            if (user.getRole() != MucOptions.Role.NONE) {
                activity.xmppConnectionService.changeRoleInConference(conversation, user.getName(), MucOptions.Role.NONE);
            }
            return true;
        case R.id.send_private_message:
            if (activity instanceof ConversationsActivity) {
                ConversationFragment conversationFragment = ConversationFragment.get(activity);
                if (conversationFragment != null) {
                    conversationFragment.privateMessageWith(user.getFullJid());
                    return true;
                }
            }
            activity.privateMsgInMuc(conversation, user.getName());
            return true;
        case R.id.invite:
            if (user.getAffiliation().ranks(MucOptions.Affiliation.MEMBER)) {
                activity.xmppConnectionService.directInvite(conversation, jid.asBareJid());
            } else {
                activity.xmppConnectionService.invite(conversation, jid);
            }
            return true;
        default:
            return false;
    }
}
Also used : Account(eu.siacs.conversations.entities.Account) XmppConnectionService(eu.siacs.conversations.services.XmppConnectionService) Jid(eu.siacs.conversations.xmpp.Jid) Conversation(eu.siacs.conversations.entities.Conversation) ConversationFragment(eu.siacs.conversations.ui.ConversationFragment) ConversationsActivity(eu.siacs.conversations.ui.ConversationsActivity) Contact(eu.siacs.conversations.entities.Contact)

Aggregations

Account (eu.siacs.conversations.entities.Account)1 Contact (eu.siacs.conversations.entities.Contact)1 Conversation (eu.siacs.conversations.entities.Conversation)1 XmppConnectionService (eu.siacs.conversations.services.XmppConnectionService)1 ConversationFragment (eu.siacs.conversations.ui.ConversationFragment)1 ConversationsActivity (eu.siacs.conversations.ui.ConversationsActivity)1 Jid (eu.siacs.conversations.xmpp.Jid)1