mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-10-10 01:22:43 +02:00
Adding content-sensitivity warnings for LiveStreams
This commit is contained in:
@@ -34,6 +34,7 @@ import androidx.compose.ui.unit.dp
|
|||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
import com.vitorpamplona.amethyst.R
|
import com.vitorpamplona.amethyst.R
|
||||||
import com.vitorpamplona.amethyst.model.Note
|
import com.vitorpamplona.amethyst.model.Note
|
||||||
|
import com.vitorpamplona.amethyst.service.model.EventInterface
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
||||||
import com.vitorpamplona.amethyst.ui.theme.ButtonBorder
|
import com.vitorpamplona.amethyst.ui.theme.ButtonBorder
|
||||||
|
|
||||||
@@ -43,7 +44,18 @@ fun SensitivityWarning(
|
|||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
content: @Composable () -> Unit
|
content: @Composable () -> Unit
|
||||||
) {
|
) {
|
||||||
val hasSensitiveContent = remember(note) { note.event?.isSensitive() ?: false }
|
note.event?.let {
|
||||||
|
SensitivityWarning(it, accountViewModel, content)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun SensitivityWarning(
|
||||||
|
event: EventInterface,
|
||||||
|
accountViewModel: AccountViewModel,
|
||||||
|
content: @Composable () -> Unit
|
||||||
|
) {
|
||||||
|
val hasSensitiveContent = remember(event) { event.isSensitive() ?: false }
|
||||||
|
|
||||||
if (hasSensitiveContent) {
|
if (hasSensitiveContent) {
|
||||||
SensitivityWarning(accountViewModel, content)
|
SensitivityWarning(accountViewModel, content)
|
||||||
|
@@ -56,6 +56,7 @@ import com.vitorpamplona.amethyst.service.model.LiveActivitiesEvent
|
|||||||
import com.vitorpamplona.amethyst.service.model.LiveActivitiesEvent.Companion.STATUS_ENDED
|
import com.vitorpamplona.amethyst.service.model.LiveActivitiesEvent.Companion.STATUS_ENDED
|
||||||
import com.vitorpamplona.amethyst.service.model.LiveActivitiesEvent.Companion.STATUS_LIVE
|
import com.vitorpamplona.amethyst.service.model.LiveActivitiesEvent.Companion.STATUS_LIVE
|
||||||
import com.vitorpamplona.amethyst.service.model.LiveActivitiesEvent.Companion.STATUS_PLANNED
|
import com.vitorpamplona.amethyst.service.model.LiveActivitiesEvent.Companion.STATUS_PLANNED
|
||||||
|
import com.vitorpamplona.amethyst.ui.components.SensitivityWarning
|
||||||
import com.vitorpamplona.amethyst.ui.screen.equalImmutableLists
|
import com.vitorpamplona.amethyst.ui.screen.equalImmutableLists
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.ChannelHeader
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.ChannelHeader
|
||||||
@@ -321,11 +322,16 @@ fun InnerChannelCardWithReactions(
|
|||||||
nav: (String) -> Unit
|
nav: (String) -> Unit
|
||||||
) {
|
) {
|
||||||
Column(StdPadding) {
|
Column(StdPadding) {
|
||||||
RenderNoteRow(
|
SensitivityWarning(
|
||||||
baseNote,
|
note = baseNote,
|
||||||
accountViewModel,
|
accountViewModel = accountViewModel
|
||||||
nav
|
) {
|
||||||
)
|
RenderNoteRow(
|
||||||
|
baseNote,
|
||||||
|
accountViewModel,
|
||||||
|
nav
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -99,6 +99,7 @@ import com.vitorpamplona.amethyst.ui.actions.UploadFromGallery
|
|||||||
import com.vitorpamplona.amethyst.ui.actions.toImmutableListOfLists
|
import com.vitorpamplona.amethyst.ui.actions.toImmutableListOfLists
|
||||||
import com.vitorpamplona.amethyst.ui.components.LoadNote
|
import com.vitorpamplona.amethyst.ui.components.LoadNote
|
||||||
import com.vitorpamplona.amethyst.ui.components.RobohashAsyncImageProxy
|
import com.vitorpamplona.amethyst.ui.components.RobohashAsyncImageProxy
|
||||||
|
import com.vitorpamplona.amethyst.ui.components.SensitivityWarning
|
||||||
import com.vitorpamplona.amethyst.ui.components.TranslatableRichTextViewer
|
import com.vitorpamplona.amethyst.ui.components.TranslatableRichTextViewer
|
||||||
import com.vitorpamplona.amethyst.ui.components.ZoomableContentView
|
import com.vitorpamplona.amethyst.ui.components.ZoomableContentView
|
||||||
import com.vitorpamplona.amethyst.ui.components.ZoomableUrlVideo
|
import com.vitorpamplona.amethyst.ui.components.ZoomableUrlVideo
|
||||||
@@ -580,7 +581,7 @@ fun ChannelHeader(
|
|||||||
) {
|
) {
|
||||||
Column(Modifier.fillMaxWidth()) {
|
Column(Modifier.fillMaxWidth()) {
|
||||||
if (showVideo && baseChannel is LiveActivitiesChannel) {
|
if (showVideo && baseChannel is LiveActivitiesChannel) {
|
||||||
ShowVideoStreaming(baseChannel)
|
ShowVideoStreaming(baseChannel, accountViewModel)
|
||||||
}
|
}
|
||||||
|
|
||||||
var expanded = remember { mutableStateOf(false) }
|
var expanded = remember { mutableStateOf(false) }
|
||||||
@@ -607,26 +608,34 @@ fun ChannelHeader(
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun ShowVideoStreaming(
|
private fun ShowVideoStreaming(
|
||||||
baseChannel: LiveActivitiesChannel
|
baseChannel: LiveActivitiesChannel,
|
||||||
|
accountViewModel: AccountViewModel
|
||||||
) {
|
) {
|
||||||
val streamingUrl by baseChannel.live.map {
|
baseChannel.info?.let {
|
||||||
val activity = it.channel as? LiveActivitiesChannel
|
SensitivityWarning(
|
||||||
activity?.info?.streaming()
|
event = it,
|
||||||
}.distinctUntilChanged().observeAsState(baseChannel.info?.streaming())
|
accountViewModel = accountViewModel
|
||||||
|
) {
|
||||||
|
val streamingUrl by baseChannel.live.map {
|
||||||
|
val activity = it.channel as? LiveActivitiesChannel
|
||||||
|
activity?.info?.streaming()
|
||||||
|
}.distinctUntilChanged().observeAsState(baseChannel.info?.streaming())
|
||||||
|
|
||||||
streamingUrl?.let {
|
streamingUrl?.let {
|
||||||
CheckIfUrlIsOnline(it) {
|
CheckIfUrlIsOnline(it) {
|
||||||
Row(
|
Row(
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
modifier = remember { Modifier.heightIn(max = 300.dp) }
|
modifier = remember { Modifier.heightIn(max = 300.dp) }
|
||||||
) {
|
) {
|
||||||
val zoomableUrlVideo = remember(it) {
|
val zoomableUrlVideo = remember(it) {
|
||||||
ZoomableUrlVideo(url = it)
|
ZoomableUrlVideo(url = it)
|
||||||
|
}
|
||||||
|
|
||||||
|
ZoomableContentView(
|
||||||
|
content = zoomableUrlVideo
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ZoomableContentView(
|
|
||||||
content = zoomableUrlVideo
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user