Skip to content

Commit

Permalink
v1.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
sosauce committed Aug 12, 2024
1 parent 0ba7e2f commit 7c385fe
Show file tree
Hide file tree
Showing 24 changed files with 167 additions and 146 deletions.
Empty file.
8 changes: 4 additions & 4 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ plugins {

android {
namespace = "com.sosauce.cutemusic"
compileSdk = 34
compileSdk = 35

defaultConfig {
applicationId = "com.sosauce.cutemusic"
minSdk = 26
targetSdk = 34
versionCode = 7
versionName = "1.4.0"
targetSdk = 35
versionCode = 8
versionName = "1.4.1"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down
Binary file modified app/release/baselineProfiles/0/app-release.dm
Binary file not shown.
Binary file modified app/release/baselineProfiles/1/app-release.dm
Binary file not shown.
4 changes: 2 additions & 2 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 7,
"versionName": "1.4.0",
"versionCode": 8,
"versionName": "1.4.1",
"outputFile": "app-release.apk"
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ sealed interface PlayerActions {
data object SeekToNextMusic : PlayerActions
data object SeekToPreviousMusic : PlayerActions
data class SeekTo(val position: Long) : PlayerActions
data class RewindTo(val position: Long) : PlayerActions
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@ data class Music(
val folder: String,
val uri: Uri,
val albumId: Long,
var art: Bitmap? = null
var art: Bitmap? = null,
val bitrate: Long,
val size: Long,
val mimeType: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ class MediaStoreHelper(
MediaStore.Audio.Media.TITLE,
MediaStore.Audio.Media.ARTIST,
MediaStore.Audio.Media.ALBUM_ID,
MediaStore.Audio.Media.DATA
MediaStore.Audio.Media.DATA,
MediaStore.Audio.Media.BITRATE,
MediaStore.Audio.Media.SIZE,
MediaStore.Audio.Media.MIME_TYPE,
)

context.contentResolver.query(
Expand All @@ -38,6 +41,9 @@ class MediaStoreHelper(
val artistColumn = cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.ARTIST)
val albumIdColumn = cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.ALBUM_ID)
val folderColumn = cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.DATA)
val bitrateColumn = cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.BITRATE)
val sizeColumn = cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.SIZE)
val mimeTypeColumn = cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.MIME_TYPE)

while (cursor.moveToNext()) {
val id = cursor.getLong(idColumn)
Expand All @@ -46,6 +52,9 @@ class MediaStoreHelper(
val albumId = cursor.getLong(albumIdColumn)
val filePath = cursor.getString(folderColumn)
val folder = filePath.substring(0, filePath.lastIndexOf('/'))
val bitrate = cursor.getLong(bitrateColumn)
val size = cursor.getLong(sizeColumn)
val mimeType = cursor.getString(mimeTypeColumn)
val uri = ContentUris.withAppendedId(
MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
id
Expand All @@ -57,7 +66,10 @@ class MediaStoreHelper(
artist = artist,
uri = uri,
albumId = albumId,
folder = folder
folder = folder,
bitrate = bitrate,
size = size,
mimeType = mimeType
))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fun Long.formatBinarySize(): String {
)
} MB"

else -> "Bigger than 1024 TB"
else -> "Too Big!"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ fun AlbumDetailsLandscape(
Spacer(modifier = Modifier.width(5.dp))
LazyColumn {
items(albumSongs, key = { it.id }) { music ->
AlbumSong(music = music, onShortClick = { viewModel.playAtIndex(music.uri) })
AlbumSong(music = music, onShortClick = { viewModel.itemClicked(music.uri) })
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package com.sosauce.cutemusic.ui.screens.album

import android.content.res.Configuration
import android.graphics.Bitmap
import android.net.Uri
import androidx.compose.animation.ExperimentalSharedTransitionApi
import androidx.compose.foundation.clickable
Expand All @@ -17,6 +18,7 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.shape.RoundedCornerShape
Expand All @@ -27,12 +29,15 @@ import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.ModalBottomSheet
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.rememberModalBottomSheetState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
Expand Down Expand Up @@ -156,7 +161,7 @@ private fun AlbumDetailsContent(
HorizontalDivider()
LazyColumn {
itemsIndexed(albumSongs) { _, music ->
AlbumSong(music = music, onShortClick = { viewModel.playAtIndex(music.uri) })
AlbumSong(music = music, onShortClick = { viewModel.itemClicked(music.uri) })
}
}
}
Expand All @@ -174,6 +179,15 @@ fun AlbumSong(

val sheetState = rememberModalBottomSheetState(false)
var isSheetOpen by remember { mutableStateOf(false) }
val context = LocalContext.current
var art: Bitmap? by remember { mutableStateOf(null) }

LaunchedEffect(music.uri) {
art = ImageUtils.getMusicArt(context, music.uri)
}
DisposableEffect(music.uri) {
onDispose { art?.recycle() }
}

if (isSheetOpen) {
ModalBottomSheet(
Expand All @@ -193,8 +207,18 @@ fun AlbumSong(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween
) {

Row(verticalAlignment = Alignment.CenterVertically) {
AsyncImage(
model = ImageUtils.imageRequester(
img = art,
context = context
),
contentDescription = "Artwork",
modifier = Modifier
.padding(start = 10.dp)
.size(45.dp),
contentScale = ContentScale.Crop,
)
Column(
modifier = Modifier.padding(15.dp)
) {
Expand All @@ -205,7 +229,8 @@ fun AlbumSong(
)
Text(
text = music.artist,
fontFamily = GlobalFont
fontFamily = GlobalFont,
color = MaterialTheme.colorScheme.onBackground.copy(0.85f)
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,16 @@ fun AlbumCard(
)
Text(
text = album.artist,
fontFamily = GlobalFont
fontFamily = GlobalFont,
color = MaterialTheme.colorScheme.onBackground.copy(0.85f)
)
}
}
}
}

// Previews are commented by default, un-comment to use them, re-comment them when finalizing your changes for a PR

//@Preview
//@Composable
//private fun AlbumScreenPreview() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ private fun AlbumCardLandscape(
)
Text(
text = album.artist,
fontFamily = GlobalFont
fontFamily = GlobalFont,
color = MaterialTheme.colorScheme.onBackground.copy(0.85f)
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ fun ArtistDetails(
onNavigateUp = navController::navigateUp,
artistAlbums = artistAlbums,
artistSongs = artistSongs,
onClickPlay = { viewModel.playAtIndex(it) },
onClickPlay = { viewModel.itemClicked(it) },
onNavigate = { navController.navigate(it) },
chargePVMAlbumSongs = { postViewModel.albumSongs(it) },
artist = artist
Expand Down Expand Up @@ -143,7 +143,7 @@ fun ArtistDetails(
items(artistSongs) {music ->
ArtistMusicList(
music = music,
onShortClick = { viewModel.playAtIndex(music.uri) },
onShortClick = { viewModel.itemClicked(music.uri) },
onSelected = { /*TODO*/ },
isSelected = false
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ fun ArtistsScreen(
viewModel.selectedItem = index
launchSingleTop = true
}
}
},
chargePVMLists = {
postViewModel.artistSongs(it)
postViewModel.artistAlbums(it)
},
onNavigate = { navController.navigate(it) }
)
} else {
ArtistsScreenContent(
Expand Down Expand Up @@ -140,7 +145,7 @@ private fun ArtistsScreenContent(


@Composable
private fun ArtistInfoList(
fun ArtistInfoList(
artist: Artist,
onClick: () -> Unit
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.grid.GridCells
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
import androidx.compose.foundation.lazy.grid.items
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
Expand All @@ -31,6 +33,7 @@ import com.sosauce.cutemusic.R
import com.sosauce.cutemusic.domain.model.Artist
import com.sosauce.cutemusic.ui.customs.textCutter
import com.sosauce.cutemusic.ui.navigation.Screen
import com.sosauce.cutemusic.ui.screens.main.MusicListItem
import com.sosauce.cutemusic.ui.shared_components.CuteNavigationRail
import com.sosauce.cutemusic.ui.shared_components.NavigationItem
import com.sosauce.cutemusic.ui.shared_components.PostViewModel
Expand All @@ -44,6 +47,8 @@ fun ArtistsScreenLandscape(
postViewModel: PostViewModel,
bottomBarIndex: Int,
onBottomBarNavigation: (Int, NavigationItem) -> Unit,
chargePVMLists: (name: String) -> Unit,
onNavigate: (Screen) -> Unit
) {

Scaffold { values ->
Expand All @@ -65,22 +70,18 @@ fun ArtistsScreenLandscape(

}
} else {
LazyVerticalGrid(
columns = GridCells.Fixed(3),
LazyColumn(
modifier = Modifier
.fillMaxSize()
.fillMaxWidth()
.padding(values)
.padding(start = 80.dp)
.padding(start = 80.dp),
verticalArrangement = Arrangement.Top
) {
items(items = artists, key = { it.id }) {artist ->
ArtistCardLandscape(
artist = artist,
onClick = {
postViewModel.artistSongs(artist.name)
postViewModel.artistAlbums(artist.name)
navController.navigate(Screen.ArtistsDetails(id = artist.id))
},
)
items(artists, key = { it.id }) { artist ->
ArtistInfoList(artist) {
chargePVMLists(artist.name)
onNavigate(Screen.ArtistsDetails(artist.id))
}
}
}
}
Expand All @@ -92,48 +93,3 @@ fun ArtistsScreenLandscape(
}

}

@Composable
private fun ArtistCardLandscape(
artist: Artist,
onClick: () -> Unit,
) {
val context = LocalContext.current
Card(
colors = CardDefaults.cardColors(MaterialTheme.colorScheme.surfaceContainer),
modifier = Modifier
.padding(horizontal = 5.dp, vertical = 5.dp)
.clip(RoundedCornerShape(15.dp))
.clickable { onClick() },
) {
Column(
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier
.fillMaxWidth()
) {
AsyncImage(
model = ImageUtils.imageRequester(
img = R.drawable.artist,
context = context
),
contentDescription = "Artwork",
modifier = Modifier
.size(215.dp)
.padding(top = 7.dp)
.clip(RoundedCornerShape(15)),
contentScale = ContentScale.Crop
)
Column(
modifier = Modifier.padding(15.dp),
horizontalAlignment = Alignment.CenterHorizontally
) {
Text(
text = textCutter(artist.name, 15),
fontFamily = GlobalFont,
maxLines = 1
)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ fun MainScreen(
isCurrentlyPlaying = viewModel.isCurrentlyPlaying,
onHandlePlayerActions = viewModel::handlePlayerActions,
onShortClick = {
viewModel.populateLists()
viewModel.playAtIndex(it)
viewModel.itemClicked(it)
},
onBottomBarNavigation = { index, item ->
navController.navigate(item.navigateTo) {
Expand Down
Loading

0 comments on commit 7c385fe

Please sign in to comment.