diff options
author | Christian Schneppe <christian@pix-art.de> | 2019-04-01 21:31:00 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2019-04-01 21:31:00 +0200 |
commit | d3a8282bf6b3313450aa81b6eada2e07a9be870e (patch) | |
tree | b2b902ae3c21a1b9df733842c5413e71492b5c71 /src | |
parent | a2c2b2e658617e14342f95b3d467900778c309cd (diff) |
add ability to kick user from room and not just ban them
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/util/MucDetailsContextMenuHelper.java | 85 | ||||
-rw-r--r-- | src/main/res/menu/muc_details_context.xml | 12 | ||||
-rw-r--r-- | src/main/res/values/strings.xml | 9 |
3 files changed, 66 insertions, 40 deletions
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 c229dbf00..b9876c4b4 100644 --- a/src/main/java/de/pixart/messenger/ui/util/MucDetailsContextMenuHelper.java +++ b/src/main/java/de/pixart/messenger/ui/util/MucDetailsContextMenuHelper.java @@ -61,10 +61,10 @@ public final class MucDetailsContextMenuHelper { MenuItem removeAdminPrivileges = menu.findItem(R.id.remove_admin_privileges); MenuItem giveOwnerPrivileges = menu.findItem(R.id.give_owner_privileges); MenuItem removeOwnerPrivileges = menu.findItem(R.id.revoke_owner_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); + MenuItem removeFromRoom = menu.findItem(R.id.kick_from_room); + removeFromRoom.setTitle(isGroupChat ? R.string.kick_from_room : R.string.remove_from_channel); + MenuItem banFromConference = menu.findItem(R.id.ban_from_room); banFromConference.setTitle(isGroupChat ? R.string.ban_from_conference : R.string.ban_from_channel); MenuItem invite = menu.findItem(R.id.invite); MenuItem highlightInMuc = menu.findItem(R.id.highlight_in_muc); @@ -96,11 +96,11 @@ public final class MucDetailsContextMenuHelper { managePermissionsVisible = true; banFromConference.setVisible(true); } - } else { - if (!Config.DISABLE_BAN || conversation.getMucOptions().membersOnly()) { - removeFromRoom.setVisible(true); - } } + if (!Config.DISABLE_BAN) { + removeFromRoom.setVisible(true); + } + } if (self.getAffiliation().ranks(MucOptions.Affiliation.OWNER)) { if (isGroupChat || advancedMode || user.getAffiliation() == MucOptions.Affiliation.OWNER) { @@ -165,14 +165,11 @@ public final class MucDetailsContextMenuHelper { case R.id.revoke_owner_privileges: activity.xmppConnectionService.changeAffiliationInConference(conversation, jid, MucOptions.Affiliation.MEMBER, onAffiliationChanged); return true; - case R.id.remove_from_room: - removeFromRoom(user, activity, onAffiliationChanged); + case R.id.kick_from_room: + kickFromRoom(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); - } + case R.id.ban_from_room: + banFromRoom(user, activity, onAffiliationChanged); return true; case R.id.send_private_message: if (activity instanceof ConversationsActivity) { @@ -195,32 +192,56 @@ public final class MucDetailsContextMenuHelper { } } - private static void removeFromRoom(final User user, XmppActivity activity, XmppConnectionService.OnAffiliationChanged onAffiliationChanged) { + private static void kickFromRoom(final User user, XmppActivity activity, XmppConnectionService.OnAffiliationChanged onAffiliationChanged) { final Conversation conversation = user.getConversation(); + AlertDialog.Builder builder = new AlertDialog.Builder(activity); + builder.setTitle(R.string.kick_from_conference); + String jid = user.getRealJid().asBareJid().toString(); + SpannableString message; if (conversation.getMucOptions().membersOnly()) { + message = new SpannableString(activity.getString(R.string.kicking_from_conference, jid)); + } else { + message = new SpannableString(activity.getString(R.string.kicking_from_public_conference, jid)); + } + int start = message.toString().indexOf(jid); + if (start >= 0) { + message.setSpan(new TypefaceSpan("monospace"), start, start + jid.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + } + builder.setMessage(message); + builder.setNegativeButton(R.string.cancel, null); + builder.setPositiveButton(R.string.kick_now, (dialog, which) -> { activity.xmppConnectionService.changeAffiliationInConference(conversation, user.getRealJid(), MucOptions.Affiliation.NONE, onAffiliationChanged); if (user.getRole() != MucOptions.Role.NONE) { activity.xmppConnectionService.changeRoleInConference(conversation, user.getName(), MucOptions.Role.NONE); } + }); + builder.create().show(); + } + + private static void banFromRoom(final User user, XmppActivity activity, XmppConnectionService.OnAffiliationChanged onAffiliationChanged) { + final Conversation conversation = user.getConversation(); + AlertDialog.Builder builder = new AlertDialog.Builder(activity); + builder.setTitle(R.string.ban_from_conference); + String jid = user.getRealJid().asBareJid().toString(); + SpannableString message; + if (conversation.getMucOptions().membersOnly()) { + message = new SpannableString(activity.getString(R.string.ban_from_conference_message, jid)); } else { - AlertDialog.Builder builder = new AlertDialog.Builder(activity); - builder.setTitle(R.string.ban_from_conference); - String jid = user.getRealJid().asBareJid().toString(); - SpannableString message = new SpannableString(activity.getString(R.string.removing_from_public_conference, jid)); - int start = message.toString().indexOf(jid); - if (start >= 0) { - message.setSpan(new TypefaceSpan("monospace"), start, start + jid.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); - } - builder.setMessage(message); - builder.setNegativeButton(R.string.cancel, null); - builder.setPositiveButton(R.string.ban_now, (dialog, which) -> { - activity.xmppConnectionService.changeAffiliationInConference(conversation, user.getRealJid(), MucOptions.Affiliation.OUTCAST, onAffiliationChanged); - if (user.getRole() != MucOptions.Role.NONE) { - activity.xmppConnectionService.changeRoleInConference(conversation, user.getName(), MucOptions.Role.NONE); - } - }); - builder.create().show(); + message = new SpannableString(activity.getString(R.string.ban_from_public_conference_message, jid)); } + int start = message.toString().indexOf(jid); + if (start >= 0) { + message.setSpan(new TypefaceSpan("monospace"), start, start + jid.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + } + builder.setMessage(message); + builder.setNegativeButton(R.string.cancel, null); + builder.setPositiveButton(R.string.ban_now, (dialog, which) -> { + activity.xmppConnectionService.changeAffiliationInConference(conversation, user.getRealJid(), MucOptions.Affiliation.OUTCAST, onAffiliationChanged); + if (user.getRole() != MucOptions.Role.NONE) { + activity.xmppConnectionService.changeRoleInConference(conversation, user.getName(), MucOptions.Role.NONE); + } + }); + builder.create().show(); } private static void startConversation(User user, XmppActivity activity) { diff --git a/src/main/res/menu/muc_details_context.xml b/src/main/res/menu/muc_details_context.xml index c3d54e5c6..44522cf87 100644 --- a/src/main/res/menu/muc_details_context.xml +++ b/src/main/res/menu/muc_details_context.xml @@ -49,14 +49,14 @@ android:id="@+id/revoke_owner_privileges" android:title="@string/remove_owner_privileges" android:visible="false" /> - <item - android:id="@+id/ban_from_conference" - android:title="@string/ban_from_conference" - android:visible="false" /> </menu> </item> <item - android:id="@+id/remove_from_room" - android:title="@string/remove_from_room" + android:id="@+id/kick_from_room" + android:title="@string/kick_from_room" + android:visible="false" /> + <item + android:id="@+id/ban_from_room" + android:title="@string/ban_from_conference" android:visible="false" /> </menu> diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 477c74ddc..90bcb50b7 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -365,11 +365,16 @@ <string name="remove_membership">Revoke member privileges</string> <string name="grant_admin_privileges">Grant admin privileges</string> <string name="remove_admin_privileges">Revoke admin privileges</string> - <string name="remove_from_room">Remove from group chat</string> + <string name="kick_from_room">Kick from group chat</string> <string name="could_not_change_affiliation">Could not change affiliation of %s</string> <string name="ban_from_conference">Ban from group chat</string> - <string name="removing_from_public_conference">You are trying to remove %s from a public channel. The only way to do that is to ban that user for ever.</string> + <string name="kick_from_conference">Kick from group chat</string> + <string name="ban_from_public_conference_message">You are trying to ban %s for ever from a public channel.</string> + <string name="ban_from_conference_message">You are trying to ban %s for ever from a group chat</string> + <string name="kicking_from_public_conference">You are trying to kick %s from a public channel.</string> + <string name="kicking_from_conference">You are trying to kick %s from a group chat.</string> <string name="ban_now">Ban now</string> + <string name="kick_now">Kick now</string> <string name="non_anonymous">Make Jabber IDs visible to anyone</string> <string name="moderated">Make channel moderated</string> <string name="you_are_not_participating">You are not participating</string> |