aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/de/pixart/messenger/entities/Bookmark.java23
-rw-r--r--src/main/java/de/pixart/messenger/services/XmppConnectionService.java4
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java3
-rw-r--r--src/main/java/de/pixart/messenger/utils/StringUtils.java4
-rw-r--r--src/main/java/de/pixart/messenger/xml/Element.java5
5 files changed, 25 insertions, 14 deletions
diff --git a/src/main/java/de/pixart/messenger/entities/Bookmark.java b/src/main/java/de/pixart/messenger/entities/Bookmark.java
index 079b283c0..fc7725bb5 100644
--- a/src/main/java/de/pixart/messenger/entities/Bookmark.java
+++ b/src/main/java/de/pixart/messenger/entities/Bookmark.java
@@ -9,6 +9,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
+import de.pixart.messenger.utils.StringUtils;
import de.pixart.messenger.utils.UIHelper;
import de.pixart.messenger.xml.Element;
import de.pixart.messenger.xmpp.InvalidJid;
@@ -40,6 +41,14 @@ public class Bookmark extends Element implements ListItem {
return bookmark;
}
+ public static boolean printableValue(@Nullable String value, boolean permitNone) {
+ return value != null && !value.trim().isEmpty() && (permitNone || !"None".equals(value));
+ }
+
+ public static boolean printableValue(@Nullable String value) {
+ return printableValue(value, true);
+ }
+
public void setAutojoin(boolean autojoin) {
if (autojoin) {
this.setAttribute("autojoin", "true");
@@ -68,14 +77,6 @@ public class Bookmark extends Element implements ListItem {
}
}
- public static boolean printableValue(@Nullable String value, boolean permitNone) {
- return value != null && !value.trim().isEmpty() && (permitNone || !"None".equals(value));
- }
-
- public static boolean printableValue(@Nullable String value) {
- return printableValue(value, true);
- }
-
@Override
public int getOffline() {
return 0;
@@ -168,11 +169,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);
}
}
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
index ceb37a2fd..cca4d5fc2 100644
--- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
+++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
@@ -2710,7 +2710,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);
}
}
@@ -2800,7 +2800,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);
}
diff --git a/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java b/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java
index 8a8099060..294bb6e0c 100644
--- a/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java
@@ -53,6 +53,7 @@ import de.pixart.messenger.ui.util.MyLinkify;
import de.pixart.messenger.ui.util.SoftKeyboardUtils;
import de.pixart.messenger.utils.EmojiWrapper;
import de.pixart.messenger.utils.MenuDoubleTabUtil;
+import de.pixart.messenger.utils.StringUtils;
import de.pixart.messenger.utils.StylingHelper;
import de.pixart.messenger.utils.TimeframeUtils;
import de.pixart.messenger.utils.UIHelper;
@@ -406,7 +407,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);
}
}
diff --git a/src/main/java/de/pixart/messenger/utils/StringUtils.java b/src/main/java/de/pixart/messenger/utils/StringUtils.java
index 3980e9a4a..8d0988a0d 100644
--- a/src/main/java/de/pixart/messenger/utils/StringUtils.java
+++ b/src/main/java/de/pixart/messenger/utils/StringUtils.java
@@ -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;
+ }
+
}
diff --git a/src/main/java/de/pixart/messenger/xml/Element.java b/src/main/java/de/pixart/messenger/xml/Element.java
index f90efa555..e9eaa1394 100644
--- a/src/main/java/de/pixart/messenger/xml/Element.java
+++ b/src/main/java/de/pixart/messenger/xml/Element.java
@@ -134,6 +134,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;