Skip to content

Commit

Permalink
Merge pull request #1059
Browse files Browse the repository at this point in the history
v2.4.6
  • Loading branch information
antoinepirlot authored Nov 14, 2024
2 parents 6dc7451 + 93c4a9e commit 6e846d3
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 30 deletions.
6 changes: 5 additions & 1 deletion RELEASES_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ Tu peux retrouver ce fichier en [français 🇫🇷](RELEASES_FR.md)

## 2.4 (Android 5.1.1 Lollipop and later)

### 2.4.5
### 2.4.6

Improvements, optimizations and troubleshooting:

* Fix Android Auto not playing the selected music and not respecting the default shuffle mode

### 2.4.5

Nothing new, issue happened while updating

### 2.4.4

Improvements, optimizations and troubleshooting:
Expand Down
6 changes: 5 additions & 1 deletion RELEASES_FR.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ You can find this file in [english 🇬🇧](RELEASES_EN.md)

## 2.4 (Android 5.1.1 Lollipop et ultérieur)

### 2.4.5
### 2.4.6

Améliorations, optimisations et dépannage:

* Correction du bogue d'Android Auto qui ne lit pas la musique séléctionnée et qui ne respecte pas
le mode aléatoire par défaut

### 2.4.5

Rien de nouveau. Une erreur est survenue lors de la mise à jour

### 2.4.4

Améliorations, optimisations et dépannage:
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ android {
applicationId = nameSpace
minSdk = 22
targetSdk = 34
versionCode = 63
versionName = "2.4.5"
versionCode = 64
versionName = "2.4.6"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,13 @@ import android.support.v4.media.session.PlaybackStateCompat.ACTION_SKIP_TO_PREVI
import android.support.v4.media.session.PlaybackStateCompat.STATE_PAUSED
import android.support.v4.media.session.PlaybackStateCompat.STATE_PLAYING
import io.github.antoinepirlot.satunes.car.pages.ScreenPages
import io.github.antoinepirlot.satunes.database.models.Album
import io.github.antoinepirlot.satunes.database.models.Artist
import io.github.antoinepirlot.satunes.database.models.Folder
import io.github.antoinepirlot.satunes.database.models.Genre
import io.github.antoinepirlot.satunes.database.models.MediaImpl
import io.github.antoinepirlot.satunes.database.models.Music
import io.github.antoinepirlot.satunes.database.models.Playlist
import io.github.antoinepirlot.satunes.database.services.data.DataManager
import io.github.antoinepirlot.satunes.playback.services.PlaybackManager
import kotlinx.coroutines.CoroutineScope
Expand Down Expand Up @@ -83,14 +88,12 @@ internal object SatunesCarCallBack : MediaSessionCompat.Callback() {
}

override fun onPlayFromMediaId(mediaId: String, extras: Bundle?) {
RouteManager.setShuffleButtonSelected(selected = true)
val shuffleMode: Boolean = RouteManager.isShuffleButtonSelected()
loadMusic()
RouteManager.setShuffleButtonSelected(selected = false)
var musicToPlay: Music? = null
if (!shuffleMode) {
if (mediaId == SatunesCarMusicService.SHUFFLE_ID)
RouteManager.setShuffleButtonSelected(selected = true)
else
musicToPlay = DataManager.getMusic(id = mediaId.toLong())
}
loadMusic(musicToPlay = musicToPlay)
PlaybackManager.start(
context = SatunesCarMusicService.instance.applicationContext,
musicToPlay = musicToPlay
Expand Down Expand Up @@ -141,30 +144,61 @@ internal object SatunesCarCallBack : MediaSessionCompat.Callback() {
/**
* Load music from the last route deque route.
*/
private fun loadMusic() {
private fun loadMusic(musicToPlay: Music? = null) {
val selectedTab: ScreenPages = RouteManager.getSelectedTab()
var musicToPlay: Music? = null
val selectedMediaImpl: MediaImpl? = RouteManager.getSelectedMediaImpl()
var musicSet: Set<Music> = DataManager.getMusicSet()
var musicSet: Set<Music>
if (selectedMediaImpl != null) {
musicSet = when (selectedTab) {
ScreenPages.ALL_FOLDERS -> selectedMediaImpl.getMusicSet()
ScreenPages.ALL_ALBUMS -> selectedMediaImpl.getMusicSet()
ScreenPages.ALL_ARTISTS -> selectedMediaImpl.getMusicSet()
ScreenPages.ALL_GENRES -> selectedMediaImpl.getMusicSet()
ScreenPages.ALL_PLAYLISTS -> selectedMediaImpl.getMusicSet()
ScreenPages.ALL_MUSICS -> DataManager.getMusicSet()
else -> {
musicToPlay = selectedMediaImpl as Music
musicSet
else -> throw UnsupportedOperationException()
}
} else {
val musics: MutableSet<Music> = mutableSetOf()
when (RouteManager.getSelectedTab()) {
ScreenPages.ALL_FOLDERS -> DataManager.getFolderSet().forEach { folder: Folder ->
musics.addAll(elements = folder.getMusicSet())
}

ScreenPages.ALL_ARTISTS ->
DataManager.getArtistSet().forEach { artist: Artist ->
musics.addAll(elements = artist.getMusicSet())
}

ScreenPages.ALL_ALBUMS ->
DataManager.getAlbumSet().forEach { album: Album ->
musics.addAll(elements = album.getMusicSet())
}

ScreenPages.ALL_GENRES -> DataManager.getGenreSet().forEach { genre: Genre ->
musics.addAll(elements = genre.getMusicSet())
}

ScreenPages.ALL_PLAYLISTS -> DataManager.getPlaylistSet()
.forEach { playlist: Playlist ->
musics.addAll(elements = playlist.getMusicSet())
}

else -> throw UnsupportedOperationException()
}
musicSet = musics.toSet()
}
PlaybackManager.loadMusics(
context = SatunesCarMusicService.instance.applicationContext,
musicSet = musicSet,
shuffleMode = RouteManager.isShuffleButtonSelected(),
musicToPlay = musicToPlay
)
if (RouteManager.isShuffleButtonSelected())
PlaybackManager.loadMusics(
context = SatunesCarMusicService.instance.applicationContext,
musicSet = musicSet,
shuffleMode = RouteManager.isShuffleButtonSelected(),
musicToPlay = musicToPlay
)
else
PlaybackManager.loadMusics(
context = SatunesCarMusicService.instance.applicationContext,
musicSet = musicSet,
musicToPlay = musicToPlay
)
}
}
4 changes: 1 addition & 3 deletions fastlane/metadata/android/en-US/changelogs/63.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
Improvements, optimizations and troubleshooting:

* Fix Android Auto not playing the selected music and not respecting the default shuffle mode
Nothing new, issue happened while updating
3 changes: 3 additions & 0 deletions fastlane/metadata/android/en-US/changelogs/64.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Improvements, optimizations and troubleshooting:

* Fix Android Auto not playing the selected music and not respecting the default shuffle mode
4 changes: 1 addition & 3 deletions fastlane/metadata/android/fr-FR/changelogs/63.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
Améliorations, optimisations et dépannage:

* Correction du bogue d'Android Auto qui ne lit pas la musique séléctionnée et qui ne respecte pas le mode aléatoire par défaut
Rien de nouveau. Une erreur est survenue lors de la mise à jour
4 changes: 4 additions & 0 deletions fastlane/metadata/android/fr-FR/changelogs/64.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Améliorations, optimisations et dépannage:

* Correction du bogue d'Android Auto qui ne lit pas la musique séléctionnée et qui ne respecte pas
le mode aléatoire par défaut
2 changes: 1 addition & 1 deletion libs

0 comments on commit 6e846d3

Please sign in to comment.