Show internal conversation settings for groups.
This commit is contained in:
parent
33ac48e771
commit
5115717f67
4 changed files with 106 additions and 84 deletions
|
@ -314,8 +314,7 @@ class ConversationSettingsFragment : DSLSettingsFragment(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
state.withRecipientSettingsState { recipientState ->
|
if (state.displayInternalRecipientDetails) {
|
||||||
if (recipientState.displayInternalRecipientDetails) {
|
|
||||||
customPref(
|
customPref(
|
||||||
InternalPreference.Model(
|
InternalPreference.Model(
|
||||||
recipient = state.recipient,
|
recipient = state.recipient,
|
||||||
|
@ -326,7 +325,6 @@ class ConversationSettingsFragment : DSLSettingsFragment(
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
customPref(
|
customPref(
|
||||||
ButtonStripPreference.Model(
|
ButtonStripPreference.Model(
|
||||||
|
|
|
@ -16,6 +16,7 @@ data class ConversationSettingsState(
|
||||||
val canModifyBlockedState: Boolean = false,
|
val canModifyBlockedState: Boolean = false,
|
||||||
val sharedMedia: Cursor? = null,
|
val sharedMedia: Cursor? = null,
|
||||||
val sharedMediaIds: List<Long> = listOf(),
|
val sharedMediaIds: List<Long> = listOf(),
|
||||||
|
val displayInternalRecipientDetails: Boolean = false,
|
||||||
private val sharedMediaLoaded: Boolean = false,
|
private val sharedMediaLoaded: Boolean = false,
|
||||||
private val specificSettingsState: SpecificSettingsState,
|
private val specificSettingsState: SpecificSettingsState,
|
||||||
) {
|
) {
|
||||||
|
@ -49,8 +50,7 @@ sealed class SpecificSettingsState {
|
||||||
val selfHasGroups: Boolean = false,
|
val selfHasGroups: Boolean = false,
|
||||||
val canShowMoreGroupsInCommon: Boolean = false,
|
val canShowMoreGroupsInCommon: Boolean = false,
|
||||||
val groupsInCommonExpanded: Boolean = false,
|
val groupsInCommonExpanded: Boolean = false,
|
||||||
val contactLinkState: ContactLinkState = ContactLinkState.NONE,
|
val contactLinkState: ContactLinkState = ContactLinkState.NONE
|
||||||
val displayInternalRecipientDetails: Boolean
|
|
||||||
) : SpecificSettingsState() {
|
) : SpecificSettingsState() {
|
||||||
|
|
||||||
override val isLoaded: Boolean = true
|
override val isLoaded: Boolean = true
|
||||||
|
|
|
@ -71,7 +71,8 @@ sealed class ConversationSettingsViewModel(
|
||||||
state.copy(
|
state.copy(
|
||||||
sharedMedia = cursor.orNull(),
|
sharedMedia = cursor.orNull(),
|
||||||
sharedMediaIds = ids,
|
sharedMediaIds = ids,
|
||||||
sharedMediaLoaded = true
|
sharedMediaLoaded = true,
|
||||||
|
displayInternalRecipientDetails = repository.isInternalRecipientDetailsEnabled()
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
cursor.orNull().ensureClosed()
|
cursor.orNull().ensureClosed()
|
||||||
|
@ -121,9 +122,7 @@ sealed class ConversationSettingsViewModel(
|
||||||
private val repository: ConversationSettingsRepository
|
private val repository: ConversationSettingsRepository
|
||||||
) : ConversationSettingsViewModel(
|
) : ConversationSettingsViewModel(
|
||||||
repository,
|
repository,
|
||||||
SpecificSettingsState.RecipientSettingsState(
|
SpecificSettingsState.RecipientSettingsState()
|
||||||
displayInternalRecipientDetails = repository.isInternalRecipientDetailsEnabled()
|
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
|
|
||||||
private val liveRecipient = Recipient.live(recipientId)
|
private val liveRecipient = Recipient.live(recipientId)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package org.thoughtcrime.securesms.components.settings.conversation
|
package org.thoughtcrime.securesms.components.settings.conversation
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.text.TextUtils
|
import android.text.TextUtils
|
||||||
import android.widget.Toast
|
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.components.settings.configure
|
||||||
import org.thoughtcrime.securesms.database.DatabaseFactory
|
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
|
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
|
||||||
|
import org.thoughtcrime.securesms.groups.GroupId
|
||||||
import org.thoughtcrime.securesms.recipients.Recipient
|
import org.thoughtcrime.securesms.recipients.Recipient
|
||||||
import org.thoughtcrime.securesms.recipients.RecipientForeverObserver
|
import org.thoughtcrime.securesms.recipients.RecipientForeverObserver
|
||||||
import org.thoughtcrime.securesms.recipients.RecipientId
|
import org.thoughtcrime.securesms.recipients.RecipientId
|
||||||
|
@ -57,12 +59,23 @@ class InternalConversationSettingsFragment : DSLSettingsFragment(
|
||||||
summary = DSLSettingsText.from(recipient.id.serialize())
|
summary = DSLSettingsText.from(recipient.id.serialize())
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (!recipient.isGroup) {
|
||||||
val uuid = recipient.uuid.transform(UUID::toString).or("null")
|
val uuid = recipient.uuid.transform(UUID::toString).or("null")
|
||||||
longClickPref(
|
longClickPref(
|
||||||
title = DSLSettingsText.from("UUID"),
|
title = DSLSettingsText.from("UUID"),
|
||||||
summary = DSLSettingsText.from(uuid),
|
summary = DSLSettingsText.from(uuid),
|
||||||
onLongClick = { copyToClipboard(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"
|
val threadId: String = if (state.threadId != null) state.threadId.toString() else "N/A"
|
||||||
longClickPref(
|
longClickPref(
|
||||||
|
@ -71,6 +84,7 @@ class InternalConversationSettingsFragment : DSLSettingsFragment(
|
||||||
onLongClick = { copyToClipboard(threadId) }
|
onLongClick = { copyToClipboard(threadId) }
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (!recipient.isGroup) {
|
||||||
textPref(
|
textPref(
|
||||||
title = DSLSettingsText.from("Profile Name"),
|
title = DSLSettingsText.from("Profile Name"),
|
||||||
summary = DSLSettingsText.from("[${recipient.profileName.givenName}] [${state.recipient.profileName.familyName}]")
|
summary = DSLSettingsText.from("[${recipient.profileName.givenName}] [${state.recipient.profileName.familyName}]")
|
||||||
|
@ -94,17 +108,21 @@ class InternalConversationSettingsFragment : DSLSettingsFragment(
|
||||||
title = DSLSettingsText.from("Sealed Sender Mode"),
|
title = DSLSettingsText.from("Sealed Sender Mode"),
|
||||||
summary = DSLSettingsText.from(recipient.unidentifiedAccessMode.toString())
|
summary = DSLSettingsText.from(recipient.unidentifiedAccessMode.toString())
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
textPref(
|
textPref(
|
||||||
title = DSLSettingsText.from("Profile Sharing (AKA \"Whitelisted\")"),
|
title = DSLSettingsText.from("Profile Sharing (AKA \"Whitelisted\")"),
|
||||||
summary = DSLSettingsText.from(recipient.isProfileSharing.toString())
|
summary = DSLSettingsText.from(recipient.isProfileSharing.toString())
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (!recipient.isGroup) {
|
||||||
textPref(
|
textPref(
|
||||||
title = DSLSettingsText.from("Capabilities"),
|
title = DSLSettingsText.from("Capabilities"),
|
||||||
summary = DSLSettingsText.from(buildCapabilitySpan(recipient))
|
summary = DSLSettingsText.from(buildCapabilitySpan(recipient))
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!recipient.isGroup) {
|
||||||
sectionHeaderPref(DSLSettingsText.from("Actions"))
|
sectionHeaderPref(DSLSettingsText.from("Actions"))
|
||||||
|
|
||||||
clickPref(
|
clickPref(
|
||||||
|
@ -139,6 +157,7 @@ class InternalConversationSettingsFragment : DSLSettingsFragment(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun copyToClipboard(text: String) {
|
private fun copyToClipboard(text: String) {
|
||||||
Util.copyToClipboard(requireContext(), text)
|
Util.copyToClipboard(requireContext(), text)
|
||||||
|
@ -171,7 +190,13 @@ class InternalConversationSettingsFragment : DSLSettingsFragment(
|
||||||
val recipientId: RecipientId
|
val recipientId: RecipientId
|
||||||
) : ViewModel(), RecipientForeverObserver {
|
) : 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 state = store.stateLiveData
|
||||||
val liveRecipient = Recipient.live(recipientId)
|
val liveRecipient = Recipient.live(recipientId)
|
||||||
|
@ -180,16 +205,15 @@ class InternalConversationSettingsFragment : DSLSettingsFragment(
|
||||||
liveRecipient.observeForever(this)
|
liveRecipient.observeForever(this)
|
||||||
|
|
||||||
SignalExecutors.BOUNDED.execute {
|
SignalExecutors.BOUNDED.execute {
|
||||||
val threadId: Long? = DatabaseFactory.getThreadDatabase(ApplicationDependencies.getApplication()).getThreadIdFor(recipientId)
|
val context: Context = ApplicationDependencies.getApplication()
|
||||||
store.update { state -> state.copy(threadId = threadId) }
|
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) {
|
override fun onRecipientChanged(recipient: Recipient) {
|
||||||
SignalExecutors.BOUNDED.execute {
|
store.update { state -> state.copy(recipient = recipient) }
|
||||||
val threadId: Long? = DatabaseFactory.getThreadDatabase(ApplicationDependencies.getApplication()).getThreadIdFor(recipient.id)
|
|
||||||
store.update { InternalState(recipient, threadId) }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCleared() {
|
override fun onCleared() {
|
||||||
|
@ -205,6 +229,7 @@ class InternalConversationSettingsFragment : DSLSettingsFragment(
|
||||||
|
|
||||||
data class InternalState(
|
data class InternalState(
|
||||||
val recipient: Recipient,
|
val recipient: Recipient,
|
||||||
val threadId: Long?
|
val threadId: Long?,
|
||||||
|
val groupId: GroupId?
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue