aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/pixart')
-rw-r--r--src/main/java/de/pixart/messenger/entities/MucOptions.java16
-rw-r--r--src/main/java/de/pixart/messenger/services/XmppConnectionService.java17
-rw-r--r--src/main/java/de/pixart/messenger/ui/StartConversationActivity.java5
3 files changed, 25 insertions, 13 deletions
diff --git a/src/main/java/de/pixart/messenger/entities/MucOptions.java b/src/main/java/de/pixart/messenger/entities/MucOptions.java
index d1e30062a..aedb01144 100644
--- a/src/main/java/de/pixart/messenger/entities/MucOptions.java
+++ b/src/main/java/de/pixart/messenger/entities/MucOptions.java
@@ -426,12 +426,16 @@ public class MucOptions {
} else if (!conversation.getJid().isBareJid()) {
return conversation.getJid().getResource();
} else {
- final String displayName = normalize(account.getJid(), account.getDisplayName());
- if (displayName == null) {
- return JidHelper.localPartOrFallback(account.getJid());
- } else {
- return displayName;
- }
+ return defaultNick(account);
+ }
+ }
+
+ public static String defaultNick(final Account account) {
+ final String displayName = normalize(account.getJid(), account.getDisplayName());
+ if (displayName == null) {
+ return JidHelper.localPartOrFallback(account.getJid());
+ } else {
+ return displayName;
}
}
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
index 5028fea28..c1d5655f5 100644
--- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
+++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
@@ -3073,7 +3073,13 @@ public class XmppConnectionService extends Service {
final Bookmark bookmark = conversation.getBookmark();
final String bookmarkedNick = bookmark == null ? null : bookmark.getNick();
if (bookmark != null && (tookProposedNickFromBookmark || TextUtils.isEmpty(bookmarkedNick)) && !full.getResource().equals(bookmarkedNick)) {
- Log.d(Config.LOGTAG, conversation.getAccount().getJid().asBareJid() + ": persist nick '" + full.getResource() + "' into bookmark for " + conversation.getJid().asBareJid());
+ final Account account = conversation.getAccount();
+ final String defaultNick = MucOptions.defaultNick(account);
+ if (TextUtils.isEmpty(bookmarkedNick) && full.getResource().equals(defaultNick)) {
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": do not overwrite empty bookmark nick with default nick for " + conversation.getJid().asBareJid());
+ return;
+ }
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": persist nick '" + full.getResource() + "' into bookmark for " + conversation.getJid().asBareJid());
bookmark.setNick(full.getResource());
pushBookmarks(bookmark.getAccount());
}
@@ -4779,10 +4785,11 @@ public class XmppConnectionService extends Service {
}
public void saveConversationAsBookmark(Conversation conversation, String name) {
- Account account = conversation.getAccount();
- Bookmark bookmark = new Bookmark(account, conversation.getJid().asBareJid());
- if (!conversation.getJid().isBareJid()) {
- bookmark.setNick(conversation.getJid().getResource());
+ final Account account = conversation.getAccount();
+ final Bookmark bookmark = new Bookmark(account, conversation.getJid().asBareJid());
+ final String nick = conversation.getJid().getResource();
+ if (nick != null && !nick.isEmpty() && !nick.equals(MucOptions.defaultNick(account))) {
+ bookmark.setNick(nick);
}
if (!TextUtils.isEmpty(name)) {
bookmark.setBookmarkName(name);
diff --git a/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java b/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java
index 68aa128b6..1918d73d0 100644
--- a/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java
@@ -61,6 +61,7 @@ import de.pixart.messenger.entities.Bookmark;
import de.pixart.messenger.entities.Contact;
import de.pixart.messenger.entities.Conversation;
import de.pixart.messenger.entities.ListItem;
+import de.pixart.messenger.entities.MucOptions;
import de.pixart.messenger.entities.Presence;
import de.pixart.messenger.services.QuickConversationsService;
import de.pixart.messenger.services.XmppConnectionService;
@@ -1002,8 +1003,8 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
} else {
final Bookmark bookmark = new Bookmark(account, conferenceJid.asBareJid());
bookmark.setAutojoin(getBooleanPreference("autojoin", R.bool.autojoin));
- String nick = conferenceJid.getResource();
- if (nick != null && !nick.isEmpty()) {
+ final String nick = conferenceJid.getResource();
+ if (nick != null && !nick.isEmpty() && !nick.equals(MucOptions.defaultNick(account))) {
bookmark.setNick(nick);
}
account.getBookmarks().add(bookmark);