reset subject and name on empty

This commit is contained in:
Daniel Gultsch 2018-06-24 16:33:15 +02:00
parent 4c9e331e01
commit e8a1f069c2
5 changed files with 17 additions and 6 deletions

View File

@ -9,6 +9,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import eu.siacs.conversations.utils.StringUtils;
import eu.siacs.conversations.utils.UIHelper;
import eu.siacs.conversations.xml.Element;
import eu.siacs.conversations.xmpp.InvalidJid;
@ -163,11 +164,11 @@ public class Bookmark extends Element implements ListItem {
public boolean setBookmarkName(String name) {
String before = getBookmarkName();
if (name != null && !name.equals(before)) {
if (name != null) {
this.setAttribute("name", name);
return true;
} else {
return false;
this.removeAttribute("name");
}
return StringUtils.changed(before, name);
}
}

View File

@ -2462,7 +2462,7 @@ public class XmppConnectionService extends Service {
}
if (bookmark != null && (sameBefore || bookmark.getBookmarkName() == null)) {
if (bookmark.setBookmarkName(mucOptions.getName())) {
if (bookmark.setBookmarkName(StringUtils.nullOnEmpty(mucOptions.getName()))) {
pushBookmarks(account);
}
}
@ -2555,7 +2555,7 @@ public class XmppConnectionService extends Service {
}
public void pushSubjectToConference(final Conversation conference, final String subject) {
MessagePacket packet = this.getMessageGenerator().conferenceSubject(conference, subject);
MessagePacket packet = this.getMessageGenerator().conferenceSubject(conference, StringUtils.nullOnEmpty(subject));
this.sendMessagePacket(conference.getAccount(), packet);
}

View File

@ -52,6 +52,7 @@ import eu.siacs.conversations.ui.util.MenuDoubleTabUtil;
import eu.siacs.conversations.ui.util.MyLinkify;
import eu.siacs.conversations.ui.util.SoftKeyboardUtils;
import eu.siacs.conversations.utils.EmojiWrapper;
import eu.siacs.conversations.utils.StringUtils;
import eu.siacs.conversations.utils.StylingHelper;
import eu.siacs.conversations.utils.UIHelper;
import eu.siacs.conversations.utils.XmppUri;
@ -364,7 +365,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
if (mucOptions.getSelf().getAffiliation().ranks(MucOptions.Affiliation.OWNER) && changed(mucOptions.getName(), name)) {
Bundle options = new Bundle();
options.putString("muc#roomconfig_persistentroom", "1");
options.putString("muc#roomconfig_roomname", name);
options.putString("muc#roomconfig_roomname", StringUtils.nullOnEmpty(name));
xmppConnectionService.pushConferenceConfiguration(mConversation, options, this);
}
}

View File

@ -43,4 +43,8 @@ public class StringUtils {
return !equals(one, two);
}
public static String nullOnEmpty(String input) {
return input == null || input.trim().isEmpty() ? null : input;
}
}

View File

@ -136,6 +136,11 @@ public class Element {
return this;
}
public Element removeAttribute(String name) {
this.attributes.remove(name);
return this;
}
public Element setAttributes(Hashtable<String, String> attributes) {
this.attributes = attributes;
return this;