From 1e7647e385a55598843f80fe39fadeda64295f87 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Mon, 1 Feb 2016 13:54:08 +0100 Subject: opt out handling of the autojoin flag. fixes #1666 --- .../siacs/conversations/services/XmppConnectionService.java | 13 ++++++++++--- .../siacs/conversations/ui/ConferenceDetailsActivity.java | 2 +- .../siacs/conversations/ui/StartConversationActivity.java | 2 +- src/main/res/values/strings.xml | 2 ++ src/main/res/xml/preferences.xml | 6 ++++++ 5 files changed, 20 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index d4fda1b8..99183dff 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -1001,6 +1001,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa final Element query = packet.query(); final HashMap bookmarks = new HashMap<>(); final Element storage = query.findChild("storage", "storage:bookmarks"); + final boolean autojoin = respectAutojoin(); if (storage != null) { for (final Element item : storage.getChildren()) { if (item.getName().equals("conference")) { @@ -1012,7 +1013,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa Conversation conversation = find(bookmark); if (conversation != null) { conversation.setBookmark(bookmark); - } else if (bookmark.autojoin() && bookmark.getJid() != null) { + } else if (bookmark.autojoin() && bookmark.getJid() != null && autojoin) { conversation = findOrCreateConversation( account, bookmark.getJid(), true); conversation.setBookmark(bookmark); @@ -1330,7 +1331,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa if (conversation.getMode() == Conversation.MODE_MULTI) { if (conversation.getAccount().getStatus() == Account.State.ONLINE) { Bookmark bookmark = conversation.getBookmark(); - if (bookmark != null && bookmark.autojoin()) { + if (bookmark != null && bookmark.autojoin() && respectAutojoin()) { bookmark.setAutojoin(false); pushBookmarks(bookmark.getAccount()); } @@ -1791,7 +1792,9 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa if (conversation.getMode() == Conversation.MODE_MULTI) { conversation.getMucOptions().setPassword(password); if (conversation.getBookmark() != null) { - conversation.getBookmark().setAutojoin(true); + if (respectAutojoin()) { + conversation.getBookmark().setAutojoin(true); + } pushBookmarks(conversation.getAccount()); } databaseBackend.updateConversation(conversation); @@ -2578,6 +2581,10 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa return !getPreferences().getBoolean("dont_save_encrypted", false); } + private boolean respectAutojoin() { + return getPreferences().getBoolean("autojoin", true); + } + public boolean indicateReceived() { return getPreferences().getBoolean("indicate_received", false); } diff --git a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java index 6653dd24..be454936 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java @@ -468,7 +468,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers bookmark.setNick(mConversation.getJid().getResourcepart()); } bookmark.setBookmarkName(mConversation.getMucOptions().getSubject()); - bookmark.setAutojoin(true); + bookmark.setAutojoin(getPreferences().getBoolean("autojoin",true)); account.getBookmarks().add(bookmark); xmppConnectionService.pushBookmarks(account); mConversation.setBookmark(bookmark); diff --git a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java index 3d895a34..c46251c1 100644 --- a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java @@ -286,7 +286,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU if (!conversation.getMucOptions().online()) { xmppConnectionService.joinMuc(conversation); } - if (!bookmark.autojoin()) { + if (!bookmark.autojoin() && getPreferences().getBoolean("autojoin", true)) { bookmark.setAutojoin(true); xmppConnectionService.pushBookmarks(bookmark.getAccount()); } diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index febe2ae3..9c472d0c 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -331,6 +331,8 @@ Other Conference name Use room’s subject instead of JID to identify conferences + Automatically join conferences + Respect the autojoin flag in conference bookmarks OTR fingerprint copied to clipboard! OMEMO fingerprint copied to clipboard! You are banned from this conference diff --git a/src/main/res/xml/preferences.xml b/src/main/res/xml/preferences.xml index 6a5974c0..382b3199 100644 --- a/src/main/res/xml/preferences.xml +++ b/src/main/res/xml/preferences.xml @@ -186,6 +186,12 @@ android:title="@string/pref_xa_on_silent_mode"/> +