mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 16:57:50 +00:00
Legacy settings ui tweaks
This commit is contained in:
parent
4b66e0516d
commit
a6f9e17122
@ -15,6 +15,7 @@ import kotlinx.coroutines.launch
|
||||
import network.loki.messenger.BuildConfig
|
||||
import network.loki.messenger.R
|
||||
import network.loki.messenger.databinding.ActivityExpirationSettingsBinding
|
||||
import org.session.libsession.messaging.messages.ExpirationConfiguration
|
||||
import org.session.libsignal.protos.SignalServiceProtos.Content.ExpirationType
|
||||
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase
|
||||
@ -74,24 +75,7 @@ class ExpirationSettingsActivity: PassphraseRequiredActionBarActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
val deleteTypeOptions = listOf(
|
||||
RadioOption(value = "-1", title = getString(R.string.expiration_off)),
|
||||
RadioOption(
|
||||
value = "0",
|
||||
title = getString(R.string.expiration_type_disappear_legacy),
|
||||
subtitle = getString(R.string.expiration_type_disappear_legacy_description)
|
||||
),
|
||||
RadioOption(
|
||||
value = ExpirationType.DELETE_AFTER_READ_VALUE.toString(),
|
||||
title = getString(R.string.expiration_type_disappear_after_read),
|
||||
subtitle = getString(R.string.expiration_type_disappear_after_read_description)
|
||||
),
|
||||
RadioOption(
|
||||
value = ExpirationType.DELETE_AFTER_SEND_VALUE.toString(),
|
||||
title = getString(R.string.expiration_type_disappear_after_send),
|
||||
subtitle = getString(R.string.expiration_type_disappear_after_send_description)
|
||||
)
|
||||
)
|
||||
val deleteTypeOptions = getDeleteOptions()
|
||||
val deleteTypeOptionAdapter = RadioOptionAdapter {
|
||||
viewModel.onExpirationTypeSelected(it)
|
||||
}
|
||||
@ -152,6 +136,74 @@ class ExpirationSettingsActivity: PassphraseRequiredActionBarActivity() {
|
||||
|
||||
}
|
||||
|
||||
private fun getDeleteOptions(): List<RadioOption> {
|
||||
if (!viewModel.showExpirationTypeSelector) return emptyList()
|
||||
|
||||
val deleteTypeOptions = mutableListOf<RadioOption>()
|
||||
if (ExpirationConfiguration.isNewConfigEnabled) {
|
||||
if (viewModel.recipient.value?.isContactRecipient == true && viewModel.recipient.value?.isLocalNumber == false) {
|
||||
deleteTypeOptions.addAll(
|
||||
listOf(
|
||||
RadioOption(value = "-1", title = getString(R.string.expiration_off)),
|
||||
RadioOption(
|
||||
value = ExpirationType.DELETE_AFTER_READ_VALUE.toString(),
|
||||
title = getString(R.string.expiration_type_disappear_after_read),
|
||||
subtitle = getString(R.string.expiration_type_disappear_after_read_description)
|
||||
),
|
||||
RadioOption(
|
||||
value = ExpirationType.DELETE_AFTER_SEND_VALUE.toString(),
|
||||
title = getString(R.string.expiration_type_disappear_after_send),
|
||||
subtitle = getString(R.string.expiration_type_disappear_after_send_description)
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
} else {
|
||||
if (viewModel.recipient.value?.isContactRecipient == true && viewModel.recipient.value?.isLocalNumber == false) {
|
||||
deleteTypeOptions.addAll(
|
||||
listOf(
|
||||
RadioOption(value = "-1", title = getString(R.string.expiration_off)),
|
||||
RadioOption(
|
||||
value = "0",
|
||||
title = getString(R.string.expiration_type_disappear_legacy),
|
||||
subtitle = getString(R.string.expiration_type_disappear_legacy_description)
|
||||
),
|
||||
RadioOption(
|
||||
value = ExpirationType.DELETE_AFTER_READ_VALUE.toString(),
|
||||
title = getString(R.string.expiration_type_disappear_after_read),
|
||||
subtitle = getString(R.string.expiration_type_disappear_after_read_description),
|
||||
enabled = false
|
||||
),
|
||||
RadioOption(
|
||||
value = ExpirationType.DELETE_AFTER_SEND_VALUE.toString(),
|
||||
title = getString(R.string.expiration_type_disappear_after_send),
|
||||
subtitle = getString(R.string.expiration_type_disappear_after_send_description),
|
||||
enabled = false
|
||||
)
|
||||
)
|
||||
)
|
||||
} else {
|
||||
deleteTypeOptions.addAll(
|
||||
listOf(
|
||||
RadioOption(value = "-1", title = getString(R.string.expiration_off)),
|
||||
RadioOption(
|
||||
value = "0",
|
||||
title = getString(R.string.expiration_type_disappear_legacy),
|
||||
subtitle = getString(R.string.expiration_type_disappear_legacy_description)
|
||||
),
|
||||
RadioOption(
|
||||
value = ExpirationType.DELETE_AFTER_SEND_VALUE.toString(),
|
||||
title = getString(R.string.expiration_type_disappear_after_send),
|
||||
subtitle = getString(R.string.expiration_type_disappear_after_send_description),
|
||||
enabled = false
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
return deleteTypeOptions
|
||||
}
|
||||
|
||||
private fun setUpToolbar() {
|
||||
setSupportActionBar(binding.toolbar)
|
||||
val actionBar = supportActionBar ?: return
|
||||
|
@ -48,7 +48,7 @@ class ExpirationSettingsViewModel(
|
||||
expirationConfig = storage.getExpirationConfiguration(threadId)
|
||||
val recipient = threadDb.getRecipientForThreadId(threadId)
|
||||
_recipient.value = recipient
|
||||
showExpirationTypeSelector = recipient?.isContactRecipient == true && recipient.isLocalNumber == false
|
||||
showExpirationTypeSelector = !ExpirationConfiguration.isNewConfigEnabled || (recipient?.isContactRecipient == true && !recipient.isLocalNumber)
|
||||
if (recipient?.isLocalNumber == true || recipient?.isClosedGroupRecipient == true) {
|
||||
_selectedExpirationType.value = ExpirationType.DELETE_AFTER_SEND
|
||||
} else {
|
||||
@ -67,7 +67,7 @@ class ExpirationSettingsViewModel(
|
||||
else -> emptyList()
|
||||
}
|
||||
}.onEach { options ->
|
||||
_expirationTimerOptions.value = if (recipient.value?.isLocalNumber == true || recipient.value?.isClosedGroupRecipient == true) {
|
||||
_expirationTimerOptions.value = if (ExpirationConfiguration.isNewConfigEnabled && (recipient.value?.isLocalNumber == true || recipient.value?.isClosedGroupRecipient == true)) {
|
||||
options
|
||||
} else {
|
||||
options.slice(1 until options.size)
|
||||
|
@ -47,11 +47,19 @@ class RadioOptionAdapter(
|
||||
val binding = ItemSelectableBinding.bind(itemView)
|
||||
|
||||
fun bind(option: RadioOption, isSelected: Boolean, toggleSelection: (RadioOption) -> Unit) {
|
||||
val alpha = if (option.enabled) 1f else 0.5f
|
||||
binding.root.isEnabled = option.enabled
|
||||
binding.titleTextView.alpha = alpha
|
||||
binding.subtitleTextView.alpha = alpha
|
||||
binding.selectButton.alpha = alpha
|
||||
|
||||
binding.titleTextView.text = option.title
|
||||
binding.subtitleTextView.text = option.subtitle
|
||||
binding.subtitleTextView.isVisible = !option.subtitle.isNullOrEmpty()
|
||||
binding.root.setOnClickListener { toggleSelection(option) }
|
||||
binding.selectButton.isSelected = isSelected
|
||||
if (option.enabled) {
|
||||
binding.root.setOnClickListener { toggleSelection(option) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -60,5 +68,6 @@ class RadioOptionAdapter(
|
||||
data class RadioOption(
|
||||
val value: String,
|
||||
val title: String,
|
||||
val subtitle: String? = null
|
||||
val subtitle: String? = null,
|
||||
val enabled: Boolean = true
|
||||
)
|
||||
|
@ -10,6 +10,6 @@ class ExpirationConfiguration(
|
||||
) {
|
||||
val isEnabled = durationSeconds > 0
|
||||
companion object {
|
||||
val isNewConfigEnabled = System.currentTimeMillis() > 1_671_062_400_000 // 15/12/2022
|
||||
val isNewConfigEnabled = System.currentTimeMillis() > 1_674_000_000_000 // 18/01/2023
|
||||
}
|
||||
}
|
@ -95,7 +95,7 @@ object UpdateMessageBuilder {
|
||||
}
|
||||
} else {
|
||||
if (ExpirationConfiguration.isNewConfigEnabled) {
|
||||
context.getString(R.string.MessageRecord_s_turned_off_disappearing_messages)
|
||||
context.getString(R.string.MessageRecord_s_turned_off_disappearing_messages, senderName)
|
||||
} else {
|
||||
context.getString(R.string.MessageRecord_s_disabled_disappearing_messages, senderName)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user