Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Commit

Permalink
Warn in notifications settings if UnifiedPush setup is not finished
Browse files Browse the repository at this point in the history
  • Loading branch information
p1gp1g authored and valldrac committed Oct 24, 2024
1 parent 408f172 commit 34b6498
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import org.thoughtcrime.securesms.R
import org.thoughtcrime.securesms.components.PromptBatterySaverDialogFragment
import org.thoughtcrime.securesms.components.settings.DSLConfiguration
import org.thoughtcrime.securesms.components.settings.DSLSettingsFragment
import org.thoughtcrime.securesms.components.settings.DSLSettingsIcon
import org.thoughtcrime.securesms.components.settings.DSLSettingsText
import org.thoughtcrime.securesms.components.settings.PreferenceModel
import org.thoughtcrime.securesms.components.settings.PreferenceViewHolder
Expand Down Expand Up @@ -335,10 +336,12 @@ class NotificationsSettingsFragment : DSLSettingsFragment(R.string.preferences__
}
)

val unifiedPushEnabled = state.notificationDeliveryMethod == NotificationDeliveryMethod.UNIFIEDPUSH
clickPref(
title = DSLSettingsText.from(R.string.NotificationsSettingsFragment__unifiedpush),
summary = DSLSettingsText.from(R.string.NotificationsSettingsFragment__unifiedpushDescription),
isEnabled = state.notificationDeliveryMethod == NotificationDeliveryMethod.UNIFIEDPUSH,
isEnabled = unifiedPushEnabled,
iconEnd = if (unifiedPushEnabled && !state.unifiedPushOk) DSLSettingsIcon.from(R.drawable.ic_alert) else null,
onClick = {
findNavController().safeNavigate(R.id.action_notificationsSettingsFragment_to_unifiedPushFragment)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ data class NotificationsSettingsState(
val notifyWhileLocked: Boolean,
val canEnableNotifyWhileLocked: Boolean,
val notifyWhenContactJoinsSignal: Boolean,
val notificationDeliveryMethod: NotificationDeliveryMethod
val notificationDeliveryMethod: NotificationDeliveryMethod,
val unifiedPushOk: Boolean,
)

data class MessageNotificationsState(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import im.molly.unifiedpush.jobs.UnifiedPushRefreshJob
import im.molly.unifiedpush.model.UnifiedPushStatus

import im.molly.unifiedpush.util.UnifiedPushHelper
import org.signal.core.util.concurrent.SignalExecutors
Expand Down Expand Up @@ -177,7 +178,8 @@ class NotificationsSettingsViewModel(private val sharedPreferences: SharedPrefer
notifyWhileLocked = TextSecurePreferences.isPassphraseLockNotificationsEnabled(AppDependencies.application) && SignalStore.account.pushAvailable,
canEnableNotifyWhileLocked = SignalStore.account.pushAvailable,
notifyWhenContactJoinsSignal = SignalStore.settings.isNotifyWhenContactJoinsSignal,
notificationDeliveryMethod = SignalStore.settings.notificationDeliveryMethod
notificationDeliveryMethod = SignalStore.settings.notificationDeliveryMethod,
unifiedPushOk = UnifiedPushHelper.isUnifiedPushAvailable()
)

private fun canEnableNotifications(): Boolean {
Expand Down

0 comments on commit 34b6498

Please sign in to comment.