diff --git a/app/src/main/java/org/thoughtcrime/securesms/configs/ConfigToDatabaseSync.kt b/app/src/main/java/org/thoughtcrime/securesms/configs/ConfigToDatabaseSync.kt index e070a38fc0..3b5ba393f9 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/configs/ConfigToDatabaseSync.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/configs/ConfigToDatabaseSync.kt @@ -259,7 +259,7 @@ class ConfigToDatabaseSync @Inject constructor( val toAddCommunities = userGroups.communityInfo.filter { it.community.fullUrl() !in existingCommunities.map { it.value.joinURL } } val existingJoinUrls = existingCommunities.values.map { it.joinURL } - val existingLegacyClosedGroups = storage.getAllGroups(includeInactive = true).filter { it.isLegacyClosedGroup } + val existingLegacyClosedGroups = storage.getAllGroups(includeInactive = true).filter { it.isLegacyGroup } val lgcIds = userGroups.legacyGroupInfo.map { it.accountId } val toDeleteLegacyClosedGroups = existingLegacyClosedGroups.filter { group -> GroupUtil.doubleDecodeGroupId(group.encodedId) !in lgcIds diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/menus/ConversationMenuHelper.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/menus/ConversationMenuHelper.kt index 7f4a4bf5b2..2aeebacc27 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/menus/ConversationMenuHelper.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/menus/ConversationMenuHelper.kt @@ -182,8 +182,8 @@ object ConversationMenuHelper { R.id.menu_block_delete -> { blockAndDelete(context, thread) } R.id.menu_copy_account_id -> { copyAccountID(context, thread) } R.id.menu_copy_open_group_url -> { copyOpenGroupUrl(context, thread) } - R.id.menu_edit_group -> { editClosedGroup(context, thread) } - R.id.menu_leave_group -> { return leaveClosedGroup(context, thread, threadID, factory, storage, groupManager) } + R.id.menu_edit_group -> { editGroup(context, thread) } + R.id.menu_leave_group -> { return leaveGroup(context, thread, threadID, factory, storage, groupManager) } R.id.menu_invite_to_open_group -> { inviteContacts(context, thread) } R.id.menu_unmute_notifications -> { unmute(context, thread) } R.id.menu_mute_notifications -> { mute(context, thread) } @@ -316,7 +316,7 @@ object ConversationMenuHelper { listener.copyOpenGroupUrl(thread) } - private fun editClosedGroup(context: Context, thread: Recipient) { + private fun editGroup(context: Context, thread: Recipient) { when { thread.isGroupV2Recipient -> { context.startActivity(EditGroupActivity.createIntent(context, thread.address.serialize())) @@ -331,7 +331,7 @@ object ConversationMenuHelper { } } - fun leaveClosedGroup( + fun leaveGroup( context: Context, thread: Recipient, threadID: Long, @@ -346,7 +346,7 @@ object ConversationMenuHelper { val accountID = TextSecurePreferences.getLocalNumber(context) val isCurrentUserAdmin = admins.any { it.toString() == accountID } - confirmAndLeaveClosedGroup( + confirmAndLeaveGroup( context = context, groupName = group.title, isAdmin = isCurrentUserAdmin, @@ -372,7 +372,7 @@ object ConversationMenuHelper { val channel = Channel() - confirmAndLeaveClosedGroup( + confirmAndLeaveGroup( context = context, groupName = name, isAdmin = group.hasAdminKey(), @@ -394,7 +394,7 @@ object ConversationMenuHelper { return null } - private fun confirmAndLeaveClosedGroup( + private fun confirmAndLeaveGroup( context: Context, groupName: String, isAdmin: Boolean, diff --git a/app/src/main/java/org/thoughtcrime/securesms/dependencies/ConfigFactory.kt b/app/src/main/java/org/thoughtcrime/securesms/dependencies/ConfigFactory.kt index 0b00e12445..df0100ae64 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/dependencies/ConfigFactory.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/dependencies/ConfigFactory.kt @@ -509,7 +509,7 @@ private fun MutableUserGroupsConfig.initFrom(storage: StorageProtocol) { storage .getAllGroups(includeInactive = false) - .asSequence().filter { it.isLegacyClosedGroup && it.isActive && it.members.size > 1 } + .asSequence().filter { it.isLegacyGroup && it.isActive && it.members.size > 1 } .mapNotNull { group -> val groupAddress = Address.fromSerialized(group.encodedId) val groupPublicKey = GroupUtil.doubleDecodeGroupID(groupAddress.serialize()).toHexString() diff --git a/app/src/main/java/org/thoughtcrime/securesms/groups/ClosedGroupManager.kt b/app/src/main/java/org/thoughtcrime/securesms/groups/ClosedGroupManager.kt index e6acdd506e..cfc0e87c65 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/groups/ClosedGroupManager.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/groups/ClosedGroupManager.kt @@ -34,7 +34,7 @@ object ClosedGroupManager { } fun ConfigFactory.updateLegacyGroup(group: GroupRecord) { - if (!group.isLegacyClosedGroup) return + if (!group.isLegacyGroup) return val storage = MessagingModuleConfiguration.shared.storage val threadId = storage.getThreadId(group.encodedId) ?: return val groupPublicKey = GroupUtil.doubleEncodeGroupID(group.getId()) diff --git a/app/src/main/java/org/thoughtcrime/securesms/home/HomeActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/home/HomeActivity.kt index b0e42275a9..574148296d 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/home/HomeActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/home/HomeActivity.kt @@ -583,8 +583,8 @@ class HomeActivity : PassphraseRequiredActionBarActivity(), val threadID = thread.threadId val recipient = thread.recipient - if (recipient.isGroupV2Recipient || recipient.isLegacyGroupRecipient) { - ConversationMenuHelper.leaveClosedGroup( + if (recipient.isGroupRecipient) { + ConversationMenuHelper.leaveGroup( context = this, thread = recipient, threadID = threadID, diff --git a/app/src/main/java/org/thoughtcrime/securesms/home/search/GlobalSearchAdapterUtils.kt b/app/src/main/java/org/thoughtcrime/securesms/home/search/GlobalSearchAdapterUtils.kt index 9d466d7463..9930dbff92 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/home/search/GlobalSearchAdapterUtils.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/home/search/GlobalSearchAdapterUtils.kt @@ -89,7 +89,7 @@ private fun getHighlight(query: String?, toSearch: String): Spannable? { fun ContentView.bindModel(query: String?, model: LegacyGroupConversation) { binding.searchResultProfilePicture.isVisible = true - binding.searchResultSubtitle.isVisible = model.groupRecord.isLegacyClosedGroup + binding.searchResultSubtitle.isVisible = model.groupRecord.isLegacyGroup binding.searchResultTimestamp.isVisible = false val threadRecipient = Recipient.from(binding.root.context, Address.fromSerialized(model.groupRecord.encodedId), false) binding.searchResultProfilePicture.update(threadRecipient) @@ -99,7 +99,7 @@ fun ContentView.bindModel(query: String?, model: LegacyGroupConversation) { val groupRecipients = model.groupRecord.members.map { Recipient.from(binding.root.context, it, false) } val membersString = groupRecipients.joinToString(transform = Recipient::getSearchName) - if (model.groupRecord.isLegacyClosedGroup) { + if (model.groupRecord.isLegacyGroup) { binding.searchResultSubtitle.text = getHighlight(query, membersString) } } diff --git a/libsession/src/main/java/org/session/libsession/messaging/messages/control/ConfigurationMessage.kt b/libsession/src/main/java/org/session/libsession/messaging/messages/control/ConfigurationMessage.kt index c876610069..a86afb07fc 100644 --- a/libsession/src/main/java/org/session/libsession/messaging/messages/control/ConfigurationMessage.kt +++ b/libsession/src/main/java/org/session/libsession/messaging/messages/control/ConfigurationMessage.kt @@ -124,7 +124,7 @@ class ConfigurationMessage(var closedGroups: List, var openGroups: val profileKey = ProfileKeyUtil.getProfileKey(context) val groups = storage.getAllGroups(includeInactive = false) for (group in groups) { - if (group.isLegacyClosedGroup && group.isActive) { + if (group.isLegacyGroup && group.isActive) { if (!group.members.contains(Address.fromSerialized(storage.getUserPublicKey()!!))) continue val groupPublicKey = GroupUtil.doubleDecodeGroupID(group.encodedId).toHexString() val encryptionKeyPair = storage.getLatestClosedGroupEncryptionKeyPair(groupPublicKey) ?: continue @@ -137,7 +137,7 @@ class ConfigurationMessage(var closedGroups: List, var openGroups: ) closedGroups.add(closedGroup) } - if (group.isOpenGroup) { + if (group.isCommunity) { val threadID = storage.getThreadId(group.encodedId) ?: continue val openGroup = storage.getOpenGroup(threadID) val shareUrl = openGroup?.joinURL ?: continue diff --git a/libsession/src/main/java/org/session/libsession/utilities/GroupRecord.kt b/libsession/src/main/java/org/session/libsession/utilities/GroupRecord.kt index 339b945cc7..05a7622d2f 100644 --- a/libsession/src/main/java/org/session/libsession/utilities/GroupRecord.kt +++ b/libsession/src/main/java/org/session/libsession/utilities/GroupRecord.kt @@ -21,11 +21,11 @@ class GroupRecord( } } - val isOpenGroup: Boolean + val isCommunity: Boolean get() = Address.fromSerialized(encodedId).isCommunity - val isLegacyClosedGroup: Boolean + val isLegacyGroup: Boolean get() = Address.fromSerialized(encodedId).isLegacyGroup - val isClosedGroupV2: Boolean + val isGroupV2: Boolean get() = Address.fromSerialized(encodedId).isGroupV2 init { diff --git a/libsession/src/main/java/org/session/libsession/utilities/recipients/Recipient.java b/libsession/src/main/java/org/session/libsession/utilities/recipients/Recipient.java index 8f21a9f60a..a9186066ea 100644 --- a/libsession/src/main/java/org/session/libsession/utilities/recipients/Recipient.java +++ b/libsession/src/main/java/org/session/libsession/utilities/recipients/Recipient.java @@ -480,6 +480,10 @@ public class Recipient implements RecipientModifiedListener { return address.isLegacyGroup(); } + public boolean isGroupRecipient() { + return address.isGroup(); + } + public boolean isGroupV2Recipient() { return address.isGroupV2(); }