Show internal conversation settings for groups.

fork-5.53.8
Greyson Parrelli 2021-09-30 19:04:34 -04:00
rodzic 33ac48e771
commit 5115717f67
4 zmienionych plików z 106 dodań i 84 usunięć

Wyświetl plik

@ -314,8 +314,7 @@ class ConversationSettingsFragment : DSLSettingsFragment(
}
}
state.withRecipientSettingsState { recipientState ->
if (recipientState.displayInternalRecipientDetails) {
if (state.displayInternalRecipientDetails) {
customPref(
InternalPreference.Model(
recipient = state.recipient,
@ -326,7 +325,6 @@ class ConversationSettingsFragment : DSLSettingsFragment(
)
)
}
}
customPref(
ButtonStripPreference.Model(

Wyświetl plik

@ -16,6 +16,7 @@ data class ConversationSettingsState(
val canModifyBlockedState: Boolean = false,
val sharedMedia: Cursor? = null,
val sharedMediaIds: List<Long> = listOf(),
val displayInternalRecipientDetails: Boolean = false,
private val sharedMediaLoaded: Boolean = false,
private val specificSettingsState: SpecificSettingsState,
) {
@ -49,8 +50,7 @@ sealed class SpecificSettingsState {
val selfHasGroups: Boolean = false,
val canShowMoreGroupsInCommon: Boolean = false,
val groupsInCommonExpanded: Boolean = false,
val contactLinkState: ContactLinkState = ContactLinkState.NONE,
val displayInternalRecipientDetails: Boolean
val contactLinkState: ContactLinkState = ContactLinkState.NONE
) : SpecificSettingsState() {
override val isLoaded: Boolean = true

Wyświetl plik

@ -71,7 +71,8 @@ sealed class ConversationSettingsViewModel(
state.copy(
sharedMedia = cursor.orNull(),
sharedMediaIds = ids,
sharedMediaLoaded = true
sharedMediaLoaded = true,
displayInternalRecipientDetails = repository.isInternalRecipientDetailsEnabled()
)
} else {
cursor.orNull().ensureClosed()
@ -121,9 +122,7 @@ sealed class ConversationSettingsViewModel(
private val repository: ConversationSettingsRepository
) : ConversationSettingsViewModel(
repository,
SpecificSettingsState.RecipientSettingsState(
displayInternalRecipientDetails = repository.isInternalRecipientDetailsEnabled()
)
SpecificSettingsState.RecipientSettingsState()
) {
private val liveRecipient = Recipient.live(recipientId)

Wyświetl plik

@ -1,5 +1,6 @@
package org.thoughtcrime.securesms.components.settings.conversation
import android.content.Context
import android.graphics.Color
import android.text.TextUtils
import android.widget.Toast
@ -16,6 +17,7 @@ import org.thoughtcrime.securesms.components.settings.DSLSettingsText
import org.thoughtcrime.securesms.components.settings.configure
import org.thoughtcrime.securesms.database.DatabaseFactory
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
import org.thoughtcrime.securesms.groups.GroupId
import org.thoughtcrime.securesms.recipients.Recipient
import org.thoughtcrime.securesms.recipients.RecipientForeverObserver
import org.thoughtcrime.securesms.recipients.RecipientId
@ -57,12 +59,23 @@ class InternalConversationSettingsFragment : DSLSettingsFragment(
summary = DSLSettingsText.from(recipient.id.serialize())
)
if (!recipient.isGroup) {
val uuid = recipient.uuid.transform(UUID::toString).or("null")
longClickPref(
title = DSLSettingsText.from("UUID"),
summary = DSLSettingsText.from(uuid),
onLongClick = { copyToClipboard(uuid) }
)
}
if (state.groupId != null) {
val groupId: String = state.groupId.toString()
longClickPref(
title = DSLSettingsText.from("GroupId"),
summary = DSLSettingsText.from(groupId),
onLongClick = { copyToClipboard(groupId) }
)
}
val threadId: String = if (state.threadId != null) state.threadId.toString() else "N/A"
longClickPref(
@ -71,6 +84,7 @@ class InternalConversationSettingsFragment : DSLSettingsFragment(
onLongClick = { copyToClipboard(threadId) }
)
if (!recipient.isGroup) {
textPref(
title = DSLSettingsText.from("Profile Name"),
summary = DSLSettingsText.from("[${recipient.profileName.givenName}] [${state.recipient.profileName.familyName}]")
@ -94,17 +108,21 @@ class InternalConversationSettingsFragment : DSLSettingsFragment(
title = DSLSettingsText.from("Sealed Sender Mode"),
summary = DSLSettingsText.from(recipient.unidentifiedAccessMode.toString())
)
}
textPref(
title = DSLSettingsText.from("Profile Sharing (AKA \"Whitelisted\")"),
summary = DSLSettingsText.from(recipient.isProfileSharing.toString())
)
if (!recipient.isGroup) {
textPref(
title = DSLSettingsText.from("Capabilities"),
summary = DSLSettingsText.from(buildCapabilitySpan(recipient))
)
}
if (!recipient.isGroup) {
sectionHeaderPref(DSLSettingsText.from("Actions"))
clickPref(
@ -139,6 +157,7 @@ class InternalConversationSettingsFragment : DSLSettingsFragment(
)
}
}
}
private fun copyToClipboard(text: String) {
Util.copyToClipboard(requireContext(), text)
@ -171,7 +190,13 @@ class InternalConversationSettingsFragment : DSLSettingsFragment(
val recipientId: RecipientId
) : ViewModel(), RecipientForeverObserver {
private val store = Store(InternalState(Recipient.resolved(recipientId), null))
private val store = Store(
InternalState(
recipient = Recipient.resolved(recipientId),
threadId = null,
groupId = null
)
)
val state = store.stateLiveData
val liveRecipient = Recipient.live(recipientId)
@ -180,16 +205,15 @@ class InternalConversationSettingsFragment : DSLSettingsFragment(
liveRecipient.observeForever(this)
SignalExecutors.BOUNDED.execute {
val threadId: Long? = DatabaseFactory.getThreadDatabase(ApplicationDependencies.getApplication()).getThreadIdFor(recipientId)
store.update { state -> state.copy(threadId = threadId) }
val context: Context = ApplicationDependencies.getApplication()
val threadId: Long? = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(recipientId)
val groupId: GroupId? = DatabaseFactory.getGroupDatabase(context).getGroup(recipientId).transform { it.id }.orNull()
store.update { state -> state.copy(threadId = threadId, groupId = groupId) }
}
}
override fun onRecipientChanged(recipient: Recipient) {
SignalExecutors.BOUNDED.execute {
val threadId: Long? = DatabaseFactory.getThreadDatabase(ApplicationDependencies.getApplication()).getThreadIdFor(recipient.id)
store.update { InternalState(recipient, threadId) }
}
store.update { state -> state.copy(recipient = recipient) }
}
override fun onCleared() {
@ -205,6 +229,7 @@ class InternalConversationSettingsFragment : DSLSettingsFragment(
data class InternalState(
val recipient: Recipient,
val threadId: Long?
val threadId: Long?,
val groupId: GroupId?
)
}