Default to first expiration timer option

This commit is contained in:
charles 2022-12-19 13:12:41 +11:00
parent 70abf8a4d2
commit d52fc4d70a
3 changed files with 5 additions and 1 deletions

View File

@ -3,6 +3,7 @@ package org.thoughtcrime.securesms.conversation.expiration
import android.os.Bundle import android.os.Bundle
import android.os.Parcelable import android.os.Parcelable
import android.util.SparseArray import android.util.SparseArray
import android.widget.Toast
import androidx.activity.viewModels import androidx.activity.viewModels
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.core.text.HtmlCompat import androidx.core.text.HtmlCompat
@ -108,6 +109,7 @@ class ExpirationSettingsActivity: PassphraseRequiredActionBarActivity() {
launch { launch {
viewModel.uiState.collect { uiState -> viewModel.uiState.collect { uiState ->
if (uiState.settingsSaved == true) { if (uiState.settingsSaved == true) {
Toast.makeText(this@ExpirationSettingsActivity, getString(R.string.ExpirationSettingsActivity_settings_saved), Toast.LENGTH_SHORT).show()
finish() finish()
} }
} }

View File

@ -98,8 +98,9 @@ class ExpirationSettingsViewModel(
} }
fun onSetClick() = viewModelScope.launch { fun onSetClick() = viewModelScope.launch {
val expiresIn = _selectedExpirationTimer.value?.value?.toIntOrNull() ?: 0
val expiryType = _selectedExpirationType.value val expiryType = _selectedExpirationType.value
val firstOption = _expirationTimerOptions.value.firstOrNull()?.value?.toIntOrNull() ?: 0
val expiresIn = _selectedExpirationTimer.value?.value?.toIntOrNull() ?: if (expiryType >= 0) firstOption else 0
val expiryChangeTimestampMs = System.currentTimeMillis() val expiryChangeTimestampMs = System.currentTimeMillis()
storage.setExpirationConfiguration(ExpirationConfiguration(threadId, expiresIn, expiryType, expiryChangeTimestampMs)) storage.setExpirationConfiguration(ExpirationConfiguration(threadId, expiresIn, expiryType, expiryChangeTimestampMs))

View File

@ -885,4 +885,5 @@
<string name="activity_expiration_settings_timer">Timer</string> <string name="activity_expiration_settings_timer">Timer</string>
<string name="activity_expiration_settings_group_footer"><![CDATA[This setting applies to everyone in this conversation.<br/>Only group admins can change this setting.]]></string> <string name="activity_expiration_settings_group_footer"><![CDATA[This setting applies to everyone in this conversation.<br/>Only group admins can change this setting.]]></string>
<string name="activity_conversation_outdated_client_banner_text">%s is using an outdated client. Disappearing messages may not work as expected.</string> <string name="activity_conversation_outdated_client_banner_text">%s is using an outdated client. Disappearing messages may not work as expected.</string>
<string name="ExpirationSettingsActivity_settings_saved">Settings saved</string>
</resources> </resources>