|
|
@ -8,7 +8,9 @@ import androidx.activity.viewModels
|
|
|
|
import androidx.core.content.ContextCompat
|
|
|
|
import androidx.core.content.ContextCompat
|
|
|
|
import androidx.core.text.HtmlCompat
|
|
|
|
import androidx.core.text.HtmlCompat
|
|
|
|
import androidx.core.view.isVisible
|
|
|
|
import androidx.core.view.isVisible
|
|
|
|
|
|
|
|
import androidx.lifecycle.Lifecycle
|
|
|
|
import androidx.lifecycle.lifecycleScope
|
|
|
|
import androidx.lifecycle.lifecycleScope
|
|
|
|
|
|
|
|
import androidx.lifecycle.repeatOnLifecycle
|
|
|
|
import androidx.recyclerview.widget.DividerItemDecoration
|
|
|
|
import androidx.recyclerview.widget.DividerItemDecoration
|
|
|
|
import androidx.recyclerview.widget.RecyclerView
|
|
|
|
import androidx.recyclerview.widget.RecyclerView
|
|
|
|
import dagger.hilt.android.AndroidEntryPoint
|
|
|
|
import dagger.hilt.android.AndroidEntryPoint
|
|
|
@ -109,39 +111,50 @@ class ExpirationSettingsActivity: PassphraseRequiredActionBarActivity() {
|
|
|
|
binding.buttonSet.setOnClickListener {
|
|
|
|
binding.buttonSet.setOnClickListener {
|
|
|
|
viewModel.onSetClick()
|
|
|
|
viewModel.onSetClick()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
lifecycleScope.launchWhenStarted {
|
|
|
|
lifecycleScope.launch {
|
|
|
|
launch {
|
|
|
|
repeatOnLifecycle(Lifecycle.State.STARTED) {
|
|
|
|
viewModel.uiState.collect { uiState ->
|
|
|
|
viewModel.uiState.collect { uiState ->
|
|
|
|
when (uiState.settingsSaved) {
|
|
|
|
when (uiState.settingsSaved) {
|
|
|
|
true -> {
|
|
|
|
true -> {
|
|
|
|
showToast(getString(R.string.ExpirationSettingsActivity_settings_updated))
|
|
|
|
showToast(getString(R.string.ExpirationSettingsActivity_settings_updated))
|
|
|
|
finish()
|
|
|
|
finish()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
false -> showToast(getString(R.string.ExpirationSettingsActivity_settings_not_updated))
|
|
|
|
false -> showToast(getString(R.string.ExpirationSettingsActivity_settings_not_updated))
|
|
|
|
else -> {}
|
|
|
|
else -> {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
launch {
|
|
|
|
}
|
|
|
|
|
|
|
|
lifecycleScope.launch {
|
|
|
|
|
|
|
|
repeatOnLifecycle(Lifecycle.State.STARTED) {
|
|
|
|
viewModel.selectedExpirationType.collect { type ->
|
|
|
|
viewModel.selectedExpirationType.collect { type ->
|
|
|
|
val position = deleteTypeOptions.indexOfFirst { it.value.toIntOrNull() == type }
|
|
|
|
val position = deleteTypeOptions.indexOfFirst { it.value.toIntOrNull() == type }
|
|
|
|
deleteTypeOptionAdapter.setSelectedPosition(max(0, position))
|
|
|
|
deleteTypeOptionAdapter.setSelectedPosition(max(0, position))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
launch {
|
|
|
|
}
|
|
|
|
|
|
|
|
lifecycleScope.launch {
|
|
|
|
|
|
|
|
repeatOnLifecycle(Lifecycle.State.STARTED) {
|
|
|
|
viewModel.selectedExpirationTimer.collect { option ->
|
|
|
|
viewModel.selectedExpirationTimer.collect { option ->
|
|
|
|
val position = viewModel.expirationTimerOptions.value.indexOfFirst { it.value == option?.value }
|
|
|
|
val position =
|
|
|
|
|
|
|
|
viewModel.expirationTimerOptions.value.indexOfFirst { it.value == option?.value }
|
|
|
|
timerOptionAdapter.setSelectedPosition(max(0, position))
|
|
|
|
timerOptionAdapter.setSelectedPosition(max(0, position))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
launch {
|
|
|
|
}
|
|
|
|
|
|
|
|
lifecycleScope.launch {
|
|
|
|
|
|
|
|
repeatOnLifecycle(Lifecycle.State.STARTED) {
|
|
|
|
viewModel.expirationTimerOptions.collect { options ->
|
|
|
|
viewModel.expirationTimerOptions.collect { options ->
|
|
|
|
binding.textViewTimer.isVisible = options.isNotEmpty() && viewModel.uiState.value.showExpirationTypeSelector
|
|
|
|
binding.textViewTimer.isVisible =
|
|
|
|
|
|
|
|
options.isNotEmpty() && viewModel.uiState.value.showExpirationTypeSelector
|
|
|
|
binding.layoutTimer.isVisible = options.isNotEmpty()
|
|
|
|
binding.layoutTimer.isVisible = options.isNotEmpty()
|
|
|
|
timerOptionAdapter.submitList(options)
|
|
|
|
timerOptionAdapter.submitList(options)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
launch {
|
|
|
|
}
|
|
|
|
|
|
|
|
lifecycleScope.launch {
|
|
|
|
|
|
|
|
repeatOnLifecycle(Lifecycle.State.STARTED) {
|
|
|
|
viewModel.recipient.collect {
|
|
|
|
viewModel.recipient.collect {
|
|
|
|
binding.textViewDeleteType.isVisible = viewModel.uiState.value.showExpirationTypeSelector
|
|
|
|
binding.textViewDeleteType.isVisible = viewModel.uiState.value.showExpirationTypeSelector
|
|
|
|
binding.layoutDeleteTypes.isVisible = viewModel.uiState.value.showExpirationTypeSelector
|
|
|
|
binding.layoutDeleteTypes.isVisible = viewModel.uiState.value.showExpirationTypeSelector
|
|
|
|