This commit is contained in:
Benoit Marty 2024-12-12 17:27:34 +01:00 committed by Benoit Marty
parent 1424df59f7
commit 1a2fa09737

View file

@ -14,7 +14,6 @@ import android.widget.FrameLayout
import androidx.compose.foundation.background import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
@ -69,8 +68,8 @@ import io.element.android.libraries.mediaviewer.impl.local.LocalMediaViewState
import io.element.android.libraries.mediaviewer.impl.local.PlayableState import io.element.android.libraries.mediaviewer.impl.local.PlayableState
import io.element.android.libraries.mediaviewer.impl.local.player.MediaPlayerControllerState import io.element.android.libraries.mediaviewer.impl.local.player.MediaPlayerControllerState
import io.element.android.libraries.mediaviewer.impl.local.player.MediaPlayerControllerView import io.element.android.libraries.mediaviewer.impl.local.player.MediaPlayerControllerView
import io.element.android.libraries.mediaviewer.impl.local.player.seekToEnsurePlaying
import io.element.android.libraries.mediaviewer.impl.local.player.rememberExoPlayer import io.element.android.libraries.mediaviewer.impl.local.player.rememberExoPlayer
import io.element.android.libraries.mediaviewer.impl.local.player.seekToEnsurePlaying
import io.element.android.libraries.mediaviewer.impl.local.player.togglePlay import io.element.android.libraries.mediaviewer.impl.local.player.togglePlay
import io.element.android.libraries.mediaviewer.impl.local.rememberLocalMediaViewState import io.element.android.libraries.mediaviewer.impl.local.rememberLocalMediaViewState
import kotlinx.collections.immutable.toPersistentList import kotlinx.collections.immutable.toPersistentList
@ -270,6 +269,7 @@ private fun ExoPlayerMediaAudioView(
if (waveform == null) { if (waveform == null) {
// Display the info below the player // Display the info below the player
AudioInfoView( AudioInfoView(
modifier = Modifier.padding(horizontal = 16.dp),
info = info, info = info,
metadata = metadata, metadata = metadata,
) )
@ -308,40 +308,46 @@ private fun ExoPlayerMediaAudioView(
} }
@Composable @Composable
fun ColumnScope.AudioInfoView( private fun AudioInfoView(
info: MediaInfo?, info: MediaInfo?,
metadata: MediaMetadata?, metadata: MediaMetadata?,
modifier: Modifier = Modifier,
) { ) {
// Render the info about the file and from the metadata Column(
val metaDataInfo = metadata.buildInfo() modifier = modifier.fillMaxWidth(),
if (metaDataInfo.isNotEmpty()) { horizontalAlignment = Alignment.CenterHorizontally,
Spacer(modifier = Modifier.height(16.dp)) ) {
Text( // Render the info about the file and from the metadata
text = metaDataInfo, val metaDataInfo = metadata.buildInfo()
style = ElementTheme.typography.fontBodyMdRegular, if (metaDataInfo.isNotEmpty()) {
maxLines = 1, Spacer(modifier = Modifier.height(16.dp))
overflow = TextOverflow.Ellipsis, Text(
color = MaterialTheme.colorScheme.primary text = metaDataInfo,
) style = ElementTheme.typography.fontBodyMdRegular,
} maxLines = 1,
if (info != null) { overflow = TextOverflow.Ellipsis,
Spacer(modifier = Modifier.height(24.dp)) color = MaterialTheme.colorScheme.primary
Text( )
text = info.filename, }
maxLines = 2, if (info != null) {
style = ElementTheme.typography.fontBodyLgRegular, Spacer(modifier = Modifier.height(24.dp))
overflow = TextOverflow.Ellipsis, Text(
textAlign = TextAlign.Center, text = info.filename,
color = MaterialTheme.colorScheme.primary maxLines = 2,
) style = ElementTheme.typography.fontBodyLgRegular,
Spacer(modifier = Modifier.height(4.dp)) overflow = TextOverflow.Ellipsis,
Text( textAlign = TextAlign.Center,
text = formatFileExtensionAndSize(info.fileExtension, info.formattedFileSize), color = MaterialTheme.colorScheme.primary
style = ElementTheme.typography.fontBodyMdRegular, )
maxLines = 1, Spacer(modifier = Modifier.height(4.dp))
overflow = TextOverflow.Ellipsis, Text(
color = MaterialTheme.colorScheme.primary text = formatFileExtensionAndSize(info.fileExtension, info.formattedFileSize),
) style = ElementTheme.typography.fontBodyMdRegular,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
color = MaterialTheme.colorScheme.primary
)
}
} }
} }