Skip to content

Commit

Permalink
Disable UnifiedPush for linkedDevices
Browse files Browse the repository at this point in the history
  • Loading branch information
p1gp1g committed Sep 20, 2023
1 parent d47c769 commit 015be2b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 015be2b

Please sign in to comment.