From 9b55d907053779c79f31e966fe5607f93461815e Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sun, 16 Feb 2020 16:04:42 +0100 Subject: [PATCH] do not warn user if bookmark already exists fixes #3631 --- .../java/eu/siacs/conversations/entities/Account.java | 8 +------- .../conversations/ui/StartConversationActivity.java | 9 ++++++--- src/main/res/values/strings.xml | 1 - 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/entities/Account.java b/src/main/java/eu/siacs/conversations/entities/Account.java index fdc5634da..365df734e 100644 --- a/src/main/java/eu/siacs/conversations/entities/Account.java +++ b/src/main/java/eu/siacs/conversations/entities/Account.java @@ -508,13 +508,7 @@ public class Account extends AbstractEntity implements AvatarService.Avatarable } } - public boolean hasBookmarkFor(final Jid jid) { - synchronized (this.bookmarks) { - return this.bookmarks.containsKey(jid.asBareJid()); - } - } - - Bookmark getBookmark(final Jid jid) { + public Bookmark getBookmark(final Jid jid) { synchronized (this.bookmarks) { return this.bookmarks.get(jid.asBareJid()); } diff --git a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java index a75ef519b..95b189126 100644 --- a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java @@ -1032,10 +1032,12 @@ public class StartConversationActivity extends XmppActivity implements XmppConne } if (isBookmarkChecked) { - if (account.hasBookmarkFor(conferenceJid)) { - layout.setError(getString(R.string.bookmark_already_exists)); + Bookmark bookmark = account.getBookmark(conferenceJid); + if (bookmark != null) { + dialog.dismiss(); + openConversationsForBookmark(bookmark); } else { - final Bookmark bookmark = new Bookmark(account, conferenceJid.asBareJid()); + bookmark = new Bookmark(account, conferenceJid.asBareJid()); bookmark.setAutojoin(getBooleanPreference("autojoin", R.bool.autojoin)); final String nick = conferenceJid.getResource(); 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; if (mResContextMenu == R.menu.conference_context) { activity.conference_context_id = acmi.position; + //TODO hide share if known to be private } else if (mResContextMenu == R.menu.contact_context) { activity.contact_context_id = acmi.position; final Contact contact = (Contact) activity.contacts.get(acmi.position); diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index ccf8138ac..f0936412e 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -236,7 +236,6 @@ Are you sure you want to destroy this public channel?\n\nWarning: The channel will be completely removed on the server. Could not destroy group chat Could not destroy channel - This bookmark already exists Edit group chat subject Topic Joining group chat…