Skip to content

Commit

Permalink
Player layout improvements:
Browse files Browse the repository at this point in the history
* Added link to album page
* The artist and album links are now buttons
  • Loading branch information
fast4x committed Oct 8, 2023
1 parent 74241bc commit 8846609
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 29 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ android {
minSdk = 21
targetSdk = 33
versionCode = 4
versionName = "0.6.2"
versionName = "0.6.3"
}

splits {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package it.vfsfitvnm.vimusic.ui.screens.player

import android.util.Log
import androidx.compose.animation.animateContentSize
import androidx.compose.animation.core.LinearEasing
import androidx.compose.animation.core.animateDp
import androidx.compose.animation.core.tween
Expand All @@ -22,6 +20,7 @@ import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.BasicText
import androidx.compose.foundation.text.ClickableText
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
Expand All @@ -34,6 +33,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.media3.common.C
Expand All @@ -45,6 +45,8 @@ import it.vfsfitvnm.vimusic.models.Song
import it.vfsfitvnm.vimusic.query
import it.vfsfitvnm.vimusic.ui.components.SeekBar
import it.vfsfitvnm.vimusic.ui.components.themed.IconButton
import it.vfsfitvnm.vimusic.ui.screens.albumRoute
import it.vfsfitvnm.vimusic.ui.screens.artistRoute
import it.vfsfitvnm.vimusic.ui.styling.LocalAppearance
import it.vfsfitvnm.vimusic.ui.styling.favoritesIcon
import it.vfsfitvnm.vimusic.utils.bold
Expand All @@ -56,17 +58,7 @@ import it.vfsfitvnm.vimusic.utils.secondary
import it.vfsfitvnm.vimusic.utils.semiBold
import it.vfsfitvnm.vimusic.utils.trackLoopEnabledKey
import kotlinx.coroutines.flow.distinctUntilChanged
import androidx.compose.foundation.text.ClickableText
import androidx.compose.ui.draw.blur
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.semantics.Role.Companion.Button
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.withStyle
import it.vfsfitvnm.compose.reordering.animateItemPlacement
import it.vfsfitvnm.vimusic.models.Info
import it.vfsfitvnm.vimusic.ui.screens.artistRoute
import okio.utf8Size

@OptIn(ExperimentalFoundationApi::class)
@Composable
Expand All @@ -75,6 +67,7 @@ fun Controls(
title: String?,
artist: String?,
artistIds: ArrayList<String>?,
albumId: String?,
shouldBePlaying: Boolean,
position: Long,
duration: Long,
Expand All @@ -92,6 +85,7 @@ fun Controls(
}

val onGoToArtist = artistRoute::global
val onGoToAlbum = albumRoute::global

var likedAt by rememberSaveable {
mutableStateOf<Long?>(null)
Expand Down Expand Up @@ -121,7 +115,7 @@ fun Controls(
modifier = Modifier
.weight(1f)
)
*/
BasicText(
text = "Title: " + title ?: "",
style = typography.l.bold,
Expand All @@ -147,6 +141,75 @@ fun Controls(
}
)
Spacer(
modifier = Modifier
.weight(0.4f)
)
*/
Row(
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier.fillMaxWidth()
) {
IconButton(
icon = R.drawable.disc,
color = if (albumId == null) colorPalette.textDisabled else colorPalette.text,
enabled = if (albumId == null) false else true,
onClick = {
onGoToAlbum(albumId)
},
modifier = Modifier
.size(24.dp)
)

Spacer(
modifier = Modifier
.width(8.dp)
)

BasicText(
text = AnnotatedString(title ?: ""),
style = typography.l.semiBold,
maxLines = 1,
overflow = TextOverflow.Ellipsis
)

}

Spacer(
modifier = Modifier
.weight(0.4f)
)

Row(
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier.fillMaxWidth()
) {
IconButton(
icon = R.drawable.person,
color = if (artistIds?.size == 0) colorPalette.textDisabled else colorPalette.text,
enabled = if (artistIds?.size == 0) false else true,
onClick = {
onGoToArtist(artistIds?.get(0).toString())
},
modifier = Modifier
.size(24.dp)
)

Spacer(
modifier = Modifier
.width(8.dp)
)

BasicText(
text = AnnotatedString(artist ?: ""),
style = typography.l.secondary,
maxLines = 1,
overflow = TextOverflow.Ellipsis

)

}

Spacer(
modifier = Modifier
.weight(2f)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,23 +160,32 @@ fun Player(
}
}

var artistIds = arrayListOf<String>()
//var albumIds = arrayListOf<String>()
//val ExistIdsExtras = mediaItem.mediaMetadata.extras?.getStringArrayList("artistIds")?.size.toString()

artistsInfo?.forEach { (id) -> artistIds = arrayListOf(id) }
if (artistsInfo == null) mediaItem.mediaMetadata.extras?.getStringArray("artistIds")?.toCollection(artistIds)

/* TODO Album name */
// albumInfo?.forEach { (id) -> albumIds = arrayListOf(id) }
// if (albumInfo == null) mediaItem.mediaMetadata.extras?.getStringArray("artistIds")?.toCollection(albumIds)
val ExistIdsExtras = mediaItem.mediaMetadata.extras?.getStringArrayList("artistIds")?.size.toString()
val ExistAlbumIdExtras = mediaItem.mediaMetadata.extras?.getString("albumId")?.toString()

var albumId = albumInfo?.id
if (albumId == null) albumId = ExistAlbumIdExtras

//Log.d("mediaItem_play_mediaId",mediaItem.mediaId)
//Log.d("mediaItem_play_extra?",ExistIdsExtras.toString())
//Log.d("mediaItem_play_extras",mediaItem.mediaMetadata.extras.toString())
//Log.d("mediaItem_play_artinfo",artistsInfo.toString())
//Log.d("mediaItem_play_artid",artistIds.toString())
//Log.d("mediaItem_play_albinfo",albumInfo.toString())
var artistIds = arrayListOf<String>()
artistsInfo?.forEach { (id) -> artistIds = arrayListOf(id) }
if (ExistIdsExtras.equals(0).not()) mediaItem.mediaMetadata.extras?.getStringArrayList("artistIds")?.toCollection(artistIds)

/*
//Log.d("mediaItem_pl_mediaId",mediaItem.mediaId)
Log.d("mediaItem_pl","--- START LOG ARTIST ---")
Log.d("mediaItem_pl_extraArt?",ExistIdsExtras.toString())
Log.d("mediaItem_pl_extrasArt",mediaItem.mediaMetadata.extras?.getStringArrayList("artistIds").toString())
Log.d("mediaItem_pl_artinfo",artistsInfo.toString())
Log.d("mediaItem_pl_artId",artistIds.toString())
Log.d("mediaItem_pl","--- START LOG ALBUM ---")
Log.d("mediaItem_pl_extraAlb?",ExistAlbumIdExtras.toString())
//Log.d("mediaItem_pl_extras",mediaItem.mediaMetadata.extras.toString())
Log.d("mediaItem_pl_albinfo",albumInfo.toString())
Log.d("mediaItem_pl_albId",albumId.toString())
Log.d("mediaItem_pl","--- END LOG ---")
*/

OnGlobalRoute {
layoutState.collapseSoft()
Expand Down Expand Up @@ -336,6 +345,7 @@ fun Player(
title = mediaItem.mediaMetadata.title?.toString(),
artist = mediaItem.mediaMetadata.artist?.toString(),
artistIds = artistIds,
albumId = albumId,
shouldBePlaying = shouldBePlaying,
position = positionAndDuration.first,
duration = positionAndDuration.second,
Expand Down

0 comments on commit 8846609

Please sign in to comment.