From bfaf10aa72726d11cbc2cdcaae5931c275d7fbde Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Thu, 7 Feb 2019 18:11:21 +0100 Subject: [PATCH] brought back 'moderated' config in advanced mode --- .../ui/ConferenceDetailsActivity.java | 2 +- .../ui/util/MucConfiguration.java | 47 ++++++++++++++----- .../ui/util/MucDetailsContextMenuHelper.java | 14 ++++-- src/main/res/menu/muc_details_context.xml | 36 +++++++------- src/main/res/values/strings.xml | 10 ++-- 5 files changed, 68 insertions(+), 41 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java index a0b1cb59d..a0cf80ad9 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java @@ -125,7 +125,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers public void onClick(View v) { final MucOptions mucOptions = mConversation.getMucOptions(); AlertDialog.Builder builder = new AlertDialog.Builder(ConferenceDetailsActivity.this); - MucConfiguration configuration = MucConfiguration.get(ConferenceDetailsActivity.this, mucOptions); + MucConfiguration configuration = MucConfiguration.get(ConferenceDetailsActivity.this, mAdvancedMode, mucOptions); builder.setTitle(configuration.title); final boolean[] values = configuration.values; builder.setMultiChoiceItems(configuration.names, values, (dialog, which, isChecked) -> values[which] = isChecked); diff --git a/src/main/java/eu/siacs/conversations/ui/util/MucConfiguration.java b/src/main/java/eu/siacs/conversations/ui/util/MucConfiguration.java index ccdbf3a6f..3f40f714f 100644 --- a/src/main/java/eu/siacs/conversations/ui/util/MucConfiguration.java +++ b/src/main/java/eu/siacs/conversations/ui/util/MucConfiguration.java @@ -22,7 +22,7 @@ public class MucConfiguration { this.options = options; } - public static MucConfiguration get(Context context, MucOptions mucOptions) { + public static MucConfiguration get(Context context, boolean advanced, MucOptions mucOptions) { if (mucOptions.isPrivateAndNonAnonymous()) { String[] names = new String[]{ context.getString(R.string.allow_participants_to_edit_subject), @@ -38,18 +38,39 @@ public class MucConfiguration { }; return new MucConfiguration(R.string.conference_options, names, values, options); } else { - String[] names = new String[]{ - context.getString(R.string.non_anonymous), - context.getString(R.string.allow_participants_to_edit_subject), - }; - boolean[] values = new boolean[]{ - mucOptions.nonanonymous(), - mucOptions.participantsCanChangeSubject() - }; - final Option[] options = new Option[]{ - new Option("muc#roomconfig_whois","anyone","moderators"), - new Option("muc#roomconfig_changesubject") - }; + final String[] names; + final boolean[] values; + final Option[] options; + if (advanced) { + names = new String[]{ + context.getString(R.string.non_anonymous), + context.getString(R.string.allow_participants_to_edit_subject), + context.getString(R.string.moderated) + }; + values = new boolean[]{ + mucOptions.nonanonymous(), + mucOptions.participantsCanChangeSubject(), + mucOptions.moderated() + }; + options = new Option[]{ + new Option("muc#roomconfig_whois", "anyone", "moderators"), + new Option("muc#roomconfig_changesubject"), + new Option("muc#roomconfig_moderatedroom") + }; + } else { + names = new String[]{ + context.getString(R.string.non_anonymous), + context.getString(R.string.allow_participants_to_edit_subject), + }; + values = new boolean[]{ + mucOptions.nonanonymous(), + mucOptions.participantsCanChangeSubject() + }; + options = new Option[]{ + new Option("muc#roomconfig_whois", "anyone", "moderators"), + new Option("muc#roomconfig_changesubject") + }; + } return new MucConfiguration(R.string.channel_options, names, values, options); } } diff --git a/src/main/java/eu/siacs/conversations/ui/util/MucDetailsContextMenuHelper.java b/src/main/java/eu/siacs/conversations/ui/util/MucDetailsContextMenuHelper.java index 1eaf96c69..edf1d6593 100644 --- a/src/main/java/eu/siacs/conversations/ui/util/MucDetailsContextMenuHelper.java +++ b/src/main/java/eu/siacs/conversations/ui/util/MucDetailsContextMenuHelper.java @@ -63,7 +63,7 @@ public final class MucDetailsContextMenuHelper { 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 managePermisisons = menu.findItem(R.id.manage_permissions); + 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); @@ -80,13 +80,15 @@ public final class MucDetailsContextMenuHelper { boolean managePermissionsVisible = false; if ((self.getAffiliation().ranks(MucOptions.Affiliation.ADMIN) && self.getAffiliation().outranks(user.getAffiliation())) || self.getAffiliation() == MucOptions.Affiliation.OWNER) { if (advancedMode) { - managePermissionsVisible = true; 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 { @@ -98,23 +100,25 @@ public final class MucDetailsContextMenuHelper { } if (self.getAffiliation().ranks(MucOptions.Affiliation.OWNER)) { if (isGroupChat || advancedMode || user.getAffiliation() == MucOptions.Affiliation.OWNER) { - managePermissionsVisible = true; 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) { - managePermissionsVisible = true; if (!user.getAffiliation().ranks(MucOptions.Affiliation.ADMIN)) { + managePermissionsVisible = true; giveAdminPrivileges.setVisible(true); } else if (user.getAffiliation() == MucOptions.Affiliation.ADMIN) { + managePermissionsVisible = true; removeAdminPrivileges.setVisible(true); } } } - managePermisisons.setVisible(managePermissionsVisible); + managePermissions.setVisible(managePermissionsVisible); sendPrivateMessage.setVisible(!isGroupChat && mucOptions.allowPm() && user.getRole().ranks(MucOptions.Role.VISITOR)); } else { sendPrivateMessage.setVisible(true); diff --git a/src/main/res/menu/muc_details_context.xml b/src/main/res/menu/muc_details_context.xml index 2b735d1f5..54e0506eb 100644 --- a/src/main/res/menu/muc_details_context.xml +++ b/src/main/res/menu/muc_details_context.xml @@ -3,54 +3,56 @@ + android:visible="false" /> + android:visible="false" /> + android:visible="false" /> - + android:visible="false" /> + + android:visible="false" /> + android:visible="false" /> + android:visible="false" /> + android:visible="false" /> + android:visible="false" /> + android:visible="false" /> - + android:visible="false" /> + diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index fb7959971..a426afaf4 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -364,8 +364,8 @@ Outcast Member Advanced mode - Grant membership - Revoke membership + Grant member privileges + Revoke member privileges Grant admin privileges Revoke admin privileges Grant owner privileges @@ -375,14 +375,14 @@ Could not change affiliation of %s Ban from group chat Ban from channel - You are trying to remove %s from a public group chat. The only way to do that is to ban that user for ever. + You are trying to remove %s from a public channel. The only way to do that is to ban that user for ever. Ban now Could not change role of %s Private group chat configuration Public channel configuration Private, members only Make Jabber IDs visible to anyone - Moderated + Make channel moderated You are not participating Modified group chat options! Could not modify group chat options @@ -848,5 +848,5 @@ Jabber IDs are visible to anyone. This public channel has no participants. Invite your contacts or use the share button to distribute its XMPP address. This private group chat has no participants. - Manage permissions + Manage privileges