diff --git a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/adapters/ArtistRowBinder.kt b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/adapters/ArtistRowBinder.kt index bb18f9ae..76543e82 100644 --- a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/adapters/ArtistRowBinder.kt +++ b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/adapters/ArtistRowBinder.kt @@ -1,6 +1,6 @@ /* - * ArtistRowAdapter.kt - * Copyright (C) 2009-2021 Ultrasonic developers + * ArtistRowBinder.kt + * Copyright (C) 2009-2022 Ultrasonic developers * * Distributed under terms of the GNU GPLv3 license. */ @@ -110,11 +110,7 @@ class ArtistRowBinder( } private fun showArtistPicture(): Boolean { - val isOnline = !ActiveServerProvider.isOffline() - val shouldShowArtistPicture = Settings.shouldShowArtistPicture - - val id3Enabled = (isOnline && Settings.shouldUseId3Tags) || Settings.useId3TagsOffline - return id3Enabled && shouldShowArtistPicture + return ActiveServerProvider.isID3Enabled() && Settings.shouldShowArtistPicture } /** diff --git a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/data/ActiveServerProvider.kt b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/data/ActiveServerProvider.kt index a63e9f0d..5e3cc2d0 100644 --- a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/data/ActiveServerProvider.kt +++ b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/data/ActiveServerProvider.kt @@ -249,6 +249,13 @@ class ActiveServerProvider( return preferences.getBoolean(Constants.PREFERENCES_KEY_SCROBBLE, false) } + /** + * Queries if ID3 tags should be used + */ + fun isID3Enabled(): Boolean { + return Settings.shouldUseId3Tags && (!isOffline() || Settings.useId3TagsOffline) + } + /** * Queries if Server Scaling is enabled */ diff --git a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/fragment/TrackCollectionFragment.kt b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/fragment/TrackCollectionFragment.kt index b9b9f549..54587ee5 100644 --- a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/fragment/TrackCollectionFragment.kt +++ b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/fragment/TrackCollectionFragment.kt @@ -1,6 +1,6 @@ /* * TrackCollectionFragment.kt - * Copyright (C) 2009-2021 Ultrasonic developers + * Copyright (C) 2009-2022 Ultrasonic developers * * Distributed under terms of the GNU GPLv3 license. */ @@ -31,6 +31,7 @@ import org.moire.ultrasonic.adapters.AlbumHeader import org.moire.ultrasonic.adapters.AlbumRowBinder import org.moire.ultrasonic.adapters.HeaderViewBinder import org.moire.ultrasonic.adapters.TrackViewBinder +import org.moire.ultrasonic.data.ActiveServerProvider import org.moire.ultrasonic.data.ActiveServerProvider.Companion.isOffline import org.moire.ultrasonic.domain.Identifiable import org.moire.ultrasonic.domain.MusicDirectory @@ -604,7 +605,7 @@ open class TrackCollectionFragment : MultiListFragment() { listModel.getRandom(albumListSize) } else { setTitle(name) - if (!isOffline() && Settings.shouldUseId3Tags || Settings.useId3TagsOffline) { + if (ActiveServerProvider.isID3Enabled()) { if (isAlbum) { listModel.getAlbum(refresh2, id!!, name) } else { diff --git a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/model/ArtistListModel.kt b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/model/ArtistListModel.kt index 76118894..e41c6bbc 100644 --- a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/model/ArtistListModel.kt +++ b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/model/ArtistListModel.kt @@ -1,20 +1,8 @@ /* - This file is part of Subsonic. - - Subsonic is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Subsonic is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Subsonic. If not, see . - - Copyright 2020 (C) Jozsef Varga + * ArtistListModel.kt + * Copyright (C) 2009-2022 Ultrasonic developers + * + * Distributed under terms of the GNU GPLv3 license. */ package org.moire.ultrasonic.model @@ -24,9 +12,9 @@ import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.swiperefreshlayout.widget.SwipeRefreshLayout import java.text.Collator +import org.moire.ultrasonic.data.ActiveServerProvider import org.moire.ultrasonic.domain.ArtistOrIndex import org.moire.ultrasonic.service.MusicService -import org.moire.ultrasonic.util.Settings /** * Provides ViewModel which contains the list of available Artists @@ -57,12 +45,10 @@ class ArtistListModel(application: Application) : GenericListModel(application) val musicFolderId = activeServer.musicFolderId - val result: List - - if (!isOffline && useId3Tags || Settings.useId3TagsOffline) { - result = musicService.getArtists(refresh) + val result = if (ActiveServerProvider.isID3Enabled()) { + musicService.getArtists(refresh) } else { - result = musicService.getIndexes(musicFolderId, refresh) + musicService.getIndexes(musicFolderId, refresh) } artists.postValue(result.toMutableList().sortedWith(comparator)) diff --git a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/util/Settings.kt b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/util/Settings.kt index ce559913..a6a131ec 100644 --- a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/util/Settings.kt +++ b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/util/Settings.kt @@ -1,6 +1,6 @@ /* * Settings.kt - * Copyright (C) 2009-2021 Ultrasonic developers + * Copyright (C) 2009-2022 Ultrasonic developers * * Distributed under terms of the GNU GPLv3 license. */ @@ -160,9 +160,12 @@ object Settings { var showNowPlayingDetails by BooleanSetting(Constants.PREFERENCES_KEY_SHOW_NOW_PLAYING_DETAILS, false) + // Normally you don't need to use these Settings directly, + // use ActiveServerProvider.isID3Enabled() instead @JvmStatic var shouldUseId3Tags by BooleanSetting(Constants.PREFERENCES_KEY_ID3_TAGS, false) + // See comment above. @JvmStatic var useId3TagsOffline by BooleanSetting(Constants.PREFERENCES_KEY_ID3_TAGS_OFFLINE, false)