Skip to content

Commit

Permalink
Merge pull request #28 from realOxy/m3
Browse files Browse the repository at this point in the history
fix: replace some unstable parameters.
upgrade: 1.13.0-alpha02 (75)
  • Loading branch information
oxyroid authored Nov 19, 2023
2 parents 4f04ca0 + 37c905f commit f4e04f5
Show file tree
Hide file tree
Showing 14 changed files with 100 additions and 138 deletions.
4 changes: 2 additions & 2 deletions androidApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ android {
applicationId = "com.m3u.androidApp"
minSdk = 26
targetSdk = 33
versionCode = 74
versionName = "1.13.0-alpha01"
versionCode = 75
versionName = "1.13.0-alpha02"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArguments["androidx.benchmark.profiling.mode"] = "MethodTracing"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fun AppNavigation(
) {
Content(
navigate = navigate,
destinations = destinations,
destinationsFactory = { destinations },
rootDestination = rootDestination,
fob = fob,
selectedColor = selectedColor,
Expand All @@ -69,7 +69,7 @@ fun AppNavigation(
) {
Content(
navigate = navigate,
destinations = destinations,
destinationsFactory = { destinations },
rootDestination = rootDestination,
fob = fob,
selectedColor = selectedColor,
Expand All @@ -85,7 +85,7 @@ fun AppNavigation(
@Composable
private fun Content(
navigate: Navigate,
destinations: List<Destination.Root>,
destinationsFactory: () -> List<Destination.Root>,
rootDestination: Destination.Root?,
fob: Fob?,
selectedColor: Color,
Expand All @@ -94,6 +94,7 @@ private fun Content(
) {
val relation = fob?.rootDestination
val actualActiveDestination = rootDestination ?: relation
val destinations = destinationsFactory()
destinations.forEach { default ->
val fobbed = default == relation
val selected = default == actualActiveDestination
Expand Down
27 changes: 4 additions & 23 deletions features/live/src/main/java/com/m3u/features/live/LiveScreen.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.m3u.features.live

import android.graphics.Rect
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.pager.VerticalPager
Expand All @@ -20,8 +19,6 @@ import androidx.compose.ui.util.lerp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.media3.common.PlaybackException
import androidx.media3.common.Player
import com.m3u.core.annotation.ClipMode
import com.m3u.core.unspecified.UBoolean
import com.m3u.core.unspecified.unspecifiable
Expand Down Expand Up @@ -114,13 +111,9 @@ internal fun LiveRoute(
onFavourite = { viewModel.onEvent(LiveEvent.OnFavourite(it)) },
onBackPressed = onBackPressed,
maskState = maskState,
player = playerState.player,
playState = playerState.playState,
videoSize = playerState.videoSize,
playerError = playerState.playerError,
playerState = playerState,
onInstallMedia = { viewModel.onEvent(LiveEvent.InstallMedia(it)) },
onUninstallMedia = { viewModel.onEvent(LiveEvent.UninstallMedia) },
muted = playerState.muted,
onMuted = { viewModel.onEvent(LiveEvent.OnMuted) },
modifier = modifier
)
Expand All @@ -138,13 +131,9 @@ private fun LiveScreen(
onBackPressed: () -> Unit,
maskState: MaskState,
experimentalMode: Boolean,
player: Player?,
playState: @Player.State Int,
videoSize: Rect,
playerError: PlaybackException?,
playerState: LiveState.PlayerState,
onInstallMedia: (String) -> Unit,
onUninstallMedia: () -> Unit,
muted: Boolean,
onMuted: () -> Unit,
modifier: Modifier = Modifier,
) {
Expand All @@ -155,10 +144,7 @@ private fun LiveScreen(
val url = live?.url.orEmpty()
val favourite = live?.favourite ?: false
LiveFragment(
player = player,
playState = playState,
videoSize = videoSize,
playerError = playerError,
playerState = playerState,
title = init.live?.title ?: "--",
url = url,
cover = init.live?.cover.orEmpty(),
Expand All @@ -175,7 +161,6 @@ private fun LiveScreen(
onBackPressed = onBackPressed,
onInstallMedia = onInstallMedia,
onUninstallMedia = onUninstallMedia,
muted = muted,
onMuted = onMuted,
modifier = modifier
.fillMaxSize()
Expand All @@ -197,10 +182,7 @@ private fun LiveScreen(
val url = live.url
val favourite = live.favourite
LiveFragment(
player = player,
playState = playState,
videoSize = videoSize,
playerError = playerError,
playerState = playerState,
title = live.title,
feedTitle = init.feed?.title.orEmpty(),
url = url,
Expand All @@ -217,7 +199,6 @@ private fun LiveScreen(
onBackPressed = onBackPressed,
onInstallMedia = onInstallMedia,
onUninstallMedia = onUninstallMedia,
muted = muted,
onMuted = onMuted,
modifier = Modifier
.fillMaxSize()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.m3u.features.live

import android.graphics.Rect
import androidx.compose.runtime.Immutable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.setValue
import androidx.media3.common.PlaybackException
Expand Down Expand Up @@ -32,6 +33,7 @@ data class LiveState(
val initialIndex: Int = 0
) : Init()

@Immutable
data class PlayerState(
val playState: @Player.State Int = Player.STATE_IDLE,
val videoSize: Rect = Rect(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import androidx.compose.material3.MaterialTheme

@Composable
internal fun DlnaDeviceItem(
device: Device<*, *, *>,
deviceFactory: () -> Device<*, *, *>,
connected: Boolean,
requestConnection: () -> Unit,
loseConnection: () -> Unit,
Expand All @@ -29,7 +29,7 @@ internal fun DlnaDeviceItem(

ListItem(
headlineContent = {
Text(device.displayString)
Text(deviceFactory().displayString)
},
trailingContent = {
Crossfade(connected, label = "icon") { connected ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ fun DlnaDevicesBottomSheet(
) {
items(devices ?: emptyList()) { device ->
DlnaDeviceItem(
device = device,
deviceFactory = { device },
connected = device == connected,
requestConnection = { connectDlnaDevice(device) },
loseConnection = { disconnectDlnaDevice(device) }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.m3u.features.live.fragments

import android.graphics.Rect
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.foundation.basicMarquee
import androidx.compose.foundation.layout.Arrangement
Expand Down Expand Up @@ -38,6 +37,7 @@ import androidx.media3.common.PlaybackException
import androidx.media3.common.Player
import com.m3u.core.annotation.ClipMode
import com.m3u.core.util.basic.isNotEmpty
import com.m3u.features.live.LiveState
import com.m3u.features.live.components.CoverPlaceholder
import com.m3u.features.live.components.LiveMask
import com.m3u.i18n.R.string
Expand All @@ -53,10 +53,7 @@ import com.m3u.ui.rememberPlayerState

@Composable
internal fun LiveFragment(
player: Player?,
playState: @Player.State Int,
videoSize: Rect,
playerError: PlaybackException?,
playerState: LiveState.PlayerState,
title: String,
feedTitle: String,
url: String,
Expand All @@ -73,7 +70,6 @@ internal fun LiveFragment(
onBackPressed: () -> Unit,
onInstallMedia: (String) -> Unit,
onUninstallMedia: () -> Unit,
muted: Boolean,
onMuted: () -> Unit,
modifier: Modifier = Modifier
) {
Expand All @@ -85,7 +81,7 @@ internal fun LiveFragment(
Box(modifier) {
val helper = LocalHelper.current
val state = rememberPlayerState(
player = player,
player = playerState.player,
url = url,
clipMode = clipMode,
onInstallMedia = onInstallMedia,
Expand All @@ -97,7 +93,7 @@ internal fun LiveFragment(
modifier = Modifier.fillMaxSize()
)

val shouldShowPlaceholder = cover.isNotEmpty() && videoSize.isEmpty
val shouldShowPlaceholder = cover.isNotEmpty() && playerState.videoSize.isEmpty

CoverPlaceholder(
visible = shouldShowPlaceholder,
Expand All @@ -117,12 +113,12 @@ internal fun LiveFragment(
Spacer(modifier = Modifier.weight(1f))
MaskButton(
state = maskState,
icon = if (muted) Icons.AutoMirrored.Rounded.VolumeOff
icon = if (playerState.muted) Icons.AutoMirrored.Rounded.VolumeOff
else Icons.AutoMirrored.Rounded.VolumeUp,
onClick = onMuted,
contentDescription = if (muted) stringResource(string.feat_live_tooltip_unmute)
contentDescription = if (playerState.muted) stringResource(string.feat_live_tooltip_unmute)
else stringResource(string.feat_live_tooltip_mute),
tint = if (muted) theme.error else Color.Unspecified
tint = if (playerState.muted) theme.error else Color.Unspecified
)
MaskButton(
state = maskState,
Expand All @@ -144,7 +140,7 @@ internal fun LiveFragment(
contentDescription = if (recording) stringResource(string.feat_live_tooltip_unrecord)
else stringResource(string.feat_live_tooltip_record)
)
if (playState != Player.STATE_IDLE) {
if (playerState.playState != Player.STATE_IDLE) {
MaskButton(
state = maskState,
icon = Icons.Rounded.Cast,
Expand All @@ -153,12 +149,12 @@ internal fun LiveFragment(
)
}
}
if (videoSize.isNotEmpty) {
if (playerState.videoSize.isNotEmpty) {
MaskButton(
state = maskState,
icon = Icons.Rounded.PictureInPicture,
onClick = {
helper.enterPipMode(videoSize)
helper.enterPipMode(playerState.videoSize)
maskState.sleep()
},
contentDescription = stringResource(string.feat_live_tooltip_enter_pip_mode)
Expand Down Expand Up @@ -205,9 +201,9 @@ internal fun LiveFragment(
modifier = Modifier.basicMarquee()
)
val playStateDisplayText =
LiveFragmentDefaults.playStateDisplayText(playState)
LiveFragmentDefaults.playStateDisplayText(playerState.playState)
val exceptionDisplayText =
LiveFragmentDefaults.playbackExceptionDisplayText(playerError)
LiveFragmentDefaults.playbackExceptionDisplayText(playerState.playerError)
if (playStateDisplayText.isNotEmpty() || exceptionDisplayText.isNotEmpty()) {
Spacer(
modifier = Modifier.height(spacing.small)
Expand Down Expand Up @@ -238,8 +234,8 @@ internal fun LiveFragment(
}
}
)
LaunchedEffect(playerError) {
if (playerError != null) {
LaunchedEffect(playerState.playerError) {
if (playerState.playerError != null) {
maskState.active()
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.m3u.features.main.components

import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.background
import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.layout.Box
Expand All @@ -9,24 +8,22 @@ import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.rounded.DriveFileMove
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.OutlinedCard
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import com.m3u.material.components.OuterRow
import com.m3u.material.ktx.animateColor
import com.m3u.material.ktx.animateDp
import com.m3u.material.ktx.animated
import com.m3u.material.model.LocalSpacing

Expand All @@ -41,22 +38,11 @@ internal fun FeedItem(
) {
val spacing = LocalSpacing.current
val theme = MaterialTheme.colorScheme
val actualBackgroundColor by theme.surface.animated("FeedItemBackground")
val actualContentColor by theme.onSurface.animated("FeedItemContent")
val actualBorderDp by animateDp("FeedItemBorder") {
if (local) spacing.extraSmall
else spacing.none
}
val actualBorderColor by animateColor("FeedItemBorderColor") {
if (local) Color.Black.copy(alpha = 0.12f)
else Color.Transparent
}
Surface(

OutlinedCard(
shape = RoundedCornerShape(spacing.medium),
color = actualBackgroundColor,
contentColor = actualContentColor,
tonalElevation = spacing.none,
border = BorderStroke(actualBorderDp, actualBorderColor)
border = CardDefaults.outlinedCardBorder(local)
) {
OuterRow(
modifier = modifier
Expand Down
Loading

0 comments on commit f4e04f5

Please sign in to comment.