diff --git a/.github/FUNDING.YML b/.github/FUNDING.YML new file mode 100644 index 0000000..54061c2 --- /dev/null +++ b/.github/FUNDING.YML @@ -0,0 +1 @@ +ko_fi: rldjl \ No newline at end of file diff --git a/androidApp/build.gradle.kts b/androidApp/build.gradle.kts index af55526..5c46623 100644 --- a/androidApp/build.gradle.kts +++ b/androidApp/build.gradle.kts @@ -16,18 +16,18 @@ dependencies { implementation("androidx.activity:activity-compose:1.4.0") implementation("androidx.palette:palette-ktx:1.0.0") - implementation("androidx.compose.ui:ui-util:1.2.0-beta03") - implementation("androidx.compose.material:material:1.2.0-beta03") - implementation("androidx.compose.ui:ui:1.2.0-beta03") - implementation("androidx.compose.animation:animation:1.1.1") - debugImplementation("androidx.compose.ui:ui-tooling:1.1.1") - implementation("androidx.compose.ui:ui-tooling-preview:1.1.1") + implementation("androidx.compose.ui:ui-util:1.2.0-rc01") + implementation("androidx.compose.material:material:1.2.0-rc01") + implementation("androidx.compose.ui:ui:1.2.0-rc01") + implementation("androidx.compose.animation:animation:1.2.0-rc01") + debugImplementation("androidx.compose.ui:ui-tooling:1.2.0-rc01") + implementation("androidx.compose.ui:ui-tooling-preview:1.2.0-rc01") implementation ("com.google.android.exoplayer:exoplayer-core:2.17.1") implementation ("com.google.android.exoplayer:extension-mediasession:2.17.1") implementation ("com.google.android.exoplayer:exoplayer-ui:2.17.1") - implementation("androidx.lifecycle:lifecycle-process:2.4.1") + implementation("androidx.lifecycle:lifecycle-process:2.5.0-rc02") implementation("io.coil-kt:coil-compose:2.1.0") implementation("com.google.dagger:hilt-android:2.42") kapt("com.google.dagger:hilt-android-compiler:2.42") @@ -47,8 +47,8 @@ android { applicationId = "com.rld.justlisten.android" minSdk = 21 targetSdk = 32 - versionCode = 16 - versionName = "1.0.4" + versionCode = 17 + versionName = "1.0.5" vectorDrawables { useSupportLibrary = true } diff --git a/androidApp/src/main/java/com/rld/justlisten/android/ui/OnePane.kt b/androidApp/src/main/java/com/rld/justlisten/android/ui/OnePane.kt index f1871c6..ab68e4a 100644 --- a/androidApp/src/main/java/com/rld/justlisten/android/ui/OnePane.kt +++ b/androidApp/src/main/java/com/rld/justlisten/android/ui/OnePane.kt @@ -2,6 +2,7 @@ package com.rld.justlisten.android.ui import android.media.session.PlaybackState import android.widget.Toast +import androidx.activity.compose.BackHandler import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.offset @@ -57,6 +58,13 @@ fun Navigation.OnePane( val addPlaylistList = remember { mutableStateOf(events.getPlaylist()) } val coroutineScope = rememberCoroutineScope() + if (scaffoldState.bottomSheetState.isExpanded) { + BackHandler { + coroutineScope.launch { + scaffoldState.bottomSheetState.collapse() + } + } + } Scaffold( bottomBar = { if (currentScreenIdentifier.screen.navigationLevel == 1) { @@ -101,16 +109,16 @@ fun Navigation.OnePane( clickedToAddSongToPlaylist = { playlistTitle, playlistDescription, songList -> val list = songList.toMutableList() list.add(musicServiceConnection.currentPlayingSong.value?.id ?: "") - events.updatePlaylistSongs( - playlistTitle, - playlistDescription, - list - ) Toast.makeText( context, "The song was added to $playlistTitle", Toast.LENGTH_SHORT ).show() + events.updatePlaylistSongs( + playlistTitle, + playlistDescription, + list + ) }, newDominantColor = { color -> updateStatusBarColor( @@ -121,7 +129,8 @@ fun Navigation.OnePane( }, playBarMinimizedClicked = { coroutineScope.launch { scaffoldState.bottomSheetState.expand() } - } + }, + events = events ) }, content = { Column( diff --git a/androidApp/src/main/java/com/rld/justlisten/android/ui/addplaylistscreen/AddPlaylistScreen.kt b/androidApp/src/main/java/com/rld/justlisten/android/ui/addplaylistscreen/AddPlaylistScreen.kt index 580e56a..ab08810 100644 --- a/androidApp/src/main/java/com/rld/justlisten/android/ui/addplaylistscreen/AddPlaylistScreen.kt +++ b/androidApp/src/main/java/com/rld/justlisten/android/ui/addplaylistscreen/AddPlaylistScreen.kt @@ -12,13 +12,15 @@ import androidx.compose.ui.unit.dp import com.rld.justlisten.android.ui.addplaylistscreen.components.AddPlaylistDialog import com.rld.justlisten.android.ui.addplaylistscreen.components.AddPlaylistRow import com.rld.justlisten.android.ui.addplaylistscreen.components.PlaylistViewItem +import com.rld.justlisten.viewmodel.Events import com.rld.justlisten.viewmodel.screens.addplaylist.AddPlaylistState @Composable fun AddPlaylistScreen( addPlaylistState: AddPlaylistState, onAddPlaylistClicked: (String, String?) -> Unit, - clickedToAddSongToPlaylist: (String, String?, List) -> Unit + clickedToAddSongToPlaylist: (String, String?, List) -> Unit, + events: Events ) { val openDialog = remember { mutableStateOf(false) } LazyColumn(Modifier.fillMaxWidth()) { @@ -26,7 +28,7 @@ fun AddPlaylistScreen( item { Divider(thickness = 2.dp) } item { AddPlaylistDialog(openDialog, onAddPlaylistClicked) } itemsIndexed(addPlaylistState.playlistsCreated) { _, playlist -> - PlaylistViewItem(playlist, clickedToAddSongToPlaylist) + PlaylistViewItem(playlist, clickedToAddSongToPlaylist, events) } } } diff --git a/androidApp/src/main/java/com/rld/justlisten/android/ui/addplaylistscreen/components/PlaylistViewItem.kt b/androidApp/src/main/java/com/rld/justlisten/android/ui/addplaylistscreen/components/PlaylistViewItem.kt index f23e94c..21d2b6d 100644 --- a/androidApp/src/main/java/com/rld/justlisten/android/ui/addplaylistscreen/components/PlaylistViewItem.kt +++ b/androidApp/src/main/java/com/rld/justlisten/android/ui/addplaylistscreen/components/PlaylistViewItem.kt @@ -7,20 +7,28 @@ import androidx.compose.material.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.painterResource import androidx.compose.ui.unit.dp +import coil.compose.AsyncImage +import coil.request.ImageRequest +import coil.transform.RoundedCornersTransformation import com.rld.justlisten.android.R import com.rld.justlisten.datalayer.localdb.addplaylistscreen.AddPlaylist +import com.rld.justlisten.datalayer.models.PlayListModel +import com.rld.justlisten.viewmodel.Events +import com.rld.justlisten.viewmodel.screens.library.getSongWithId @Composable fun PlaylistViewItem( playlist: AddPlaylist, - clickedToAddSongToPlaylist: (String, String?, List) -> Unit + clickedToAddSongToPlaylist: (String, String?, List) -> Unit, + events: Events? ) { Row( horizontalArrangement = Arrangement.Start, verticalAlignment = Alignment.CenterVertically, - modifier = Modifier + modifier = Modifier.padding(10.dp) .clickable(onClick = { clickedToAddSongToPlaylist( playlist.playlistName, @@ -29,11 +37,24 @@ fun PlaylistViewItem( ) }) ) { - Icon( - painterResource(id = R.drawable.ic_playlist_icon), - contentDescription = null, - modifier = Modifier.height(75.dp) - ) + val playListModel: PlayListModel? + if (!playlist.songsList.isNullOrEmpty()) { + playListModel = events?.getSongWithId(playlist.songsList!![0]) + AsyncImage( + modifier = Modifier.height(50.dp).width(50.dp), + model = ImageRequest.Builder(LocalContext.current) + .data( playListModel?.songImgList?.songImageURL480px).transformations(RoundedCornersTransformation(10f)) + .build(), + contentDescription = "Icon" + ) + } else { + Icon( + painterResource(id = R.drawable.ic_playlist_icon), + contentDescription = null, + modifier = Modifier.height(75.dp) + ) + } + Spacer(modifier = Modifier.width(10.dp)) Text(playlist.playlistName, modifier = Modifier.fillMaxWidth()) } diff --git a/androidApp/src/main/java/com/rld/justlisten/android/ui/bottombars/playbar/PlayerBarSheetContent.kt b/androidApp/src/main/java/com/rld/justlisten/android/ui/bottombars/playbar/PlayerBarSheetContent.kt index 7f2e24d..671dfe3 100644 --- a/androidApp/src/main/java/com/rld/justlisten/android/ui/bottombars/playbar/PlayerBarSheetContent.kt +++ b/androidApp/src/main/java/com/rld/justlisten/android/ui/bottombars/playbar/PlayerBarSheetContent.kt @@ -1,5 +1,6 @@ package com.rld.justlisten.android.ui.bottombars.playbar +import androidx.activity.compose.BackHandler import androidx.compose.material.* import androidx.compose.runtime.* import androidx.compose.ui.graphics.painter.Painter @@ -13,6 +14,7 @@ import com.rld.justlisten.android.ui.bottombars.sheets.SheetLayout import com.rld.justlisten.datalayer.localdb.addplaylistscreen.AddPlaylist import com.rld.justlisten.datalayer.models.SongIconList import com.rld.justlisten.datalayer.models.UserModel +import com.rld.justlisten.viewmodel.Events import kotlinx.coroutines.InternalCoroutinesApi import kotlinx.coroutines.launch @@ -33,7 +35,8 @@ fun PlayerBarSheetContent( getLatestPlaylist: () -> Unit, clickedToAddSongToPlaylist: (String, String?, List) -> Unit, newDominantColor: (Int) -> Unit, - playBarMinimizedClicked: () -> Unit + playBarMinimizedClicked: () -> Unit, + events: Events ) { val songIcon by remember { derivedStateOf { musicServiceConnection.currentPlayingSong.value?.description?.iconUri.toString() } } val title by remember { derivedStateOf { @@ -67,6 +70,12 @@ fun PlayerBarSheetContent( if (scaffoldState.bottomSheetState.isCollapsed) currentBottomSheet = null + if (scaffoldState.bottomSheetState.isExpanded) { + BackHandler { + closeSheet() + } + } + BottomSheetScaffold( scaffoldState = scaffoldState, sheetContent = { @@ -80,7 +89,11 @@ fun PlayerBarSheetContent( addPlaylistList, onAddPlaylistClicked, getLatestPlaylist, - clickedToAddSongToPlaylist + clickedToAddSongToPlaylist = { playlistTitle, playlistDescription, songList -> + closeSheet() + clickedToAddSongToPlaylist(playlistTitle, playlistDescription, songList) + }, + events ) } }, diff --git a/androidApp/src/main/java/com/rld/justlisten/android/ui/bottombars/playbar/components/addplaylist/AddPlaylistOption.kt b/androidApp/src/main/java/com/rld/justlisten/android/ui/bottombars/playbar/components/addplaylist/AddPlaylistOption.kt index 2930ca5..3100526 100644 --- a/androidApp/src/main/java/com/rld/justlisten/android/ui/bottombars/playbar/components/addplaylist/AddPlaylistOption.kt +++ b/androidApp/src/main/java/com/rld/justlisten/android/ui/bottombars/playbar/components/addplaylist/AddPlaylistOption.kt @@ -17,6 +17,7 @@ import com.rld.justlisten.android.ui.addplaylistscreen.components.AddPlaylistRow import com.rld.justlisten.android.ui.addplaylistscreen.components.PlaylistViewItem import com.rld.justlisten.android.ui.bottombars.playbar.components.more.TopSection import com.rld.justlisten.datalayer.localdb.addplaylistscreen.AddPlaylist +import com.rld.justlisten.viewmodel.Events @Composable fun AddPlaylistOption( @@ -24,7 +25,8 @@ fun AddPlaylistOption( painter: MutableState, addPlaylistList: List, onAddPlaylistClicked: (String, String?) -> Unit, - clickedToAddSongToPlaylist: (String, String?, List) -> Unit + clickedToAddSongToPlaylist: (String, String?, List) -> Unit, + events: Events ) { val openDialog = remember { mutableStateOf(false) } @@ -34,7 +36,7 @@ fun AddPlaylistOption( Divider(thickness = 2.dp) } itemsIndexed(items = addPlaylistList) { _, playlist -> - PlaylistViewItem(playlist, clickedToAddSongToPlaylist) + PlaylistViewItem(playlist, clickedToAddSongToPlaylist, events) } item { AddPlaylistRow(openDialog) diff --git a/androidApp/src/main/java/com/rld/justlisten/android/ui/bottombars/sheets/SheetLayout.kt b/androidApp/src/main/java/com/rld/justlisten/android/ui/bottombars/sheets/SheetLayout.kt index f7217b2..3488774 100644 --- a/androidApp/src/main/java/com/rld/justlisten/android/ui/bottombars/sheets/SheetLayout.kt +++ b/androidApp/src/main/java/com/rld/justlisten/android/ui/bottombars/sheets/SheetLayout.kt @@ -6,6 +6,7 @@ import androidx.compose.ui.graphics.painter.Painter import com.rld.justlisten.android.ui.bottombars.playbar.components.addplaylist.AddPlaylistOption import com.rld.justlisten.android.ui.bottombars.playbar.components.more.PlayBarMoreAction import com.rld.justlisten.datalayer.localdb.addplaylistscreen.AddPlaylist +import com.rld.justlisten.viewmodel.Events @Composable fun SheetLayout( @@ -17,7 +18,8 @@ fun SheetLayout( addPlaylistList: List, onAddPlaylistClicked: (String, String?) -> Unit, getLatestPlaylist: () -> Unit, - clickedToAddSongToPlaylist: (String, String?, List) -> Unit + clickedToAddSongToPlaylist: (String, String?, List) -> Unit, + events: Events ) { when (currentScreen) { BottomSheetScreen.AddPlaylist -> { @@ -26,7 +28,8 @@ fun SheetLayout( mutablePainter, addPlaylistList, onAddPlaylistClicked, - clickedToAddSongToPlaylist + clickedToAddSongToPlaylist, + events ) getLatestPlaylist() } diff --git a/androidApp/src/main/java/com/rld/justlisten/android/ui/donationscreen/DonationScreen.kt b/androidApp/src/main/java/com/rld/justlisten/android/ui/donationscreen/DonationScreen.kt index f3d3450..9740300 100644 --- a/androidApp/src/main/java/com/rld/justlisten/android/ui/donationscreen/DonationScreen.kt +++ b/androidApp/src/main/java/com/rld/justlisten/android/ui/donationscreen/DonationScreen.kt @@ -13,8 +13,13 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalClipboardManager import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.platform.LocalUriHandler import androidx.compose.ui.text.AnnotatedString +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.text.style.TextDecoration import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp @Composable fun DonationScreen() { @@ -111,5 +116,17 @@ fun DonationScreen() { colors = TextFieldDefaults.textFieldColors(unfocusedIndicatorColor = Color.Transparent) ) } + val uriHandler = LocalUriHandler.current + Text( + text = "Ko-Fi", modifier = Modifier + .clickable { + uriHandler.openUri("https://ko-fi.com/rldjl") + } + .fillMaxWidth(), + textAlign = TextAlign.Center, + color = Color.Cyan, + style = TextStyle(textDecoration = TextDecoration.Underline), + fontSize = 18.sp + ) } } \ No newline at end of file diff --git a/androidApp/src/main/java/com/rld/justlisten/android/ui/playlistscreen/components/PlaylistRowItem.kt b/androidApp/src/main/java/com/rld/justlisten/android/ui/playlistscreen/components/PlaylistRowItem.kt index f4ad575..38eedaf 100644 --- a/androidApp/src/main/java/com/rld/justlisten/android/ui/playlistscreen/components/PlaylistRowItem.kt +++ b/androidApp/src/main/java/com/rld/justlisten/android/ui/playlistscreen/components/PlaylistRowItem.kt @@ -45,7 +45,7 @@ fun PlaylistRowItem( playlistItem.id, playlistItem.songIconList.songImageURL480px, playlistItem.playlistTitle, - playlistItem.user, + playlistItem.playlistTitle, playlistItem.isFavorite ) } diff --git a/androidApp/src/main/java/com/rld/justlisten/android/ui/screenpicker/ScreenPicker.kt b/androidApp/src/main/java/com/rld/justlisten/android/ui/screenpicker/ScreenPicker.kt index 41c3fd7..fc31d93 100644 --- a/androidApp/src/main/java/com/rld/justlisten/android/ui/screenpicker/ScreenPicker.kt +++ b/androidApp/src/main/java/com/rld/justlisten/android/ui/screenpicker/ScreenPicker.kt @@ -211,6 +211,7 @@ fun Navigation.ScreenPicker( } ) AddPlaylist -> AddPlaylistScreen(addPlaylistState = stateProvider.get(screenIdentifier), + events = events, onAddPlaylistClicked = { playlistName, playlistDescription -> events.addPlaylist(playlistName, playlistDescription) events.updatePlaylist() diff --git a/shared/src/commonMain/kotlin/com/rld/justlisten/datalayer/datacalls/library/LibraryCalls.kt b/shared/src/commonMain/kotlin/com/rld/justlisten/datalayer/datacalls/library/LibraryCalls.kt index 10509b9..d0df493 100644 --- a/shared/src/commonMain/kotlin/com/rld/justlisten/datalayer/datacalls/library/LibraryCalls.kt +++ b/shared/src/commonMain/kotlin/com/rld/justlisten/datalayer/datacalls/library/LibraryCalls.kt @@ -25,6 +25,10 @@ fun Repository.getFavoritePlaylist(): List { return localDb.getFavoritePlaylist() } +fun Repository.getSongWithId(songId: String): PlayListModel { + return localDb.getSongWithId(songId) +} + fun Repository.getMostPlayedSongs(numberOfLines: Long): List { return localDb.getMostPlayedSongs(numberOfLines) } diff --git a/shared/src/commonMain/kotlin/com/rld/justlisten/datalayer/localdb/libraryscreen/Library.sq b/shared/src/commonMain/kotlin/com/rld/justlisten/datalayer/localdb/libraryscreen/Library.sq index 92fce19..03640af 100644 --- a/shared/src/commonMain/kotlin/com/rld/justlisten/datalayer/localdb/libraryscreen/Library.sq +++ b/shared/src/commonMain/kotlin/com/rld/justlisten/datalayer/localdb/libraryscreen/Library.sq @@ -25,6 +25,9 @@ SELECT * FROM Library WHERE recentPlayed = 1 ORDER BY recentIncrement DESC LIMIT getCustomPlaylistSongs: SELECT * FROM Library WHERE id IN :songsList; +getSongWithId: +SELECT * FROM Library WHERE id = :id; + getMostPlayed: SELECT * FROM Library WHERE songCounter NOT NULL ORDER BY songCounter DESC LIMIT :numberOfSongs; diff --git a/shared/src/commonMain/kotlin/com/rld/justlisten/datalayer/localdb/libraryscreen/LibraryFunctions.kt b/shared/src/commonMain/kotlin/com/rld/justlisten/datalayer/localdb/libraryscreen/LibraryFunctions.kt index 625f9ce..e2f2e18 100644 --- a/shared/src/commonMain/kotlin/com/rld/justlisten/datalayer/localdb/libraryscreen/LibraryFunctions.kt +++ b/shared/src/commonMain/kotlin/com/rld/justlisten/datalayer/localdb/libraryscreen/LibraryFunctions.kt @@ -42,6 +42,12 @@ fun LocalDb.getCustomPlaylistSongs(songsList: List): List }).executeAsList() } +fun LocalDb.getSongWithId(songId: String): PlayListModel { + return libraryQueries.getSongWithId(songId, mapper = { id, title, user, songImgList, _, _, _, _, _ + -> PlayListModel(id, title, title, songImgList, user) + }).executeAsOne() +} + fun LocalDb.getFavoritePlaylistWithId(id: String): String? { return libraryQueries.getFavoritePlaylistWithId(id).executeAsOneOrNull() } diff --git a/shared/src/commonMain/kotlin/com/rld/justlisten/viewmodel/screens/library/LibraryEvents.kt b/shared/src/commonMain/kotlin/com/rld/justlisten/viewmodel/screens/library/LibraryEvents.kt index 697f5ec..6671d98 100644 --- a/shared/src/commonMain/kotlin/com/rld/justlisten/viewmodel/screens/library/LibraryEvents.kt +++ b/shared/src/commonMain/kotlin/com/rld/justlisten/viewmodel/screens/library/LibraryEvents.kt @@ -1,9 +1,6 @@ package com.rld.justlisten.viewmodel.screens.library -import com.rld.justlisten.datalayer.datacalls.library.getRecentSongs -import com.rld.justlisten.datalayer.datacalls.library.saveSongToFavorites -import com.rld.justlisten.datalayer.datacalls.library.saveSongToMostPlayed -import com.rld.justlisten.datalayer.datacalls.library.saveSongToRecent +import com.rld.justlisten.datalayer.datacalls.library.* import com.rld.justlisten.datalayer.models.SongIconList import com.rld.justlisten.datalayer.models.UserModel import com.rld.justlisten.viewmodel.Events @@ -53,4 +50,6 @@ fun Events.getLastPlayed(numberOfSongs: Long) = screenCoroutine { it.copy(recentSongsItems = recentSongs) } } -} \ No newline at end of file +} + +fun Events.getSongWithId(songId: String) = dataRepository.getSongWithId(songId)