From 015be2b23f0e1e7695e61d9e100781a47741571a Mon Sep 17 00:00:00 2001 From: sim Date: Wed, 13 Sep 2023 22:22:29 +0200 Subject: [PATCH] Disable UnifiedPush for linkedDevices --- .../NotificationsSettingsFragment.kt | 38 ++++++++++--------- .../NotificationsSettingsState.kt | 1 + .../NotificationsSettingsViewModel.kt | 1 + 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/notifications/NotificationsSettingsFragment.kt b/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/notifications/NotificationsSettingsFragment.kt index 826ce586b1..eb10d5df1d 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/notifications/NotificationsSettingsFragment.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/notifications/NotificationsSettingsFragment.kt @@ -266,27 +266,29 @@ class NotificationsSettingsFragment : DSLSettingsFragment(R.string.preferences__ } ) - dividerPref() + if (!state.isLinkedDevice) { + dividerPref() - sectionHeaderPref(R.string.NotificationsSettingsFragment__pushStrategy) + sectionHeaderPref(R.string.NotificationsSettingsFragment__pushStrategy) - radioListPref( - title = DSLSettingsText.from(R.string.NotificationsSettingsFragment__deliveryMethod), - listItems = notificationMethodLabels, - selected = notificationMethodValues.indexOf(state.notificationDeliveryMethod), - onSelected = { - viewModel.setNotificationDeliveryMethod(notificationMethodValues[it]) - } - ) + radioListPref( + title = DSLSettingsText.from(R.string.NotificationsSettingsFragment__deliveryMethod), + listItems = notificationMethodLabels, + selected = notificationMethodValues.indexOf(state.notificationDeliveryMethod), + onSelected = { + viewModel.setNotificationDeliveryMethod(notificationMethodValues[it]) + } + ) - clickPref( - title = DSLSettingsText.from(R.string.NotificationsSettingsFragment__unifiedpush), - summary = DSLSettingsText.from(R.string.NotificationsSettingsFragment__unifiedpushDescription), - isEnabled = state.notificationDeliveryMethod == NotificationDeliveryMethod.UNIFIEDPUSH, - onClick = { - findNavController().safeNavigate(R.id.action_notificationsSettingsFragment_to_unifiedPushFragment) - } - ) + clickPref( + title = DSLSettingsText.from(R.string.NotificationsSettingsFragment__unifiedpush), + summary = DSLSettingsText.from(R.string.NotificationsSettingsFragment__unifiedpushDescription), + isEnabled = state.notificationDeliveryMethod == NotificationDeliveryMethod.UNIFIEDPUSH, + onClick = { + findNavController().safeNavigate(R.id.action_notificationsSettingsFragment_to_unifiedPushFragment) + } + ) + } } } diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/notifications/NotificationsSettingsState.kt b/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/notifications/NotificationsSettingsState.kt index dba608049e..a25c24ce0f 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/notifications/NotificationsSettingsState.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/notifications/NotificationsSettingsState.kt @@ -4,6 +4,7 @@ import android.net.Uri import org.thoughtcrime.securesms.keyvalue.SettingsValues.NotificationDeliveryMethod data class NotificationsSettingsState( + val isLinkedDevice: Boolean, val messageNotificationsState: MessageNotificationsState, val callNotificationsState: CallNotificationsState, val notifyWhenContactJoinsSignal: Boolean, diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/notifications/NotificationsSettingsViewModel.kt b/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/notifications/NotificationsSettingsViewModel.kt index 83ff41a4b2..03ec8b8cb3 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/notifications/NotificationsSettingsViewModel.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/notifications/NotificationsSettingsViewModel.kt @@ -126,6 +126,7 @@ class NotificationsSettingsViewModel(private val sharedPreferences: SharedPrefer } private fun getState(): NotificationsSettingsState = NotificationsSettingsState( + isLinkedDevice = SignalStore.account().isLinkedDevice, messageNotificationsState = MessageNotificationsState( notificationsEnabled = SignalStore.settings().isMessageNotificationsEnabled, sound = SignalStore.settings().messageNotificationSound,