diff --git a/app/src/main/java/org/thoughtcrime/securesms/preferences/compose/NotificationsPreferenceScreen.kt b/app/src/main/java/org/thoughtcrime/securesms/preferences/compose/NotificationsPreferenceScreen.kt index 9e6332297a..7491119c29 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/preferences/compose/NotificationsPreferenceScreen.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/preferences/compose/NotificationsPreferenceScreen.kt @@ -11,7 +11,6 @@ import androidx.compose.runtime.collectAsState import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource -import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.tooling.preview.Preview import androidx.lifecycle.Lifecycle import androidx.lifecycle.compose.LifecycleEventEffect @@ -141,7 +140,8 @@ fun NotificationsPreference( title = annotatedStringResource(R.string.useFastMode), subtitle = annotatedStringResource(fastModeDescription), subtitleStyle = LocalType.current.large, - checked = uiState.isPushEnabled, + checked = uiState.fastModeSelected, + enabled = uiState.fastModeEnabled, qaTag = R.string.qa_preferences_enable_push, switchQaTag = R.string.qa_preferences_enable_push_toggle, onCheckedChange = {isEnabled -> sendCommand(TogglePushEnabled(isEnabled)) } diff --git a/app/src/main/java/org/thoughtcrime/securesms/preferences/compose/NotificationsPreferenceViewModel.kt b/app/src/main/java/org/thoughtcrime/securesms/preferences/compose/NotificationsPreferenceViewModel.kt index 001f7c0914..f50f5a979b 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/preferences/compose/NotificationsPreferenceViewModel.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/preferences/compose/NotificationsPreferenceViewModel.kt @@ -21,6 +21,7 @@ import org.thoughtcrime.securesms.notifications.NotificationPreferences.PRIVACY import org.thoughtcrime.securesms.notifications.NotificationPreferences.PUSH_ENABLED import org.thoughtcrime.securesms.notifications.NotificationPreferences.SOUND_WHEN_APP_OPEN import org.thoughtcrime.securesms.notifications.NotificationPrivacy +import org.thoughtcrime.securesms.onboarding.messagenotifications.isFastModeAvailable import org.thoughtcrime.securesms.preferences.PreferenceStorage import org.thoughtcrime.securesms.ui.isWhitelistedFromDoze import javax.inject.Inject @@ -32,7 +33,9 @@ class NotificationsPreferenceViewModel @Inject constructor( private val channels: NotificationChannelManager, ) : ViewModel() { - private val _uiState = MutableStateFlow(UIState()) + private val _uiState = MutableStateFlow(UIState( + fastModeEnabled = application.isFastModeAvailable() + )) val uiState: StateFlow get() = _uiState private val _uiEvents = MutableSharedFlow() @@ -63,7 +66,7 @@ class NotificationsPreferenceViewModel @Inject constructor( _uiState.update { old -> old.copy( // strategy - isPushEnabled = isPushEnabled, + fastModeSelected = isPushEnabled, checkedDozeWhitelist = notif.checkedDozeWhitelist, // keep the current doze whitelist status; you refresh it separately @@ -204,7 +207,8 @@ class NotificationsPreferenceViewModel @Inject constructor( data class UIState( // Strategy - val isPushEnabled: Boolean = false, + val fastModeSelected: Boolean = false, + val fastModeEnabled: Boolean = false, val isWhitelistedFromDoze: Boolean = false, // run in background val checkedDozeWhitelist: Boolean = false, // whitelist dialog's first time // style/behavior