use of eu.siacs.conversations.entities.MucOptions in project Conversations by siacs.
the class AvatarService method get.
public Bitmap get(Message message, int size, boolean cachedOnly) {
final Conversational conversation = message.getConversation();
if (message.getType() == Message.TYPE_STATUS && message.getCounterparts() != null && message.getCounterparts().size() > 1) {
return get(message.getCounterparts(), size, cachedOnly);
} else if (message.getStatus() == Message.STATUS_RECEIVED) {
Contact c = message.getContact();
if (c != null && (c.getProfilePhoto() != null || c.getAvatarFilename() != null)) {
return get(c, size, cachedOnly);
} else if (conversation instanceof Conversation && message.getConversation().getMode() == Conversation.MODE_MULTI) {
final Jid trueCounterpart = message.getTrueCounterpart();
final MucOptions mucOptions = ((Conversation) conversation).getMucOptions();
MucOptions.User user;
if (trueCounterpart != null) {
user = mucOptions.findOrCreateUserByRealJid(trueCounterpart, message.getCounterpart());
} else {
user = mucOptions.findUserByFullJid(message.getCounterpart());
}
if (user != null) {
return getImpl(user, size, cachedOnly);
}
} else if (c != null) {
return get(c, size, cachedOnly);
}
Jid tcp = message.getTrueCounterpart();
String seed = tcp != null ? tcp.asBareJid().toString() : null;
return get(UIHelper.getMessageDisplayName(message), seed, size, cachedOnly);
} else {
return get(conversation.getAccount(), size, cachedOnly);
}
}
use of eu.siacs.conversations.entities.MucOptions in project Conversations by siacs.
the class MucDetailsContextMenuHelper method configureMucDetailsContextMenu.
public static void configureMucDetailsContextMenu(Activity activity, Menu menu, Conversation conversation, User user) {
final MucOptions mucOptions = conversation.getMucOptions();
final boolean advancedMode = PreferenceManager.getDefaultSharedPreferences(activity).getBoolean("advanced_muc_mode", false);
final boolean isGroupChat = mucOptions.isPrivateAndNonAnonymous();
MenuItem sendPrivateMessage = menu.findItem(R.id.send_private_message);
if (user != null && user.getRealJid() != null) {
MenuItem showContactDetails = menu.findItem(R.id.action_contact_details);
MenuItem startConversation = menu.findItem(R.id.start_conversation);
MenuItem giveMembership = menu.findItem(R.id.give_membership);
MenuItem removeMembership = menu.findItem(R.id.remove_membership);
MenuItem giveAdminPrivileges = menu.findItem(R.id.give_admin_privileges);
MenuItem giveOwnerPrivileges = menu.findItem(R.id.give_owner_privileges);
MenuItem removeOwnerPrivileges = menu.findItem(R.id.revoke_owner_privileges);
MenuItem removeAdminPrivileges = menu.findItem(R.id.remove_admin_privileges);
MenuItem removeFromRoom = menu.findItem(R.id.remove_from_room);
MenuItem managePermissions = menu.findItem(R.id.manage_permissions);
removeFromRoom.setTitle(isGroupChat ? R.string.remove_from_room : R.string.remove_from_channel);
MenuItem banFromConference = menu.findItem(R.id.ban_from_conference);
banFromConference.setTitle(isGroupChat ? R.string.ban_from_conference : R.string.ban_from_channel);
MenuItem invite = menu.findItem(R.id.invite);
startConversation.setVisible(true);
final Contact contact = user.getContact();
final User self = conversation.getMucOptions().getSelf();
if ((contact != null && contact.showInRoster()) || mucOptions.isPrivateAndNonAnonymous()) {
showContactDetails.setVisible(contact == null || !contact.isSelf());
}
if ((activity instanceof ConferenceDetailsActivity || activity instanceof MucUsersActivity) && user.getRole() == MucOptions.Role.NONE) {
invite.setVisible(true);
}
boolean managePermissionsVisible = false;
if ((self.getAffiliation().ranks(MucOptions.Affiliation.ADMIN) && self.getAffiliation().outranks(user.getAffiliation())) || self.getAffiliation() == MucOptions.Affiliation.OWNER) {
if (advancedMode) {
if (!user.getAffiliation().ranks(MucOptions.Affiliation.MEMBER)) {
managePermissionsVisible = true;
giveMembership.setVisible(true);
} else if (user.getAffiliation() == MucOptions.Affiliation.MEMBER) {
managePermissionsVisible = true;
removeMembership.setVisible(true);
}
if (!Config.DISABLE_BAN) {
managePermissionsVisible = true;
banFromConference.setVisible(true);
}
} else {
if (!Config.DISABLE_BAN || conversation.getMucOptions().membersOnly()) {
removeFromRoom.setVisible(true);
}
}
}
if (self.getAffiliation().ranks(MucOptions.Affiliation.OWNER)) {
if (isGroupChat || advancedMode || user.getAffiliation() == MucOptions.Affiliation.OWNER) {
if (!user.getAffiliation().ranks(MucOptions.Affiliation.OWNER)) {
managePermissionsVisible = true;
giveOwnerPrivileges.setVisible(true);
} else if (user.getAffiliation() == MucOptions.Affiliation.OWNER) {
managePermissionsVisible = true;
removeOwnerPrivileges.setVisible(true);
}
}
if (!isGroupChat || advancedMode || user.getAffiliation() == MucOptions.Affiliation.ADMIN) {
if (!user.getAffiliation().ranks(MucOptions.Affiliation.ADMIN)) {
managePermissionsVisible = true;
giveAdminPrivileges.setVisible(true);
} else if (user.getAffiliation() == MucOptions.Affiliation.ADMIN) {
managePermissionsVisible = true;
removeAdminPrivileges.setVisible(true);
}
}
}
managePermissions.setVisible(managePermissionsVisible);
sendPrivateMessage.setVisible(!isGroupChat && mucOptions.allowPm() && user.getRole().ranks(MucOptions.Role.VISITOR));
} else {
sendPrivateMessage.setVisible(true);
sendPrivateMessage.setEnabled(user != null && mucOptions.allowPm() && user.getRole().ranks(MucOptions.Role.VISITOR));
}
}
Aggregations