do not warn user if bookmark already exists

fixes #3631
This commit is contained in:
Daniel Gultsch 2020-02-16 16:04:42 +01:00
parent d64bc1776b
commit 9b55d90705
3 changed files with 7 additions and 11 deletions

View File

@ -508,13 +508,7 @@ public class Account extends AbstractEntity implements AvatarService.Avatarable
} }
} }
public boolean hasBookmarkFor(final Jid jid) { public Bookmark getBookmark(final Jid jid) {
synchronized (this.bookmarks) {
return this.bookmarks.containsKey(jid.asBareJid());
}
}
Bookmark getBookmark(final Jid jid) {
synchronized (this.bookmarks) { synchronized (this.bookmarks) {
return this.bookmarks.get(jid.asBareJid()); return this.bookmarks.get(jid.asBareJid());
} }

View File

@ -1032,10 +1032,12 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
} }
if (isBookmarkChecked) { if (isBookmarkChecked) {
if (account.hasBookmarkFor(conferenceJid)) { Bookmark bookmark = account.getBookmark(conferenceJid);
layout.setError(getString(R.string.bookmark_already_exists)); if (bookmark != null) {
dialog.dismiss();
openConversationsForBookmark(bookmark);
} else { } else {
final Bookmark bookmark = new Bookmark(account, conferenceJid.asBareJid()); bookmark = new Bookmark(account, conferenceJid.asBareJid());
bookmark.setAutojoin(getBooleanPreference("autojoin", R.bool.autojoin)); bookmark.setAutojoin(getBooleanPreference("autojoin", R.bool.autojoin));
final String nick = conferenceJid.getResource(); final String nick = conferenceJid.getResource();
if (nick != null && !nick.isEmpty() && !nick.equals(MucOptions.defaultNick(account))) { if (nick != null && !nick.isEmpty() && !nick.equals(MucOptions.defaultNick(account))) {
@ -1145,6 +1147,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
final AdapterView.AdapterContextMenuInfo acmi = (AdapterContextMenuInfo) menuInfo; final AdapterView.AdapterContextMenuInfo acmi = (AdapterContextMenuInfo) menuInfo;
if (mResContextMenu == R.menu.conference_context) { if (mResContextMenu == R.menu.conference_context) {
activity.conference_context_id = acmi.position; activity.conference_context_id = acmi.position;
//TODO hide share if known to be private
} else if (mResContextMenu == R.menu.contact_context) { } else if (mResContextMenu == R.menu.contact_context) {
activity.contact_context_id = acmi.position; activity.contact_context_id = acmi.position;
final Contact contact = (Contact) activity.contacts.get(acmi.position); final Contact contact = (Contact) activity.contacts.get(acmi.position);

View File

@ -236,7 +236,6 @@
<string name="destroy_channel_dialog">Are you sure you want to destroy this public channel?\n\n<b>Warning:</b> The channel will be completely removed on the server.</string> <string name="destroy_channel_dialog">Are you sure you want to destroy this public channel?\n\n<b>Warning:</b> The channel will be completely removed on the server.</string>
<string name="could_not_destroy_room">Could not destroy group chat</string> <string name="could_not_destroy_room">Could not destroy group chat</string>
<string name="could_not_destroy_channel">Could not destroy channel</string> <string name="could_not_destroy_channel">Could not destroy channel</string>
<string name="bookmark_already_exists">This bookmark already exists</string>
<string name="action_edit_subject">Edit group chat subject</string> <string name="action_edit_subject">Edit group chat subject</string>
<string name="topic">Topic</string> <string name="topic">Topic</string>
<string name="joining_conference">Joining group chat…</string> <string name="joining_conference">Joining group chat…</string>