address pr feedback

This commit is contained in:
Ida Delphine authored and Tobi committed 2026-11-23 10:03:51 +01:00
1 parent ca36f36ccc
commit 3f29c3ffc3
3 files changed
+22 -5

No files matched your search

@@ -7,13 +7,13 @@ package org.schabi.newpipe.settings
import android.content.Context
import android.content.Intent
import io.reactivex.rxjava3.schedulers.Schedulers
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.reactive.asFlow
import kotlinx.coroutines.rx3.await
import kotlinx.coroutines.withContext
import net.newpipe.app.model.ChannelNotification
import net.newpipe.app.platform.NotificationHost
import org.schabi.newpipe.App
@@ -75,9 +75,12 @@ class ComposeNotificationHost(private val context: Context) : NotificationHost {
override suspend fun setChannelNotificationsEnabled(channel: ChannelNotification, enabled: Boolean) {
val mode = if (enabled) NotificationMode.ENABLED else NotificationMode.DISABLED
try {
subscriptionManager.updateNotificationMode(channel.serviceId, channel.url, mode)
.subscribeOn(Schedulers.io())
.await()
withContext(Dispatchers.IO) {
val subscriptionTable = subscriptionManager.subscriptionTable()
val subscription = subscriptionTable.getSubscription(channel.id)
subscription.notificationMode = mode
subscriptionTable.update(subscription)
}
} catch (cancellation: CancellationException) {
throw cancellation
} catch (error: Exception) {
@@ -327,6 +327,7 @@
<string name="channels">Channels</string>
<string name="notifications_disabled">Notifications are disabled</string>
<string name="toggle_all">Toggle all</string>
<string name="channel_notifications_description">Select the channels for which you want to receive notifications about new streams</string>
<!-- Player notification -->
<string name="notification_scale_to_square_image_title">Crop thumbnail to 1:1 aspect ratio</string>
@@ -17,6 +17,7 @@ import androidx.compose.material3.Checkbox
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.ListItem
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
@@ -26,6 +27,7 @@ import androidx.compose.ui.semantics.Role
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.PreviewLightDark
import androidx.compose.ui.tooling.preview.PreviewWrapper
import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import net.newpipe.app.composable.TopAppBar
import net.newpipe.app.model.ChannelNotification
@@ -33,6 +35,7 @@ import net.newpipe.app.navigation.Navigator
import net.newpipe.app.preview.ThemePreviewProvider
import net.newpipe.app.viewmodel.settings.ChannelNotificationSettingsViewModel
import newpipe.shared.generated.resources.Res
import newpipe.shared.generated.resources.channel_notifications_description
import newpipe.shared.generated.resources.channels
import newpipe.shared.generated.resources.ic_checklist
import newpipe.shared.generated.resources.toggle_all
@@ -42,6 +45,7 @@ import org.koin.compose.koinInject
import org.koin.compose.viewmodel.koinViewModel
private const val CHANNEL_NAME_MAX_LINES = 2
private const val DESCRIPTION_KEY = "description"
@Composable
fun ChannelNotificationSettingsScreen(
@@ -87,6 +91,15 @@ fun ChannelNotificationSettingsScreenContent(
.padding(top = paddingValues.calculateTopPadding()),
contentPadding = WindowInsets.navigationBars.asPaddingValues()
) {
item(key = DESCRIPTION_KEY) {
Text(
text = stringResource(Res.string.channel_notifications_description),
modifier = Modifier.padding(16.dp),
color = MaterialTheme.colorScheme.onSurfaceVariant,
style = MaterialTheme.typography.bodyMedium
)
}
items(items = channels, key = { channel -> channel.id }) { channel ->
ListItem(
modifier = Modifier.toggleable(