kopia lustrzana https://github.com/ryukoposting/Signal-Android
Fix issue where custom notifications were never enabled.
Older API levels do not have notification channel support, and we were not checking this state to see if we should enable the controls. Fix is to add a new controlsEnabled flag on the state object and set it whenever we finish loading or when recp changes.fork-5.53.8
rodzic
de2c7d38bf
commit
b9ffbb8e92
|
@ -65,8 +65,6 @@ class CustomNotificationsSettingsFragment : DSLSettingsFragment(R.string.CustomN
|
|||
private fun getConfiguration(state: CustomNotificationsSettingsState): DSLConfiguration {
|
||||
return configure {
|
||||
|
||||
val controlsEnabled = state.hasCustomNotifications && state.isInitialLoadComplete
|
||||
|
||||
sectionHeaderPref(R.string.CustomNotificationsDialogFragment__messages)
|
||||
|
||||
if (NotificationChannels.supported()) {
|
||||
|
@ -81,21 +79,21 @@ class CustomNotificationsSettingsFragment : DSLSettingsFragment(R.string.CustomN
|
|||
clickPref(
|
||||
title = DSLSettingsText.from(R.string.CustomNotificationsDialogFragment__notification_sound),
|
||||
summary = DSLSettingsText.from(getRingtoneSummary(requireContext(), state.messageSound, Settings.System.DEFAULT_NOTIFICATION_URI)),
|
||||
isEnabled = controlsEnabled,
|
||||
isEnabled = state.controlsEnabled,
|
||||
onClick = { requestSound(state.messageSound, false) }
|
||||
)
|
||||
|
||||
if (NotificationChannels.supported()) {
|
||||
switchPref(
|
||||
title = DSLSettingsText.from(R.string.CustomNotificationsDialogFragment__vibrate),
|
||||
isEnabled = controlsEnabled,
|
||||
isEnabled = state.controlsEnabled,
|
||||
isChecked = state.messageVibrateEnabled,
|
||||
onClick = { viewModel.setMessageVibrate(RecipientDatabase.VibrateState.fromBoolean(!state.messageVibrateEnabled)) }
|
||||
)
|
||||
} else {
|
||||
radioListPref(
|
||||
title = DSLSettingsText.from(R.string.CustomNotificationsDialogFragment__vibrate),
|
||||
isEnabled = controlsEnabled,
|
||||
isEnabled = state.controlsEnabled,
|
||||
listItems = vibrateLabels,
|
||||
selected = state.messageVibrateState.id,
|
||||
onSelected = {
|
||||
|
@ -112,13 +110,13 @@ class CustomNotificationsSettingsFragment : DSLSettingsFragment(R.string.CustomN
|
|||
clickPref(
|
||||
title = DSLSettingsText.from(R.string.CustomNotificationsDialogFragment__ringtone),
|
||||
summary = DSLSettingsText.from(getRingtoneSummary(requireContext(), state.callSound, Settings.System.DEFAULT_RINGTONE_URI)),
|
||||
isEnabled = controlsEnabled,
|
||||
isEnabled = state.controlsEnabled,
|
||||
onClick = { requestSound(state.callSound, true) }
|
||||
)
|
||||
|
||||
radioListPref(
|
||||
title = DSLSettingsText.from(R.string.CustomNotificationsDialogFragment__vibrate),
|
||||
isEnabled = controlsEnabled,
|
||||
isEnabled = state.controlsEnabled,
|
||||
listItems = vibrateLabels,
|
||||
selected = state.callVibrateState.id,
|
||||
onSelected = {
|
||||
|
|
|
@ -6,6 +6,7 @@ import org.thoughtcrime.securesms.database.RecipientDatabase
|
|||
data class CustomNotificationsSettingsState(
|
||||
val isInitialLoadComplete: Boolean = false,
|
||||
val hasCustomNotifications: Boolean = false,
|
||||
val controlsEnabled: Boolean = false,
|
||||
val messageVibrateState: RecipientDatabase.VibrateState = RecipientDatabase.VibrateState.DEFAULT,
|
||||
val messageVibrateEnabled: Boolean = false,
|
||||
val messageSound: Uri? = null,
|
||||
|
|
|
@ -22,12 +22,19 @@ class CustomNotificationsSettingsViewModel(
|
|||
|
||||
init {
|
||||
repository.initialize(recipientId) {
|
||||
store.update { it.copy(isInitialLoadComplete = true) }
|
||||
store.update {
|
||||
it.copy(
|
||||
isInitialLoadComplete = true,
|
||||
controlsEnabled = (!NotificationChannels.supported() || it.hasCustomNotifications)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
store.update(Recipient.live(recipientId).liveData) { recipient, state ->
|
||||
val recipientHasCustomNotifications = NotificationChannels.supported() && recipient.notificationChannel != null
|
||||
state.copy(
|
||||
hasCustomNotifications = NotificationChannels.supported() && recipient.notificationChannel != null,
|
||||
hasCustomNotifications = recipientHasCustomNotifications,
|
||||
controlsEnabled = (!NotificationChannels.supported() || recipientHasCustomNotifications) && state.isInitialLoadComplete,
|
||||
messageSound = recipient.messageRingtone,
|
||||
messageVibrateState = recipient.messageVibrate,
|
||||
messageVibrateEnabled = when (recipient.messageVibrate) {
|
||||
|
|
Ładowanie…
Reference in New Issue