diff --git a/app/release/app-release.apk b/app/release/app-release.apk index e0dd131..df55cea 100644 Binary files a/app/release/app-release.apk and b/app/release/app-release.apk differ diff --git a/app/release/baselineProfiles/0/app-release.dm b/app/release/baselineProfiles/0/app-release.dm index 0fc5d5a..25ae419 100644 Binary files a/app/release/baselineProfiles/0/app-release.dm and b/app/release/baselineProfiles/0/app-release.dm differ diff --git a/app/release/baselineProfiles/1/app-release.dm b/app/release/baselineProfiles/1/app-release.dm index fc8aab0..68b9be5 100644 Binary files a/app/release/baselineProfiles/1/app-release.dm and b/app/release/baselineProfiles/1/app-release.dm differ diff --git a/app/src/main/java/com/shub39/rush/database/LrcLibSong.kt b/app/src/main/java/com/shub39/rush/database/LrcLibSong.kt index c019693..4472027 100644 --- a/app/src/main/java/com/shub39/rush/database/LrcLibSong.kt +++ b/app/src/main/java/com/shub39/rush/database/LrcLibSong.kt @@ -8,6 +8,6 @@ data class LrcLibSong ( val albumName: String, val duration: Double, val instrumental: Boolean, - val plainLyrics: String, + val plainLyrics: String?, val syncedLyrics: String? ) \ No newline at end of file diff --git a/app/src/main/java/com/shub39/rush/lyrics/LyricsFetcher.kt b/app/src/main/java/com/shub39/rush/lyrics/LyricsFetcher.kt index 05a2be7..4d6f0da 100644 --- a/app/src/main/java/com/shub39/rush/lyrics/LyricsFetcher.kt +++ b/app/src/main/java/com/shub39/rush/lyrics/LyricsFetcher.kt @@ -71,8 +71,8 @@ object LyricsFetcher { val jsonSong = response.body() if (!jsonSong.isNullOrEmpty()) { val song = jsonSong[0] - val lyrics = song.plainLyrics - val syncedLyrics = song.syncedLyrics + val lyrics = song.plainLyrics ?: jsonSong[1].plainLyrics ?: "" + val syncedLyrics = song.syncedLyrics ?: if (jsonSong.size > 1) jsonSong[1].syncedLyrics else null return Pair(lyrics, syncedLyrics) } } diff --git a/app/src/main/java/com/shub39/rush/page/LyricsPage.kt b/app/src/main/java/com/shub39/rush/page/LyricsPage.kt index 809bb7f..e4aa965 100644 --- a/app/src/main/java/com/shub39/rush/page/LyricsPage.kt +++ b/app/src/main/java/com/shub39/rush/page/LyricsPage.kt @@ -109,7 +109,10 @@ fun LyricsPage( } if ( nonNullSong.syncedLyrics != null - && (currentPlayingSong?.first ?: "") == nonNullSong.title + && + (currentPlayingSong?.first ?: "").trim() + .lowercase() == nonNullSong.title.trim() + .lowercase() ) { syncedAvailable = true sync = true @@ -117,8 +120,11 @@ fun LyricsPage( } LaunchedEffect(currentPlayingSong) { - syncedAvailable = (nonNullSong.syncedLyrics != null - && (currentPlayingSong?.first ?: "") == nonNullSong.title) + syncedAvailable = ( + nonNullSong.syncedLyrics != null + && (currentPlayingSong?.first ?: "").trim() + .lowercase() == nonNullSong.title.trim().lowercase() + ) sync = syncedAvailable } @@ -378,9 +384,9 @@ fun LyricsPage( } } - } else { + } else if (nonNullSong.syncedLyrics != null) { val syncedLazyList = rememberLazyListState() - val parsedSyncedLyrics = parseLyrics(nonNullSong.syncedLyrics!!) + val parsedSyncedLyrics = parseLyrics(nonNullSong.syncedLyrics) LaunchedEffect(currentSongPosition) { coroutineScope.launch { @@ -394,22 +400,30 @@ fun LyricsPage( modifier = Modifier.padding(end = 16.dp, start = 16.dp, bottom = 16.dp), state = syncedLazyList ) { - items(parsedSyncedLyrics, key = { it.time }) { + items(parsedSyncedLyrics, key = { it.time }) { lyric -> Row( - modifier = Modifier - .fillMaxWidth() + modifier = Modifier.fillMaxWidth() ) { - Card( - modifier = Modifier - .padding(6.dp), - colors = CardDefaults.cardColors( + val color = if (lyric.time <= currentSongPosition + 2000) { + CardDefaults.cardColors( + containerColor = MaterialTheme.colorScheme.primary, + contentColor = MaterialTheme.colorScheme.onPrimary + ) + } else { + CardDefaults.cardColors( containerColor = MaterialTheme.colorScheme.primaryContainer, contentColor = MaterialTheme.colorScheme.onPrimaryContainer ) - ) { - if (it.text.isNotEmpty()) { + } + + Card( + modifier = Modifier.padding(6.dp), + colors = color, + shape = MaterialTheme.shapes.small, + ) { + if (lyric.text.isNotEmpty()) { Text( - text = it.text, + text = lyric.text, style = MaterialTheme.typography.bodyLarge, fontWeight = FontWeight.Bold, modifier = Modifier.padding(6.dp) @@ -417,14 +431,12 @@ fun LyricsPage( } else { Icon( painter = painterResource(id = R.drawable.round_music_note_24), - contentDescription = null, - modifier = Modifier.padding(6.dp) + contentDescription = null ) } } } } - } } } diff --git a/app/src/main/java/com/shub39/rush/viewmodel/RushViewModel.kt b/app/src/main/java/com/shub39/rush/viewmodel/RushViewModel.kt index c4b1d89..7ffe667 100644 --- a/app/src/main/java/com/shub39/rush/viewmodel/RushViewModel.kt +++ b/app/src/main/java/com/shub39/rush/viewmodel/RushViewModel.kt @@ -44,6 +44,7 @@ class RushViewModel( _songs.value = songDao.getAllSongs() MediaListener.songInfoFlow.collect { songInfo -> _currentPlayingSongInfo.value = songInfo + Log.d("RushViewModel", "SongInfo: $songInfo") } } viewModelScope.launch {