Skip to content
Draft
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 @@ -30,6 +30,7 @@ class ConferenceService(
private val storage: ApplicationStorage,
private val localNotificationService: LocalNotificationService,
private val scope: CoroutineScope,
private val flags: Flags,
logger: Logger,
) {
companion object {
Expand Down Expand Up @@ -317,6 +318,11 @@ class ConferenceService(
sessionId: SessionId,
title: String,
) {
if (!flags.supportsLocalNotifications) {
taggedLogger.log { "Local notifications are disabled, skipping schedule" }
return
}

val now = timeProvider.now()

val reminderTime = start - 5.minutes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import kotlinx.serialization.Serializable
@Serializable
data class Flags(
val enableBackOnMainScreens: Boolean = true,
val supportsNotifications: Boolean = true,
val supportsLocalNotifications: Boolean = true,
val supportsRemoteNotifications: Boolean = true,
val rippleEnabled: Boolean = true,
val redirectFeedbackToSessionPage: Boolean = false,
val hideKeyboardOnDrag: Boolean = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,8 @@ fun NavGraphBuilder.startScreens(
startDestination = StartPrivacyNoticeScreen
) {
composable<StartPrivacyNoticeScreen> {
val skipNotifications = LocalFlags.current.supportsNotifications.not()
val skipNotifications =
!(LocalFlags.current.supportsLocalNotifications || LocalFlags.current.supportsRemoteNotifications)
AppPrivacyNoticePrompt(
onRejectNotice = {
navController.navigate(if (skipNotifications) MainScreen else StartNotificationsScreen) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,17 @@ fun DeveloperMenuScreen(
)

SettingsItem(
title = "Supports notifications",
note = "Whether this device should display notification settings",
enabled = flags.supportsNotifications,
onToggle = { flags = flags.copy(supportsNotifications = it) }
title = "Supports local notifications",
note = "Whether this device can display local notification settings (such as sessions)",
enabled = flags.supportsLocalNotifications,
onToggle = { flags = flags.copy(supportsLocalNotifications = it) }
)

SettingsItem(
title = "Supports remote notifications",
note = "Whether this device can display remote notification settings (such as news)",
enabled = flags.supportsRemoteNotifications,
onToggle = { flags = flags.copy(supportsRemoteNotifications = it) }
)

SettingsItem(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import kotlinconfapp.shared.generated.resources.notifications_schedule_update_ti
import kotlinconfapp.shared.generated.resources.notifications_session_reminders_description
import kotlinconfapp.shared.generated.resources.notifications_session_reminders_title
import org.jetbrains.compose.resources.stringResource
import org.jetbrains.kotlinconf.Flags
import org.jetbrains.kotlinconf.LocalFlags
import org.jetbrains.kotlinconf.NotificationSettings
import org.jetbrains.kotlinconf.ui.components.SettingsItem

Expand All @@ -26,29 +28,34 @@ fun NotificationSettings(
Column(
verticalArrangement = Arrangement.spacedBy(8.dp)
) {
SettingsItem(
title = stringResource(Res.string.notifications_session_reminders_title),
enabled = notificationSettings.sessionReminders,
onToggle = { enabled -> onChangeSettings(notificationSettings.copy(sessionReminders = enabled)) },
note = stringResource(Res.string.notifications_session_reminders_description),
)
SettingsItem(
title = stringResource(Res.string.notifications_schedule_update_title),
enabled = notificationSettings.scheduleUpdates,
onToggle = { enabled -> onChangeSettings(notificationSettings.copy(scheduleUpdates = enabled)) },
note = stringResource(Res.string.notifications_schedule_update_description),
)
SettingsItem(
title = stringResource(Res.string.notifications_kotlinconf_news_title),
enabled = notificationSettings.kotlinConfNews,
onToggle = { enabled -> onChangeSettings(notificationSettings.copy(kotlinConfNews = enabled)) },
note = stringResource(Res.string.notifications_kotlinconf_news_description),
)
SettingsItem(
title = stringResource(Res.string.notifications_jetbrains_news_title),
enabled = notificationSettings.jetBrainsNews,
onToggle = { enabled -> onChangeSettings(notificationSettings.copy(jetBrainsNews = enabled)) },
note = stringResource(Res.string.notifications_jetbrains_news_description),
)
if (LocalFlags.current.supportsLocalNotifications) {
SettingsItem(
title = stringResource(Res.string.notifications_session_reminders_title),
enabled = notificationSettings.sessionReminders,
onToggle = { enabled -> onChangeSettings(notificationSettings.copy(sessionReminders = enabled)) },
note = stringResource(Res.string.notifications_session_reminders_description),
)
SettingsItem(
title = stringResource(Res.string.notifications_schedule_update_title),
enabled = notificationSettings.scheduleUpdates,
onToggle = { enabled -> onChangeSettings(notificationSettings.copy(scheduleUpdates = enabled)) },
note = stringResource(Res.string.notifications_schedule_update_description),
)
}

if (LocalFlags.current.supportsRemoteNotifications) {
SettingsItem(
title = stringResource(Res.string.notifications_kotlinconf_news_title),
enabled = notificationSettings.kotlinConfNews,
onToggle = { enabled -> onChangeSettings(notificationSettings.copy(kotlinConfNews = enabled)) },
note = stringResource(Res.string.notifications_kotlinconf_news_description),
)
SettingsItem(
title = stringResource(Res.string.notifications_jetbrains_news_title),
enabled = notificationSettings.jetBrainsNews,
onToggle = { enabled -> onChangeSettings(notificationSettings.copy(jetBrainsNews = enabled)) },
note = stringResource(Res.string.notifications_jetbrains_news_description),
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,15 @@ private fun SettingsScreenImpl(

Spacer(Modifier.height(24.dp))

if (LocalFlags.current.supportsNotifications) {
if (LocalFlags.current.supportsLocalNotifications || LocalFlags.current.supportsRemoteNotifications) {
val notificationSettings = viewModel.notificationSettings.collectAsStateWithLifecycle().value
if (notificationSettings != null) {
SectionHeading(stringResource(AppRes.string.settings_notifications_title))
NotificationSettings(
notificationSettings = notificationSettings,
onChangeSettings = { newSettings ->
viewModel.setNotificationSettings(newSettings)
}
},
)
}
}
Expand Down
3 changes: 2 additions & 1 deletion shared/src/jsMain/kotlin/org/jetbrains/kotlinconf/main.js.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ fun main() {
},
platformModule = platformModule,
flags = Flags(
supportsNotifications = supportsNotifications
supportsLocalNotifications = supportsNotifications,
supportsRemoteNotifications = false,
),
)

Expand Down
9 changes: 8 additions & 1 deletion shared/src/jvmMain/kotlin/org/jetbrains/kotlinconf/main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@ class JvmLogger : Logger {
}

fun main() {
initApp(JvmLogger(), platformModule, Flags(supportsNotifications = false))
initApp(
platformLogger = JvmLogger(),
platformModule = platformModule,
flags = Flags(
supportsLocalNotifications = true,
supportsRemoteNotifications = true,
)
)

System.setProperty("apple.awt.application.appearance", "system")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ private val jsJodaTz = JsJodaTimeZoneModule
fun main() {
initCoil()

val supportsNotifications = window["supportsNotifications"] as? Boolean ?: false
val supportsLocalNotifications = window["supportsNotifications"] as? Boolean ?: false
initApp(
platformLogger = object : Logger {
override fun log(tag: String, lazyMessage: () -> String) {
Expand All @@ -25,7 +25,8 @@ fun main() {
},
platformModule = platformModule,
flags = Flags(
supportsNotifications = supportsNotifications
supportsLocalNotifications = supportsLocalNotifications,
supportsRemoteNotifications = false,
),
)

Expand Down
Loading