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;
}
}
Aggregations