diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index bfaeaec88..f67a15d39 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -1267,7 +1267,7 @@ public class XmppConnectionService extends Service { Log.e(Config.LOGTAG, "unable to initialize security provider", throwable); } Resolver.init(this); - updateMemorizingTrustmanager(); + updateMemorizingTrustManager(); final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024); final int cacheSize = maxMemory / 8; this.mBitmapCache = new LruCache(cacheSize) { @@ -2010,14 +2010,13 @@ public class XmppConnectionService extends Service { return true; } - public void processBookmarksInitial(Account account, Map bookmarks, final boolean pep) { + public void processBookmarksInitial(final Account account, final Map bookmarks, final boolean pep) { final Set previousBookmarks = account.getBookmarkedJids(); - final boolean synchronizeWithBookmarks = synchronizeWithBookmarks(); - for (Bookmark bookmark : bookmarks.values()) { + for (final Bookmark bookmark : bookmarks.values()) { previousBookmarks.remove(bookmark.getJid().asBareJid()); - processModifiedBookmark(bookmark, pep, synchronizeWithBookmarks); + processModifiedBookmark(bookmark, pep); } - if (pep && synchronizeWithBookmarks) { + if (pep) { Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": " + previousBookmarks.size() + " bookmarks have been removed"); for (Jid jid : previousBookmarks) { processDeletedBookmark(account, jid); @@ -2034,7 +2033,7 @@ public class XmppConnectionService extends Service { } } - private void processModifiedBookmark(Bookmark bookmark, final boolean pep, final boolean synchronizeWithBookmarks) { + private void processModifiedBookmark(final Bookmark bookmark, final boolean pep) { final Account account = bookmark.getAccount(); Conversation conversation = find(bookmark); if (conversation != null) { @@ -2042,7 +2041,7 @@ public class XmppConnectionService extends Service { return; } bookmark.setConversation(conversation); - if (pep && synchronizeWithBookmarks && !bookmark.autojoin()) { + if (pep && !bookmark.autojoin()) { Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": archiving conference (" + conversation.getJid() + ") after receiving pep"); archiveConversation(conversation, false); } else { @@ -2056,15 +2055,14 @@ public class XmppConnectionService extends Service { } } } - } else if (synchronizeWithBookmarks && bookmark.autojoin()) { + } else if (bookmark.autojoin()) { conversation = findOrCreateConversation(account, bookmark.getFullJid(), true, true, false); bookmark.setConversation(conversation); } } - public void processModifiedBookmark(Bookmark bookmark) { - final boolean synchronizeWithBookmarks = synchronizeWithBookmarks(); - processModifiedBookmark(bookmark, true, synchronizeWithBookmarks); + public void processModifiedBookmark(final Bookmark bookmark) { + processModifiedBookmark(bookmark, true); } public void createBookmark(final Account account, final Bookmark bookmark) { @@ -2531,7 +2529,7 @@ public class XmppConnectionService extends Service { if (conversation.getMode() == Conversation.MODE_MULTI) { if (conversation.getAccount().getStatus() == Account.State.ONLINE) { final Bookmark bookmark = conversation.getBookmark(); - if (maySynchronizeWithBookmarks && bookmark != null && synchronizeWithBookmarks()) { + if (maySynchronizeWithBookmarks && bookmark != null) { if (conversation.getMucOptions().getError() == MucOptions.Error.DESTROYED) { Account account = bookmark.getAccount(); bookmark.setConversation(null); @@ -3290,14 +3288,12 @@ public class XmppConnectionService extends Service { Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": fetching members for " + conversation.getName()); } - public void providePasswordForMuc(Conversation conversation, String password) { + public void providePasswordForMuc(final Conversation conversation, final String password) { if (conversation.getMode() == Conversation.MODE_MULTI) { conversation.getMucOptions().setPassword(password); if (conversation.getBookmark() != null) { final Bookmark bookmark = conversation.getBookmark(); - if (synchronizeWithBookmarks()) { - bookmark.setAutojoin(true); - } + bookmark.setAutojoin(true); createBookmark(conversation.getAccount(), bookmark); } updateConversation(conversation); @@ -4453,10 +4449,6 @@ public class XmppConnectionService extends Service { return getBooleanPreference("chat_states", R.bool.chat_states); } - private boolean synchronizeWithBookmarks() { - return getBooleanPreference("autojoin", R.bool.autojoin); - } - public boolean useTorToConnect() { return QuickConversationsService.isConversations() && getBooleanPreference("use_tor", R.bool.use_tor); } @@ -4732,15 +4724,15 @@ public class XmppConnectionService extends Service { this.mMemorizingTrustManager = trustManager; } - public void updateMemorizingTrustmanager() { - final MemorizingTrustManager tm; - final boolean dontTrustSystemCAs = getBooleanPreference("dont_trust_system_cas", R.bool.dont_trust_system_cas); - if (dontTrustSystemCAs) { - tm = new MemorizingTrustManager(getApplicationContext(), null); + public void updateMemorizingTrustManager() { + final MemorizingTrustManager trustManager; + final var appSettings = new AppSettings(this); + if (appSettings.isTrustSystemCAStore()) { + trustManager = new MemorizingTrustManager(getApplicationContext()); } else { - tm = new MemorizingTrustManager(getApplicationContext()); + trustManager = new MemorizingTrustManager(getApplicationContext(), null); } - setMemorizingTrustManager(tm); + setMemorizingTrustManager(trustManager); } public LruCache getBitmapCache() { @@ -5153,7 +5145,7 @@ public class XmppConnectionService extends Service { return templates; } - public void saveConversationAsBookmark(Conversation conversation, String name) { + public void saveConversationAsBookmark(final Conversation conversation, final String name) { final Account account = conversation.getAccount(); final Bookmark bookmark = new Bookmark(account, conversation.getJid().asBareJid()); final String nick = conversation.getJid().getResource(); @@ -5163,7 +5155,7 @@ public class XmppConnectionService extends Service { if (!TextUtils.isEmpty(name)) { bookmark.setBookmarkName(name); } - bookmark.setAutojoin(getPreferences().getBoolean("autojoin", getResources().getBoolean(R.bool.autojoin))); + bookmark.setAutojoin(true); createBookmark(account, bookmark); bookmark.setConversation(conversation); } diff --git a/src/main/java/eu/siacs/conversations/ui/ChannelDiscoveryActivity.java b/src/main/java/eu/siacs/conversations/ui/ChannelDiscoveryActivity.java index 5a9c31d20..92240d4f1 100644 --- a/src/main/java/eu/siacs/conversations/ui/ChannelDiscoveryActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ChannelDiscoveryActivity.java @@ -275,7 +275,6 @@ public class ChannelDiscoveryActivity extends XmppActivity implements MenuItem.O public void joinChannelSearchResult(final String selectedAccount, final Room result) { final Jid jid = Jid.ofEscaped(selectedAccount); - final boolean syncAutoJoin = getBooleanPreference("autojoin", R.bool.autojoin); final Account account = xmppConnectionService.findAccountByJid(jid); final Conversation conversation = xmppConnectionService.findOrCreateConversation( @@ -283,10 +282,10 @@ public class ChannelDiscoveryActivity extends XmppActivity implements MenuItem.O final var existingBookmark = conversation.getBookmark(); if (existingBookmark == null) { final var bookmark = new Bookmark(account, conversation.getJid().asBareJid()); - bookmark.setAutojoin(syncAutoJoin); + bookmark.setAutojoin(true); xmppConnectionService.createBookmark(account, bookmark); } else { - if (!existingBookmark.autojoin() && syncAutoJoin) { + if (!existingBookmark.autojoin()) { existingBookmark.setAutojoin(true); xmppConnectionService.createBookmark(account, existingBookmark); } diff --git a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java index 28b3688bb..8f1b4ad25 100644 --- a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java @@ -462,7 +462,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne } Conversation conversation = xmppConnectionService.findOrCreateConversation(bookmark.getAccount(), jid, true, true, true); bookmark.setConversation(conversation); - if (!bookmark.autojoin() && getPreferences().getBoolean("autojoin", getResources().getBoolean(R.bool.autojoin))) { + if (!bookmark.autojoin()) { bookmark.setAutojoin(true); xmppConnectionService.createBookmark(bookmark.getAccount(), bookmark); } @@ -1150,7 +1150,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne openConversationsForBookmark(bookmark); } else { bookmark = new Bookmark(account, conferenceJid.asBareJid()); - bookmark.setAutojoin(getBooleanPreference("autojoin", R.bool.autojoin)); + bookmark.setAutojoin(true); final String nick = conferenceJid.getResource(); if (nick != null && !nick.isEmpty() && !nick.equals(MucOptions.defaultNick(account))) { bookmark.setNick(nick); diff --git a/src/main/java/eu/siacs/conversations/ui/fragment/settings/SecuritySettingsFragment.java b/src/main/java/eu/siacs/conversations/ui/fragment/settings/SecuritySettingsFragment.java index ba64c5fc3..66bc8bb15 100644 --- a/src/main/java/eu/siacs/conversations/ui/fragment/settings/SecuritySettingsFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/fragment/settings/SecuritySettingsFragment.java @@ -67,7 +67,7 @@ public class SecuritySettingsFragment extends XmppPreferenceFragment { OmemoSetting.load(requireContext()); } case AppSettings.TRUST_SYSTEM_CA_STORE -> { - requireService().updateMemorizingTrustmanager(); + requireService().updateMemorizingTrustManager(); reconnectAccounts(); } case AppSettings.REQUIRE_CHANNEL_BINDING -> {} diff --git a/src/main/res/values/defaults.xml b/src/main/res/values/defaults.xml index 898e3fafa..7433ad68b 100644 --- a/src/main/res/values/defaults.xml +++ b/src/main/res/values/defaults.xml @@ -12,7 +12,6 @@ false true true - false content://settings/system/notification_sound content://settings/system/ringtone 144 @@ -23,7 +22,6 @@ false true 0 - false true true false @@ -31,7 +29,6 @@ false false false - true true true false @@ -40,7 +37,6 @@ false true default_on - small false false 360