do not put default nick into bookmark if none has been set before
This commit is contained in:
parent
8574bea280
commit
f11adf4c02
|
@ -426,6 +426,11 @@ public class MucOptions {
|
||||||
} else if (!conversation.getJid().isBareJid()) {
|
} else if (!conversation.getJid().isBareJid()) {
|
||||||
return conversation.getJid().getResource();
|
return conversation.getJid().getResource();
|
||||||
} else {
|
} else {
|
||||||
|
return defaultNick(account);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String defaultNick(final Account account) {
|
||||||
final String displayName = normalize(account.getJid(), account.getDisplayName());
|
final String displayName = normalize(account.getJid(), account.getDisplayName());
|
||||||
if (displayName == null) {
|
if (displayName == null) {
|
||||||
return JidHelper.localPartOrFallback(account.getJid());
|
return JidHelper.localPartOrFallback(account.getJid());
|
||||||
|
@ -433,7 +438,6 @@ public class MucOptions {
|
||||||
return displayName;
|
return displayName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private static String normalize(Jid account, String nick) {
|
private static String normalize(Jid account, String nick) {
|
||||||
if (account == null || TextUtils.isEmpty(nick)) {
|
if (account == null || TextUtils.isEmpty(nick)) {
|
||||||
|
|
|
@ -2801,7 +2801,13 @@ public class XmppConnectionService extends Service {
|
||||||
final Bookmark bookmark = conversation.getBookmark();
|
final Bookmark bookmark = conversation.getBookmark();
|
||||||
final String bookmarkedNick = bookmark == null ? null : bookmark.getNick();
|
final String bookmarkedNick = bookmark == null ? null : bookmark.getNick();
|
||||||
if (bookmark != null && (tookProposedNickFromBookmark || TextUtils.isEmpty(bookmarkedNick)) && !full.getResource().equals(bookmarkedNick)) {
|
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());
|
bookmark.setNick(full.getResource());
|
||||||
pushBookmarks(bookmark.getAccount());
|
pushBookmarks(bookmark.getAccount());
|
||||||
}
|
}
|
||||||
|
@ -4420,10 +4426,11 @@ public class XmppConnectionService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveConversationAsBookmark(Conversation conversation, String name) {
|
public void saveConversationAsBookmark(Conversation conversation, String name) {
|
||||||
Account account = conversation.getAccount();
|
final Account account = conversation.getAccount();
|
||||||
Bookmark bookmark = new Bookmark(account, conversation.getJid().asBareJid());
|
final Bookmark bookmark = new Bookmark(account, conversation.getJid().asBareJid());
|
||||||
if (!conversation.getJid().isBareJid()) {
|
final String nick = conversation.getJid().getResource();
|
||||||
bookmark.setNick(conversation.getJid().getResource());
|
if (nick != null && !nick.isEmpty() && !nick.equals(MucOptions.defaultNick(account))) {
|
||||||
|
bookmark.setNick(nick);
|
||||||
}
|
}
|
||||||
if (!TextUtils.isEmpty(name)) {
|
if (!TextUtils.isEmpty(name)) {
|
||||||
bookmark.setBookmarkName(name);
|
bookmark.setBookmarkName(name);
|
||||||
|
|
|
@ -62,6 +62,7 @@ import eu.siacs.conversations.entities.Bookmark;
|
||||||
import eu.siacs.conversations.entities.Contact;
|
import eu.siacs.conversations.entities.Contact;
|
||||||
import eu.siacs.conversations.entities.Conversation;
|
import eu.siacs.conversations.entities.Conversation;
|
||||||
import eu.siacs.conversations.entities.ListItem;
|
import eu.siacs.conversations.entities.ListItem;
|
||||||
|
import eu.siacs.conversations.entities.MucOptions;
|
||||||
import eu.siacs.conversations.entities.Presence;
|
import eu.siacs.conversations.entities.Presence;
|
||||||
import eu.siacs.conversations.services.QuickConversationsService;
|
import eu.siacs.conversations.services.QuickConversationsService;
|
||||||
import eu.siacs.conversations.services.XmppConnectionService;
|
import eu.siacs.conversations.services.XmppConnectionService;
|
||||||
|
@ -1021,8 +1022,8 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
|
||||||
} else {
|
} else {
|
||||||
final Bookmark bookmark = new Bookmark(account, conferenceJid.asBareJid());
|
final Bookmark bookmark = new Bookmark(account, conferenceJid.asBareJid());
|
||||||
bookmark.setAutojoin(getBooleanPreference("autojoin", R.bool.autojoin));
|
bookmark.setAutojoin(getBooleanPreference("autojoin", R.bool.autojoin));
|
||||||
String nick = conferenceJid.getResource();
|
final String nick = conferenceJid.getResource();
|
||||||
if (nick != null && !nick.isEmpty()) {
|
if (nick != null && !nick.isEmpty() && !nick.equals(MucOptions.defaultNick(account))) {
|
||||||
bookmark.setNick(nick);
|
bookmark.setNick(nick);
|
||||||
}
|
}
|
||||||
account.getBookmarks().add(bookmark);
|
account.getBookmarks().add(bookmark);
|
||||||
|
|
Loading…
Reference in a new issue