Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ class Dependencies(
clearStorage = clearStorage::invoke,
supportsCrashReporting = flavorConfig.isCrashReportingEnabled,
knownBatteryState = platformInfo.knownBatteryState,
supportsNotificationSettings = platformInfo.supportsNotificationSettings,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class GetSettings(
val observeStorageUsed: () -> Flow<Long>,
private val supportsCrashReporting: Boolean,
private val knownBatteryState: Boolean,
private val supportsNotificationSettings: Boolean,
) {
operator fun invoke(): Flow<List<SettingsCategoryItem>> {
return combine(
Expand Down Expand Up @@ -103,6 +104,26 @@ class GetSettings(
}
}

private fun createNotificationsSettings(): SettingsCategoryItem {
return SettingsCategoryItem(
icon = Res.drawable.notifications,
title = Res.string.Settings_Notifications_Label,
route = PreferenceCategoryKey.NOTIFICATIONS,
settings = listOf(
SettingsItem(
title = Res.string.Settings_Notifications_Enabled,
key = SettingsKey.NOTIFICATIONS_ENABLED,
type = PreferenceItemType.SWITCH,
),
),
footerContent = {
SettingsDescription(
Res.string.Modal_EnableNotifications_Paragraph,
)
},
)
}

private fun buildSettings(
hasWebsitesDescriptor: Boolean,
uploadResultsEnabled: Boolean,
Expand All @@ -114,23 +135,7 @@ class GetSettings(
supportsCrashReporting: Boolean = false,
): List<SettingsCategoryItem> {
return listOfNotNull(
SettingsCategoryItem(
icon = Res.drawable.notifications,
title = Res.string.Settings_Notifications_Label,
route = PreferenceCategoryKey.NOTIFICATIONS,
settings = listOf(
SettingsItem(
title = Res.string.Settings_Notifications_Enabled,
key = SettingsKey.NOTIFICATIONS_ENABLED,
type = PreferenceItemType.SWITCH,
),
),
footerContent = {
SettingsDescription(
Res.string.Modal_EnableNotifications_Paragraph,
)
},
),
createNotificationsSettings().takeIf { supportsNotificationSettings },
SettingsCategoryItem(
icon = Res.drawable.ic_settings,
title = Res.string.Settings_TestOptions_Label,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ data class PlatformInfo(
val osVersion: String,
val model: String,
val needsToRequestNotificationsPermission: Boolean,
val supportsNotificationSettings: Boolean = true,
val knownBatteryState: Boolean = true,
val sentryDsn: String,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ private fun buildPlatformInfo() =
osVersion = "1.0",
model = "model",
needsToRequestNotificationsPermission = false,
supportsNotificationSettings = false,
knownBatteryState = false,
sentryDsn = "",
)
Expand Down
Loading