diff --git a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/activity/NavigationActivity.kt b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/activity/NavigationActivity.kt index bbaea16b..d6aa2737 100644 --- a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/activity/NavigationActivity.kt +++ b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/activity/NavigationActivity.kt @@ -152,6 +152,12 @@ class NavigationActivity : AppCompatActivity() { var showWelcomeScreen = Util.isFirstRun() val areServersMigrated: Boolean = serverSettingsModel.migrateFromPreferences() + // Migrate Feature storage if needed + // TODO: Remove in December 2022 + if (!Settings.hasKey(Constants.PREFERENCES_KEY_USE_FIVE_STAR_RATING)) { + Settings.migrateFeatureStorage() + } + // If there are any servers in the DB, do not show the welcome screen showWelcomeScreen = showWelcomeScreen and !areServersMigrated diff --git a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/adapters/TrackViewHolder.kt b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/adapters/TrackViewHolder.kt index 6c58d85a..2ec56ddb 100644 --- a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/adapters/TrackViewHolder.kt +++ b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/adapters/TrackViewHolder.kt @@ -13,12 +13,9 @@ import androidx.lifecycle.MutableLiveData import androidx.recyclerview.widget.RecyclerView import io.reactivex.rxjava3.disposables.Disposable import org.koin.core.component.KoinComponent -import org.koin.core.component.get import org.moire.ultrasonic.R import org.moire.ultrasonic.data.ActiveServerProvider import org.moire.ultrasonic.domain.MusicDirectory -import org.moire.ultrasonic.featureflags.Feature -import org.moire.ultrasonic.featureflags.FeatureStorage import org.moire.ultrasonic.service.DownloadFile import org.moire.ultrasonic.service.DownloadStatus import org.moire.ultrasonic.service.MusicServiceFactory @@ -61,11 +58,6 @@ class TrackViewHolder(val view: View) : RecyclerView.ViewHolder(view), Checkable var observableChecked = MutableLiveData(false) - private val useFiveStarRating: Boolean by lazy { - val features: FeatureStorage = get() - features.isFeatureEnabled(Feature.FIVE_STAR_RATING) - } - lateinit var imageHelper: Utils.ImageHelper fun setSong( @@ -74,6 +66,7 @@ class TrackViewHolder(val view: View) : RecyclerView.ViewHolder(view), Checkable draggable: Boolean, isSelected: Boolean = false ) { + val useFiveStarRating = Settings.useFiveStarRating val song = file.song downloadFile = file entry = song @@ -98,7 +91,7 @@ class TrackViewHolder(val view: View) : RecyclerView.ViewHolder(view), Checkable star.isVisible = false rating.isVisible = false } else { - setupStarButtons(song) + setupStarButtons(song, useFiveStarRating) } updateProgress(downloadFile!!.progress.value!!) @@ -138,7 +131,7 @@ class TrackViewHolder(val view: View) : RecyclerView.ViewHolder(view), Checkable } } - private fun setupStarButtons(song: MusicDirectory.Entry) { + private fun setupStarButtons(song: MusicDirectory.Entry, useFiveStarRating: Boolean) { if (useFiveStarRating) { // Hide single star star.isVisible = false diff --git a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/app/UApp.kt b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/app/UApp.kt index 36eb3786..2096928f 100644 --- a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/app/UApp.kt +++ b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/app/UApp.kt @@ -9,7 +9,6 @@ import org.moire.ultrasonic.BuildConfig import org.moire.ultrasonic.di.appPermanentStorage import org.moire.ultrasonic.di.applicationModule import org.moire.ultrasonic.di.baseNetworkModule -import org.moire.ultrasonic.di.featureFlagsModule import org.moire.ultrasonic.di.mediaPlayerModule import org.moire.ultrasonic.di.musicServiceModule import org.moire.ultrasonic.log.FileLoggerTree @@ -47,7 +46,6 @@ class UApp : MultiDexApplication() { applicationModule, appPermanentStorage, baseNetworkModule, - featureFlagsModule, musicServiceModule, mediaPlayerModule ) diff --git a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/di/FeatureFlagsModule.kt b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/di/FeatureFlagsModule.kt deleted file mode 100644 index 303f058a..00000000 --- a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/di/FeatureFlagsModule.kt +++ /dev/null @@ -1,12 +0,0 @@ -package org.moire.ultrasonic.di - -import org.koin.android.ext.koin.androidContext -import org.koin.dsl.module -import org.moire.ultrasonic.featureflags.FeatureStorage - -/** - * This Koin module contains the registration for the Feature Flags - */ -val featureFlagsModule = module { - factory { FeatureStorage(androidContext()) } -} diff --git a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/featureflags/Feature.kt b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/featureflags/Feature.kt deleted file mode 100644 index a92edbc4..00000000 --- a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/featureflags/Feature.kt +++ /dev/null @@ -1,18 +0,0 @@ -package org.moire.ultrasonic.featureflags - -/** - * Contains a list of new features/implementations that are not yet finished, - * but possible to try it out. - */ -enum class Feature( - val defaultValue: Boolean -) { - /** - * Enables new image downloader implementation. - */ - NEW_IMAGE_DOWNLOADER(false), - /** - * Enables five star rating system. - */ - FIVE_STAR_RATING(false) -} diff --git a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/featureflags/FeatureStorage.kt b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/featureflags/FeatureStorage.kt deleted file mode 100644 index dca9bb4f..00000000 --- a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/featureflags/FeatureStorage.kt +++ /dev/null @@ -1,31 +0,0 @@ -package org.moire.ultrasonic.featureflags - -import android.content.Context - -private const val SP_NAME = "feature_flags" - -/** - * Provides storage for current feature flag state. - */ -class FeatureStorage( - context: Context -) { - private val sp = context.getSharedPreferences(SP_NAME, Context.MODE_PRIVATE) - - /** - * Get [feature] current enabled state. - */ - fun isFeatureEnabled(feature: Feature): Boolean { - return sp.getBoolean(feature.name, feature.defaultValue) - } - - /** - * Update [feature] enabled state to [isEnabled]. - */ - fun changeFeatureFlag( - feature: Feature, - isEnabled: Boolean - ) { - sp.edit().putBoolean(feature.name, isEnabled).apply() - } -} diff --git a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/fragment/PlayerFragment.kt b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/fragment/PlayerFragment.kt index 04f9c2d3..e1a145ae 100644 --- a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/fragment/PlayerFragment.kt +++ b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/fragment/PlayerFragment.kt @@ -70,8 +70,6 @@ import org.moire.ultrasonic.domain.Identifiable import org.moire.ultrasonic.domain.MusicDirectory import org.moire.ultrasonic.domain.PlayerState import org.moire.ultrasonic.domain.RepeatMode -import org.moire.ultrasonic.featureflags.Feature -import org.moire.ultrasonic.featureflags.FeatureStorage import org.moire.ultrasonic.fragment.FragmentTitle.Companion.setTitle import org.moire.ultrasonic.service.DownloadFile import org.moire.ultrasonic.service.LocalMediaPlayer @@ -210,7 +208,7 @@ class PlayerFragment : val width = size.x val height = size.y setHasOptionsMenu(true) - useFiveStarRating = get().isFeatureEnabled(Feature.FIVE_STAR_RATING) + useFiveStarRating = Settings.useFiveStarRating swipeDistance = (width + height) * PERCENTAGE_OF_SCREEN_FOR_SWIPE / 100 swipeVelocity = swipeDistance gestureScanner = GestureDetector(context, this) diff --git a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/fragment/SettingsFragment.kt b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/fragment/SettingsFragment.kt index 5603aa82..a50fa32b 100644 --- a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/fragment/SettingsFragment.kt +++ b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/fragment/SettingsFragment.kt @@ -23,12 +23,9 @@ import androidx.preference.PreferenceFragmentCompat import java.io.File import kotlin.math.ceil import org.koin.core.component.KoinComponent -import org.koin.java.KoinJavaComponent.get import org.koin.java.KoinJavaComponent.inject import org.moire.ultrasonic.R import org.moire.ultrasonic.app.UApp -import org.moire.ultrasonic.featureflags.Feature -import org.moire.ultrasonic.featureflags.FeatureStorage import org.moire.ultrasonic.fragment.FragmentTitle.Companion.setTitle import org.moire.ultrasonic.log.FileLoggerTree import org.moire.ultrasonic.log.FileLoggerTree.Companion.deleteLogFiles @@ -142,7 +139,6 @@ class SettingsFragment : sharingDefaultGreeting!!.text = shareGreeting setupClearSearchPreference() - setupFeatureFlagsPreferences() setupCacheLocationPreference() setupBluetoothDevicePreferences() @@ -371,21 +367,6 @@ class SettingsFragment : } } - private fun setupFeatureFlagsPreferences() { - val featureStorage = get(FeatureStorage::class.java) - val useFiveStarRating = findPreference( - Constants.PREFERENCES_KEY_USE_FIVE_STAR_RATING - ) as CheckBoxPreference? - if (useFiveStarRating != null) { - useFiveStarRating.isChecked = featureStorage.isFeatureEnabled(Feature.FIVE_STAR_RATING) - useFiveStarRating.onPreferenceChangeListener = - Preference.OnPreferenceChangeListener { _: Preference?, o: Any? -> - featureStorage.changeFeatureFlag(Feature.FIVE_STAR_RATING, (o as Boolean?)!!) - true - } - } - } - private fun update() { theme!!.summary = theme!!.entry maxBitrateWifi!!.summary = maxBitrateWifi!!.entry diff --git a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/service/MediaPlayerController.kt b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/service/MediaPlayerController.kt index 55bffc4c..55cf2796 100644 --- a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/service/MediaPlayerController.kt +++ b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/service/MediaPlayerController.kt @@ -8,15 +8,12 @@ package org.moire.ultrasonic.service import android.content.Intent import org.koin.core.component.KoinComponent -import org.koin.core.component.get import org.koin.core.component.inject import org.moire.ultrasonic.app.UApp import org.moire.ultrasonic.data.ActiveServerProvider import org.moire.ultrasonic.domain.MusicDirectory import org.moire.ultrasonic.domain.PlayerState import org.moire.ultrasonic.domain.RepeatMode -import org.moire.ultrasonic.featureflags.Feature -import org.moire.ultrasonic.featureflags.FeatureStorage import org.moire.ultrasonic.service.MediaPlayerService.Companion.executeOnStartedMediaPlayerService import org.moire.ultrasonic.service.MediaPlayerService.Companion.getInstance import org.moire.ultrasonic.service.MediaPlayerService.Companion.runningInstance @@ -473,8 +470,7 @@ class MediaPlayerController( @Suppress("TooGenericExceptionCaught") // The interface throws only generic exceptions fun setSongRating(rating: Int) { - val features: FeatureStorage = get() - if (!features.isFeatureEnabled(Feature.FIVE_STAR_RATING)) return + if (!Settings.useFiveStarRating) return if (localMediaPlayer.currentPlaying == null) return val song = localMediaPlayer.currentPlaying!!.song song.userRating = rating 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 29c13b18..e5240e33 100644 --- a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/util/Settings.kt +++ b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/util/Settings.kt @@ -297,11 +297,6 @@ object Settings { return 0 } - var shouldShowAllSongsByArtist by BooleanSetting( - Constants.PREFERENCES_KEY_SHOW_ALL_SONGS_BY_ARTIST, - false - ) - @JvmStatic var resumeOnBluetoothDevice by IntSetting( Constants.PREFERENCES_KEY_RESUME_ON_BLUETOOTH_DEVICE, @@ -320,6 +315,18 @@ object Settings { val preferences: SharedPreferences get() = PreferenceManager.getDefaultSharedPreferences(Util.appContext()) + var useFiveStarRating by BooleanSetting(Constants.PREFERENCES_KEY_USE_FIVE_STAR_RATING, false) + + // TODO: Remove in December 2022 + fun migrateFeatureStorage() { + val sp = appContext.getSharedPreferences("feature_flags", Context.MODE_PRIVATE) + useFiveStarRating = sp.getBoolean("FIVE_STAR_RATING", false) + } + + fun hasKey(key: String): Boolean { + return preferences.contains(key) + } + private val appContext: Context get() { return UApp.applicationContext() diff --git a/ultrasonic/src/main/res/values-cs/strings.xml b/ultrasonic/src/main/res/values-cs/strings.xml index d4819465..034a12f0 100644 --- a/ultrasonic/src/main/res/values-cs/strings.xml +++ b/ultrasonic/src/main/res/values-cs/strings.xml @@ -428,10 +428,10 @@ Nekompatibilní verze. Aktualizujte prosím Ultrasonic Android aplikaci. Nekompatibilní verze. Aktualizujte prosím Subsonic server. - - Příznaky funkcí - Používat pět hvězdiček pro hodnocení skladeb - Používat pět hvězdiček pro hodnocení skladeb + + Příznaky funkcí + Používat pět hvězdiček pro hodnocení skladeb + Používat pět hvězdiček pro hodnocení skladeb namísto jednoduchého jednohvězdičkového hodnocení. diff --git a/ultrasonic/src/main/res/values-de/strings.xml b/ultrasonic/src/main/res/values-de/strings.xml index 03b7b4a1..32fedc2a 100644 --- a/ultrasonic/src/main/res/values-de/strings.xml +++ b/ultrasonic/src/main/res/values-de/strings.xml @@ -360,10 +360,10 @@ Inkompatible Versionen. Bitte die Ultrasonic App aktualisieren. Inkompatible Versionen. Bitte den subsonic Server aktualisieren. - - Funktionseinstellungem - Verwenden Sie Fünf-Sterne-Bewertung für Songs - Verwenden Sie Fünf-Sterne-Bewertungssystem für Songs + + Funktionseinstellungem + Verwenden Sie Fünf-Sterne-Bewertung für Songs + Verwenden Sie Fünf-Sterne-Bewertungssystem für Songs          anstatt einfach Elemente zu markieren / zu entfernen. diff --git a/ultrasonic/src/main/res/values-es/strings.xml b/ultrasonic/src/main/res/values-es/strings.xml index 75ef533d..c3010b41 100644 --- a/ultrasonic/src/main/res/values-es/strings.xml +++ b/ultrasonic/src/main/res/values-es/strings.xml @@ -450,10 +450,10 @@ Versiones incompatibles. Por favor actualiza la aplicación de Android Ultrasonic. Versiones incompatibles. Por favor actualiza el servidor de Subsonic. - - Funciones experimentales - Use cinco estrellas para las canciones - Utilice el sistema de calificación de cinco estrellas para canciones + + Funciones experimentales + Use cinco estrellas para las canciones + Utilice el sistema de calificación de cinco estrellas para canciones en lugar de simplemente destacar / desestimar elementos. diff --git a/ultrasonic/src/main/res/values-fr/strings.xml b/ultrasonic/src/main/res/values-fr/strings.xml index d59744f2..c538e37a 100644 --- a/ultrasonic/src/main/res/values-fr/strings.xml +++ b/ultrasonic/src/main/res/values-fr/strings.xml @@ -439,10 +439,10 @@ Versions incompatibles. Veuillez mette à jour l\'application Android Ultrasonic. Versions incompatibles. Veuillez mette à jour le serveur Subsonic. - - Drapeaux des fonctionnalités - Utiliser les étoiles pour noter les morceaux - Utiliser un système de notation à base d\'étoiles pour les morceaux + + Drapeaux des fonctionnalités + Utiliser les étoiles pour noter les morceaux + Utiliser un système de notation à base d\'étoiles pour les morceaux au lieu de simplement mettre en avant les morceaux. diff --git a/ultrasonic/src/main/res/values-hu/strings.xml b/ultrasonic/src/main/res/values-hu/strings.xml index d8f35055..efa3dcd0 100644 --- a/ultrasonic/src/main/res/values-hu/strings.xml +++ b/ultrasonic/src/main/res/values-hu/strings.xml @@ -434,10 +434,10 @@ Nem kompatibilis verzió. Kérjük, frissítse az Ultrasonic Android alkalmazást! Nem kompatibilis verzió. Kérjük, frissítse a Subsonic kiszolgálót! - - Jellemzők Zászlók - Öt csillagos értékelés használata a dalokhoz - Öt csillag használata az értékeléshez az egyszerű + + Jellemzők Zászlók + Öt csillagos értékelés használata a dalokhoz + Öt csillag használata az értékeléshez az egyszerű csillaggal jelölés helyett. diff --git a/ultrasonic/src/main/res/values-nl/strings.xml b/ultrasonic/src/main/res/values-nl/strings.xml index 5478b41b..194afb24 100644 --- a/ultrasonic/src/main/res/values-nl/strings.xml +++ b/ultrasonic/src/main/res/values-nl/strings.xml @@ -450,10 +450,10 @@ Incompatibele versies. Werk de Ultrasonic Android-app bij. Incompatibele versies. Werk je Subsonic-server bij. - - Experimentele functies - Gebruik vijf sterren voor nummers - Gebruik vijf sterren ratingsysteem voor liedjes + + Experimentele functies + Gebruik vijf sterren voor nummers + Gebruik vijf sterren ratingsysteem voor liedjes in plaats van items simpelweg in de hoofdrol te zetten / niet te verwijderen. diff --git a/ultrasonic/src/main/res/values-pl/strings.xml b/ultrasonic/src/main/res/values-pl/strings.xml index 1651e37e..8832e780 100644 --- a/ultrasonic/src/main/res/values-pl/strings.xml +++ b/ultrasonic/src/main/res/values-pl/strings.xml @@ -404,10 +404,10 @@ ponieważ api Subsonic nie wspiera nowego sposobu autoryzacji dla użytkowników Brak zgodności wersji. Uaktualnij aplikację Ultrasonic na Androida. Brak zgodności wersji. Uaktualnij serwer Subsonic. - - Flagi funkcji - Użyj pięciu gwiazdek dla utworów - W przypadku utworów użyj systemu pięciu gwiazdek + + Flagi funkcji + Użyj pięciu gwiazdek dla utworów + W przypadku utworów użyj systemu pięciu gwiazdek zamiast po prostu grać gwiazdkami / bez gwiazd. diff --git a/ultrasonic/src/main/res/values-pt-rBR/strings.xml b/ultrasonic/src/main/res/values-pt-rBR/strings.xml index 781e6ec3..5fd380a2 100644 --- a/ultrasonic/src/main/res/values-pt-rBR/strings.xml +++ b/ultrasonic/src/main/res/values-pt-rBR/strings.xml @@ -443,10 +443,10 @@ Versões incompativeis. Atualize o aplicativo Ultrasonic para Android. Versões incompativeis. Atualize o servidor Ultrasonic. - - Sinalização de Recursos - Usar Classif. 5 Estrelas para Músicas - Usar o sistema de classificação de 5 estrelas para músicas + + Sinalização de Recursos + Usar Classif. 5 Estrelas para Músicas + Usar o sistema de classificação de 5 estrelas para músicas em vez de simplesmente estrelar/não estrelar itens diff --git a/ultrasonic/src/main/res/values-pt/strings.xml b/ultrasonic/src/main/res/values-pt/strings.xml index 21d56dae..1a277b2d 100644 --- a/ultrasonic/src/main/res/values-pt/strings.xml +++ b/ultrasonic/src/main/res/values-pt/strings.xml @@ -389,10 +389,10 @@ Versões incompativeis. Atualize o aplicativo Ultrasonic para Android. Versões incompativeis. Atualize o servidor Ultrasonic. - - Bandeiras de recursos - Use classificação de cinco estrelas para músicas - Use o sistema de classificação de cinco estrelas para músicas + + Bandeiras de recursos + Use classificação de cinco estrelas para músicas + Use o sistema de classificação de cinco estrelas para músicas em vez de simplesmente estrelar / não estrelar itens. diff --git a/ultrasonic/src/main/res/values-ru/strings.xml b/ultrasonic/src/main/res/values-ru/strings.xml index 9be7d70b..28c81902 100644 --- a/ultrasonic/src/main/res/values-ru/strings.xml +++ b/ultrasonic/src/main/res/values-ru/strings.xml @@ -453,10 +453,10 @@ Несовместимые версии. Пожалуйста, обновите приложение Ultrasonic для Android. Несовместимые версии. Пожалуйста, обновите Subsonic сервер. - - Флаги - Использовать пятизвездочный рейтинг для песен - Использовать пятизвездочную систему рейтинга для песен + + Флаги + Использовать пятизвездочный рейтинг для песен + Использовать пятизвездочную систему рейтинга для песен вместо того, чтобы просто ставить/не ставить звезды. diff --git a/ultrasonic/src/main/res/values-zh-rCN/strings.xml b/ultrasonic/src/main/res/values-zh-rCN/strings.xml index 7e4a1e04..97927f41 100644 --- a/ultrasonic/src/main/res/values-zh-rCN/strings.xml +++ b/ultrasonic/src/main/res/values-zh-rCN/strings.xml @@ -432,10 +432,10 @@ 版本不兼容,请升级 Ultrasonic 应用。 不兼容的版本。请升级Subsonic 服务。 - - 特性标志 - 为歌曲使用五星评分 - 对歌曲使用五星级评级系统 + + 特性标志 + 为歌曲使用五星评分 + 对歌曲使用五星级评级系统 而不是简单地为项目加星标/取消星标。 diff --git a/ultrasonic/src/main/res/values/strings.xml b/ultrasonic/src/main/res/values/strings.xml index 1e744543..04bbc31f 100644 --- a/ultrasonic/src/main/res/values/strings.xml +++ b/ultrasonic/src/main/res/values/strings.xml @@ -461,10 +461,10 @@ Incompatible versions. Please upgrade Ultrasonic Android app. Incompatible versions. Please upgrade Subsonic server. - - Feature Flags - Use five star rating for songs - Use five star rating system for songs + + Features + Use five star rating for songs + Use five star rating system for songs instead of simply starring/unstarring items. diff --git a/ultrasonic/src/main/res/xml/settings.xml b/ultrasonic/src/main/res/xml/settings.xml index 73c611f6..5f96a81b 100644 --- a/ultrasonic/src/main/res/xml/settings.xml +++ b/ultrasonic/src/main/res/xml/settings.xml @@ -345,14 +345,14 @@ app:iconSpaceReserved="false"/> + a:summary="@string/settings.five_star_rating_description" + a:title="@string/settings.five_star_rating_title" + app:iconSpaceReserved="false" />