aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2015-09-13 17:13:46 +0200
committerDaniel Gultsch <daniel@gultsch.de>2015-09-13 17:13:46 +0200
commit96575d6290d3fc28c79ec37c493e1062735cbf41 (patch)
tree797e1a77044498f1d12503d86d6faca6470b3a45 /src
parentadd4302385257a07fdf234d5ab8ae675040a6aea (diff)
added possibiltiy to set conferences as moderated (only visible in advanced mode)
Diffstat (limited to 'src')
-rw-r--r--src/main/java/eu/siacs/conversations/entities/MucOptions.java26
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java37
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ConversationActivity.java2
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ConversationFragment.java9
-rw-r--r--src/main/res/values/strings.xml4
5 files changed, 62 insertions, 16 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/MucOptions.java b/src/main/java/eu/siacs/conversations/entities/MucOptions.java
index 52a862ef..cf49cf65 100644
--- a/src/main/java/eu/siacs/conversations/entities/MucOptions.java
+++ b/src/main/java/eu/siacs/conversations/entities/MucOptions.java
@@ -23,7 +23,7 @@ public class MucOptions {
OUTCAST("outcast", 0, R.string.outcast),
NONE("none", 1, R.string.no_affiliation);
- private Affiliation(String string, int rank, int resId) {
+ Affiliation(String string, int rank, int resId) {
this.string = string;
this.resId = resId;
this.rank = rank;
@@ -52,18 +52,20 @@ public class MucOptions {
}
public enum Role {
- MODERATOR("moderator", R.string.moderator),
- VISITOR("visitor", R.string.visitor),
- PARTICIPANT("participant", R.string.participant),
- NONE("none", R.string.no_role);
+ MODERATOR("moderator", R.string.moderator,3),
+ VISITOR("visitor", R.string.visitor,1),
+ PARTICIPANT("participant", R.string.participant,2),
+ NONE("none", R.string.no_role,0);
- private Role(String string, int resId) {
+ private Role(String string, int resId, int rank) {
this.string = string;
this.resId = resId;
+ this.rank = rank;
}
private String string;
private int resId;
+ private int rank;
public int getResId() {
return resId;
@@ -73,6 +75,10 @@ public class MucOptions {
public String toString() {
return this.string;
}
+
+ public boolean ranks(Role role) {
+ return rank >= role.rank;
+ }
}
public static final int ERROR_NO_ERROR = 0;
@@ -233,6 +239,10 @@ public class MucOptions {
return !membersOnly() || self.getAffiliation().ranks(Affiliation.ADMIN);
}
+ public boolean participating() {
+ return !online() || self.getRole().ranks(Role.PARTICIPANT);
+ }
+
public boolean membersOnly() {
return hasFeature("muc_membersonly");
}
@@ -245,6 +255,10 @@ public class MucOptions {
return hasFeature("muc_persistent");
}
+ public boolean moderated() {
+ return hasFeature("muc_moderated");
+ }
+
public void deleteUser(String name) {
for (int i = 0; i < users.size(); ++i) {
if (users.get(i).getName().equals(name)) {
diff --git a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java
index 12b66c35..2f9d567e 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java
@@ -102,11 +102,29 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
final MucOptions mucOptions = mConversation.getMucOptions();
AlertDialog.Builder builder = new AlertDialog.Builder(ConferenceDetailsActivity.this);
builder.setTitle(R.string.conference_options);
- String[] options = {getString(R.string.members_only),
- getString(R.string.non_anonymous)};
- final boolean[] values = new boolean[options.length];
- values[0] = mucOptions.membersOnly();
- values[1] = mucOptions.nonanonymous();
+ final String[] options;
+ final boolean[] values;
+ if (mAdvancedMode) {
+ options = new String[]{
+ getString(R.string.members_only),
+ getString(R.string.moderated),
+ getString(R.string.non_anonymous)
+ };
+ values = new boolean[]{
+ mucOptions.membersOnly(),
+ mucOptions.moderated(),
+ mucOptions.nonanonymous()
+ };
+ } else {
+ options = new String[]{
+ getString(R.string.members_only),
+ getString(R.string.non_anonymous)
+ };
+ values = new boolean[]{
+ mucOptions.membersOnly(),
+ mucOptions.nonanonymous()
+ };
+ }
builder.setMultiChoiceItems(options,values,new DialogInterface.OnMultiChoiceClickListener() {
@Override
public void onClick(DialogInterface dialog, int which, boolean isChecked) {
@@ -124,7 +142,12 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
}
Bundle options = new Bundle();
options.putString("muc#roomconfig_membersonly", values[0] ? "1" : "0");
- options.putString("muc#roomconfig_whois", values[1] ? "anyone" : "moderators");
+ if (values.length == 2) {
+ options.putString("muc#roomconfig_whois", values[1] ? "anyone" : "moderators");
+ } else if (values.length == 3) {
+ options.putString("muc#roomconfig_moderatedroom", values[1] ? "1" : "0");
+ options.putString("muc#roomconfig_whois", values[2] ? "anyone" : "moderators");
+ }
options.putString("muc#roomconfig_persistentroom", "1");
xmppConnectionService.pushConferenceConfiguration(mConversation,
options,
@@ -193,6 +216,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
});
}
});
+ this.mAdvancedMode = getPreferences().getBoolean("advanced_muc_mode", false);
}
@Override
@@ -215,6 +239,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
case R.id.action_advanced_mode:
this.mAdvancedMode = !menuItem.isChecked();
menuItem.setChecked(this.mAdvancedMode);
+ getPreferences().edit().putBoolean("advanced_muc_mode", mAdvancedMode).commit();
invalidateOptionsMenu();
updateView();
break;
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
index 552587ee..913190b4 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
@@ -399,7 +399,7 @@ public class ConversationActivity extends XmppActivity
}
if (this.getSelectedConversation().getMode() == Conversation.MODE_MULTI) {
menuContactDetails.setVisible(false);
- menuAttach.setVisible(getSelectedConversation().getAccount().httpUploadAvailable());
+ menuAttach.setVisible(getSelectedConversation().getAccount().httpUploadAvailable() && getSelectedConversation().getMucOptions().participating());
menuInviteContact.setVisible(getSelectedConversation().getMucOptions().canInvite());
menuSecure.setVisible(!Config.HIDE_PGP_IN_UI); //if pgp is hidden conferences have no choice of encryption
} else {
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
index 244487fd..aced2798 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
@@ -320,11 +320,13 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
}
public void updateChatMsgHint() {
- if (conversation.getMode() == Conversation.MODE_MULTI
- && conversation.getNextCounterpart() != null) {
+ final boolean multi = conversation.getMode() == Conversation.MODE_MULTI;
+ if (multi && conversation.getNextCounterpart() != null) {
this.mEditMessage.setHint(getString(
R.string.send_private_message_to,
conversation.getNextCounterpart().getResourcepart()));
+ } else if (multi && !conversation.getMucOptions().participating()) {
+ this.mEditMessage.setHint(R.string.you_are_not_participating);
} else {
switch (conversation.getNextEncryption()) {
case Message.ENCRYPTION_NONE:
@@ -664,6 +666,9 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
if (this.conversation.getMode() == Conversation.MODE_MULTI) {
this.conversation.setNextCounterpart(null);
}
+ boolean canWrite = this.conversation.getMode() == Conversation.MODE_SINGLE || this.conversation.getMucOptions().participating();
+ this.mEditMessage.setEnabled(canWrite);
+ this.mSendButton.setEnabled(canWrite);
this.mEditMessage.setKeyboardListener(null);
this.mEditMessage.setText("");
this.mEditMessage.append(this.conversation.getNextMessage());
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index 5f3a587a..aafcc2af 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -440,8 +440,10 @@
<string name="public_conference">Publicly accessible conference</string>
<string name="private_conference">Private, members only conference</string>
<string name="conference_options">Conference options</string>
- <string name="members_only">Private (Members only)</string>
+ <string name="members_only">Private, members only</string>
<string name="non_anonymous">Non-anonymous</string>
+ <string name="moderated">Moderated</string>
+ <string name="you_are_not_participating">You are not participating</string>
<string name="modified_conference_options">Modified conference options!</string>
<string name="could_not_modify_conference_options">Could not modify conference options</string>
<string name="never">Never</string>