hide subject edit button if not editable by user
This commit is contained in:
parent
23ef1c660a
commit
60211a315e
|
@ -9,6 +9,8 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import eu.siacs.conversations.R;
|
import eu.siacs.conversations.R;
|
||||||
import eu.siacs.conversations.crypto.PgpEngine;
|
import eu.siacs.conversations.crypto.PgpEngine;
|
||||||
import eu.siacs.conversations.xml.Element;
|
import eu.siacs.conversations.xml.Element;
|
||||||
|
import eu.siacs.conversations.xmpp.forms.Data;
|
||||||
|
import eu.siacs.conversations.xmpp.forms.Field;
|
||||||
import eu.siacs.conversations.xmpp.jid.InvalidJidException;
|
import eu.siacs.conversations.xmpp.jid.InvalidJidException;
|
||||||
import eu.siacs.conversations.xmpp.jid.Jid;
|
import eu.siacs.conversations.xmpp.jid.Jid;
|
||||||
import eu.siacs.conversations.xmpp.stanzas.PresencePacket;
|
import eu.siacs.conversations.xmpp.stanzas.PresencePacket;
|
||||||
|
@ -207,6 +209,7 @@ public class MucOptions {
|
||||||
private Account account;
|
private Account account;
|
||||||
private List<User> users = new CopyOnWriteArrayList<>();
|
private List<User> users = new CopyOnWriteArrayList<>();
|
||||||
private List<String> features = new ArrayList<>();
|
private List<String> features = new ArrayList<>();
|
||||||
|
private Data form = new Data();
|
||||||
private Conversation conversation;
|
private Conversation conversation;
|
||||||
private boolean isOnline = false;
|
private boolean isOnline = false;
|
||||||
private int error = ERROR_UNKNOWN;
|
private int error = ERROR_UNKNOWN;
|
||||||
|
@ -226,12 +229,22 @@ public class MucOptions {
|
||||||
this.features.addAll(features);
|
this.features.addAll(features);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateFormData(Data form) {
|
||||||
|
this.form = form;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean hasFeature(String feature) {
|
public boolean hasFeature(String feature) {
|
||||||
return this.features.contains(feature);
|
return this.features.contains(feature);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canInvite() {
|
public boolean canInvite() {
|
||||||
return !membersOnly() || self.getAffiliation().ranks(Affiliation.ADMIN);
|
Field field = this.form.getFieldByName("muc#roomconfig_allowinvites");
|
||||||
|
return !membersOnly() || self.getRole().ranks(Role.MODERATOR) || (field != null && "1".equals(field.getValue()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canChangeSubject() {
|
||||||
|
Field field = this.form.getFieldByName("muc#roomconfig_changesubject");
|
||||||
|
return self.getRole().ranks(Role.MODERATOR) || (field != null && "1".equals(field.getValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean participating() {
|
public boolean participating() {
|
||||||
|
@ -472,11 +485,12 @@ public class MucOptions {
|
||||||
ids.add(user.getPgpKeyId());
|
ids.add(user.getPgpKeyId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
long[] primitivLongArray = new long[ids.size()];
|
ids.add(account.getPgpId());
|
||||||
|
long[] primitiveLongArray = new long[ids.size()];
|
||||||
for (int i = 0; i < ids.size(); ++i) {
|
for (int i = 0; i < ids.size(); ++i) {
|
||||||
primitivLongArray[i] = ids.get(i);
|
primitiveLongArray[i] = ids.get(i);
|
||||||
}
|
}
|
||||||
return primitivLongArray;
|
return primitiveLongArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean pgpKeysInUse() {
|
public boolean pgpKeysInUse() {
|
||||||
|
|
|
@ -1940,7 +1940,8 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
|
||||||
public void onIqPacketReceived(Account account, IqPacket packet) {
|
public void onIqPacketReceived(Account account, IqPacket packet) {
|
||||||
if (packet.getType() == IqPacket.TYPE.RESULT) {
|
if (packet.getType() == IqPacket.TYPE.RESULT) {
|
||||||
ArrayList<String> features = new ArrayList<>();
|
ArrayList<String> features = new ArrayList<>();
|
||||||
for (Element child : packet.query().getChildren()) {
|
Element query = packet.query();
|
||||||
|
for (Element child : query.getChildren()) {
|
||||||
if (child != null && child.getName().equals("feature")) {
|
if (child != null && child.getName().equals("feature")) {
|
||||||
String var = child.getAttribute("var");
|
String var = child.getAttribute("var");
|
||||||
if (var != null) {
|
if (var != null) {
|
||||||
|
@ -1948,6 +1949,10 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Element form = query.findChild("x","jabber:x:data");
|
||||||
|
if (form != null) {
|
||||||
|
conversation.getMucOptions().updateFormData(Data.parse(form));
|
||||||
|
}
|
||||||
conversation.getMucOptions().updateFeatures(features);
|
conversation.getMucOptions().updateFeatures(features);
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
callback.onConferenceConfigurationFetched(conversation);
|
callback.onConferenceConfigurationFetched(conversation);
|
||||||
|
|
|
@ -267,6 +267,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
|
||||||
MenuItem menuItemSaveBookmark = menu.findItem(R.id.action_save_as_bookmark);
|
MenuItem menuItemSaveBookmark = menu.findItem(R.id.action_save_as_bookmark);
|
||||||
MenuItem menuItemDeleteBookmark = menu.findItem(R.id.action_delete_bookmark);
|
MenuItem menuItemDeleteBookmark = menu.findItem(R.id.action_delete_bookmark);
|
||||||
MenuItem menuItemAdvancedMode = menu.findItem(R.id.action_advanced_mode);
|
MenuItem menuItemAdvancedMode = menu.findItem(R.id.action_advanced_mode);
|
||||||
|
MenuItem menuItemChangeSubject = menu.findItem(R.id.action_edit_subject);
|
||||||
menuItemAdvancedMode.setChecked(mAdvancedMode);
|
menuItemAdvancedMode.setChecked(mAdvancedMode);
|
||||||
if (mConversation == null) {
|
if (mConversation == null) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -279,6 +280,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
|
||||||
menuItemDeleteBookmark.setVisible(false);
|
menuItemDeleteBookmark.setVisible(false);
|
||||||
menuItemSaveBookmark.setVisible(true);
|
menuItemSaveBookmark.setVisible(true);
|
||||||
}
|
}
|
||||||
|
menuItemChangeSubject.setVisible(mConversation.getMucOptions().canChangeSubject());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,4 +47,8 @@ public class Field extends Element {
|
||||||
field.setChildren(element.getChildren());
|
field.setChildren(element.getChildren());
|
||||||
return field;
|
return field;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return findChildContent("value");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue