Skip to content

Commit c80624b

Browse files
authored
feat: hide settings notifications on desktop (#642)
1 parent 517df0c commit c80624b

File tree

4 files changed

+25
-17
lines changed

4 files changed

+25
-17
lines changed

composeApp/src/commonMain/kotlin/org/ooni/probe/di/Dependencies.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ class Dependencies(
318318
clearStorage = clearStorage::invoke,
319319
supportsCrashReporting = flavorConfig.isCrashReportingEnabled,
320320
knownBatteryState = platformInfo.knownBatteryState,
321+
supportsNotificationSettings = platformInfo.supportsNotificationSettings,
321322
)
322323
}
323324

composeApp/src/commonMain/kotlin/org/ooni/probe/domain/GetSettings.kt

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ class GetSettings(
7575
val observeStorageUsed: () -> Flow<Long>,
7676
private val supportsCrashReporting: Boolean,
7777
private val knownBatteryState: Boolean,
78+
private val supportsNotificationSettings: Boolean,
7879
) {
7980
operator fun invoke(): Flow<List<SettingsCategoryItem>> {
8081
return combine(
@@ -103,6 +104,26 @@ class GetSettings(
103104
}
104105
}
105106

107+
private fun createNotificationsSettings(): SettingsCategoryItem {
108+
return SettingsCategoryItem(
109+
icon = Res.drawable.notifications,
110+
title = Res.string.Settings_Notifications_Label,
111+
route = PreferenceCategoryKey.NOTIFICATIONS,
112+
settings = listOf(
113+
SettingsItem(
114+
title = Res.string.Settings_Notifications_Enabled,
115+
key = SettingsKey.NOTIFICATIONS_ENABLED,
116+
type = PreferenceItemType.SWITCH,
117+
),
118+
),
119+
footerContent = {
120+
SettingsDescription(
121+
Res.string.Modal_EnableNotifications_Paragraph,
122+
)
123+
},
124+
)
125+
}
126+
106127
private fun buildSettings(
107128
hasWebsitesDescriptor: Boolean,
108129
uploadResultsEnabled: Boolean,
@@ -114,23 +135,7 @@ class GetSettings(
114135
supportsCrashReporting: Boolean = false,
115136
): List<SettingsCategoryItem> {
116137
return listOfNotNull(
117-
SettingsCategoryItem(
118-
icon = Res.drawable.notifications,
119-
title = Res.string.Settings_Notifications_Label,
120-
route = PreferenceCategoryKey.NOTIFICATIONS,
121-
settings = listOf(
122-
SettingsItem(
123-
title = Res.string.Settings_Notifications_Enabled,
124-
key = SettingsKey.NOTIFICATIONS_ENABLED,
125-
type = PreferenceItemType.SWITCH,
126-
),
127-
),
128-
footerContent = {
129-
SettingsDescription(
130-
Res.string.Modal_EnableNotifications_Paragraph,
131-
)
132-
},
133-
),
138+
createNotificationsSettings().takeIf { supportsNotificationSettings },
134139
SettingsCategoryItem(
135140
icon = Res.drawable.ic_settings,
136141
title = Res.string.Settings_TestOptions_Label,

composeApp/src/commonMain/kotlin/org/ooni/probe/shared/PlatformInfo.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ data class PlatformInfo(
77
val osVersion: String,
88
val model: String,
99
val needsToRequestNotificationsPermission: Boolean,
10+
val supportsNotificationSettings: Boolean = true,
1011
val knownBatteryState: Boolean = true,
1112
val sentryDsn: String,
1213
) {

composeApp/src/desktopMain/kotlin/org/ooni/probe/BuildDependencies.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ private fun buildPlatformInfo() =
5454
osVersion = "1.0",
5555
model = "model",
5656
needsToRequestNotificationsPermission = false,
57+
supportsNotificationSettings = false,
5758
knownBatteryState = false,
5859
sentryDsn = "",
5960
)

0 commit comments

Comments
 (0)