Skip to content

Commit

Permalink
Merge pull request #9 from RLD-JL/version-1.0.5
Browse files Browse the repository at this point in the history
Version 1.0.5
  • Loading branch information
RLD-JL authored Jun 21, 2022
2 parents 58467c2 + 70f0d44 commit 4cc9d47
Show file tree
Hide file tree
Showing 15 changed files with 117 additions and 36 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.YML
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ko_fi: rldjl
18 changes: 9 additions & 9 deletions androidApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
}
Expand Down
21 changes: 15 additions & 6 deletions androidApp/src/main/java/com/rld/justlisten/android/ui/OnePane.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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(
Expand All @@ -121,7 +129,8 @@ fun Navigation.OnePane(
},
playBarMinimizedClicked = {
coroutineScope.launch { scaffoldState.bottomSheetState.expand() }
}
},
events = events
)
}, content = {
Column(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,23 @@ 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<String>) -> Unit
clickedToAddSongToPlaylist: (String, String?, List<String>) -> Unit,
events: Events
) {
val openDialog = remember { mutableStateOf(false) }
LazyColumn(Modifier.fillMaxWidth()) {
item { AddPlaylistRow(openDialog) }
item { Divider(thickness = 2.dp) }
item { AddPlaylistDialog(openDialog, onAddPlaylistClicked) }
itemsIndexed(addPlaylistState.playlistsCreated) { _, playlist ->
PlaylistViewItem(playlist, clickedToAddSongToPlaylist)
PlaylistViewItem(playlist, clickedToAddSongToPlaylist, events)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>) -> Unit
clickedToAddSongToPlaylist: (String, String?, List<String>) -> Unit,
events: Events?
) {
Row(
horizontalArrangement = Arrangement.Start,
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
modifier = Modifier.padding(10.dp)
.clickable(onClick = {
clickedToAddSongToPlaylist(
playlist.playlistName,
Expand All @@ -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())
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

Expand All @@ -33,7 +35,8 @@ fun PlayerBarSheetContent(
getLatestPlaylist: () -> Unit,
clickedToAddSongToPlaylist: (String, String?, List<String>) -> 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 {
Expand Down Expand Up @@ -67,6 +70,12 @@ fun PlayerBarSheetContent(
if (scaffoldState.bottomSheetState.isCollapsed)
currentBottomSheet = null

if (scaffoldState.bottomSheetState.isExpanded) {
BackHandler {
closeSheet()
}
}

BottomSheetScaffold(
scaffoldState = scaffoldState,
sheetContent = {
Expand All @@ -80,7 +89,11 @@ fun PlayerBarSheetContent(
addPlaylistList,
onAddPlaylistClicked,
getLatestPlaylist,
clickedToAddSongToPlaylist
clickedToAddSongToPlaylist = { playlistTitle, playlistDescription, songList ->
closeSheet()
clickedToAddSongToPlaylist(playlistTitle, playlistDescription, songList)
},
events
)
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ 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(
title: String,
painter: MutableState<Painter?>,
addPlaylistList: List<AddPlaylist>,
onAddPlaylistClicked: (String, String?) -> Unit,
clickedToAddSongToPlaylist: (String, String?, List<String>) -> Unit
clickedToAddSongToPlaylist: (String, String?, List<String>) -> Unit,
events: Events
) {
val openDialog = remember { mutableStateOf(false) }

Expand All @@ -34,7 +36,7 @@ fun AddPlaylistOption(
Divider(thickness = 2.dp)
}
itemsIndexed(items = addPlaylistList) { _, playlist ->
PlaylistViewItem(playlist, clickedToAddSongToPlaylist)
PlaylistViewItem(playlist, clickedToAddSongToPlaylist, events)
}
item {
AddPlaylistRow(openDialog)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -17,7 +18,8 @@ fun SheetLayout(
addPlaylistList: List<AddPlaylist>,
onAddPlaylistClicked: (String, String?) -> Unit,
getLatestPlaylist: () -> Unit,
clickedToAddSongToPlaylist: (String, String?, List<String>) -> Unit
clickedToAddSongToPlaylist: (String, String?, List<String>) -> Unit,
events: Events
) {
when (currentScreen) {
BottomSheetScreen.AddPlaylist -> {
Expand All @@ -26,7 +28,8 @@ fun SheetLayout(
mutablePainter,
addPlaylistList,
onAddPlaylistClicked,
clickedToAddSongToPlaylist
clickedToAddSongToPlaylist,
events
)
getLatestPlaylist()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ fun PlaylistRowItem(
playlistItem.id,
playlistItem.songIconList.songImageURL480px,
playlistItem.playlistTitle,
playlistItem.user,
playlistItem.playlistTitle,
playlistItem.isFavorite
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ fun Navigation.ScreenPicker(
}
)
AddPlaylist -> AddPlaylistScreen(addPlaylistState = stateProvider.get(screenIdentifier),
events = events,
onAddPlaylistClicked = { playlistName, playlistDescription ->
events.addPlaylist(playlistName, playlistDescription)
events.updatePlaylist()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ fun Repository.getFavoritePlaylist(): List<PlayListModel> {
return localDb.getFavoritePlaylist()
}

fun Repository.getSongWithId(songId: String): PlayListModel {
return localDb.getSongWithId(songId)
}

fun Repository.getMostPlayedSongs(numberOfLines: Long): List<PlayListModel> {
return localDb.getMostPlayedSongs(numberOfLines)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ fun LocalDb.getCustomPlaylistSongs(songsList: List<String>): List<PlayListModel>
}).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()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -53,4 +50,6 @@ fun Events.getLastPlayed(numberOfSongs: Long) = screenCoroutine {
it.copy(recentSongsItems = recentSongs)
}
}
}
}

fun Events.getSongWithId(songId: String) = dataRepository.getSongWithId(songId)

0 comments on commit 4cc9d47

Please sign in to comment.