From 81cc42669b08b0e6ee15aca9c3dd261577c81cc2 Mon Sep 17 00:00:00 2001 From: kerollosy Date: Fri, 22 Nov 2024 19:49:26 +0200 Subject: [PATCH 1/4] Rename syncedMusixmatch to unsyncedFallbackMusixmatch and update related methods and references --- .../pl/lambada/songsync/data/UserSettingsController.kt | 10 +++++----- .../remote/lyrics_providers/LyricsProviderService.kt | 4 ++-- .../remote/lyrics_providers/others/MusixmatchAPI.kt | 6 +++--- .../lambada/songsync/ui/screens/home/HomeViewModel.kt | 2 +- .../ui/screens/lyricsFetch/LyricsFetchViewModel.kt | 2 +- .../songsync/ui/screens/settings/SettingsScreen.kt | 4 ++-- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/pl/lambada/songsync/data/UserSettingsController.kt b/app/src/main/java/pl/lambada/songsync/data/UserSettingsController.kt index 8a4abe0..6fc58fc 100644 --- a/app/src/main/java/pl/lambada/songsync/data/UserSettingsController.kt +++ b/app/src/main/java/pl/lambada/songsync/data/UserSettingsController.kt @@ -37,7 +37,7 @@ class UserSettingsController(private val dataStore: DataStore) { var multiPersonWordByWord by mutableStateOf(dataStore.get(multiPersonWordByWordKey, true)) private set - var syncedMusixmatch by mutableStateOf(dataStore.get(syncedMusixmatchKey, true)) + var unsyncedFallbackMusixmatch by mutableStateOf(dataStore.get(unsyncedFallbackMusixmatchKey, true)) private set var pureBlack by mutableStateOf(dataStore.get(pureBlackKey, false)) @@ -97,9 +97,9 @@ class UserSettingsController(private val dataStore: DataStore) { multiPersonWordByWord = to } - fun updateSyncedMusixmatch(to: Boolean) { - dataStore.set(syncedMusixmatchKey, to) - syncedMusixmatch = to + fun updateUnsyncedFallbackMusixmatch(to: Boolean) { + dataStore.set(unsyncedFallbackMusixmatchKey, to) + unsyncedFallbackMusixmatch = to } fun updateDisableMarquee(to: Boolean) { @@ -144,7 +144,7 @@ private val blacklistedFoldersKey = stringPreferencesKey("blacklist") private val hideLyricsKey = booleanPreferencesKey("hide_lyrics") private val includeTranslationKey = booleanPreferencesKey("include_translation") private val multiPersonWordByWordKey = booleanPreferencesKey("multi_person_word_by_word") -private val syncedMusixmatchKey = booleanPreferencesKey("synced_lyrics") +private val unsyncedFallbackMusixmatchKey = booleanPreferencesKey("unsynced_lyrics_fallback") private val disableMarqueeKey = booleanPreferencesKey("marquee_disable") private val pureBlackKey = booleanPreferencesKey("pure_black") private val sdCardPathKey = stringPreferencesKey("sd_card_path") diff --git a/app/src/main/java/pl/lambada/songsync/data/remote/lyrics_providers/LyricsProviderService.kt b/app/src/main/java/pl/lambada/songsync/data/remote/lyrics_providers/LyricsProviderService.kt index 53a129b..134c0d2 100644 --- a/app/src/main/java/pl/lambada/songsync/data/remote/lyrics_providers/LyricsProviderService.kt +++ b/app/src/main/java/pl/lambada/songsync/data/remote/lyrics_providers/LyricsProviderService.kt @@ -95,7 +95,7 @@ class LyricsProviderService { // TODO providers could be a sealed interface to include such parameters includeTranslationNetEase: Boolean = false, multiPersonWordByWord: Boolean = false, - syncedMusixmatch: Boolean = true + unsyncedFallbackMusixmatch: Boolean = true ): String? { return try { when (provider) { @@ -111,7 +111,7 @@ class LyricsProviderService { ) Providers.MUSIXMATCH -> MusixmatchAPI().getLyrics( musixmatchSongInfo, - syncedMusixmatch + unsyncedFallbackMusixmatch ) } } catch (e: Exception) { diff --git a/app/src/main/java/pl/lambada/songsync/data/remote/lyrics_providers/others/MusixmatchAPI.kt b/app/src/main/java/pl/lambada/songsync/data/remote/lyrics_providers/others/MusixmatchAPI.kt index 57c5159..dd527a1 100644 --- a/app/src/main/java/pl/lambada/songsync/data/remote/lyrics_providers/others/MusixmatchAPI.kt +++ b/app/src/main/java/pl/lambada/songsync/data/remote/lyrics_providers/others/MusixmatchAPI.kt @@ -63,10 +63,10 @@ class MusixmatchAPI { /** * Returns the lyrics. * @param songInfo The SongInfo of the song from search results. + * @param preferUnsynced Flag to prefer unsynced lyrics when synced lyrics are not available. * @return The lyrics as a string or null if the lyrics were not found. */ - fun getLyrics(songInfo: SongInfo?, synced: Boolean = true): String? { - return if(synced) songInfo?.syncedLyrics - else songInfo?.unsyncedLyrics + fun getLyrics(songInfo: SongInfo?, preferUnsynced: Boolean = true): String? { + return songInfo?.syncedLyrics ?: if (preferUnsynced) songInfo?.unsyncedLyrics else null } } \ No newline at end of file diff --git a/app/src/main/java/pl/lambada/songsync/ui/screens/home/HomeViewModel.kt b/app/src/main/java/pl/lambada/songsync/ui/screens/home/HomeViewModel.kt index 14e6af9..48b72ab 100644 --- a/app/src/main/java/pl/lambada/songsync/ui/screens/home/HomeViewModel.kt +++ b/app/src/main/java/pl/lambada/songsync/ui/screens/home/HomeViewModel.kt @@ -282,7 +282,7 @@ class HomeViewModel( provider = userSettingsController.selectedProvider, includeTranslationNetEase = userSettingsController.includeTranslation, multiPersonWordByWord = userSettingsController.multiPersonWordByWord, - syncedMusixmatch = userSettingsController.syncedMusixmatch + unsyncedFallbackMusixmatch = userSettingsController.unsyncedFallbackMusixmatch ) } diff --git a/app/src/main/java/pl/lambada/songsync/ui/screens/lyricsFetch/LyricsFetchViewModel.kt b/app/src/main/java/pl/lambada/songsync/ui/screens/lyricsFetch/LyricsFetchViewModel.kt index 57bd55f..07987ec 100644 --- a/app/src/main/java/pl/lambada/songsync/ui/screens/lyricsFetch/LyricsFetchViewModel.kt +++ b/app/src/main/java/pl/lambada/songsync/ui/screens/lyricsFetch/LyricsFetchViewModel.kt @@ -50,7 +50,7 @@ class LyricsFetchViewModel( userSettingsController.selectedProvider, userSettingsController.includeTranslation, userSettingsController.multiPersonWordByWord, - userSettingsController.syncedMusixmatch + userSettingsController.unsyncedFallbackMusixmatch ) fun loadSongInfo(context: Context, tryingAgain: Boolean = false) { diff --git a/app/src/main/java/pl/lambada/songsync/ui/screens/settings/SettingsScreen.kt b/app/src/main/java/pl/lambada/songsync/ui/screens/settings/SettingsScreen.kt index ff14238..8d925c3 100644 --- a/app/src/main/java/pl/lambada/songsync/ui/screens/settings/SettingsScreen.kt +++ b/app/src/main/java/pl/lambada/songsync/ui/screens/settings/SettingsScreen.kt @@ -102,8 +102,8 @@ fun SettingsScreen( item { SyncedLyricsSwitch( - selected = userSettingsController.syncedMusixmatch, - onToggle = { userSettingsController.updateSyncedMusixmatch(it) } + selected = userSettingsController.unsyncedFallbackMusixmatch, + onToggle = { userSettingsController.updateUnsyncedFallbackMusixmatch(it) } ) } From a522cea29360395a6e2397f807d60045ca359c16 Mon Sep 17 00:00:00 2001 From: kerollosy Date: Fri, 22 Nov 2024 19:49:52 +0200 Subject: [PATCH 2/4] Update string resources to reflect unsynced lyrics fallback behavior --- app/src/main/res/values/strings.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f7dba66..2ba7bb4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -128,8 +128,8 @@ Offset Show song path Show the path of a song file on song list - Get Synced Lyrics - Toggle to switch between synced and unsynced lyrics from Musixmatch. + Get Unsynced Lyrics + Toggle to get unsynced lyrics from Musixmatch when synced lyrics aren't found. Title Artist Album From 47b831e33aab8edf83cacd6edcee0a42064c9447 Mon Sep 17 00:00:00 2001 From: Lambada10 <62511588+Lambada10@users.noreply.github.com> Date: Thu, 28 Nov 2024 12:32:14 +0100 Subject: [PATCH 3/4] Update strings.xml --- app/src/main/res/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3ed5e51..4279795 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -129,7 +129,7 @@ Show song path Show the path of a song file on song list Get Unsynced Lyrics - Toggle to get unsynced lyrics from Musixmatch when synced lyrics aren't found. + Toggle to get unsynced lyrics from Musixmatch when synced lyrics aren\'t found. Title Artist Album From b324b63e79e50734159d66473ac37fc91bd0a5e1 Mon Sep 17 00:00:00 2001 From: Lambada10 <62511588+Lambada10@users.noreply.github.com> Date: Thu, 28 Nov 2024 12:58:04 +0100 Subject: [PATCH 4/4] Conflicts moment --- .../quicksearch/viewmodel/QuickLyricsSearchViewModel.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/pl/lambada/songsync/activities/quicksearch/viewmodel/QuickLyricsSearchViewModel.kt b/app/src/main/java/pl/lambada/songsync/activities/quicksearch/viewmodel/QuickLyricsSearchViewModel.kt index 34de372..9bfd008 100644 --- a/app/src/main/java/pl/lambada/songsync/activities/quicksearch/viewmodel/QuickLyricsSearchViewModel.kt +++ b/app/src/main/java/pl/lambada/songsync/activities/quicksearch/viewmodel/QuickLyricsSearchViewModel.kt @@ -113,7 +113,7 @@ class QuickLyricsSearchViewModel( userSettingsController.selectedProvider, userSettingsController.includeTranslation, userSettingsController.multiPersonWordByWord, - userSettingsController.syncedMusixmatch + userSettingsController.unsyncedFallbackMusixmatch ) private fun updateScreenState(screenState: ScreenState) {