Skip to content

Commit

Permalink
Merge pull request #7 from RLD-JL/version-1.0.4
Browse files Browse the repository at this point in the history
Version 1.0.4
  • Loading branch information
RLD-JL authored Jun 15, 2022
2 parents b259ede + 8e782e7 commit 96b232c
Show file tree
Hide file tree
Showing 69 changed files with 1,083 additions and 700 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ The app is high network data consumption, since it streams songs at 320 kbps. I
- [UAMP](https://github.com/android/uamp) for media player sample using ExoPlayer.
- Every other person that motivated me and helped with testing.

## Contibutors
## Contributors
Contributors are way more than welcomed, especially for iOS development.

## Contact
Expand Down
38 changes: 21 additions & 17 deletions androidApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,32 @@ plugins {

dependencies {
implementation(project(":shared"))
implementation("com.google.android.material:material:1.6.0")
implementation("androidx.appcompat:appcompat:1.4.1")
implementation("com.google.android.material:material:1.6.1")
implementation("androidx.appcompat:appcompat:1.4.2")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.4.1")
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.5.0-rc01")
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-beta02")
implementation("androidx.compose.material:material:1.2.0-beta02")
implementation("androidx.compose.ui:ui:1.2.0-beta02")
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("com.google.android.exoplayer:exoplayer:2.17.1")
implementation("com.google.android.exoplayer:extension-mediasession:2.17.1")
implementation("com.google.android.exoplayer:extension-cast:2.17.1")

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("io.coil-kt:coil-compose:2.1.0")
implementation("com.google.dagger:hilt-android:2.38.1")
kapt("com.google.dagger:hilt-android-compiler:2.38.1")
implementation("com.google.dagger:hilt-android:2.42")
kapt("com.google.dagger:hilt-android-compiler:2.42")

implementation("com.google.accompanist:accompanist-swiperefresh:0.24.1-alpha")
implementation("androidx.core:core-splashscreen:1.0.0-rc01")

androidTestImplementation("androidx.compose.ui:ui-test-junit4:${rootProject.extra["compose_version"]}")
debugImplementation("androidx.compose.ui:ui-tooling:${rootProject.extra["compose_version"]}")
debugImplementation("com.squareup.leakcanary:leakcanary-android:2.7")
}

Expand All @@ -51,8 +47,8 @@ android {
applicationId = "com.rld.justlisten.android"
minSdk = 21
targetSdk = 32
versionCode = 15
versionName = "1.0.3"
versionCode = 16
versionName = "1.0.4"
vectorDrawables {
useSupportLibrary = true
}
Expand All @@ -79,7 +75,7 @@ android {
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.2.0-alpha08"
kotlinCompilerExtensionVersion = "1.2.0-beta03"
}

packagingOptions {
Expand All @@ -88,4 +84,12 @@ android {
}
}
namespace = "com.rld.justlisten.android"
}

sourceSets {
android {
kotlinOptions {
freeCompilerArgs = listOf("-opt-in=kotlin.RequiresOptIn")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.support.v4.media.MediaBrowserCompat
import android.support.v4.media.MediaDescriptionCompat
import android.support.v4.media.MediaMetadataCompat
import android.support.v4.media.session.MediaSessionCompat
import androidx.compose.runtime.mutableStateOf
import androidx.media.MediaBrowserServiceCompat
import com.google.android.exoplayer2.ExoPlayer
import com.google.android.exoplayer2.Player
Expand All @@ -33,7 +34,7 @@ class MusicService : MediaBrowserServiceCompat() {
@Inject
lateinit var exoPlayer: ExoPlayer

lateinit var musicNotificationManager: MusicNotificationManager
private lateinit var musicNotificationManager: MusicNotificationManager

private val serviceJob = SupervisorJob()
private val serviceScope = CoroutineScope(Dispatchers.Main + serviceJob)
Expand All @@ -57,6 +58,7 @@ class MusicService : MediaBrowserServiceCompat() {
companion object {
var curSongDuration = 0L
private set
val songHasRepeated = mutableStateOf(false)
}

override fun onCreate() {
Expand Down Expand Up @@ -93,7 +95,9 @@ class MusicService : MediaBrowserServiceCompat() {

musicNotificationManager.showNotification(exoPlayer)

musicPlayerEventListener = MusicPlayerEventListener(this, musicNotificationManager, exoPlayer)
musicPlayerEventListener = MusicPlayerEventListener(this, musicNotificationManager, exoPlayer) {
songHasRepeated.value = true
}
exoPlayer.addListener(musicPlayerEventListener)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import android.widget.Toast
import com.google.android.exoplayer2.ExoPlayer
import com.google.android.exoplayer2.PlaybackException
import com.google.android.exoplayer2.Player
import com.google.android.exoplayer2.Player.DISCONTINUITY_REASON_AUTO_TRANSITION
import com.rld.justlisten.android.exoplayer.MusicNotificationManager
import com.rld.justlisten.android.exoplayer.MusicService

class MusicPlayerEventListener(
private val musicService: MusicService,
private val notificationManager: MusicNotificationManager,
private val exoPlayer: ExoPlayer
private val exoPlayer: ExoPlayer,
val songHasRepeated: () -> Unit
) : Player.Listener {
override fun onPlayWhenReadyChanged(playWhenReady: Boolean, reason: Int) {
super.onPlayWhenReadyChanged(playWhenReady, reason)
Expand All @@ -22,7 +24,11 @@ class MusicPlayerEventListener(

override fun onPlayerError(error: PlaybackException) {
super.onPlayerError(error)
Toast.makeText(musicService, "Unfortunately this song has issues, try another one", Toast.LENGTH_SHORT).show()
Toast.makeText(
musicService,
"Unfortunately this song has issues, try another one",
Toast.LENGTH_SHORT
).show()
}

override fun onPlaybackStateChanged(playbackState: Int) {
Expand All @@ -36,4 +42,17 @@ class MusicPlayerEventListener(
}
}
}

override fun onPositionDiscontinuity(
oldPosition: Player.PositionInfo,
newPosition: Player.PositionInfo,
reason: Int
) {

if (exoPlayer.repeatMode == Player.REPEAT_MODE_ONE) {
if (reason == DISCONTINUITY_REASON_AUTO_TRANSITION) {
songHasRepeated()
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import coil.annotation.ExperimentalCoilApi
import com.rld.justlisten.Navigation
import com.rld.justlisten.android.exoplayer.MusicServiceConnection
import com.rld.justlisten.android.exoplayer.library.extension.id
import com.rld.justlisten.android.ui.bottombars.Level1BottomBar
import com.rld.justlisten.android.ui.bottombars.bottombarnav.Level1BottomBar
import com.rld.justlisten.android.ui.bottombars.playbar.PlayerBarSheetContent
import com.rld.justlisten.android.ui.extensions.fraction
import com.rld.justlisten.android.ui.screenpicker.ScreenPicker
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,17 @@
package com.rld.justlisten.android.ui.addplaylistscreen

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.material.Divider
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusDirection
import androidx.compose.ui.input.key.Key
import androidx.compose.ui.input.key.key
import androidx.compose.ui.input.key.onPreviewKeyEvent
import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.rld.justlisten.android.R
import com.rld.justlisten.datalayer.localdb.addplaylistscreen.AddPlaylist
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.screens.addplaylist.AddPlaylistState

@Composable
Expand All @@ -38,149 +25,9 @@ fun AddPlaylistScreen(
item { AddPlaylistRow(openDialog) }
item { Divider(thickness = 2.dp) }
item { AddPlaylistDialog(openDialog, onAddPlaylistClicked) }
itemsIndexed(addPlaylistState.playlistsCreated) { index, playlist ->
itemsIndexed(addPlaylistState.playlistsCreated) { _, playlist ->
PlaylistViewItem(playlist, clickedToAddSongToPlaylist)
}
}
}

@Composable
fun AddPlaylistRow(openDialog: MutableState<Boolean>) {
Row(
horizontalArrangement = Arrangement.Start,
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
.clickable(onClick = { openDialog.value = true })
) {
Icon(
painterResource(id = R.drawable.ic_add_to_playlist_foreground),
contentDescription = null,
modifier = Modifier.height(75.dp)
)
Text("New Playlist", modifier = Modifier.fillMaxWidth())
}
}

@Composable
fun PlaylistViewItem(
playlist: AddPlaylist,
clickedToAddSongToPlaylist: (String, String?, List<String>) -> Unit
) {
Row(
horizontalArrangement = Arrangement.Start,
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
.clickable(onClick = {
clickedToAddSongToPlaylist(
playlist.playlistName,
playlist.playlistDescription,
playlist.songsList ?: emptyList()
)
})
) {
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())
}
}

@OptIn(ExperimentalComposeUiApi::class)
@Composable
fun AddPlaylistDialog(
openDialog: MutableState<Boolean>,
onAddPlaylistClicked: (String, String?) -> Unit
) {
val focusManager = LocalFocusManager.current
val keyboardController = LocalSoftwareKeyboardController.current

var title by remember { mutableStateOf("") }
var description by remember { mutableStateOf<String?>("") }
if (openDialog.value) {
AlertDialog(
onDismissRequest = {
openDialog.value = false
},
title = null,
text = {
Column {
Text(
text = "Add New Playlist",
fontWeight = FontWeight.ExtraBold,
fontSize = 20.sp,
)
Spacer(modifier = Modifier.height(20.dp))
TextField(
singleLine = true,
modifier = Modifier.onPreviewKeyEvent {
if (it.key == Key.Tab) {
focusManager.moveFocus(FocusDirection.Down)
true
} else {
false
}
},
maxLines = 1,
value = title,
onValueChange = {
if (it.length <= 15)
title = it
},
label = { Text(text = "Title") },
keyboardOptions = KeyboardOptions(
keyboardType = KeyboardType.Text,
imeAction = ImeAction.Next
)
)
TextField(
maxLines = 2,
modifier = Modifier.padding(top = 5.dp),
value = description.toString(),
onValueChange = {
if (it.length <= 144)
description = it
},
label = { Text(text = "Description") },
keyboardOptions = KeyboardOptions(
keyboardType = KeyboardType.Text,
imeAction = ImeAction.Done
),
keyboardActions = KeyboardActions(
onDone = {
focusManager.clearFocus()
keyboardController?.hide()
openDialog.value = false
onAddPlaylistClicked(title, description)
description = ""
title = ""
}
)
)
}
},
confirmButton = {
Row(
modifier = Modifier.padding(all = 8.dp),
horizontalArrangement = Arrangement.Center
) {
Button(
modifier = Modifier.fillMaxWidth(),
onClick = {
focusManager.clearFocus()
keyboardController?.hide()
openDialog.value = false
onAddPlaylistClicked(title, description)
description = ""
title = ""
}
) {
Text("Add")
}
}
}
)
}
}
Loading

0 comments on commit 96b232c

Please sign in to comment.