Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: Malopieds/InnerTune
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.5.6
Choose a base ref
...
head repository: Malopieds/InnerTune
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.5.7-rc1
Choose a head ref
  • 14 commits
  • 48 files changed
  • 1 contributor

Commits on Apr 7, 2024

  1. feat(player): improve player UI #46

    Malopieds committed Apr 7, 2024
    Copy the full SHA
    f934057 View commit details
  2. feat(notification): remove add to library

    Malopieds committed Apr 7, 2024
    Copy the full SHA
    31eab06 View commit details

Commits on Apr 8, 2024

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    d382f52 View commit details
  2. feat(library): like is the new add to library, fix #58 and fix #57

    Malopieds committed Apr 8, 2024
    Copy the full SHA
    943b8ed View commit details
  3. feat(library): add sort to mix screen

    Malopieds committed Apr 8, 2024
    Copy the full SHA
    1b64061 View commit details

Commits on Apr 9, 2024

  1. fix(building): fix not building

    Malopieds committed Apr 9, 2024
    Copy the full SHA
    68de3ad View commit details

Commits on Apr 10, 2024

  1. feat(explore): sort new release for user

    Malopieds committed Apr 10, 2024
    Copy the full SHA
    b17040e View commit details
  2. Copy the full SHA
    34089e1 View commit details
  3. feat(UI): mutliselect implementation #12

    Malopieds committed Apr 10, 2024
    Copy the full SHA
    d99db7c View commit details
  4. fix(build): missing xml

    Malopieds committed Apr 10, 2024
    Copy the full SHA
    f7c7dd1 View commit details
  5. Copy the full SHA
    2f26e4f View commit details
  6. feat(UX): add haptic feedback on long press

    Malopieds committed Apr 10, 2024
    Copy the full SHA
    14ca8c4 View commit details

Commits on Apr 11, 2024

  1. feat(lyrics): add lrclib as provider closes #27 closes #50

    Malopieds committed Apr 11, 2024
    Copy the full SHA
    7ccbf3c View commit details

Commits on Apr 13, 2024

  1. fix(lyrics): additional space

    Malopieds committed Apr 13, 2024
    Copy the full SHA
    37024bf View commit details
Showing with 1,765 additions and 723 deletions.
  1. +1 −0 app/build.gradle.kts
  2. +0 −4 app/src/main/java/com/zionhuang/music/App.kt
  3. +4 −15 app/src/main/java/com/zionhuang/music/constants/PreferenceKeys.kt
  4. +29 −0 app/src/main/java/com/zionhuang/music/db/DatabaseDao.kt
  5. +16 −0 app/src/main/java/com/zionhuang/music/lyrics/LrcLibLyricsProvider.kt
  6. +1 −1 app/src/main/java/com/zionhuang/music/lyrics/LyricsHelper.kt
  7. +1 −1 app/src/main/java/com/zionhuang/music/lyrics/LyricsUtils.kt
  8. +5 −15 app/src/main/java/com/zionhuang/music/playback/MusicService.kt
  9. +30 −4 app/src/main/java/com/zionhuang/music/ui/component/Items.kt
  10. +209 −0 app/src/main/java/com/zionhuang/music/ui/menu/SelectionSongsMenu.kt
  11. +123 −77 app/src/main/java/com/zionhuang/music/ui/player/Player.kt
  12. +26 −40 app/src/main/java/com/zionhuang/music/ui/player/Queue.kt
  13. +4 −0 app/src/main/java/com/zionhuang/music/ui/screens/AccountScreen.kt
  14. +125 −31 app/src/main/java/com/zionhuang/music/ui/screens/AlbumScreen.kt
  15. +4 −0 app/src/main/java/com/zionhuang/music/ui/screens/ExploreScreen.kt
  16. +26 −10 app/src/main/java/com/zionhuang/music/ui/screens/HistoryScreen.kt
  17. +59 −20 app/src/main/java/com/zionhuang/music/ui/screens/HomeScreen.kt
  18. +4 −0 app/src/main/java/com/zionhuang/music/ui/screens/NewReleaseScreen.kt
  19. +27 −10 app/src/main/java/com/zionhuang/music/ui/screens/StatsScreen.kt
  20. +4 −0 app/src/main/java/com/zionhuang/music/ui/screens/YouTubeBrowseScreen.kt
  21. +4 −0 app/src/main/java/com/zionhuang/music/ui/screens/artist/ArtistItemsScreen.kt
  22. +46 −12 app/src/main/java/com/zionhuang/music/ui/screens/artist/ArtistScreen.kt
  23. +26 −11 app/src/main/java/com/zionhuang/music/ui/screens/artist/ArtistSongsScreen.kt
  24. +4 −0 app/src/main/java/com/zionhuang/music/ui/screens/library/LibraryAlbumsScreen.kt
  25. +4 −0 app/src/main/java/com/zionhuang/music/ui/screens/library/LibraryArtistsScreen.kt
  26. +45 −1 app/src/main/java/com/zionhuang/music/ui/screens/library/LibraryMixScreen.kt
  27. +4 −0 app/src/main/java/com/zionhuang/music/ui/screens/library/LibraryPlaylistsScreen.kt
  28. +120 −38 app/src/main/java/com/zionhuang/music/ui/screens/library/LibrarySongsScreen.kt
  29. +140 −55 app/src/main/java/com/zionhuang/music/ui/screens/playlist/AutoPlaylistScreen.kt
  30. +134 −42 app/src/main/java/com/zionhuang/music/ui/screens/playlist/LocalPlaylistScreen.kt
  31. +139 −53 app/src/main/java/com/zionhuang/music/ui/screens/playlist/TopPlaylistScreen.kt
  32. +13 −0 app/src/main/java/com/zionhuang/music/ui/utils/ItemWrapper.kt
  33. +20 −12 app/src/main/java/com/zionhuang/music/viewmodels/ExploreViewModel.kt
  34. +12 −78 app/src/main/java/com/zionhuang/music/viewmodels/LibraryViewModels.kt
  35. +20 −12 app/src/main/java/com/zionhuang/music/viewmodels/NewReleaseViewModel.kt
  36. +1 −19 app/src/main/java/com/zionhuang/music/viewmodels/TopPlaylistViewModel.kt
  37. +5 −0 app/src/main/res/drawable/deselect.xml
  38. +9 −0 app/src/main/res/drawable/done.xml
  39. +9 −0 app/src/main/res/drawable/select_all.xml
  40. +1 −1 app/src/main/res/values/strings.xml
  41. +1 −0 gradle/libs.versions.toml
  42. +6 −4 innertube/src/main/java/com/zionhuang/innertube/YouTube.kt
  43. +160 −157 kugou/src/main/java/com/zionhuang/kugou/KuGou.kt
  44. +1 −0 lrclib/.gitignore
  45. +20 −0 lrclib/build.gradle.kts
  46. +103 −0 lrclib/src/main/java/com/zionhuang/lrclib/LrcLib.kt
  47. +19 −0 lrclib/src/main/java/com/zionhuang/lrclib/models/Track.kt
  48. +1 −0 settings.gradle.kts
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -128,6 +128,7 @@ dependencies {

implementation(projects.innertube)
implementation(projects.kugou)
implementation(projects.lrclib)

coreLibraryDesugaring(libs.desugaring)

4 changes: 0 additions & 4 deletions app/src/main/java/com/zionhuang/music/App.kt
Original file line number Diff line number Diff line change
@@ -10,7 +10,6 @@ import coil.ImageLoaderFactory
import coil.disk.DiskCache
import com.zionhuang.innertube.YouTube
import com.zionhuang.innertube.models.YouTubeLocale
import com.zionhuang.kugou.KuGou
import com.zionhuang.music.constants.*
import com.zionhuang.music.extensions.*
import com.zionhuang.music.utils.dataStore
@@ -44,9 +43,6 @@ class App : Application(), ImageLoaderFactory {
?: languageTag.takeIf { it in LanguageCodeToName }
?: "en"
)
if (languageTag == "zh-TW") {
KuGou.useTraditionalChinese = true
}

if (dataStore[ProxyEnabledKey] == true) {
try {
19 changes: 4 additions & 15 deletions app/src/main/java/com/zionhuang/music/constants/PreferenceKeys.kt
Original file line number Diff line number Diff line change
@@ -48,15 +48,12 @@ val PlaylistSortTypeKey = stringPreferencesKey("playlistSortType")
val PlaylistSortDescendingKey = booleanPreferencesKey("playlistSortDescending")
val ArtistSongSortTypeKey = stringPreferencesKey("artistSongSortType")
val ArtistSongSortDescendingKey = booleanPreferencesKey("artistSongSortDescending")
val MixSortTypeKey = stringPreferencesKey("mixSortType")
val MixSortDescendingKey = booleanPreferencesKey("albumSortDescending")

val SongFilterKey = stringPreferencesKey("songFilter")
val ArtistFilterKey = stringPreferencesKey("artistFilter")
val ArtistViewTypeKey = stringPreferencesKey("artistViewType")
val AlbumFilterKey = stringPreferencesKey("albumFilter")
val AlbumViewTypeKey = stringPreferencesKey("albumViewType")
val PlaylistViewTypeKey = stringPreferencesKey("playlistViewType")
val LibraryFilterKey = stringPreferencesKey("libraryFilter")
val MyTopTypeKey = stringPreferencesKey("MyTopType")

val PlaylistEditLockKey = booleanPreferencesKey("playlistEditLock")

@@ -93,16 +90,8 @@ enum class PlaylistSortType {
CREATE_DATE, NAME, SONG_COUNT
}

enum class SongFilter {
LIBRARY, LIKED, DOWNLOADED
}

enum class ArtistFilter {
LIBRARY, LIKED
}

enum class AlbumFilter {
LIBRARY, LIKED
enum class MixSortType {
CREATE_DATE, NAME
}

enum class MyTopFilter {
29 changes: 29 additions & 0 deletions app/src/main/java/com/zionhuang/music/db/DatabaseDao.kt
Original file line number Diff line number Diff line change
@@ -314,6 +314,35 @@ interface DatabaseDao {
@Query("SELECT * FROM song")
fun allSongs(): Flow<List<Song>>

@Transaction
@Query(
"""
SELECT DISTINCT artist.*,
(SELECT COUNT(1)
FROM song_artist_map
JOIN event ON song_artist_map.songId = event.songId
WHERE artistId = artist.id) AS songCount
FROM artist
LEFT JOIN(SELECT artistId, SUM(songTotalPlayTime) AS totalPlayTime
FROM song_artist_map
JOIN (SELECT songId, SUM(playTime) AS songTotalPlayTime
FROM event
GROUP BY songId) AS e
ON song_artist_map.songId = e.songId
GROUP BY artistId
ORDER BY totalPlayTime DESC) AS artistTotalPlayTime
ON artist.id = artistId
OR artist.bookmarkedAt IS NOT NULL
ORDER BY
CASE
WHEN artistTotalPlayTime.artistId IS NULL THEN 1
ELSE 0
END,
artistTotalPlayTime.totalPlayTime DESC
"""
)
fun allArtistsByPlayTime(): Flow<List<Artist>>

@Query("SELECT * FROM format WHERE id = :id")
fun format(id: String?): Flow<FormatEntity?>

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.zionhuang.music.lyrics

import android.content.Context
import com.zionhuang.lrclib.LrcLib

object LrcLibLyricsProvider : LyricsProvider {
override val name = "LrcLib"
override fun isEnabled(context: Context) = true

override suspend fun getLyrics(id: String, title: String, artist: String, duration: Int): Result<String> =
LrcLib.getLyrics(title, artist, duration)

override suspend fun getAllLyrics(id: String, title: String, artist: String, duration: Int, callback: (String) -> Unit) {
LrcLib.getAllLyrics(title, artist, duration, null, callback)
}
}
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ import javax.inject.Inject
class LyricsHelper @Inject constructor(
@ApplicationContext private val context: Context,
) {
private val lyricsProviders = listOf(YouTubeSubtitleLyricsProvider, KuGouLyricsProvider, YouTubeLyricsProvider)
private val lyricsProviders = listOf(LrcLibLyricsProvider,KuGouLyricsProvider, YouTubeSubtitleLyricsProvider, YouTubeLyricsProvider)
private val cache = LruCache<String, List<LyricsResult>>(MAX_CACHE_SIZE)

suspend fun getLyrics(mediaMetadata: MediaMetadata): String {
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ import com.zionhuang.music.ui.component.animateScrollDuration

@Suppress("RegExpRedundantEscape")
object LyricsUtils {
val LINE_REGEX = "((\\[\\d\\d:\\d\\d\\.\\d{2,3}\\])+)(.+)".toRegex()
val LINE_REGEX = "((\\[\\d\\d:\\d\\d\\.\\d{2,3}\\] ?)+)(.+)".toRegex()
val TIME_REGEX = "\\[(\\d\\d):(\\d\\d)\\.(\\d{2,3})\\]".toRegex()

fun parseLyrics(lyrics: String): List<LyricsEntry> =
20 changes: 5 additions & 15 deletions app/src/main/java/com/zionhuang/music/playback/MusicService.kt
Original file line number Diff line number Diff line change
@@ -16,15 +16,11 @@ import androidx.media3.common.C
import androidx.media3.common.MediaItem
import androidx.media3.common.PlaybackException
import androidx.media3.common.Player
import androidx.media3.common.Player.EVENT_IS_PLAYING_CHANGED
import androidx.media3.common.Player.EVENT_PLAYBACK_STATE_CHANGED
import androidx.media3.common.Player.EVENT_PLAY_WHEN_READY_CHANGED
import androidx.media3.common.Player.EVENT_POSITION_DISCONTINUITY
import androidx.media3.common.Player.EVENT_TIMELINE_CHANGED
import androidx.media3.common.Player.REPEAT_MODE_ALL
import androidx.media3.common.Player.REPEAT_MODE_OFF
import androidx.media3.common.Player.REPEAT_MODE_ONE
import androidx.media3.common.Player.STATE_ENDED
import androidx.media3.common.Player.STATE_IDLE
import androidx.media3.common.Timeline
import androidx.media3.common.audio.SonicAudioProcessor
@@ -328,23 +324,12 @@ class MusicService : MediaLibraryService(),
private fun updateNotification() {
mediaSession.setCustomLayout(
listOf(
CommandButton.Builder()
.setDisplayName(getString(if (currentSong.value?.song?.inLibrary != null) R.string.remove_from_library else R.string.add_to_library))
.setIconResId(if (currentSong.value?.song?.inLibrary != null) R.drawable.library_add_check else R.drawable.library_add)
.setSessionCommand(CommandToggleLibrary)
.setEnabled(currentSong.value != null)
.build(),
CommandButton.Builder()
.setDisplayName(getString(if (currentSong.value?.song?.liked == true) R.string.action_remove_like else R.string.action_like))
.setIconResId(if (currentSong.value?.song?.liked == true) R.drawable.favorite else R.drawable.favorite_border)
.setSessionCommand(CommandToggleLike)
.setEnabled(currentSong.value != null)
.build(),
CommandButton.Builder()
.setDisplayName(getString(if (player.shuffleModeEnabled) R.string.action_shuffle_off else R.string.action_shuffle_on))
.setIconResId(if (player.shuffleModeEnabled) R.drawable.shuffle_on else R.drawable.shuffle)
.setSessionCommand(CommandToggleShuffle)
.build(),
CommandButton.Builder()
.setDisplayName(
getString(
@@ -365,6 +350,11 @@ class MusicService : MediaLibraryService(),
}
)
.setSessionCommand(CommandToggleRepeatMode)
.build(),
CommandButton.Builder()
.setDisplayName(getString(if (player.shuffleModeEnabled) R.string.action_shuffle_off else R.string.action_shuffle_on))
.setIconResId(if (player.shuffleModeEnabled) R.drawable.shuffle_on else R.drawable.shuffle)
.setSessionCommand(CommandToggleShuffle)
.build()
)
)
34 changes: 30 additions & 4 deletions app/src/main/java/com/zionhuang/music/ui/component/Items.kt
Original file line number Diff line number Diff line change
@@ -55,6 +55,7 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.util.fastForEachIndexed
import androidx.compose.ui.zIndex
import androidx.core.graphics.drawable.toBitmapOrNull
import androidx.media3.exoplayer.offline.Download
import androidx.media3.exoplayer.offline.Download.STATE_COMPLETED
@@ -291,6 +292,7 @@ fun SongListItem(
showLikedIcon: Boolean = true,
showInLibraryIcon: Boolean = false,
showDownloadIcon: Boolean = true,
isSelected: Boolean = false,
badges: @Composable RowScope.() -> Unit = {
if (showLikedIcon && song.song.liked) {
Icon(
@@ -354,12 +356,36 @@ fun SongListItem(
enter = fadeIn() + expandIn(expandFrom = Alignment.Center),
exit = shrinkOut(shrinkTowards = Alignment.Center) + fadeOut()
) {
Text(
text = albumIndex.toString(),
style = MaterialTheme.typography.labelLarge
)

if (isSelected) {
Icon(
painter = painterResource(R.drawable.done),
modifier = Modifier.align(Alignment.Center),
contentDescription = null
)
}else {
Text(
text = albumIndex.toString(),
style = MaterialTheme.typography.labelLarge
)
}
}
} else {
if (isSelected) {
Box(
modifier = Modifier
.fillMaxSize()
.zIndex(1000f)
.clip(RoundedCornerShape(ThumbnailCornerRadius))
.background(Color.Black.copy(alpha = 0.5f))
) {
Icon(
painter = painterResource(R.drawable.done),
modifier = Modifier.align(Alignment.Center),
contentDescription = null
)
}
}
AsyncImage(
model = song.song.thumbnailUrl,
contentDescription = null,
Loading