Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into playlist
Browse files Browse the repository at this point in the history
  • Loading branch information
SuhasDissa authored Dec 2, 2023
2 parents 5775dfc + a73680a commit 40c893b
Show file tree
Hide file tree
Showing 37 changed files with 609 additions and 42 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,13 @@

## Installation


[<img src="https://fdroid.gitlab.io/artwork/badge/get-it-on.png"
alt="Get it on F-Droid"
height="80">](https://f-droid.org/packages/app.suhasdissa.vibeyou/)
[<img src="https://github.com/machiav3lli/oandbackupx/blob/034b226cea5c1b30eb4f6a6f313e4dadcbb0ece4/badge_github.png"
alt="Get it on GitHub"
height="80">](https://github.com/you-apps/VibeYou/releases/latest)
alt="Get it on GitHub"
height="80">](https://github.com/you-apps/VibeYou/releases/latest)

<!-- ---------- Contribution ---------- -->
## Feedback and contributions
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ android {
applicationId = "app.suhasdissa.vibeyou"
minSdk = 24
targetSdk = 34
versionCode = 1
versionName = "1.0"
versionCode = 2
versionName = "2.0"

ksp {
arg("room.schemaLocation", "$projectDir/schemas")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ data class Song(
val artistId: Long? = null,
val isLocal: Boolean = false,
val creationDate: Long? = null,
val dateAdded: Long? = null,
val dateAdded: Long? = null
) {
fun toggleLike(): Song {
return copy(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,8 @@ class LocalMusicRepository(
suspend fun getSearchResult(query: String): List<Song> {
val lowerQuery = query.lowercase()
return getAllSongs().filter {
it.title.lowercase().contains(lowerQuery)
it.title.lowercase().contains(lowerQuery) || it.artistsText?.lowercase()
?.contains(lowerQuery) == true
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,13 @@ class PlayerService : MediaSessionService(), MediaSession.Callback, Player.Liste
super.onCreate()
val maxMBytes = Pref.sharedPreferences.getInt(Pref.exoCacheKey, 0)
val cacheEvictor =
if (maxMBytes > 0) LeastRecentlyUsedCacheEvictor(maxMBytes * 1024 * 1024L) else NoOpCacheEvictor()
if (maxMBytes > 0) {
LeastRecentlyUsedCacheEvictor(
maxMBytes * 1024 * 1024L
)
} else {
NoOpCacheEvictor()
}
val directory = cacheDir.resolve("exoplayer").also { directory ->
directory.mkdir()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ class DatabaseViewModel(private val database: SongDatabase) : ViewModel() {

context.applicationContext.contentResolver.openInputStream(uri)
?.use { inputStream ->
FileOutputStream(database.openHelper.writableDatabase.path).use { outputStream ->
FileOutputStream(
database.openHelper.writableDatabase.path
).use { outputStream ->
inputStream.copyTo(outputStream)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,18 @@ import app.suhasdissa.vibeyou.backend.data.Artist
import app.suhasdissa.vibeyou.backend.data.Song
import app.suhasdissa.vibeyou.backend.repository.LocalMusicRepository
import app.suhasdissa.vibeyou.ui.dialogs.SortOrder
import app.suhasdissa.vibeyou.utils.Pref
import kotlinx.coroutines.launch

class LocalSongViewModel(private val musicRepository: LocalMusicRepository) : ViewModel() {
var songs by mutableStateOf(listOf<Song>())
var albums by mutableStateOf(listOf<Album>())
var artists by mutableStateOf(listOf<Artist>())

var songsSortOrder = SortOrder.Alphabetic
var reverseSongs = false
var songsSortOrder = Pref.sharedPreferences.getString(Pref.latestSongsSortOrderKey, null)?.let {
runCatching { SortOrder.valueOf(it) }.getOrNull()
} ?: SortOrder.Alphabetic
var reverseSongs = Pref.sharedPreferences.getBoolean(Pref.latestReverseSongsPrefKey, false)

init {
viewModelScope.launch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fun SortOrderDialog(
onDismissRequest: () -> Unit,
onSortOrderChange: (order: SortOrder, reverse: Boolean) -> Unit,
defaultSortOrder: SortOrder,
defaultReverse: Boolean,
defaultReverse: Boolean
) {
var sortOrder by remember {
mutableStateOf(defaultSortOrder)
Expand Down Expand Up @@ -82,4 +82,4 @@ fun SortOrderDialog(
}
}
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import androidx.compose.ui.draw.clip
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.core.content.edit
import androidx.lifecycle.viewmodel.compose.viewModel
import app.suhasdissa.vibeyou.Destination
import app.suhasdissa.vibeyou.R
Expand All @@ -46,6 +47,7 @@ import app.suhasdissa.vibeyou.ui.components.AlbumList
import app.suhasdissa.vibeyou.ui.components.ArtistList
import app.suhasdissa.vibeyou.ui.dialogs.SortOrderDialog
import app.suhasdissa.vibeyou.ui.screens.songs.SongListView
import app.suhasdissa.vibeyou.utils.Pref
import kotlinx.coroutines.launch

@OptIn(ExperimentalFoundationApi::class)
Expand Down Expand Up @@ -160,7 +162,10 @@ fun LocalMusicScreen(
Spacer(modifier = Modifier.width(6.dp))
Icon(imageVector = Icons.Default.Sort, contentDescription = null)
}
SongListView(songs = localSongViewModel.songs, sortOrder = localSongViewModel.songsSortOrder)
SongListView(
songs = localSongViewModel.songs,
sortOrder = localSongViewModel.songsSortOrder
)
}
}
}
Expand Down Expand Up @@ -191,6 +196,10 @@ fun LocalMusicScreen(
localSongViewModel.songsSortOrder = sortOrder
localSongViewModel.reverseSongs = reverse
localSongViewModel.updateSongsSortOrder()
Pref.sharedPreferences.edit(true) {
putString(Pref.latestSongsSortOrderKey, sortOrder.toString())
putBoolean(Pref.latestReverseSongsPrefKey, reverse)
}
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package app.suhasdissa.vibeyou.ui.screens.player

import android.text.format.DateUtils
import android.view.SoundEffectConstants
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
Expand Down Expand Up @@ -51,6 +50,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
Expand All @@ -66,10 +66,8 @@ import app.suhasdissa.vibeyou.utils.isPlayingState
import app.suhasdissa.vibeyou.utils.maxResThumbnail
import app.suhasdissa.vibeyou.utils.mediaItemState
import app.suhasdissa.vibeyou.utils.positionAndDurationState
import coil.compose.AsyncImagePainter
import coil.compose.SubcomposeAsyncImage
import coil.compose.SubcomposeAsyncImageContent
import coil.compose.rememberAsyncImagePainter

@OptIn(ExperimentalMaterial3Api::class)
@Composable
Expand Down Expand Up @@ -118,27 +116,31 @@ fun FullScreenPlayer(
isFavourite.value = playerViewModel.isFavourite(mediaItem!!.mediaId)
}
}
var thumbnailUrl by remember {
mutableStateOf(it.maxResThumbnail)
}

SubcomposeAsyncImage(
modifier = Modifier
.size(300.dp)
.padding(8.dp)
.aspectRatio(1f)
.clip(RoundedCornerShape(16.dp)),
model = it.maxResThumbnail,
model = it.maxResThumbnail.ifEmpty { it.mediaMetadata.artworkUri },
contentDescription = stringResource(id = R.string.album_art),
contentScale = ContentScale.Crop
) {
val state = painter.state
if (state is AsyncImagePainter.State.Loading || state is AsyncImagePainter.State.Error) {
Image(
painter = rememberAsyncImagePainter(model = it.mediaMetadata.artworkUri),
contentDescription,
contentScale = ContentScale.Crop,
onError = { _ ->
if (thumbnailUrl != it.mediaMetadata.artworkUri.toString()) {
thumbnailUrl = it.mediaMetadata.artworkUri.toString()
}
},
error = {
SubcomposeAsyncImageContent(
painter = painterResource(id = R.drawable.music_placeholder),
contentScale = contentScale
)
} else {
SubcomposeAsyncImageContent(contentScale = contentScale)
}
}
)
val title = it.mediaMetadata.title.toString()
val artist = it.mediaMetadata.artist.toString()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,21 @@ fun SongOptionsSheet(
fun updatePlaybackParams() = playerViewModel.setPlaybackParams(speed, pitch)

Text(text = stringResource(R.string.playback_speed), fontSize = 16.sp)
Slider(value = speed, onValueChange = { speed = it; updatePlaybackParams() }, valueRange = 0.25f..4f, steps = 14)
Slider(value = speed, onValueChange = {
speed = it
updatePlaybackParams()
}, valueRange = 0.25f..4f, steps = 14)
ElevatedCard(modifier = Modifier.align(Alignment.CenterHorizontally)) {
Text(
modifier = Modifier.padding(horizontal = 5.dp, vertical = 2.dp),
text = "%.2f".format(speed)
)
}
Text(text = stringResource(R.string.pitch), fontSize = 16.sp)
Slider(value = pitch, onValueChange = { pitch = it; updatePlaybackParams() }, valueRange = 0.5f..2f, steps = 5)
Slider(value = pitch, onValueChange = {
pitch = it
updatePlaybackParams()
}, valueRange = 0.5f..2f, steps = 5)
ElevatedCard(modifier = Modifier.align(Alignment.CenterHorizontally)) {
Text(
modifier = Modifier.padding(horizontal = 5.dp, vertical = 2.dp),
Expand All @@ -106,4 +112,4 @@ fun SongOptionsSheet(
}
Spacer(modifier = Modifier.height(20.dp))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ fun AppearanceSettingsScreen() {
}
}
}
}
}
Loading

0 comments on commit 40c893b

Please sign in to comment.