From 57906a9b46bb57e516e6e5781bf33de574cc58cb Mon Sep 17 00:00:00 2001 From: flloschy Date: Sun, 29 Dec 2024 20:26:48 +0100 Subject: [PATCH 01/10] Added Reset Buttons for every Settings Screen --- lib/screens/album_settings_screen.dart | 19 ++- .../audio_service_settings_screen.dart | 23 ++- lib/screens/downloads_settings_screen.dart | 19 ++- lib/screens/interaction_settings_screen.dart | 21 ++- lib/screens/layout_settings_screen.dart | 19 ++- lib/screens/lyrics_settings_screen.dart | 19 ++- lib/screens/player_settings_screen.dart | 19 ++- lib/screens/settings_screen.dart | 21 ++- lib/screens/transcoding_settings_screen.dart | 21 ++- .../volume_normalization_settings_screen.dart | 22 ++- lib/services/finamp_settings_helper.dart | 131 ++++++++++++++++++ pubspec.lock | 44 +++--- 12 files changed, 332 insertions(+), 46 deletions(-) diff --git a/lib/screens/album_settings_screen.dart b/lib/screens/album_settings_screen.dart index c55593ad9..18a5261f7 100644 --- a/lib/screens/album_settings_screen.dart +++ b/lib/screens/album_settings_screen.dart @@ -5,16 +5,31 @@ import 'package:hive/hive.dart'; import '../models/finamp_models.dart'; import '../services/finamp_settings_helper.dart'; -class AlbumSettingsScreen extends StatelessWidget { +class AlbumSettingsScreen extends StatefulWidget { const AlbumSettingsScreen({super.key}); - static const routeName = "/settings/layout/album"; + @override + State createState() => + _AlbumSettingsScreenState(); +} +class _AlbumSettingsScreenState extends State { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(AppLocalizations.of(context)!.albumScreen), + actions: [ + IconButton( + onPressed: () { + setState(() { + FinampSettingsHelper.resetAlbumSettings(); + }); + }, + icon: const Icon(Icons.refresh), + tooltip: AppLocalizations.of(context)!.resetToDefaults, + ) + ], ), body: ListView( children: const [ diff --git a/lib/screens/audio_service_settings_screen.dart b/lib/screens/audio_service_settings_screen.dart index 1dd32ad90..15e253f66 100644 --- a/lib/screens/audio_service_settings_screen.dart +++ b/lib/screens/audio_service_settings_screen.dart @@ -1,5 +1,6 @@ import 'dart:io'; +import 'package:finamp/services/finamp_settings_helper.dart'; import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; @@ -10,16 +11,32 @@ import '../components/AudioServiceSettingsScreen/report_queue_to_server_toggle.d import '../components/AudioServiceSettingsScreen/song_shuffle_item_count_editor.dart'; import '../components/AudioServiceSettingsScreen/stop_foreground_selector.dart'; -class AudioServiceSettingsScreen extends StatelessWidget { - const AudioServiceSettingsScreen({Key? key}) : super(key: key); - +class AudioServiceSettingsScreen extends StatefulWidget { + const AudioServiceSettingsScreen({super.key}); static const routeName = "/settings/audioservice"; + @override + State createState() => + _AudioServiceSettingsScreenState(); +} + +class _AudioServiceSettingsScreenState extends State { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(AppLocalizations.of(context)!.audioService), + actions: [ + IconButton( + onPressed: () { + setState(() { + FinampSettingsHelper.resetAudioServiceSettings(); + }); + }, + icon: const Icon(Icons.refresh), + tooltip: AppLocalizations.of(context)!.resetToDefaults, + ) + ], ), body: ListView( children: [ diff --git a/lib/screens/downloads_settings_screen.dart b/lib/screens/downloads_settings_screen.dart index 3de45346f..c3bb982dd 100644 --- a/lib/screens/downloads_settings_screen.dart +++ b/lib/screens/downloads_settings_screen.dart @@ -15,17 +15,32 @@ import '../services/downloads_service.dart'; import '../services/finamp_settings_helper.dart'; import 'downloads_location_screen.dart'; -class DownloadsSettingsScreen extends StatelessWidget { +class DownloadsSettingsScreen extends StatefulWidget { const DownloadsSettingsScreen({super.key}); - static const routeName = "/settings/downloads"; + @override + State createState() => + _DownloadsSettingsScreenState(); +} +class _DownloadsSettingsScreenState extends State { @override Widget build(BuildContext context) { var userHelper = GetIt.instance(); return Scaffold( appBar: AppBar( title: Text(AppLocalizations.of(context)!.downloadSettings), + actions: [ + IconButton( + onPressed: () { + setState(() { + FinampSettingsHelper.resetDownloadSettings(); + }); + }, + icon: const Icon(Icons.refresh), + tooltip: AppLocalizations.of(context)!.resetToDefaults, + ) + ], ), body: ListView( children: [ diff --git a/lib/screens/interaction_settings_screen.dart b/lib/screens/interaction_settings_screen.dart index bed1cc124..3fe043c14 100644 --- a/lib/screens/interaction_settings_screen.dart +++ b/lib/screens/interaction_settings_screen.dart @@ -11,16 +11,31 @@ import '../components/InteractionSettingsScreen/disable_gestures.dart'; import '../components/InteractionSettingsScreen/disable_vibration.dart'; import '../components/InteractionSettingsScreen/swipe_insert_queue_next_selector.dart'; -class InteractionSettingsScreen extends StatelessWidget { - const InteractionSettingsScreen({Key? key}) : super(key: key); - +class InteractionSettingsScreen extends StatefulWidget { + const InteractionSettingsScreen({super.key}); static const routeName = "/settings/interactions"; + @override + State createState() => + _InteractionSettingsScreenState(); +} +class _InteractionSettingsScreenState extends State { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(AppLocalizations.of(context)!.interactions), + actions: [ + IconButton( + onPressed: () { + setState(() { + FinampSettingsHelper.resetInteractionsSettings(); + }); + }, + icon: const Icon(Icons.refresh), + tooltip: AppLocalizations.of(context)!.resetToDefaults, + ) + ], ), body: ListView( children: const [ diff --git a/lib/screens/layout_settings_screen.dart b/lib/screens/layout_settings_screen.dart index b1f2a1ba6..e8faa5fd4 100644 --- a/lib/screens/layout_settings_screen.dart +++ b/lib/screens/layout_settings_screen.dart @@ -18,11 +18,15 @@ import '../services/finamp_settings_helper.dart'; import '../components/LayoutSettingsScreen/use_cover_as_background_toggle.dart'; import 'tabs_settings_screen.dart'; -class LayoutSettingsScreen extends StatelessWidget { +class LayoutSettingsScreen extends StatefulWidget { const LayoutSettingsScreen({super.key}); - static const routeName = "/settings/layout"; + @override + State createState() => + _LayoutSettingsScreenState(); +} +class _LayoutSettingsScreenState extends State { @override Widget build(BuildContext context) { return ValueListenableBuilder>( @@ -31,6 +35,17 @@ class LayoutSettingsScreen extends StatelessWidget { return Scaffold( appBar: AppBar( title: Text(AppLocalizations.of(context)!.layoutAndTheme), + actions: [ + IconButton( + onPressed: () { + setState(() { + FinampSettingsHelper.resetLayoutSettings(); + }); + }, + icon: const Icon(Icons.refresh), + tooltip: AppLocalizations.of(context)!.resetToDefaults, + ) + ], ), body: ListView( children: [ diff --git a/lib/screens/lyrics_settings_screen.dart b/lib/screens/lyrics_settings_screen.dart index 29647d720..e69544332 100644 --- a/lib/screens/lyrics_settings_screen.dart +++ b/lib/screens/lyrics_settings_screen.dart @@ -6,16 +6,31 @@ import '../components/LayoutSettingsScreen/player_screen_minimum_cover_padding_e import '../models/finamp_models.dart'; import '../services/finamp_settings_helper.dart'; -class LyricsSettingsScreen extends StatelessWidget { +class LyricsSettingsScreen extends StatefulWidget { const LyricsSettingsScreen({super.key}); - static const routeName = "/settings/lyrics"; + @override + State createState() => + _LyricsSettingsScreenState(); +} +class _LyricsSettingsScreenState extends State { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(AppLocalizations.of(context)!.lyricsScreen), + actions: [ + IconButton( + onPressed: () { + setState(() { + FinampSettingsHelper.resetLyricsSettings(); + }); + }, + icon: const Icon(Icons.refresh), + tooltip: AppLocalizations.of(context)!.resetToDefaults, + ) + ], ), body: ListView( children: const [ diff --git a/lib/screens/player_settings_screen.dart b/lib/screens/player_settings_screen.dart index 7d37802e9..2bb05e189 100644 --- a/lib/screens/player_settings_screen.dart +++ b/lib/screens/player_settings_screen.dart @@ -6,16 +6,31 @@ import '../components/LayoutSettingsScreen/player_screen_minimum_cover_padding_e import '../models/finamp_models.dart'; import '../services/finamp_settings_helper.dart'; -class PlayerSettingsScreen extends StatelessWidget { +class PlayerSettingsScreen extends StatefulWidget { const PlayerSettingsScreen({super.key}); - static const routeName = "/settings/player"; + @override + State createState() => + _PlayerSettingsScreenState(); +} +class _PlayerSettingsScreenState extends State { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(AppLocalizations.of(context)!.playerScreen), + actions: [ + IconButton( + onPressed: () { + setState(() { + FinampSettingsHelper.resetPlayerScreenSettings(); + }); + }, + icon: const Icon(Icons.refresh), + tooltip: AppLocalizations.of(context)!.resetToDefaults, + ) + ] ), body: ListView( children: const [ diff --git a/lib/screens/settings_screen.dart b/lib/screens/settings_screen.dart index 2e503b2b7..323ab2e44 100644 --- a/lib/screens/settings_screen.dart +++ b/lib/screens/settings_screen.dart @@ -19,10 +19,16 @@ import 'transcoding_settings_screen.dart'; import 'view_selector.dart'; import 'volume_normalization_settings_screen.dart'; -class SettingsScreen extends StatelessWidget { - const SettingsScreen({Key? key}) : super(key: key); - +class SettingsScreen extends StatefulWidget { + const SettingsScreen({super.key}); static const routeName = "/settings"; + @override + State createState() => + _SettingsScreenState(); +} + + +class _SettingsScreenState extends State { static const repoLink = "https://github.com/jmshrv/finamp"; static const releaseNotesLink = "https://github.com/jmshrv/finamp/releases"; static const translationsLink = "https://hosted.weblate.org/projects/finamp"; @@ -33,6 +39,15 @@ class SettingsScreen extends StatelessWidget { appBar: AppBar( title: Text(AppLocalizations.of(context)!.settings), actions: [ + IconButton( + onPressed: () { + setState(() { + FinampSettingsHelper.resetAllSettings(); + }); + }, + icon: const Icon(Icons.refresh), + tooltip: AppLocalizations.of(context)!.resetToDefaults, + ), Semantics.fromProperties( properties: SemanticsProperties( label: AppLocalizations.of(context)!.about, diff --git a/lib/screens/transcoding_settings_screen.dart b/lib/screens/transcoding_settings_screen.dart index 63b07c989..118331494 100644 --- a/lib/screens/transcoding_settings_screen.dart +++ b/lib/screens/transcoding_settings_screen.dart @@ -9,16 +9,33 @@ import '../components/TranscodingSettingsScreen/transcode_switch.dart'; import '../models/finamp_models.dart'; import '../services/finamp_settings_helper.dart'; -class TranscodingSettingsScreen extends StatelessWidget { - const TranscodingSettingsScreen({super.key}); + +class TranscodingSettingsScreen extends StatefulWidget { + const TranscodingSettingsScreen({super.key}); static const routeName = "/settings/transcoding"; + @override + State createState() => + _TranscodingSettingsScreenState(); +} +class _TranscodingSettingsScreenState extends State { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(AppLocalizations.of(context)!.transcoding), + actions: [ + IconButton( + onPressed: () { + setState(() { + FinampSettingsHelper.resetAllSettings(); + }); + }, + icon: const Icon(Icons.refresh), + tooltip: AppLocalizations.of(context)!.resetToDefaults, + ) + ], ), body: ListView( children: [ diff --git a/lib/screens/volume_normalization_settings_screen.dart b/lib/screens/volume_normalization_settings_screen.dart index 41dfb999e..2656d6ae4 100644 --- a/lib/screens/volume_normalization_settings_screen.dart +++ b/lib/screens/volume_normalization_settings_screen.dart @@ -1,5 +1,6 @@ import 'dart:io'; +import 'package:finamp/services/finamp_settings_helper.dart'; import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; @@ -7,17 +8,32 @@ import '../components/VolumeNormalizationSettingsScreen/volume_normalization_ios import '../components/VolumeNormalizationSettingsScreen/volume_normalization_mode_selector.dart'; import '../components/VolumeNormalizationSettingsScreen/volume_normalization_switch.dart'; -class VolumeNormalizationSettingsScreen extends StatelessWidget { - const VolumeNormalizationSettingsScreen({Key? key}) : super(key: key); - +class VolumeNormalizationSettingsScreen extends StatefulWidget { + const VolumeNormalizationSettingsScreen({super.key}); static const routeName = "/settings/volume-normalization"; + @override + State createState() => + _VolumeNormalizationSettingsScreenState(); +} +class _VolumeNormalizationSettingsScreenState extends State { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text( AppLocalizations.of(context)!.volumeNormalizationSettingsTitle), + actions: [ + IconButton( + onPressed: () { + setState(() { + FinampSettingsHelper.resetNormalizationSettings(); + }); + }, + icon: const Icon(Icons.refresh), + tooltip: AppLocalizations.of(context)!.resetToDefaults, + ) + ], ), body: ListView( children: [ diff --git a/lib/services/finamp_settings_helper.dart b/lib/services/finamp_settings_helper.dart index d0da4c15c..b2437823e 100644 --- a/lib/services/finamp_settings_helper.dart +++ b/lib/services/finamp_settings_helper.dart @@ -1,4 +1,8 @@ +import 'package:finamp/screens/layout_settings_screen.dart'; +import 'package:finamp/services/locale_helper.dart'; +import 'package:finamp/services/theme_mode_helper.dart'; import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; import 'package:hive_flutter/hive_flutter.dart'; import 'package:riverpod_annotation/riverpod_annotation.dart'; import 'package:rxdart/rxdart.dart'; @@ -330,6 +334,133 @@ class FinampSettingsHelper { Hive.box("FinampSettings") .put("FinampSettings", finampSettingsTemp); } + static void resetPlayerScreenSettings() { + FinampSettings finampSettingsTemp = finampSettings; + + finampSettingsTemp.featureChipsConfiguration = finampSettingsTemp.featureChipsConfiguration.copyWith(enabled: true); + finampSettingsTemp.playerScreenCoverMinimumPadding = 1.5; + finampSettingsTemp.suppressPlayerPadding = false; + finampSettingsTemp.prioritizeCoverFactor = 8.0; + finampSettingsTemp.hidePlayerBottomActions = false; + + Hive.box("FinampSettings") + .put("FinampSettings", finampSettingsTemp); + } + static void resetLyricsSettings() { + FinampSettings finampSettingsTemp = finampSettings; + + finampSettingsTemp.showLyricsTimestamps = true; + finampSettingsTemp.showLyricsScreenAlbumPrelude = true; + finampSettingsTemp.lyricsAlignment = LyricsAlignment.start; + finampSettingsTemp.lyricsFontSize = LyricsFontSize.medium; + + Hive.box("FinampSettings") + .put("FinampSettings", finampSettingsTemp); + } + static void resetAlbumSettings() { + FinampSettings finampSettingsTemp = finampSettings; + + finampSettingsTemp.showCoversOnAlbumScreen = false; + + Hive.box("FinampSettings") + .put("FinampSettings", finampSettingsTemp); + } + static void resetLayoutSettings() { + FinampSettings finampSettingsTemp = finampSettings; + + ThemeModeHelper.setThemeMode(ThemeMode.system); + setContentViewType(ContentViewType.list); + finampSettingsTemp.useFixedSizeGridTiles = true; + setContentGridViewCrossAxisCountPortrait(2); + setContentGridViewCrossAxisCountLandscape(3); + finampSettingsTemp.fixedGridTileSize = FixedGridTileSize.medium.toInt; + finampSettingsTemp.showTextOnGridView = true; + setUseCoverAsBackground(true); + finampSettingsTemp.showArtistChipImage = true; + finampSettingsTemp.showArtistsTopSongs = true; + finampSettingsTemp.allowSplitScreen = true; + finampSettingsTemp.showProgressOnNowPlayingBar = true; + + Hive.box("FinampSettings") + .put("FinampSettings", finampSettingsTemp); + } + static void resetTranscodingSettings() { + FinampSettings finampSettingsTemp = finampSettings; + + finampSettingsTemp.shouldTranscode = false; + setTranscodeBitrate(320000); + finampSettingsTemp.transcodingSegmentContainer = FinampSegmentContainer.fragmentedMp4; + finampSettingsTemp.shouldTranscodeDownloads = TranscodeDownloadsSetting.ask; + finampSettingsTemp.downloadTranscodingCodec = FinampTranscodingCodec.opus; + finampSettingsTemp.downloadTranscodeBitrate = 128000; + + Hive.box("FinampSettings") + .put("FinampSettings", finampSettingsTemp); + } + static void resetDownloadSettings() { + FinampSettings finampSettingsTemp = finampSettings; + + finampSettingsTemp.requireWifiForDownloads = false; + finampSettingsTemp.trackOfflineFavorites = true; + finampSettingsTemp.resyncOnStartup = true; + finampSettingsTemp.preferQuickSyncs = true; + finampSettingsTemp.shouldRedownloadTranscodes = false; + finampSettingsTemp.showDownloadsWithUnknownLibrary = true; + finampSettingsTemp.downloadWorkers = 5; + finampSettingsTemp.maxConcurrentDownloads = 10; + + Hive.box("FinampSettings") + .put("FinampSettings", finampSettingsTemp); + } + static void resetAudioServiceSettings() { + setAndroidStopForegroundOnPause(true); + setSongShuffleItemCount(250); // DOES NOT update UI + setBufferDuration(Duration(seconds: 600)); // DOES NOT update UI + setAutoloadLastQueueOnStartup(true); + setPeriodicPlaybackSessionUpdateFrequencySeconds(150); // DOES NOT update UI + setReportQueueToServer(false); + } + static void resetNormalizationSettings() { + FinampSettings finampSettingsTemp = finampSettings; + + finampSettingsTemp.volumeNormalizationActive = true; + setVolumeNormalizationIOSBaseGain(-2.0); // DOES NOT update UI + finampSettingsTemp.volumeNormalizationMode = VolumeNormalizationMode.hybrid; + + Hive.box("FinampSettings") + .put("FinampSettings", finampSettingsTemp); + } + static void resetInteractionsSettings() { + FinampSettings finampSettingsTemp = finampSettings; + + setSwipeInsertQueueNext(true); + finampSettingsTemp.startInstantMixForIndividualTracks = true; + setShowFastScroller(true); + setDisableGesture(false); + setEnableVibration(true); + setKeepScreenOnOption(KeepScreenOnOption.whileLyrics); + setKeepScreenOnWhileCharging(true); + + + Hive.box("FinampSettings") + .put("FinampSettings", finampSettingsTemp); + } + static void resetAllSettings() { + resetTranscodingSettings(); + resetDownloadSettings(); + resetAudioServiceSettings(); + resetNormalizationSettings(); + resetInteractionsSettings(); + + resetLayoutSettings(); + resetCustomizationSettings(); + resetPlayerScreenSettings(); + resetLyricsSettings(); + resetAlbumSettings(); + resetTabs(); + + LocaleHelper.setLocale(null); // Reset to System Language + } static void setSwipeInsertQueueNext(bool swipeInsertQueueNext) { FinampSettings finampSettingsTemp = finampSettings; diff --git a/pubspec.lock b/pubspec.lock index e78388690..a46344728 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -5,23 +5,23 @@ packages: dependency: transitive description: name: _fe_analyzer_shared - sha256: f256b0c0ba6c7577c15e2e4e114755640a875e885099367bf6e012b19314c834 + sha256: "16e298750b6d0af7ce8a3ba7c18c69c3785d11b15ec83f6dcd0ad2a0009b3cab" url: "https://pub.dev" source: hosted - version: "72.0.0" + version: "76.0.0" _macros: dependency: transitive description: dart source: sdk - version: "0.3.2" + version: "0.3.3" analyzer: dependency: "direct overridden" description: name: analyzer - sha256: b652861553cd3990d8ed361f7979dc6d7053a9ac8843fa73820ab68ce5410139 + sha256: "1f14db053a8c23e260789e9b0980fa27f2680dd640932cae5e1137cce0e46e1e" url: "https://pub.dev" source: hosted - version: "6.7.0" + version: "6.11.0" analyzer_plugin: dependency: transitive description: @@ -299,10 +299,10 @@ packages: dependency: "direct main" description: name: collection - sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a + sha256: a1ace0a119f20aabc852d165077c036cd864315bd99b7eaa10a60100341941bf url: "https://pub.dev" source: hosted - version: "1.18.0" + version: "1.19.0" color: dependency: transitive description: @@ -847,18 +847,18 @@ packages: dependency: transitive description: name: leak_tracker - sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05" + sha256: "7bb2830ebd849694d1ec25bf1f44582d6ac531a57a365a803a6034ff751d2d06" url: "https://pub.dev" source: hosted - version: "10.0.5" + version: "10.0.7" leak_tracker_flutter_testing: dependency: transitive description: name: leak_tracker_flutter_testing - sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806" + sha256: "9491a714cca3667b60b5c420da8217e6de0d1ba7a5ec322fab01758f6998f379" url: "https://pub.dev" source: hosted - version: "3.0.5" + version: "3.0.8" leak_tracker_testing: dependency: transitive description: @@ -895,10 +895,10 @@ packages: dependency: transitive description: name: macros - sha256: "0acaed5d6b7eab89f63350bccd82119e6c602df0f391260d0e32b5e23db79536" + sha256: "1d9e801cd66f7ea3663c45fc708450db1fa57f988142c64289142c9b7ee80656" url: "https://pub.dev" source: hosted - version: "0.1.2-main.4" + version: "0.1.3-main.0" marquee: dependency: "direct main" description: @@ -1353,7 +1353,7 @@ packages: dependency: transitive description: flutter source: sdk - version: "0.0.99" + version: "0.0.0" sliver_tools: dependency: transitive description: @@ -1431,10 +1431,10 @@ packages: dependency: transitive description: name: stack_trace - sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" + sha256: "9f47fd3630d76be3ab26f0ee06d213679aa425996925ff3feffdec504931c377" url: "https://pub.dev" source: hosted - version: "1.11.1" + version: "1.12.0" state_notifier: dependency: transitive description: @@ -1463,10 +1463,10 @@ packages: dependency: transitive description: name: string_scanner - sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + sha256: "688af5ed3402a4bde5b3a6c15fd768dbf2621a614950b17f04626c431ab3c4c3" url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.3.0" synchronized: dependency: transitive description: @@ -1487,10 +1487,10 @@ packages: dependency: transitive description: name: test_api - sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb" + sha256: "664d3a9a64782fcdeb83ce9c6b39e78fd2971d4e37827b9b06c3aa1edc5e760c" url: "https://pub.dev" source: hosted - version: "0.7.2" + version: "0.7.3" time: dependency: transitive description: @@ -1671,10 +1671,10 @@ packages: dependency: transitive description: name: vm_service - sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d" + sha256: f6be3ed8bd01289b34d679c2b62226f63c0e69f9fd2e50a6b3c1c729a961041b url: "https://pub.dev" source: hosted - version: "14.2.5" + version: "14.3.0" wakelock_plus: dependency: "direct main" description: From 31ed2988044b1588ab28f8c0088eba7da6ac3174 Mon Sep 17 00:00:00 2001 From: flloschy Date: Mon, 30 Dec 2024 15:04:54 +0100 Subject: [PATCH 02/10] renamed resetTabs to resetTabsSettings; Created Helper function for the reset buttons with dialog --- lib/services/finamp_settings_helper.dart | 30 ++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/lib/services/finamp_settings_helper.dart b/lib/services/finamp_settings_helper.dart index b2437823e..8683135c3 100644 --- a/lib/services/finamp_settings_helper.dart +++ b/lib/services/finamp_settings_helper.dart @@ -1,3 +1,4 @@ +import 'package:finamp/components/confirmation_prompt_dialog.dart'; import 'package:finamp/screens/layout_settings_screen.dart'; import 'package:finamp/services/locale_helper.dart'; import 'package:finamp/services/theme_mode_helper.dart'; @@ -6,6 +7,7 @@ import 'package:flutter/material.dart'; import 'package:hive_flutter/hive_flutter.dart'; import 'package:riverpod_annotation/riverpod_annotation.dart'; import 'package:rxdart/rxdart.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import '../models/finamp_models.dart'; import '../models/jellyfin_models.dart'; @@ -314,7 +316,7 @@ class FinampSettingsHelper { .put("FinampSettings", finampSettingsTemp); } - static void resetTabs() { + static void resetTabsSettings() { FinampSettings finampSettingsTemp = finampSettings; finampSettingsTemp.tabOrder = TabContentType.values; finampSettingsTemp.showTabs = Map.fromEntries( @@ -457,7 +459,7 @@ class FinampSettingsHelper { resetPlayerScreenSettings(); resetLyricsSettings(); resetAlbumSettings(); - resetTabs(); + resetTabsSettings(); LocaleHelper.setLocale(null); // Reset to System Language } @@ -505,4 +507,28 @@ class FinampSettingsHelper { Hive.box("FinampSettings") .put("FinampSettings", finampSettingsTemp); } + + static IconButton makeSettingsResetButtonWithDialog(BuildContext context, Function() resetFunction, {bool isGlobal = false}) { + // TODO: Replace the following Strings with localization + return IconButton( + onPressed: () async{ + await showDialog( + context: context, + builder: (context) => ConfirmationPromptDialog( + promptText: isGlobal + ? "Are you sure you want to reset ALL settings?" + : "Do you want to reset these settings back to default?", + confirmButtonText: isGlobal + ? "Yes I am!" + : AppLocalizations.of(context)!.reset, + abortButtonText: "Cancel", + onConfirmed: resetFunction, + onAborted: (){}, + ) + ); + }, + icon: const Icon(Icons.refresh), + tooltip: AppLocalizations.of(context)!.resetToDefaults, + ); + } } From d776c52b5603a2a011859278edba67a7bc1be30b Mon Sep 17 00:00:00 2001 From: flloschy Date: Mon, 30 Dec 2024 15:06:02 +0100 Subject: [PATCH 03/10] utilize the reset button with dialog --- lib/screens/album_settings_screen.dart | 11 +++-------- lib/screens/audio_service_settings_screen.dart | 11 +++-------- lib/screens/customization_settings_screen.dart | 11 +++-------- lib/screens/downloads_settings_screen.dart | 11 +++-------- lib/screens/interaction_settings_screen.dart | 11 +++-------- lib/screens/layout_settings_screen.dart | 11 +++-------- lib/screens/lyrics_settings_screen.dart | 12 +++--------- lib/screens/player_settings_screen.dart | 11 +++-------- lib/screens/settings_screen.dart | 12 ++++-------- lib/screens/tabs_settings_screen.dart | 11 +++-------- lib/screens/transcoding_settings_screen.dart | 11 +++-------- .../volume_normalization_settings_screen.dart | 11 +++-------- 12 files changed, 37 insertions(+), 97 deletions(-) diff --git a/lib/screens/album_settings_screen.dart b/lib/screens/album_settings_screen.dart index 18a5261f7..de22025f6 100644 --- a/lib/screens/album_settings_screen.dart +++ b/lib/screens/album_settings_screen.dart @@ -20,14 +20,9 @@ class _AlbumSettingsScreenState extends State { appBar: AppBar( title: Text(AppLocalizations.of(context)!.albumScreen), actions: [ - IconButton( - onPressed: () { - setState(() { - FinampSettingsHelper.resetAlbumSettings(); - }); - }, - icon: const Icon(Icons.refresh), - tooltip: AppLocalizations.of(context)!.resetToDefaults, + FinampSettingsHelper.makeSettingsResetButtonWithDialog( + context, + FinampSettingsHelper.resetAlbumSettings ) ], ), diff --git a/lib/screens/audio_service_settings_screen.dart b/lib/screens/audio_service_settings_screen.dart index 15e253f66..70ff8b21b 100644 --- a/lib/screens/audio_service_settings_screen.dart +++ b/lib/screens/audio_service_settings_screen.dart @@ -27,14 +27,9 @@ class _AudioServiceSettingsScreenState extends State appBar: AppBar( title: Text(AppLocalizations.of(context)!.audioService), actions: [ - IconButton( - onPressed: () { - setState(() { - FinampSettingsHelper.resetAudioServiceSettings(); - }); - }, - icon: const Icon(Icons.refresh), - tooltip: AppLocalizations.of(context)!.resetToDefaults, + FinampSettingsHelper.makeSettingsResetButtonWithDialog( + context, + FinampSettingsHelper.resetAudioServiceSettings ) ], ), diff --git a/lib/screens/customization_settings_screen.dart b/lib/screens/customization_settings_screen.dart index d89050353..4c96c1928 100644 --- a/lib/screens/customization_settings_screen.dart +++ b/lib/screens/customization_settings_screen.dart @@ -25,14 +25,9 @@ class _CustomizationSettingsScreenState appBar: AppBar( title: Text(AppLocalizations.of(context)!.customizationSettingsTitle), actions: [ - IconButton( - onPressed: () { - setState(() { - FinampSettingsHelper.resetCustomizationSettings(); - }); - }, - icon: const Icon(Icons.refresh), - tooltip: AppLocalizations.of(context)!.resetToDefaults, + FinampSettingsHelper.makeSettingsResetButtonWithDialog( + context, + FinampSettingsHelper.resetCustomizationSettings ) ], ), diff --git a/lib/screens/downloads_settings_screen.dart b/lib/screens/downloads_settings_screen.dart index c3bb982dd..a92a23eb1 100644 --- a/lib/screens/downloads_settings_screen.dart +++ b/lib/screens/downloads_settings_screen.dart @@ -31,14 +31,9 @@ class _DownloadsSettingsScreenState extends State { appBar: AppBar( title: Text(AppLocalizations.of(context)!.downloadSettings), actions: [ - IconButton( - onPressed: () { - setState(() { - FinampSettingsHelper.resetDownloadSettings(); - }); - }, - icon: const Icon(Icons.refresh), - tooltip: AppLocalizations.of(context)!.resetToDefaults, + FinampSettingsHelper.makeSettingsResetButtonWithDialog( + context, + FinampSettingsHelper.resetDownloadSettings ) ], ), diff --git a/lib/screens/interaction_settings_screen.dart b/lib/screens/interaction_settings_screen.dart index 3fe043c14..cfb21d2a1 100644 --- a/lib/screens/interaction_settings_screen.dart +++ b/lib/screens/interaction_settings_screen.dart @@ -26,14 +26,9 @@ class _InteractionSettingsScreenState extends State { appBar: AppBar( title: Text(AppLocalizations.of(context)!.interactions), actions: [ - IconButton( - onPressed: () { - setState(() { - FinampSettingsHelper.resetInteractionsSettings(); - }); - }, - icon: const Icon(Icons.refresh), - tooltip: AppLocalizations.of(context)!.resetToDefaults, + FinampSettingsHelper.makeSettingsResetButtonWithDialog( + context, + FinampSettingsHelper.resetInteractionsSettings ) ], ), diff --git a/lib/screens/layout_settings_screen.dart b/lib/screens/layout_settings_screen.dart index e8faa5fd4..5ffd58825 100644 --- a/lib/screens/layout_settings_screen.dart +++ b/lib/screens/layout_settings_screen.dart @@ -36,14 +36,9 @@ class _LayoutSettingsScreenState extends State { appBar: AppBar( title: Text(AppLocalizations.of(context)!.layoutAndTheme), actions: [ - IconButton( - onPressed: () { - setState(() { - FinampSettingsHelper.resetLayoutSettings(); - }); - }, - icon: const Icon(Icons.refresh), - tooltip: AppLocalizations.of(context)!.resetToDefaults, + FinampSettingsHelper.makeSettingsResetButtonWithDialog( + context, + FinampSettingsHelper.resetLayoutSettings ) ], ), diff --git a/lib/screens/lyrics_settings_screen.dart b/lib/screens/lyrics_settings_screen.dart index e69544332..5e440a3c2 100644 --- a/lib/screens/lyrics_settings_screen.dart +++ b/lib/screens/lyrics_settings_screen.dart @@ -2,7 +2,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:hive/hive.dart'; -import '../components/LayoutSettingsScreen/player_screen_minimum_cover_padding_editor.dart'; import '../models/finamp_models.dart'; import '../services/finamp_settings_helper.dart'; @@ -21,14 +20,9 @@ class _LyricsSettingsScreenState extends State { appBar: AppBar( title: Text(AppLocalizations.of(context)!.lyricsScreen), actions: [ - IconButton( - onPressed: () { - setState(() { - FinampSettingsHelper.resetLyricsSettings(); - }); - }, - icon: const Icon(Icons.refresh), - tooltip: AppLocalizations.of(context)!.resetToDefaults, + FinampSettingsHelper.makeSettingsResetButtonWithDialog( + context, + FinampSettingsHelper.resetLyricsSettings ) ], ), diff --git a/lib/screens/player_settings_screen.dart b/lib/screens/player_settings_screen.dart index 2bb05e189..c144739ac 100644 --- a/lib/screens/player_settings_screen.dart +++ b/lib/screens/player_settings_screen.dart @@ -21,14 +21,9 @@ class _PlayerSettingsScreenState extends State { appBar: AppBar( title: Text(AppLocalizations.of(context)!.playerScreen), actions: [ - IconButton( - onPressed: () { - setState(() { - FinampSettingsHelper.resetPlayerScreenSettings(); - }); - }, - icon: const Icon(Icons.refresh), - tooltip: AppLocalizations.of(context)!.resetToDefaults, + FinampSettingsHelper.makeSettingsResetButtonWithDialog( + context, + FinampSettingsHelper.resetPlayerScreenSettings ) ] ), diff --git a/lib/screens/settings_screen.dart b/lib/screens/settings_screen.dart index 323ab2e44..9e6ff1e83 100644 --- a/lib/screens/settings_screen.dart +++ b/lib/screens/settings_screen.dart @@ -39,14 +39,10 @@ class _SettingsScreenState extends State { appBar: AppBar( title: Text(AppLocalizations.of(context)!.settings), actions: [ - IconButton( - onPressed: () { - setState(() { - FinampSettingsHelper.resetAllSettings(); - }); - }, - icon: const Icon(Icons.refresh), - tooltip: AppLocalizations.of(context)!.resetToDefaults, + FinampSettingsHelper.makeSettingsResetButtonWithDialog( + context, + FinampSettingsHelper.resetAllSettings, + isGlobal: true ), Semantics.fromProperties( properties: SemanticsProperties( diff --git a/lib/screens/tabs_settings_screen.dart b/lib/screens/tabs_settings_screen.dart index 638889dd3..9c193fd11 100644 --- a/lib/screens/tabs_settings_screen.dart +++ b/lib/screens/tabs_settings_screen.dart @@ -20,14 +20,9 @@ class _TabsSettingsScreenState extends State { appBar: AppBar( title: Text(AppLocalizations.of(context)!.tabs), actions: [ - IconButton( - onPressed: () { - setState(() { - FinampSettingsHelper.resetTabs(); - }); - }, - icon: const Icon(Icons.refresh), - tooltip: AppLocalizations.of(context)!.resetTabs, + FinampSettingsHelper.makeSettingsResetButtonWithDialog( + context, + FinampSettingsHelper.resetTabsSettings ) ], ), diff --git a/lib/screens/transcoding_settings_screen.dart b/lib/screens/transcoding_settings_screen.dart index 118331494..a70287480 100644 --- a/lib/screens/transcoding_settings_screen.dart +++ b/lib/screens/transcoding_settings_screen.dart @@ -26,14 +26,9 @@ class _TranscodingSettingsScreenState extends State { appBar: AppBar( title: Text(AppLocalizations.of(context)!.transcoding), actions: [ - IconButton( - onPressed: () { - setState(() { - FinampSettingsHelper.resetAllSettings(); - }); - }, - icon: const Icon(Icons.refresh), - tooltip: AppLocalizations.of(context)!.resetToDefaults, + FinampSettingsHelper.makeSettingsResetButtonWithDialog( + context, + FinampSettingsHelper.resetTranscodingSettings ) ], ), diff --git a/lib/screens/volume_normalization_settings_screen.dart b/lib/screens/volume_normalization_settings_screen.dart index 2656d6ae4..69246c573 100644 --- a/lib/screens/volume_normalization_settings_screen.dart +++ b/lib/screens/volume_normalization_settings_screen.dart @@ -24,14 +24,9 @@ class _VolumeNormalizationSettingsScreenState extends State Date: Mon, 30 Dec 2024 15:06:17 +0100 Subject: [PATCH 04/10] formatting --- lib/screens/album_settings_screen.dart | 9 +-- .../audio_service_settings_screen.dart | 12 ++-- .../customization_settings_screen.dart | 4 +- lib/screens/downloads_settings_screen.dart | 8 +-- lib/screens/interaction_settings_screen.dart | 8 +-- lib/screens/layout_settings_screen.dart | 9 +-- lib/screens/lyrics_settings_screen.dart | 9 +-- lib/screens/player_settings_screen.dart | 16 ++--- lib/screens/settings_screen.dart | 12 ++-- lib/screens/tabs_settings_screen.dart | 4 +- lib/screens/transcoding_settings_screen.dart | 10 +-- .../volume_normalization_settings_screen.dart | 11 ++-- lib/services/finamp_settings_helper.dart | 62 +++++++++++-------- .../music_player_background_task.dart | 2 +- 14 files changed, 78 insertions(+), 98 deletions(-) diff --git a/lib/screens/album_settings_screen.dart b/lib/screens/album_settings_screen.dart index de22025f6..5afd05b2b 100644 --- a/lib/screens/album_settings_screen.dart +++ b/lib/screens/album_settings_screen.dart @@ -5,12 +5,11 @@ import 'package:hive/hive.dart'; import '../models/finamp_models.dart'; import '../services/finamp_settings_helper.dart'; -class AlbumSettingsScreen extends StatefulWidget { +class AlbumSettingsScreen extends StatefulWidget { const AlbumSettingsScreen({super.key}); static const routeName = "/settings/layout/album"; @override - State createState() => - _AlbumSettingsScreenState(); + State createState() => _AlbumSettingsScreenState(); } class _AlbumSettingsScreenState extends State { @@ -21,9 +20,7 @@ class _AlbumSettingsScreenState extends State { title: Text(AppLocalizations.of(context)!.albumScreen), actions: [ FinampSettingsHelper.makeSettingsResetButtonWithDialog( - context, - FinampSettingsHelper.resetAlbumSettings - ) + context, FinampSettingsHelper.resetAlbumSettings) ], ), body: ListView( diff --git a/lib/screens/audio_service_settings_screen.dart b/lib/screens/audio_service_settings_screen.dart index 70ff8b21b..a3825fbfa 100644 --- a/lib/screens/audio_service_settings_screen.dart +++ b/lib/screens/audio_service_settings_screen.dart @@ -11,16 +11,16 @@ import '../components/AudioServiceSettingsScreen/report_queue_to_server_toggle.d import '../components/AudioServiceSettingsScreen/song_shuffle_item_count_editor.dart'; import '../components/AudioServiceSettingsScreen/stop_foreground_selector.dart'; -class AudioServiceSettingsScreen extends StatefulWidget { +class AudioServiceSettingsScreen extends StatefulWidget { const AudioServiceSettingsScreen({super.key}); static const routeName = "/settings/audioservice"; @override State createState() => - _AudioServiceSettingsScreenState(); + _AudioServiceSettingsScreenState(); } - -class _AudioServiceSettingsScreenState extends State { +class _AudioServiceSettingsScreenState + extends State { @override Widget build(BuildContext context) { return Scaffold( @@ -28,9 +28,7 @@ class _AudioServiceSettingsScreenState extends State title: Text(AppLocalizations.of(context)!.audioService), actions: [ FinampSettingsHelper.makeSettingsResetButtonWithDialog( - context, - FinampSettingsHelper.resetAudioServiceSettings - ) + context, FinampSettingsHelper.resetAudioServiceSettings) ], ), body: ListView( diff --git a/lib/screens/customization_settings_screen.dart b/lib/screens/customization_settings_screen.dart index 4c96c1928..6d8683ce7 100644 --- a/lib/screens/customization_settings_screen.dart +++ b/lib/screens/customization_settings_screen.dart @@ -26,9 +26,7 @@ class _CustomizationSettingsScreenState title: Text(AppLocalizations.of(context)!.customizationSettingsTitle), actions: [ FinampSettingsHelper.makeSettingsResetButtonWithDialog( - context, - FinampSettingsHelper.resetCustomizationSettings - ) + context, FinampSettingsHelper.resetCustomizationSettings) ], ), body: ListView( diff --git a/lib/screens/downloads_settings_screen.dart b/lib/screens/downloads_settings_screen.dart index a92a23eb1..ec65d8e14 100644 --- a/lib/screens/downloads_settings_screen.dart +++ b/lib/screens/downloads_settings_screen.dart @@ -15,12 +15,12 @@ import '../services/downloads_service.dart'; import '../services/finamp_settings_helper.dart'; import 'downloads_location_screen.dart'; -class DownloadsSettingsScreen extends StatefulWidget { +class DownloadsSettingsScreen extends StatefulWidget { const DownloadsSettingsScreen({super.key}); static const routeName = "/settings/downloads"; @override State createState() => - _DownloadsSettingsScreenState(); + _DownloadsSettingsScreenState(); } class _DownloadsSettingsScreenState extends State { @@ -32,9 +32,7 @@ class _DownloadsSettingsScreenState extends State { title: Text(AppLocalizations.of(context)!.downloadSettings), actions: [ FinampSettingsHelper.makeSettingsResetButtonWithDialog( - context, - FinampSettingsHelper.resetDownloadSettings - ) + context, FinampSettingsHelper.resetDownloadSettings) ], ), body: ListView( diff --git a/lib/screens/interaction_settings_screen.dart b/lib/screens/interaction_settings_screen.dart index cfb21d2a1..11248efc3 100644 --- a/lib/screens/interaction_settings_screen.dart +++ b/lib/screens/interaction_settings_screen.dart @@ -11,12 +11,12 @@ import '../components/InteractionSettingsScreen/disable_gestures.dart'; import '../components/InteractionSettingsScreen/disable_vibration.dart'; import '../components/InteractionSettingsScreen/swipe_insert_queue_next_selector.dart'; -class InteractionSettingsScreen extends StatefulWidget { +class InteractionSettingsScreen extends StatefulWidget { const InteractionSettingsScreen({super.key}); static const routeName = "/settings/interactions"; @override State createState() => - _InteractionSettingsScreenState(); + _InteractionSettingsScreenState(); } class _InteractionSettingsScreenState extends State { @@ -27,9 +27,7 @@ class _InteractionSettingsScreenState extends State { title: Text(AppLocalizations.of(context)!.interactions), actions: [ FinampSettingsHelper.makeSettingsResetButtonWithDialog( - context, - FinampSettingsHelper.resetInteractionsSettings - ) + context, FinampSettingsHelper.resetInteractionsSettings) ], ), body: ListView( diff --git a/lib/screens/layout_settings_screen.dart b/lib/screens/layout_settings_screen.dart index 5ffd58825..8c8f041c3 100644 --- a/lib/screens/layout_settings_screen.dart +++ b/lib/screens/layout_settings_screen.dart @@ -18,12 +18,11 @@ import '../services/finamp_settings_helper.dart'; import '../components/LayoutSettingsScreen/use_cover_as_background_toggle.dart'; import 'tabs_settings_screen.dart'; -class LayoutSettingsScreen extends StatefulWidget { +class LayoutSettingsScreen extends StatefulWidget { const LayoutSettingsScreen({super.key}); static const routeName = "/settings/layout"; @override - State createState() => - _LayoutSettingsScreenState(); + State createState() => _LayoutSettingsScreenState(); } class _LayoutSettingsScreenState extends State { @@ -37,9 +36,7 @@ class _LayoutSettingsScreenState extends State { title: Text(AppLocalizations.of(context)!.layoutAndTheme), actions: [ FinampSettingsHelper.makeSettingsResetButtonWithDialog( - context, - FinampSettingsHelper.resetLayoutSettings - ) + context, FinampSettingsHelper.resetLayoutSettings) ], ), body: ListView( diff --git a/lib/screens/lyrics_settings_screen.dart b/lib/screens/lyrics_settings_screen.dart index 5e440a3c2..24fdd5fcd 100644 --- a/lib/screens/lyrics_settings_screen.dart +++ b/lib/screens/lyrics_settings_screen.dart @@ -5,12 +5,11 @@ import 'package:hive/hive.dart'; import '../models/finamp_models.dart'; import '../services/finamp_settings_helper.dart'; -class LyricsSettingsScreen extends StatefulWidget { +class LyricsSettingsScreen extends StatefulWidget { const LyricsSettingsScreen({super.key}); static const routeName = "/settings/lyrics"; @override - State createState() => - _LyricsSettingsScreenState(); + State createState() => _LyricsSettingsScreenState(); } class _LyricsSettingsScreenState extends State { @@ -21,9 +20,7 @@ class _LyricsSettingsScreenState extends State { title: Text(AppLocalizations.of(context)!.lyricsScreen), actions: [ FinampSettingsHelper.makeSettingsResetButtonWithDialog( - context, - FinampSettingsHelper.resetLyricsSettings - ) + context, FinampSettingsHelper.resetLyricsSettings) ], ), body: ListView( diff --git a/lib/screens/player_settings_screen.dart b/lib/screens/player_settings_screen.dart index c144739ac..ac0674647 100644 --- a/lib/screens/player_settings_screen.dart +++ b/lib/screens/player_settings_screen.dart @@ -10,8 +10,7 @@ class PlayerSettingsScreen extends StatefulWidget { const PlayerSettingsScreen({super.key}); static const routeName = "/settings/player"; @override - State createState() => - _PlayerSettingsScreenState(); + State createState() => _PlayerSettingsScreenState(); } class _PlayerSettingsScreenState extends State { @@ -19,14 +18,11 @@ class _PlayerSettingsScreenState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text(AppLocalizations.of(context)!.playerScreen), - actions: [ - FinampSettingsHelper.makeSettingsResetButtonWithDialog( - context, - FinampSettingsHelper.resetPlayerScreenSettings - ) - ] - ), + title: Text(AppLocalizations.of(context)!.playerScreen), + actions: [ + FinampSettingsHelper.makeSettingsResetButtonWithDialog( + context, FinampSettingsHelper.resetPlayerScreenSettings) + ]), body: ListView( children: const [ const ShowFeatureChipsToggle(), diff --git a/lib/screens/settings_screen.dart b/lib/screens/settings_screen.dart index 9e6ff1e83..24b99de80 100644 --- a/lib/screens/settings_screen.dart +++ b/lib/screens/settings_screen.dart @@ -19,15 +19,13 @@ import 'transcoding_settings_screen.dart'; import 'view_selector.dart'; import 'volume_normalization_settings_screen.dart'; -class SettingsScreen extends StatefulWidget { +class SettingsScreen extends StatefulWidget { const SettingsScreen({super.key}); static const routeName = "/settings"; @override - State createState() => - _SettingsScreenState(); + State createState() => _SettingsScreenState(); } - class _SettingsScreenState extends State { static const repoLink = "https://github.com/jmshrv/finamp"; static const releaseNotesLink = "https://github.com/jmshrv/finamp/releases"; @@ -40,10 +38,8 @@ class _SettingsScreenState extends State { title: Text(AppLocalizations.of(context)!.settings), actions: [ FinampSettingsHelper.makeSettingsResetButtonWithDialog( - context, - FinampSettingsHelper.resetAllSettings, - isGlobal: true - ), + context, FinampSettingsHelper.resetAllSettings, + isGlobal: true), Semantics.fromProperties( properties: SemanticsProperties( label: AppLocalizations.of(context)!.about, diff --git a/lib/screens/tabs_settings_screen.dart b/lib/screens/tabs_settings_screen.dart index 9c193fd11..c39ab8814 100644 --- a/lib/screens/tabs_settings_screen.dart +++ b/lib/screens/tabs_settings_screen.dart @@ -21,9 +21,7 @@ class _TabsSettingsScreenState extends State { title: Text(AppLocalizations.of(context)!.tabs), actions: [ FinampSettingsHelper.makeSettingsResetButtonWithDialog( - context, - FinampSettingsHelper.resetTabsSettings - ) + context, FinampSettingsHelper.resetTabsSettings) ], ), body: ReorderableListView.builder( diff --git a/lib/screens/transcoding_settings_screen.dart b/lib/screens/transcoding_settings_screen.dart index a70287480..ac408648c 100644 --- a/lib/screens/transcoding_settings_screen.dart +++ b/lib/screens/transcoding_settings_screen.dart @@ -9,14 +9,12 @@ import '../components/TranscodingSettingsScreen/transcode_switch.dart'; import '../models/finamp_models.dart'; import '../services/finamp_settings_helper.dart'; - - -class TranscodingSettingsScreen extends StatefulWidget { +class TranscodingSettingsScreen extends StatefulWidget { const TranscodingSettingsScreen({super.key}); static const routeName = "/settings/transcoding"; @override State createState() => - _TranscodingSettingsScreenState(); + _TranscodingSettingsScreenState(); } class _TranscodingSettingsScreenState extends State { @@ -27,9 +25,7 @@ class _TranscodingSettingsScreenState extends State { title: Text(AppLocalizations.of(context)!.transcoding), actions: [ FinampSettingsHelper.makeSettingsResetButtonWithDialog( - context, - FinampSettingsHelper.resetTranscodingSettings - ) + context, FinampSettingsHelper.resetTranscodingSettings) ], ), body: ListView( diff --git a/lib/screens/volume_normalization_settings_screen.dart b/lib/screens/volume_normalization_settings_screen.dart index 69246c573..b3f526d9b 100644 --- a/lib/screens/volume_normalization_settings_screen.dart +++ b/lib/screens/volume_normalization_settings_screen.dart @@ -8,15 +8,16 @@ import '../components/VolumeNormalizationSettingsScreen/volume_normalization_ios import '../components/VolumeNormalizationSettingsScreen/volume_normalization_mode_selector.dart'; import '../components/VolumeNormalizationSettingsScreen/volume_normalization_switch.dart'; -class VolumeNormalizationSettingsScreen extends StatefulWidget { +class VolumeNormalizationSettingsScreen extends StatefulWidget { const VolumeNormalizationSettingsScreen({super.key}); static const routeName = "/settings/volume-normalization"; @override State createState() => - _VolumeNormalizationSettingsScreenState(); + _VolumeNormalizationSettingsScreenState(); } -class _VolumeNormalizationSettingsScreenState extends State { +class _VolumeNormalizationSettingsScreenState + extends State { @override Widget build(BuildContext context) { return Scaffold( @@ -25,9 +26,7 @@ class _VolumeNormalizationSettingsScreenState extends State("FinampSettings") .put("FinampSettings", finampSettingsTemp); } + static void resetPlayerScreenSettings() { FinampSettings finampSettingsTemp = finampSettings; - finampSettingsTemp.featureChipsConfiguration = finampSettingsTemp.featureChipsConfiguration.copyWith(enabled: true); + finampSettingsTemp.featureChipsConfiguration = + finampSettingsTemp.featureChipsConfiguration.copyWith(enabled: true); finampSettingsTemp.playerScreenCoverMinimumPadding = 1.5; finampSettingsTemp.suppressPlayerPadding = false; finampSettingsTemp.prioritizeCoverFactor = 8.0; @@ -348,6 +350,7 @@ class FinampSettingsHelper { Hive.box("FinampSettings") .put("FinampSettings", finampSettingsTemp); } + static void resetLyricsSettings() { FinampSettings finampSettingsTemp = finampSettings; @@ -359,6 +362,7 @@ class FinampSettingsHelper { Hive.box("FinampSettings") .put("FinampSettings", finampSettingsTemp); } + static void resetAlbumSettings() { FinampSettings finampSettingsTemp = finampSettings; @@ -367,7 +371,8 @@ class FinampSettingsHelper { Hive.box("FinampSettings") .put("FinampSettings", finampSettingsTemp); } - static void resetLayoutSettings() { + + static void resetLayoutSettings() { FinampSettings finampSettingsTemp = finampSettings; ThemeModeHelper.setThemeMode(ThemeMode.system); @@ -386,12 +391,14 @@ class FinampSettingsHelper { Hive.box("FinampSettings") .put("FinampSettings", finampSettingsTemp); } - static void resetTranscodingSettings() { + + static void resetTranscodingSettings() { FinampSettings finampSettingsTemp = finampSettings; finampSettingsTemp.shouldTranscode = false; setTranscodeBitrate(320000); - finampSettingsTemp.transcodingSegmentContainer = FinampSegmentContainer.fragmentedMp4; + finampSettingsTemp.transcodingSegmentContainer = + FinampSegmentContainer.fragmentedMp4; finampSettingsTemp.shouldTranscodeDownloads = TranscodeDownloadsSetting.ask; finampSettingsTemp.downloadTranscodingCodec = FinampTranscodingCodec.opus; finampSettingsTemp.downloadTranscodeBitrate = 128000; @@ -399,6 +406,7 @@ class FinampSettingsHelper { Hive.box("FinampSettings") .put("FinampSettings", finampSettingsTemp); } + static void resetDownloadSettings() { FinampSettings finampSettingsTemp = finampSettings; @@ -407,21 +415,23 @@ class FinampSettingsHelper { finampSettingsTemp.resyncOnStartup = true; finampSettingsTemp.preferQuickSyncs = true; finampSettingsTemp.shouldRedownloadTranscodes = false; - finampSettingsTemp.showDownloadsWithUnknownLibrary = true; + finampSettingsTemp.showDownloadsWithUnknownLibrary = true; finampSettingsTemp.downloadWorkers = 5; finampSettingsTemp.maxConcurrentDownloads = 10; Hive.box("FinampSettings") .put("FinampSettings", finampSettingsTemp); } + static void resetAudioServiceSettings() { - setAndroidStopForegroundOnPause(true); - setSongShuffleItemCount(250); // DOES NOT update UI - setBufferDuration(Duration(seconds: 600)); // DOES NOT update UI + setAndroidStopForegroundOnPause(true); + setSongShuffleItemCount(250); // DOES NOT update UI + setBufferDuration(Duration(seconds: 600)); // DOES NOT update UI setAutoloadLastQueueOnStartup(true); setPeriodicPlaybackSessionUpdateFrequencySeconds(150); // DOES NOT update UI setReportQueueToServer(false); } + static void resetNormalizationSettings() { FinampSettings finampSettingsTemp = finampSettings; @@ -432,6 +442,7 @@ class FinampSettingsHelper { Hive.box("FinampSettings") .put("FinampSettings", finampSettingsTemp); } + static void resetInteractionsSettings() { FinampSettings finampSettingsTemp = finampSettings; @@ -443,10 +454,10 @@ class FinampSettingsHelper { setKeepScreenOnOption(KeepScreenOnOption.whileLyrics); setKeepScreenOnWhileCharging(true); - Hive.box("FinampSettings") .put("FinampSettings", finampSettingsTemp); } + static void resetAllSettings() { resetTranscodingSettings(); resetDownloadSettings(); @@ -460,7 +471,7 @@ class FinampSettingsHelper { resetLyricsSettings(); resetAlbumSettings(); resetTabsSettings(); - + LocaleHelper.setLocale(null); // Reset to System Language } @@ -508,24 +519,25 @@ class FinampSettingsHelper { .put("FinampSettings", finampSettingsTemp); } - static IconButton makeSettingsResetButtonWithDialog(BuildContext context, Function() resetFunction, {bool isGlobal = false}) { + static IconButton makeSettingsResetButtonWithDialog( + BuildContext context, Function() resetFunction, + {bool isGlobal = false}) { // TODO: Replace the following Strings with localization return IconButton( - onPressed: () async{ + onPressed: () async { await showDialog( - context: context, - builder: (context) => ConfirmationPromptDialog( - promptText: isGlobal - ? "Are you sure you want to reset ALL settings?" - : "Do you want to reset these settings back to default?", - confirmButtonText: isGlobal - ? "Yes I am!" - : AppLocalizations.of(context)!.reset, - abortButtonText: "Cancel", - onConfirmed: resetFunction, - onAborted: (){}, - ) - ); + context: context, + builder: (context) => ConfirmationPromptDialog( + promptText: isGlobal + ? "Are you sure you want to reset ALL settings?" + : "Do you want to reset these settings back to default?", + confirmButtonText: isGlobal + ? "Yes I am!" + : AppLocalizations.of(context)!.reset, + abortButtonText: "Cancel", + onConfirmed: resetFunction, + onAborted: () {}, + )); }, icon: const Icon(Icons.refresh), tooltip: AppLocalizations.of(context)!.resetToDefaults, diff --git a/lib/services/music_player_background_task.dart b/lib/services/music_player_background_task.dart index e62eda773..df52eca0f 100644 --- a/lib/services/music_player_background_task.dart +++ b/lib/services/music_player_background_task.dart @@ -61,7 +61,7 @@ class MusicPlayerBackgroundTask extends BaseAudioHandler { ValueListenable get sleepTimer => _sleepTimer; double iosBaseVolumeGainFactor = 1.0; - + final outputSwitcherChannel = MethodChannel('com.unicornsonlsd.finamp/output_switcher'); From 6ffad11555bcfcfdb83be87ec2d77c76cb217e3e Mon Sep 17 00:00:00 2001 From: flloschy Date: Mon, 30 Dec 2024 15:40:04 +0100 Subject: [PATCH 05/10] Rebuild Cildren on some settings pages where resetting to default didnt update the ui --- .../audio_service_settings_screen.dart | 20 +++++++++++++------ .../volume_normalization_settings_screen.dart | 15 +++++++++++--- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/lib/screens/audio_service_settings_screen.dart b/lib/screens/audio_service_settings_screen.dart index a3825fbfa..d07c13edc 100644 --- a/lib/screens/audio_service_settings_screen.dart +++ b/lib/screens/audio_service_settings_screen.dart @@ -21,23 +21,31 @@ class AudioServiceSettingsScreen extends StatefulWidget { class _AudioServiceSettingsScreenState extends State { + // Overwriting this value causes the childrens to update + // this is a required workaround because some input fields + // might not update when resetting to defaults + Key _updateChildren = UniqueKey(); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(AppLocalizations.of(context)!.audioService), actions: [ - FinampSettingsHelper.makeSettingsResetButtonWithDialog( - context, FinampSettingsHelper.resetAudioServiceSettings) + FinampSettingsHelper.makeSettingsResetButtonWithDialog(context, () { + setState(() { + FinampSettingsHelper.resetAudioServiceSettings(); + _updateChildren = UniqueKey(); // Trigger rebuilding of Children + }); + }) ], ), body: ListView( children: [ - if (Platform.isAndroid) const StopForegroundSelector(), - const SongShuffleItemCountEditor(), - const BufferDurationListTile(), + if (Platform.isAndroid) StopForegroundSelector(key: _updateChildren), + SongShuffleItemCountEditor(key: _updateChildren), + BufferDurationListTile(key: _updateChildren), const LoadQueueOnStartupSelector(), - const PeriodicPlaybackSessionUpdateFrequencyEditor(), + PeriodicPlaybackSessionUpdateFrequencyEditor(key: _updateChildren), const ReportQueueToServerToggle(), ], ), diff --git a/lib/screens/volume_normalization_settings_screen.dart b/lib/screens/volume_normalization_settings_screen.dart index b3f526d9b..ca7d19235 100644 --- a/lib/screens/volume_normalization_settings_screen.dart +++ b/lib/screens/volume_normalization_settings_screen.dart @@ -18,6 +18,10 @@ class VolumeNormalizationSettingsScreen extends StatefulWidget { class _VolumeNormalizationSettingsScreenState extends State { + // Overwriting this value causes the childrens to update + // this is a required workaround because some input fields + // might not update when resetting to defaults + Key _updateChildren = UniqueKey(); @override Widget build(BuildContext context) { return Scaffold( @@ -25,14 +29,19 @@ class _VolumeNormalizationSettingsScreenState title: Text( AppLocalizations.of(context)!.volumeNormalizationSettingsTitle), actions: [ - FinampSettingsHelper.makeSettingsResetButtonWithDialog( - context, FinampSettingsHelper.resetNormalizationSettings) + FinampSettingsHelper.makeSettingsResetButtonWithDialog(context, () { + setState(() { + FinampSettingsHelper.resetNormalizationSettings(); + _updateChildren = UniqueKey(); // Trigger rebuilding of Children + }); + }) ], ), body: ListView( children: [ const VolumeNormalizationSwitch(), - if (!Platform.isAndroid) const VolumeNormalizationIOSBaseGainEditor(), + if (!Platform.isAndroid) + VolumeNormalizationIOSBaseGainEditor(key: _updateChildren), const VolumeNormalizationModeSelector(), ], ), From c3efba1ca3d2ceb7c5e335f2536be43dff4d74cf Mon Sep 17 00:00:00 2001 From: flloschy Date: Mon, 30 Dec 2024 17:45:57 +0100 Subject: [PATCH 06/10] added localizations --- lib/l10n/app_en.arb | 16 ++++++++++++++++ lib/services/finamp_settings_helper.dart | 8 ++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 2173aedf6..d07659bc0 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -1813,5 +1813,21 @@ "resetFiltersButton": "Reset filters", "@resetFiltersButton": { "description": "Button to reset filters on a list of items" + }, + "resetSettingsPromptGlobal": "Are you sure you want to reset ALL settings?", + "@resetSettingsPromptGlobal": { + "description": "Prompt which gets shown when the user is about to reset all settings to their default values" + }, + "resetSettingsPromptGlobalConfirm": "Yes I am!", + "@resetSettingsPromptGlobalConfirm": { + "description": "A differently worded Confirm button to prevent the user from instandly clicking confirm because they are about to reset all settings to their default value" + }, + "resetSettingsPromptLocal": "Do you want to reset these settings back to default?", + "@resetSettingsPromptLocal": { + "description": "Prompt which gets shown when the user is about to reset all settings in the current settings window to their default values" + }, + "genericCancel": "Cancel", + "@genericCancel": { + "description": "Used when the user stops an action from taking place inside a popup dialog window" } } diff --git a/lib/services/finamp_settings_helper.dart b/lib/services/finamp_settings_helper.dart index f2d894ded..d51ea4424 100644 --- a/lib/services/finamp_settings_helper.dart +++ b/lib/services/finamp_settings_helper.dart @@ -529,12 +529,12 @@ class FinampSettingsHelper { context: context, builder: (context) => ConfirmationPromptDialog( promptText: isGlobal - ? "Are you sure you want to reset ALL settings?" - : "Do you want to reset these settings back to default?", + ? AppLocalizations.of(context)!.resetSettingsPromptGlobal + : AppLocalizations.of(context)!.resetSettingsPromptLocal, confirmButtonText: isGlobal - ? "Yes I am!" + ? AppLocalizations.of(context)!.resetSettingsPromptGlobalConfirm : AppLocalizations.of(context)!.reset, - abortButtonText: "Cancel", + abortButtonText: AppLocalizations.of(context)!.genericCancel, onConfirmed: resetFunction, onAborted: () {}, )); From 2b37a1fcd813f82ca5f2df2a05e6364f83666cc5 Mon Sep 17 00:00:00 2001 From: flloschy Date: Mon, 30 Dec 2024 18:43:38 +0100 Subject: [PATCH 07/10] Defaults refactoring; Using actual defaults for reset; --- ...eep_screen_on_while_charging_selector.dart | 2 +- lib/main.dart | 2 +- lib/models/finamp_models.dart | 392 +++++++++--------- lib/services/finamp_settings_helper.dart | 120 +++--- 4 files changed, 262 insertions(+), 254 deletions(-) diff --git a/lib/components/InteractionSettingsScreen/keep_screen_on_while_charging_selector.dart b/lib/components/InteractionSettingsScreen/keep_screen_on_while_charging_selector.dart index a2713ce38..4aedb4989 100644 --- a/lib/components/InteractionSettingsScreen/keep_screen_on_while_charging_selector.dart +++ b/lib/components/InteractionSettingsScreen/keep_screen_on_while_charging_selector.dart @@ -19,7 +19,7 @@ class KeepScreenOnWhilePluggedInSelector extends StatelessWidget { AppLocalizations.of(context)!.keepScreenOnWhilePluggedInSubtitle), value: FinampSettingsHelper.finampSettings.keepScreenOnWhilePluggedIn, onChanged: (value) { - FinampSettingsHelper.setKeepScreenOnWhileCharging(value); + FinampSettingsHelper.setKeepScreenOnWhilePluggedIn(value); }, ); }, diff --git a/lib/main.dart b/lib/main.dart index e64d853fc..69ca1dac4 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -260,7 +260,7 @@ Future setupHive() async { // If no ThemeMode is set, we set it to the default (system) Box themeModeBox = Hive.box("ThemeMode"); - if (themeModeBox.isEmpty) ThemeModeHelper.setThemeMode(ThemeMode.system); + if (themeModeBox.isEmpty) ThemeModeHelper.setThemeMode(DefaultSettings.theme); final isar = await Isar.open( [ diff --git a/lib/models/finamp_models.dart b/lib/models/finamp_models.dart index 3ddb923b0..fe656404d 100644 --- a/lib/models/finamp_models.dart +++ b/lib/models/finamp_models.dart @@ -56,184 +56,194 @@ class FinampUser { BaseItemDto? get currentView => views[currentViewId]; } -// These consts are so that we can easily keep the same default for -// FinampSettings's constructor and Hive's defaultValue. -const _isOfflineDefault = false; -const _shouldTranscodeDefault = false; -const _transcodeBitrateDefault = 320000; -const _androidStopForegroundOnPauseDefault = true; -const _isFavouriteDefault = false; -const _songShuffleItemCountDefault = 250; -const _volumeNormalizationActiveDefault = true; -// 80% volume in dB. In my testing, most tracks were louder than the default target -// of -18.0 LUFS, so the gain rarely needed to be increased. -2.0 gives us a bit of -// headroom in case we need to boost a track (since volume can't go above 1.0), -// without reducing the volume too much. -// Ideally the maximum gain in each library should be fetched from the server, and this volume should be adjusted accordingly -const _volumeNormalizationIOSBaseGainDefault = -2.0; -const _volumeNormalizationModeDefault = VolumeNormalizationMode.hybrid; -const _contentViewType = ContentViewType.list; -const _playbackSpeedVisibility = PlaybackSpeedVisibility.automatic; -const _contentGridViewCrossAxisCountPortrait = 2; -const _contentGridViewCrossAxisCountLandscape = 3; -const _showTextOnGridView = true; -const _sleepTimerSeconds = 1800; // 30 Minutes -const _useCoverAsBackground = true; -const _playerScreenCoverMinimumPadding = 1.5; -const _showArtistsTopSongs = true; -const _disableGesture = false; -const _showFastScroller = true; -const _bufferDurationSeconds = 600; -const _tabOrder = TabContentType.values; -const _swipeInsertQueueNext = true; -const _defaultLoopMode = FinampLoopMode.none; -const _defaultPlaybackSpeed = 1.0; -const _autoLoadLastQueueOnStartup = true; -const _shouldTranscodeDownloadsDefault = TranscodeDownloadsSetting.ask; -const _shouldRedownloadTranscodesDefault = false; -const _defaultResyncOnStartup = true; -const _fixedGridTileSizeDefault = 150; -const _defaultSplitScreenPlayerWidth = 400.0; -const _enableVibration = true; -const _prioritizeCoverFactor = 8.0; -const _suppressPlayerPadding = false; -const _hidePlayerBottomActions = false; -const _reportQueueToServerDefault = false; -const _periodicPlaybackSessionUpdateFrequencySecondsDefault = 150; -const _showArtistChipImage = true; -const _trackOfflineFavoritesDefault = true; -const _showProgressOnNowPlayingBarDefault = true; -const _startInstantMixForIndividualTracksDefault = true; -const _showLyricsTimestampsDefault = true; -const _lyricsAlignmentDefault = LyricsAlignment.start; -const _lyricsFontSizeDefault = LyricsFontSize.medium; -const _showLyricsScreenAlbumPreludeDefault = true; -const _showStopButtonOnMediaNotificationDefault = false; -const _showSeekControlsOnMediaNotificationDefault = true; -const _keepScreenOnOption = KeepScreenOnOption.whileLyrics; -const _keepScreenOnWhilePluggedIn = true; -const _hasDownloadedPlaylistInfoDefault = false; -const _defaultTranscodingSegmentContainer = - FinampSegmentContainer.fragmentedMp4; -const _featureChipsConfigurationDefault = - FinampFeatureChipsConfiguration(enabled: true, features: [ - FinampFeatureChipType.playCount, - FinampFeatureChipType.additionalPeople, - FinampFeatureChipType.playbackMode, - FinampFeatureChipType.codec, - FinampFeatureChipType.bitRate, - FinampFeatureChipType.bitDepth, - FinampFeatureChipType.sampleRate, - FinampFeatureChipType.size, - FinampFeatureChipType.normalizationGain, -]); -const _showCoversOnAlbumScreenDefault = false; +class DefaultSettings { + // These consts are so that we can easily keep the same default for + // FinampSettings's constructor and Hive's defaultValue. + static const isOffline = false; + static const theme = ThemeMode.system; + static const shouldTranscode = false; + static const transcodeBitrate = 320000; + static const settingAndroidStopForegroundOnPause = true; + static const settingIsFavourite = false; + static const songShuffleItemCount = 250; + static const volumeNormalizationActive = true; + // 80% volume in dB. In my testing, most tracks were louder than the default target + // of -18.0 LUFS, so the gain rarely needed to be increased. -2.0 gives us a bit of + // headroom in case we need to boost a track (since volume can't go above 1.0), + // without reducing the volume too much. + // Ideally the maximum gain in each library should be fetched from the server, and this volume should be adjusted accordingly + static const volumeNormalizationIOSBaseGain = -2.0; + static const volumeNormalizationMode = VolumeNormalizationMode.hybrid; + static const contentViewType = ContentViewType.list; + static const playbackSpeedVisibility = PlaybackSpeedVisibility.automatic; + static const contentGridViewCrossAxisCountPortrait = 2; + static const contentGridViewCrossAxisCountLandscape = 3; + static const showTextOnGridView = true; + static const sleepTimerSeconds = 1800; // 30 Minutes + static const useCoverAsBackground = true; + static const playerScreenCoverMinimumPadding = 1.5; + static const showArtistsTopSongs = true; + static const disableGesture = false; + static const showFastScroller = true; + static const bufferDurationSeconds = 600; + static const tabOrder = TabContentType.values; + static const swipeInsertQueueNext = true; + static const loopMode = FinampLoopMode.none; + static const playbackSpeed = 1.0; + static const autoLoadLastQueueOnStartup = true; + static const shouldTranscodeDownloads = TranscodeDownloadsSetting.ask; + static const shouldRedownloadTranscodes = false; + static const resyncOnStartup = true; + static const fixedGridTileSize = 150; + static const useFixedSizeGridTiles = false; + static const splitScreenPlayerWidth = 400.0; + static const enableVibration = true; + static const prioritizeCoverFactor = 8.0; + static const suppressPlayerPadding = false; + static const hidePlayerBottomActions = false; + static const reportQueueToServer = false; + static const periodicPlaybackSessionUpdateFrequencySeconds = 150; + static const showArtistChipImage = true; + static const trackOfflineFavorites = true; + static const showProgressOnNowPlayingBar = true; + static const startInstantMixForIndividualTracks = true; + static const showLyricsTimestamps = true; + static const lyricsAlignment = LyricsAlignment.start; + static const lyricsFontSize = LyricsFontSize.medium; + static const showLyricsScreenAlbumPrelude = true; + static const showStopButtonOnMediaNotification = false; + static const showSeekControlsOnMediaNotification = true; + static const keepScreenOnOption = KeepScreenOnOption.whileLyrics; + static const keepScreenOnWhilePluggedIn = true; + static const hasDownloadedPlaylistInfo = false; + static const transcodingSegmentContainer = + FinampSegmentContainer.fragmentedMp4; + static const featureChipsConfiguration = + FinampFeatureChipsConfiguration(enabled: true, features: [ + FinampFeatureChipType.playCount, + FinampFeatureChipType.additionalPeople, + FinampFeatureChipType.playbackMode, + FinampFeatureChipType.codec, + FinampFeatureChipType.bitRate, + FinampFeatureChipType.bitDepth, + FinampFeatureChipType.sampleRate, + FinampFeatureChipType.size, + FinampFeatureChipType.normalizationGain, + ]); + static const showCoversOnAlbumScreen = false; + static const allowSplitScreen = true; + static const requireWifiForDownloads = false; + static const preferQuickSyncs = true; + static const showDownloadsWithUnknownLibrary = true; + static const downloadWorkers = 5; + static const maxConcurrentDownloads = 10; +} @HiveType(typeId: 28) class FinampSettings { FinampSettings( - {this.isOffline = _isOfflineDefault, - this.shouldTranscode = _shouldTranscodeDefault, - this.transcodeBitrate = _transcodeBitrateDefault, + {this.isOffline = DefaultSettings.isOffline, + this.shouldTranscode = DefaultSettings.shouldTranscode, + this.transcodeBitrate = DefaultSettings.transcodeBitrate, // downloadLocations is required since the other values can be created with // default values. create() is used to return a FinampSettings with // downloadLocations. required this.downloadLocations, - this.androidStopForegroundOnPause = _androidStopForegroundOnPauseDefault, + this.androidStopForegroundOnPause = DefaultSettings.settingAndroidStopForegroundOnPause, required this.showTabs, - this.onlyShowFavourite = _isFavouriteDefault, + this.onlyShowFavourite = DefaultSettings.settingIsFavourite, this.sortBy = SortBy.sortName, this.sortOrder = SortOrder.ascending, - this.songShuffleItemCount = _songShuffleItemCountDefault, - this.volumeNormalizationActive = _volumeNormalizationActiveDefault, + this.songShuffleItemCount = DefaultSettings.songShuffleItemCount, + this.volumeNormalizationActive = DefaultSettings.volumeNormalizationActive, this.volumeNormalizationIOSBaseGain = - _volumeNormalizationIOSBaseGainDefault, - this.volumeNormalizationMode = _volumeNormalizationModeDefault, - this.contentViewType = _contentViewType, - this.playbackSpeedVisibility = _playbackSpeedVisibility, + DefaultSettings.volumeNormalizationIOSBaseGain, + this.volumeNormalizationMode = DefaultSettings.volumeNormalizationMode, + this.contentViewType = DefaultSettings.contentViewType, + this.playbackSpeedVisibility = DefaultSettings.playbackSpeedVisibility, this.contentGridViewCrossAxisCountPortrait = - _contentGridViewCrossAxisCountPortrait, + DefaultSettings.contentGridViewCrossAxisCountPortrait, this.contentGridViewCrossAxisCountLandscape = - _contentGridViewCrossAxisCountLandscape, - this.showTextOnGridView = _showTextOnGridView, - this.sleepTimerSeconds = _sleepTimerSeconds, + DefaultSettings.contentGridViewCrossAxisCountLandscape, + this.showTextOnGridView = DefaultSettings.showTextOnGridView, + this.sleepTimerSeconds = DefaultSettings.sleepTimerSeconds, required this.downloadLocationsMap, - this.useCoverAsBackground = _useCoverAsBackground, - this.playerScreenCoverMinimumPadding = _playerScreenCoverMinimumPadding, - this.showArtistsTopSongs = _showArtistsTopSongs, - this.bufferDurationSeconds = _bufferDurationSeconds, + this.useCoverAsBackground = DefaultSettings.useCoverAsBackground, + this.playerScreenCoverMinimumPadding = DefaultSettings.playerScreenCoverMinimumPadding, + this.showArtistsTopSongs = DefaultSettings.showArtistsTopSongs, + this.bufferDurationSeconds = DefaultSettings.bufferDurationSeconds, required this.tabSortBy, required this.tabSortOrder, - this.loopMode = _defaultLoopMode, - this.playbackSpeed = _defaultPlaybackSpeed, - this.tabOrder = _tabOrder, - this.autoloadLastQueueOnStartup = _autoLoadLastQueueOnStartup, + this.loopMode = DefaultSettings.loopMode, + this.playbackSpeed = DefaultSettings.playbackSpeed, + this.tabOrder = DefaultSettings.tabOrder, + this.autoloadLastQueueOnStartup = DefaultSettings.autoLoadLastQueueOnStartup, this.hasCompletedBlurhashImageMigration = true, this.hasCompletedBlurhashImageMigrationIdFix = true, this.hasCompletedDownloadsServiceMigration = true, - this.requireWifiForDownloads = false, + this.requireWifiForDownloads = DefaultSettings.requireWifiForDownloads, this.onlyShowFullyDownloaded = false, - this.showDownloadsWithUnknownLibrary = true, - this.maxConcurrentDownloads = 10, - this.downloadWorkers = 5, - this.resyncOnStartup = _defaultResyncOnStartup, - this.preferQuickSyncs = true, + this.showDownloadsWithUnknownLibrary = DefaultSettings.showDownloadsWithUnknownLibrary, + this.maxConcurrentDownloads = DefaultSettings.maxConcurrentDownloads, + this.downloadWorkers = DefaultSettings.downloadWorkers, + this.resyncOnStartup = DefaultSettings.resyncOnStartup, + this.preferQuickSyncs = DefaultSettings.preferQuickSyncs, this.hasCompletedIsarUserMigration = true, this.downloadTranscodingCodec, this.downloadTranscodeBitrate, - this.shouldTranscodeDownloads = _shouldTranscodeDownloadsDefault, - this.shouldRedownloadTranscodes = _shouldRedownloadTranscodesDefault, - this.swipeInsertQueueNext = _swipeInsertQueueNext, - this.useFixedSizeGridTiles = false, - this.fixedGridTileSize = _fixedGridTileSizeDefault, - this.allowSplitScreen = true, - this.splitScreenPlayerWidth = _defaultSplitScreenPlayerWidth, - this.enableVibration = _enableVibration, - this.prioritizeCoverFactor = _prioritizeCoverFactor, - this.suppressPlayerPadding = _suppressPlayerPadding, - this.hidePlayerBottomActions = _hidePlayerBottomActions, - this.reportQueueToServer = _reportQueueToServerDefault, + this.shouldTranscodeDownloads = DefaultSettings.shouldTranscodeDownloads, + this.shouldRedownloadTranscodes = DefaultSettings.shouldRedownloadTranscodes, + this.swipeInsertQueueNext = DefaultSettings.swipeInsertQueueNext, + this.useFixedSizeGridTiles = DefaultSettings.useFixedSizeGridTiles, + this.fixedGridTileSize = DefaultSettings.fixedGridTileSize, + this.allowSplitScreen = DefaultSettings.allowSplitScreen, + this.splitScreenPlayerWidth = DefaultSettings.splitScreenPlayerWidth, + this.enableVibration = DefaultSettings.enableVibration, + this.prioritizeCoverFactor = DefaultSettings.prioritizeCoverFactor, + this.suppressPlayerPadding = DefaultSettings.suppressPlayerPadding, + this.hidePlayerBottomActions = DefaultSettings.hidePlayerBottomActions, + this.reportQueueToServer = DefaultSettings.reportQueueToServer, this.periodicPlaybackSessionUpdateFrequencySeconds = - _periodicPlaybackSessionUpdateFrequencySecondsDefault, - this.showArtistChipImage = _showArtistChipImage, - this.trackOfflineFavorites = _trackOfflineFavoritesDefault, - this.showProgressOnNowPlayingBar = _showProgressOnNowPlayingBarDefault, + DefaultSettings.periodicPlaybackSessionUpdateFrequencySeconds, + this.showArtistChipImage = DefaultSettings.showArtistChipImage, + this.trackOfflineFavorites = DefaultSettings.trackOfflineFavorites, + this.showProgressOnNowPlayingBar = DefaultSettings.showProgressOnNowPlayingBar, this.startInstantMixForIndividualTracks = - _startInstantMixForIndividualTracksDefault, - this.showLyricsTimestamps = _showLyricsTimestampsDefault, - this.lyricsAlignment = _lyricsAlignmentDefault, - this.lyricsFontSize = _lyricsFontSizeDefault, - this.showLyricsScreenAlbumPrelude = _showLyricsScreenAlbumPreludeDefault, + DefaultSettings.startInstantMixForIndividualTracks, + this.showLyricsTimestamps = DefaultSettings.showLyricsTimestamps, + this.lyricsAlignment = DefaultSettings.lyricsAlignment, + this.lyricsFontSize = DefaultSettings.lyricsFontSize, + this.showLyricsScreenAlbumPrelude = DefaultSettings.showLyricsScreenAlbumPrelude, this.showStopButtonOnMediaNotification = - _showStopButtonOnMediaNotificationDefault, + DefaultSettings.showStopButtonOnMediaNotification, this.showSeekControlsOnMediaNotification = - _showSeekControlsOnMediaNotificationDefault, - this.keepScreenOnOption = _keepScreenOnOption, - this.keepScreenOnWhilePluggedIn = _keepScreenOnWhilePluggedIn, - this.featureChipsConfiguration = _featureChipsConfigurationDefault, - this.showCoversOnAlbumScreen = _showCoversOnAlbumScreenDefault, - this.hasDownloadedPlaylistInfo = _hasDownloadedPlaylistInfoDefault, - this.transcodingSegmentContainer = _defaultTranscodingSegmentContainer}); - - @HiveField(0, defaultValue: _isOfflineDefault) + DefaultSettings.showSeekControlsOnMediaNotification, + this.keepScreenOnOption = DefaultSettings.keepScreenOnOption, + this.keepScreenOnWhilePluggedIn = DefaultSettings.keepScreenOnWhilePluggedIn, + this.featureChipsConfiguration = DefaultSettings.featureChipsConfiguration, + this.showCoversOnAlbumScreen = DefaultSettings.showCoversOnAlbumScreen, + this.hasDownloadedPlaylistInfo = DefaultSettings.hasDownloadedPlaylistInfo, + this.transcodingSegmentContainer = DefaultSettings.transcodingSegmentContainer}); + + @HiveField(0, defaultValue: DefaultSettings.isOffline) bool isOffline; - @HiveField(1, defaultValue: _shouldTranscodeDefault) + @HiveField(1, defaultValue: DefaultSettings.shouldTranscode) bool shouldTranscode; - @HiveField(2, defaultValue: _transcodeBitrateDefault) + @HiveField(2, defaultValue: DefaultSettings.transcodeBitrate) int transcodeBitrate; @Deprecated("Use downloadedLocationsMap instead") @HiveField(3) List downloadLocations; - @HiveField(4, defaultValue: _androidStopForegroundOnPauseDefault) + @HiveField(4, defaultValue: DefaultSettings.settingAndroidStopForegroundOnPause) bool androidStopForegroundOnPause; @HiveField(5) Map showTabs; /// Used to remember if the user has set their music screen to favourites /// mode. - @HiveField(6, defaultValue: _isFavouriteDefault) + @HiveField(6, defaultValue: DefaultSettings.settingIsFavourite) bool onlyShowFavourite; /// Current sort by setting. @@ -247,44 +257,44 @@ class FinampSettings { SortOrder sortOrder; /// Amount of songs to get when shuffling songs. - @HiveField(9, defaultValue: _songShuffleItemCountDefault) + @HiveField(9, defaultValue: DefaultSettings.songShuffleItemCount) int songShuffleItemCount; /// The content view type used by the music screen. - @HiveField(10, defaultValue: _contentViewType) + @HiveField(10, defaultValue: DefaultSettings.contentViewType) ContentViewType contentViewType; /// Amount of grid tiles to use per-row when portrait. - @HiveField(11, defaultValue: _contentGridViewCrossAxisCountPortrait) + @HiveField(11, defaultValue: DefaultSettings.contentGridViewCrossAxisCountPortrait) int contentGridViewCrossAxisCountPortrait; /// Amount of grid tiles to use per-row when landscape. - @HiveField(12, defaultValue: _contentGridViewCrossAxisCountLandscape) + @HiveField(12, defaultValue: DefaultSettings.contentGridViewCrossAxisCountLandscape) int contentGridViewCrossAxisCountLandscape; /// Whether or not to show the text (title, artist etc) on the grid music /// screen. - @HiveField(13, defaultValue: _showTextOnGridView) - bool showTextOnGridView = _showTextOnGridView; + @HiveField(13, defaultValue: DefaultSettings.showTextOnGridView) + bool showTextOnGridView = DefaultSettings.showTextOnGridView; /// The number of seconds to wait in a sleep timer. This is so that the app /// can remember the last duration. I'd use a Duration type here but Hive /// doesn't come with an adapter for it by default. - @HiveField(14, defaultValue: _sleepTimerSeconds) + @HiveField(14, defaultValue: DefaultSettings.sleepTimerSeconds) int sleepTimerSeconds; @HiveField(15, defaultValue: {}) Map downloadLocationsMap; /// Whether or not to use blurred cover art as background on player screen. - @HiveField(16, defaultValue: _useCoverAsBackground) - bool useCoverAsBackground = _useCoverAsBackground; + @HiveField(16, defaultValue: DefaultSettings.useCoverAsBackground) + bool useCoverAsBackground = DefaultSettings.useCoverAsBackground; - @HiveField(18, defaultValue: _bufferDurationSeconds) + @HiveField(18, defaultValue: DefaultSettings.bufferDurationSeconds) int bufferDurationSeconds; - @HiveField(19, defaultValue: _disableGesture) - bool disableGesture = _disableGesture; + @HiveField(19, defaultValue: DefaultSettings.disableGesture) + bool disableGesture = DefaultSettings.disableGesture; @HiveField(20, defaultValue: {}) Map tabSortBy; @@ -292,7 +302,7 @@ class FinampSettings { @HiveField(21, defaultValue: {}) Map tabSortOrder; - @HiveField(22, defaultValue: _tabOrder) + @HiveField(22, defaultValue: DefaultSettings.tabOrder) List tabOrder; @HiveField(23, defaultValue: false) @@ -301,25 +311,25 @@ class FinampSettings { @HiveField(24, defaultValue: false) bool hasCompletedBlurhashImageMigrationIdFix; - @HiveField(25, defaultValue: _showFastScroller) - bool showFastScroller = _showFastScroller; + @HiveField(25, defaultValue: DefaultSettings.showFastScroller) + bool showFastScroller = DefaultSettings.showFastScroller; - @HiveField(26, defaultValue: _swipeInsertQueueNext) + @HiveField(26, defaultValue: DefaultSettings.swipeInsertQueueNext) bool swipeInsertQueueNext; - @HiveField(27, defaultValue: _defaultLoopMode) + @HiveField(27, defaultValue: DefaultSettings.loopMode) FinampLoopMode loopMode; - @HiveField(28, defaultValue: _autoLoadLastQueueOnStartup) + @HiveField(28, defaultValue: DefaultSettings.autoLoadLastQueueOnStartup) bool autoloadLastQueueOnStartup; - @HiveField(29, defaultValue: _volumeNormalizationActiveDefault) + @HiveField(29, defaultValue: DefaultSettings.volumeNormalizationActive) bool volumeNormalizationActive; - @HiveField(30, defaultValue: _volumeNormalizationIOSBaseGainDefault) + @HiveField(30, defaultValue: DefaultSettings.volumeNormalizationIOSBaseGain) double volumeNormalizationIOSBaseGain; - @HiveField(33, defaultValue: _volumeNormalizationModeDefault) + @HiveField(33, defaultValue: DefaultSettings.volumeNormalizationMode) VolumeNormalizationMode volumeNormalizationMode; @HiveField(34, defaultValue: false) @@ -340,7 +350,7 @@ class FinampSettings { @HiveField(39, defaultValue: 5) int downloadWorkers; - @HiveField(40, defaultValue: _defaultResyncOnStartup) + @HiveField(40, defaultValue: DefaultSettings.resyncOnStartup) bool resyncOnStartup; @HiveField(41, defaultValue: true) @@ -352,50 +362,50 @@ class FinampSettings { @HiveField(43) FinampTranscodingCodec? downloadTranscodingCodec; - @HiveField(44, defaultValue: _shouldTranscodeDownloadsDefault) + @HiveField(44, defaultValue: DefaultSettings.shouldTranscodeDownloads) TranscodeDownloadsSetting shouldTranscodeDownloads; @HiveField(45) int? downloadTranscodeBitrate; - @HiveField(46, defaultValue: _shouldRedownloadTranscodesDefault) + @HiveField(46, defaultValue: DefaultSettings.shouldRedownloadTranscodes) bool shouldRedownloadTranscodes; - @HiveField(47, defaultValue: _enableVibration) + @HiveField(47, defaultValue: DefaultSettings.enableVibration) bool enableVibration; - @HiveField(48, defaultValue: _playerScreenCoverMinimumPadding) - double playerScreenCoverMinimumPadding = _playerScreenCoverMinimumPadding; + @HiveField(48, defaultValue: DefaultSettings.playerScreenCoverMinimumPadding) + double playerScreenCoverMinimumPadding = DefaultSettings.playerScreenCoverMinimumPadding; - @HiveField(49, defaultValue: _prioritizeCoverFactor) + @HiveField(49, defaultValue: DefaultSettings.prioritizeCoverFactor) double prioritizeCoverFactor; - @HiveField(50, defaultValue: _suppressPlayerPadding) + @HiveField(50, defaultValue: DefaultSettings.suppressPlayerPadding) bool suppressPlayerPadding; - @HiveField(51, defaultValue: _hidePlayerBottomActions) + @HiveField(51, defaultValue: DefaultSettings.hidePlayerBottomActions) bool hidePlayerBottomActions; - @HiveField(52, defaultValue: _reportQueueToServerDefault) + @HiveField(52, defaultValue: DefaultSettings.reportQueueToServer) bool reportQueueToServer; @HiveField(53, - defaultValue: _periodicPlaybackSessionUpdateFrequencySecondsDefault) + defaultValue: DefaultSettings.periodicPlaybackSessionUpdateFrequencySeconds) @HiveField(53, - defaultValue: _periodicPlaybackSessionUpdateFrequencySecondsDefault) + defaultValue: DefaultSettings.periodicPlaybackSessionUpdateFrequencySeconds) int periodicPlaybackSessionUpdateFrequencySeconds; - @HiveField(54, defaultValue: _showArtistsTopSongs) - bool showArtistsTopSongs = _showArtistsTopSongs; + @HiveField(54, defaultValue: DefaultSettings.showArtistsTopSongs) + bool showArtistsTopSongs = DefaultSettings.showArtistsTopSongs; - @HiveField(55, defaultValue: _showArtistChipImage) + @HiveField(55, defaultValue: DefaultSettings.showArtistChipImage) bool showArtistChipImage; - @HiveField(56, defaultValue: _defaultPlaybackSpeed) + @HiveField(56, defaultValue: DefaultSettings.playbackSpeed) double playbackSpeed; /// The content playback speed type defining how and whether to display the playback speed controls in the song menu - @HiveField(57, defaultValue: _playbackSpeedVisibility) + @HiveField(57, defaultValue: DefaultSettings.playbackSpeedVisibility) PlaybackSpeedVisibility playbackSpeedVisibility; @HiveField(58, defaultValue: null) @@ -404,58 +414,58 @@ class FinampSettings { @HiveField(59, defaultValue: false) bool useFixedSizeGridTiles; - @HiveField(60, defaultValue: _fixedGridTileSizeDefault) + @HiveField(60, defaultValue: DefaultSettings.fixedGridTileSize) int fixedGridTileSize; @HiveField(61, defaultValue: true) bool allowSplitScreen; - @HiveField(62, defaultValue: _defaultSplitScreenPlayerWidth) + @HiveField(62, defaultValue: DefaultSettings.splitScreenPlayerWidth) double splitScreenPlayerWidth; - @HiveField(63, defaultValue: _trackOfflineFavoritesDefault) + @HiveField(63, defaultValue: DefaultSettings.trackOfflineFavorites) bool trackOfflineFavorites; - @HiveField(64, defaultValue: _showProgressOnNowPlayingBarDefault) + @HiveField(64, defaultValue: DefaultSettings.showProgressOnNowPlayingBar) bool showProgressOnNowPlayingBar; - @HiveField(65, defaultValue: _startInstantMixForIndividualTracksDefault) + @HiveField(65, defaultValue: DefaultSettings.startInstantMixForIndividualTracks) bool startInstantMixForIndividualTracks; - @HiveField(66, defaultValue: _showLyricsTimestampsDefault) + @HiveField(66, defaultValue: DefaultSettings.showLyricsTimestamps) bool showLyricsTimestamps; - @HiveField(67, defaultValue: _lyricsAlignmentDefault) + @HiveField(67, defaultValue: DefaultSettings.lyricsAlignment) LyricsAlignment lyricsAlignment; - @HiveField(68, defaultValue: _showStopButtonOnMediaNotificationDefault) + @HiveField(68, defaultValue: DefaultSettings.showStopButtonOnMediaNotification) bool showStopButtonOnMediaNotification; - @HiveField(69, defaultValue: _showSeekControlsOnMediaNotificationDefault) + @HiveField(69, defaultValue: DefaultSettings.showSeekControlsOnMediaNotification) bool showSeekControlsOnMediaNotification; - @HiveField(70, defaultValue: _lyricsFontSizeDefault) + @HiveField(70, defaultValue: DefaultSettings.lyricsFontSize) LyricsFontSize lyricsFontSize; - @HiveField(71, defaultValue: _showLyricsScreenAlbumPreludeDefault) + @HiveField(71, defaultValue: DefaultSettings.showLyricsScreenAlbumPrelude) bool showLyricsScreenAlbumPrelude; - @HiveField(72, defaultValue: _keepScreenOnOption) + @HiveField(72, defaultValue: DefaultSettings.keepScreenOnOption) KeepScreenOnOption keepScreenOnOption; - @HiveField(73, defaultValue: _keepScreenOnWhilePluggedIn) + @HiveField(73, defaultValue: DefaultSettings.keepScreenOnWhilePluggedIn) bool keepScreenOnWhilePluggedIn; - @HiveField(74, defaultValue: _hasDownloadedPlaylistInfoDefault) + @HiveField(74, defaultValue: DefaultSettings.hasDownloadedPlaylistInfo) bool hasDownloadedPlaylistInfo; - @HiveField(75, defaultValue: _defaultTranscodingSegmentContainer) + @HiveField(75, defaultValue: DefaultSettings.transcodingSegmentContainer) FinampSegmentContainer transcodingSegmentContainer; - @HiveField(76, defaultValue: _featureChipsConfigurationDefault) + @HiveField(76, defaultValue: DefaultSettings.featureChipsConfiguration) FinampFeatureChipsConfiguration featureChipsConfiguration; - @HiveField(77, defaultValue: _showCoversOnAlbumScreenDefault) + @HiveField(77, defaultValue: DefaultSettings.showCoversOnAlbumScreen) bool showCoversOnAlbumScreen; static Future create() async { diff --git a/lib/services/finamp_settings_helper.dart b/lib/services/finamp_settings_helper.dart index d51ea4424..926823828 100644 --- a/lib/services/finamp_settings_helper.dart +++ b/lib/services/finamp_settings_helper.dart @@ -328,11 +328,11 @@ class FinampSettingsHelper { static void resetCustomizationSettings() { FinampSettings finampSettingsTemp = finampSettings; - //TODO refactor this so default settings are available here - finampSettingsTemp.playbackSpeedVisibility = - PlaybackSpeedVisibility.automatic; - finampSettingsTemp.showStopButtonOnMediaNotification = false; - finampSettingsTemp.showSeekControlsOnMediaNotification = true; + + finampSettingsTemp.playbackSpeedVisibility = DefaultSettings.playbackSpeedVisibility; + finampSettingsTemp.showStopButtonOnMediaNotification = DefaultSettings.showStopButtonOnMediaNotification; + finampSettingsTemp.showSeekControlsOnMediaNotification = DefaultSettings.showSeekControlsOnMediaNotification; + Hive.box("FinampSettings") .put("FinampSettings", finampSettingsTemp); } @@ -340,12 +340,11 @@ class FinampSettingsHelper { static void resetPlayerScreenSettings() { FinampSettings finampSettingsTemp = finampSettings; - finampSettingsTemp.featureChipsConfiguration = - finampSettingsTemp.featureChipsConfiguration.copyWith(enabled: true); - finampSettingsTemp.playerScreenCoverMinimumPadding = 1.5; - finampSettingsTemp.suppressPlayerPadding = false; - finampSettingsTemp.prioritizeCoverFactor = 8.0; - finampSettingsTemp.hidePlayerBottomActions = false; + finampSettingsTemp.featureChipsConfiguration = DefaultSettings.featureChipsConfiguration; + finampSettingsTemp.playerScreenCoverMinimumPadding = DefaultSettings.playerScreenCoverMinimumPadding; + finampSettingsTemp.suppressPlayerPadding = DefaultSettings.suppressPlayerPadding; + finampSettingsTemp.prioritizeCoverFactor = DefaultSettings.prioritizeCoverFactor; + finampSettingsTemp.hidePlayerBottomActions = DefaultSettings.hidePlayerBottomActions; Hive.box("FinampSettings") .put("FinampSettings", finampSettingsTemp); @@ -354,10 +353,10 @@ class FinampSettingsHelper { static void resetLyricsSettings() { FinampSettings finampSettingsTemp = finampSettings; - finampSettingsTemp.showLyricsTimestamps = true; - finampSettingsTemp.showLyricsScreenAlbumPrelude = true; - finampSettingsTemp.lyricsAlignment = LyricsAlignment.start; - finampSettingsTemp.lyricsFontSize = LyricsFontSize.medium; + finampSettingsTemp.showLyricsTimestamps = DefaultSettings.showLyricsTimestamps; + finampSettingsTemp.showLyricsScreenAlbumPrelude = DefaultSettings.showLyricsScreenAlbumPrelude; + finampSettingsTemp.lyricsAlignment = DefaultSettings.lyricsAlignment; + finampSettingsTemp.lyricsFontSize = DefaultSettings.lyricsFontSize; Hive.box("FinampSettings") .put("FinampSettings", finampSettingsTemp); @@ -366,7 +365,7 @@ class FinampSettingsHelper { static void resetAlbumSettings() { FinampSettings finampSettingsTemp = finampSettings; - finampSettingsTemp.showCoversOnAlbumScreen = false; + finampSettingsTemp.showCoversOnAlbumScreen = DefaultSettings.showCoversOnAlbumScreen; Hive.box("FinampSettings") .put("FinampSettings", finampSettingsTemp); @@ -375,18 +374,18 @@ class FinampSettingsHelper { static void resetLayoutSettings() { FinampSettings finampSettingsTemp = finampSettings; - ThemeModeHelper.setThemeMode(ThemeMode.system); - setContentViewType(ContentViewType.list); - finampSettingsTemp.useFixedSizeGridTiles = true; - setContentGridViewCrossAxisCountPortrait(2); - setContentGridViewCrossAxisCountLandscape(3); - finampSettingsTemp.fixedGridTileSize = FixedGridTileSize.medium.toInt; - finampSettingsTemp.showTextOnGridView = true; - setUseCoverAsBackground(true); - finampSettingsTemp.showArtistChipImage = true; - finampSettingsTemp.showArtistsTopSongs = true; - finampSettingsTemp.allowSplitScreen = true; - finampSettingsTemp.showProgressOnNowPlayingBar = true; + ThemeModeHelper.setThemeMode(DefaultSettings.theme); + setContentViewType(DefaultSettings.contentViewType); + finampSettingsTemp.useFixedSizeGridTiles = DefaultSettings.useFixedSizeGridTiles; + setContentGridViewCrossAxisCountPortrait(DefaultSettings.contentGridViewCrossAxisCountPortrait); + setContentGridViewCrossAxisCountLandscape(DefaultSettings.contentGridViewCrossAxisCountLandscape); + finampSettingsTemp.fixedGridTileSize = DefaultSettings.fixedGridTileSize; + finampSettingsTemp.showTextOnGridView = DefaultSettings.showTextOnGridView; + setUseCoverAsBackground(DefaultSettings.useCoverAsBackground); + finampSettingsTemp.showArtistChipImage = DefaultSettings.showArtistChipImage; + finampSettingsTemp.showArtistsTopSongs = DefaultSettings.showArtistsTopSongs; + finampSettingsTemp.allowSplitScreen = DefaultSettings.allowSplitScreen; + finampSettingsTemp.showProgressOnNowPlayingBar = DefaultSettings.showProgressOnNowPlayingBar; Hive.box("FinampSettings") .put("FinampSettings", finampSettingsTemp); @@ -395,13 +394,12 @@ class FinampSettingsHelper { static void resetTranscodingSettings() { FinampSettings finampSettingsTemp = finampSettings; - finampSettingsTemp.shouldTranscode = false; - setTranscodeBitrate(320000); - finampSettingsTemp.transcodingSegmentContainer = - FinampSegmentContainer.fragmentedMp4; - finampSettingsTemp.shouldTranscodeDownloads = TranscodeDownloadsSetting.ask; - finampSettingsTemp.downloadTranscodingCodec = FinampTranscodingCodec.opus; - finampSettingsTemp.downloadTranscodeBitrate = 128000; + finampSettingsTemp.shouldTranscode = DefaultSettings.shouldTranscode; + setTranscodeBitrate(DefaultSettings.transcodeBitrate); + finampSettingsTemp.transcodingSegmentContainer = DefaultSettings.transcodingSegmentContainer; + finampSettingsTemp.shouldTranscodeDownloads = DefaultSettings.shouldTranscodeDownloads; + finampSettingsTemp.downloadTranscodingCodec = FinampTranscodingCodec.opus; // starts uninitilized, idk what value this should be + finampSettingsTemp.downloadTranscodeBitrate = 128000; // starts uninitilized, idk what value this should be Hive.box("FinampSettings") .put("FinampSettings", finampSettingsTemp); @@ -410,34 +408,34 @@ class FinampSettingsHelper { static void resetDownloadSettings() { FinampSettings finampSettingsTemp = finampSettings; - finampSettingsTemp.requireWifiForDownloads = false; - finampSettingsTemp.trackOfflineFavorites = true; - finampSettingsTemp.resyncOnStartup = true; - finampSettingsTemp.preferQuickSyncs = true; - finampSettingsTemp.shouldRedownloadTranscodes = false; - finampSettingsTemp.showDownloadsWithUnknownLibrary = true; - finampSettingsTemp.downloadWorkers = 5; - finampSettingsTemp.maxConcurrentDownloads = 10; + finampSettingsTemp.requireWifiForDownloads = DefaultSettings.requireWifiForDownloads; + finampSettingsTemp.trackOfflineFavorites = DefaultSettings.trackOfflineFavorites; + finampSettingsTemp.resyncOnStartup = DefaultSettings.resyncOnStartup; + finampSettingsTemp.preferQuickSyncs = DefaultSettings.preferQuickSyncs; + finampSettingsTemp.shouldRedownloadTranscodes = DefaultSettings.shouldRedownloadTranscodes; + finampSettingsTemp.showDownloadsWithUnknownLibrary = DefaultSettings.showDownloadsWithUnknownLibrary; + finampSettingsTemp.downloadWorkers = DefaultSettings.downloadWorkers; + finampSettingsTemp.maxConcurrentDownloads = DefaultSettings.maxConcurrentDownloads; Hive.box("FinampSettings") .put("FinampSettings", finampSettingsTemp); } static void resetAudioServiceSettings() { - setAndroidStopForegroundOnPause(true); - setSongShuffleItemCount(250); // DOES NOT update UI - setBufferDuration(Duration(seconds: 600)); // DOES NOT update UI - setAutoloadLastQueueOnStartup(true); - setPeriodicPlaybackSessionUpdateFrequencySeconds(150); // DOES NOT update UI - setReportQueueToServer(false); + setAndroidStopForegroundOnPause(DefaultSettings.settingAndroidStopForegroundOnPause); + setSongShuffleItemCount(DefaultSettings.songShuffleItemCount); // DOES NOT update UI + setBufferDuration(Duration(seconds: DefaultSettings.bufferDurationSeconds)); // DOES NOT update UI + setAutoloadLastQueueOnStartup(DefaultSettings.autoLoadLastQueueOnStartup); + setPeriodicPlaybackSessionUpdateFrequencySeconds(DefaultSettings.periodicPlaybackSessionUpdateFrequencySeconds); // DOES NOT update UI + setReportQueueToServer(DefaultSettings.reportQueueToServer); } static void resetNormalizationSettings() { FinampSettings finampSettingsTemp = finampSettings; - finampSettingsTemp.volumeNormalizationActive = true; - setVolumeNormalizationIOSBaseGain(-2.0); // DOES NOT update UI - finampSettingsTemp.volumeNormalizationMode = VolumeNormalizationMode.hybrid; + finampSettingsTemp.volumeNormalizationActive = DefaultSettings.volumeNormalizationActive; + setVolumeNormalizationIOSBaseGain(DefaultSettings.volumeNormalizationIOSBaseGain); // DOES NOT update UI + finampSettingsTemp.volumeNormalizationMode = DefaultSettings.volumeNormalizationMode; Hive.box("FinampSettings") .put("FinampSettings", finampSettingsTemp); @@ -446,13 +444,13 @@ class FinampSettingsHelper { static void resetInteractionsSettings() { FinampSettings finampSettingsTemp = finampSettings; - setSwipeInsertQueueNext(true); - finampSettingsTemp.startInstantMixForIndividualTracks = true; - setShowFastScroller(true); - setDisableGesture(false); - setEnableVibration(true); - setKeepScreenOnOption(KeepScreenOnOption.whileLyrics); - setKeepScreenOnWhileCharging(true); + setSwipeInsertQueueNext(DefaultSettings.swipeInsertQueueNext); + finampSettingsTemp.startInstantMixForIndividualTracks = DefaultSettings.startInstantMixForIndividualTracks; + setShowFastScroller(DefaultSettings.showFastScroller); + setDisableGesture(DefaultSettings.disableGesture); + setEnableVibration(DefaultSettings.enableVibration); + setKeepScreenOnOption(DefaultSettings.keepScreenOnOption); + setKeepScreenOnWhilePluggedIn(DefaultSettings.keepScreenOnWhilePluggedIn); Hive.box("FinampSettings") .put("FinampSettings", finampSettingsTemp); @@ -512,9 +510,9 @@ class FinampSettingsHelper { .put("FinampSettings", finampSettingsTemp); } - static void setKeepScreenOnWhileCharging(bool keepScreenOnWhileCharging) { + static void setKeepScreenOnWhilePluggedIn(bool keepScreenOnWhilePluggedIn) { FinampSettings finampSettingsTemp = finampSettings; - finampSettingsTemp.keepScreenOnWhilePluggedIn = keepScreenOnWhileCharging; + finampSettingsTemp.keepScreenOnWhilePluggedIn = keepScreenOnWhilePluggedIn; Hive.box("FinampSettings") .put("FinampSettings", finampSettingsTemp); } From 60fc4fa7f4cde1ec4c02af2c50d62bbf72c3ca3c Mon Sep 17 00:00:00 2001 From: flloschy Date: Mon, 30 Dec 2024 18:43:53 +0100 Subject: [PATCH 08/10] Format --- lib/models/finamp_models.dart | 63 +++++++++----- lib/services/finamp_settings_helper.dart | 105 +++++++++++++++-------- 2 files changed, 112 insertions(+), 56 deletions(-) diff --git a/lib/models/finamp_models.dart b/lib/models/finamp_models.dart index fe656404d..8c71d9409 100644 --- a/lib/models/finamp_models.dart +++ b/lib/models/finamp_models.dart @@ -149,13 +149,15 @@ class FinampSettings { // default values. create() is used to return a FinampSettings with // downloadLocations. required this.downloadLocations, - this.androidStopForegroundOnPause = DefaultSettings.settingAndroidStopForegroundOnPause, + this.androidStopForegroundOnPause = + DefaultSettings.settingAndroidStopForegroundOnPause, required this.showTabs, this.onlyShowFavourite = DefaultSettings.settingIsFavourite, this.sortBy = SortBy.sortName, this.sortOrder = SortOrder.ascending, this.songShuffleItemCount = DefaultSettings.songShuffleItemCount, - this.volumeNormalizationActive = DefaultSettings.volumeNormalizationActive, + this.volumeNormalizationActive = + DefaultSettings.volumeNormalizationActive, this.volumeNormalizationIOSBaseGain = DefaultSettings.volumeNormalizationIOSBaseGain, this.volumeNormalizationMode = DefaultSettings.volumeNormalizationMode, @@ -169,7 +171,8 @@ class FinampSettings { this.sleepTimerSeconds = DefaultSettings.sleepTimerSeconds, required this.downloadLocationsMap, this.useCoverAsBackground = DefaultSettings.useCoverAsBackground, - this.playerScreenCoverMinimumPadding = DefaultSettings.playerScreenCoverMinimumPadding, + this.playerScreenCoverMinimumPadding = + DefaultSettings.playerScreenCoverMinimumPadding, this.showArtistsTopSongs = DefaultSettings.showArtistsTopSongs, this.bufferDurationSeconds = DefaultSettings.bufferDurationSeconds, required this.tabSortBy, @@ -177,13 +180,15 @@ class FinampSettings { this.loopMode = DefaultSettings.loopMode, this.playbackSpeed = DefaultSettings.playbackSpeed, this.tabOrder = DefaultSettings.tabOrder, - this.autoloadLastQueueOnStartup = DefaultSettings.autoLoadLastQueueOnStartup, + this.autoloadLastQueueOnStartup = + DefaultSettings.autoLoadLastQueueOnStartup, this.hasCompletedBlurhashImageMigration = true, this.hasCompletedBlurhashImageMigrationIdFix = true, this.hasCompletedDownloadsServiceMigration = true, this.requireWifiForDownloads = DefaultSettings.requireWifiForDownloads, this.onlyShowFullyDownloaded = false, - this.showDownloadsWithUnknownLibrary = DefaultSettings.showDownloadsWithUnknownLibrary, + this.showDownloadsWithUnknownLibrary = + DefaultSettings.showDownloadsWithUnknownLibrary, this.maxConcurrentDownloads = DefaultSettings.maxConcurrentDownloads, this.downloadWorkers = DefaultSettings.downloadWorkers, this.resyncOnStartup = DefaultSettings.resyncOnStartup, @@ -192,7 +197,8 @@ class FinampSettings { this.downloadTranscodingCodec, this.downloadTranscodeBitrate, this.shouldTranscodeDownloads = DefaultSettings.shouldTranscodeDownloads, - this.shouldRedownloadTranscodes = DefaultSettings.shouldRedownloadTranscodes, + this.shouldRedownloadTranscodes = + DefaultSettings.shouldRedownloadTranscodes, this.swipeInsertQueueNext = DefaultSettings.swipeInsertQueueNext, this.useFixedSizeGridTiles = DefaultSettings.useFixedSizeGridTiles, this.fixedGridTileSize = DefaultSettings.fixedGridTileSize, @@ -207,23 +213,29 @@ class FinampSettings { DefaultSettings.periodicPlaybackSessionUpdateFrequencySeconds, this.showArtistChipImage = DefaultSettings.showArtistChipImage, this.trackOfflineFavorites = DefaultSettings.trackOfflineFavorites, - this.showProgressOnNowPlayingBar = DefaultSettings.showProgressOnNowPlayingBar, + this.showProgressOnNowPlayingBar = + DefaultSettings.showProgressOnNowPlayingBar, this.startInstantMixForIndividualTracks = DefaultSettings.startInstantMixForIndividualTracks, this.showLyricsTimestamps = DefaultSettings.showLyricsTimestamps, this.lyricsAlignment = DefaultSettings.lyricsAlignment, this.lyricsFontSize = DefaultSettings.lyricsFontSize, - this.showLyricsScreenAlbumPrelude = DefaultSettings.showLyricsScreenAlbumPrelude, + this.showLyricsScreenAlbumPrelude = + DefaultSettings.showLyricsScreenAlbumPrelude, this.showStopButtonOnMediaNotification = DefaultSettings.showStopButtonOnMediaNotification, this.showSeekControlsOnMediaNotification = DefaultSettings.showSeekControlsOnMediaNotification, this.keepScreenOnOption = DefaultSettings.keepScreenOnOption, - this.keepScreenOnWhilePluggedIn = DefaultSettings.keepScreenOnWhilePluggedIn, - this.featureChipsConfiguration = DefaultSettings.featureChipsConfiguration, + this.keepScreenOnWhilePluggedIn = + DefaultSettings.keepScreenOnWhilePluggedIn, + this.featureChipsConfiguration = + DefaultSettings.featureChipsConfiguration, this.showCoversOnAlbumScreen = DefaultSettings.showCoversOnAlbumScreen, - this.hasDownloadedPlaylistInfo = DefaultSettings.hasDownloadedPlaylistInfo, - this.transcodingSegmentContainer = DefaultSettings.transcodingSegmentContainer}); + this.hasDownloadedPlaylistInfo = + DefaultSettings.hasDownloadedPlaylistInfo, + this.transcodingSegmentContainer = + DefaultSettings.transcodingSegmentContainer}); @HiveField(0, defaultValue: DefaultSettings.isOffline) bool isOffline; @@ -236,7 +248,8 @@ class FinampSettings { @HiveField(3) List downloadLocations; - @HiveField(4, defaultValue: DefaultSettings.settingAndroidStopForegroundOnPause) + @HiveField(4, + defaultValue: DefaultSettings.settingAndroidStopForegroundOnPause) bool androidStopForegroundOnPause; @HiveField(5) Map showTabs; @@ -265,11 +278,13 @@ class FinampSettings { ContentViewType contentViewType; /// Amount of grid tiles to use per-row when portrait. - @HiveField(11, defaultValue: DefaultSettings.contentGridViewCrossAxisCountPortrait) + @HiveField(11, + defaultValue: DefaultSettings.contentGridViewCrossAxisCountPortrait) int contentGridViewCrossAxisCountPortrait; /// Amount of grid tiles to use per-row when landscape. - @HiveField(12, defaultValue: DefaultSettings.contentGridViewCrossAxisCountLandscape) + @HiveField(12, + defaultValue: DefaultSettings.contentGridViewCrossAxisCountLandscape) int contentGridViewCrossAxisCountLandscape; /// Whether or not to show the text (title, artist etc) on the grid music @@ -375,7 +390,8 @@ class FinampSettings { bool enableVibration; @HiveField(48, defaultValue: DefaultSettings.playerScreenCoverMinimumPadding) - double playerScreenCoverMinimumPadding = DefaultSettings.playerScreenCoverMinimumPadding; + double playerScreenCoverMinimumPadding = + DefaultSettings.playerScreenCoverMinimumPadding; @HiveField(49, defaultValue: DefaultSettings.prioritizeCoverFactor) double prioritizeCoverFactor; @@ -390,9 +406,11 @@ class FinampSettings { bool reportQueueToServer; @HiveField(53, - defaultValue: DefaultSettings.periodicPlaybackSessionUpdateFrequencySeconds) + defaultValue: + DefaultSettings.periodicPlaybackSessionUpdateFrequencySeconds) @HiveField(53, - defaultValue: DefaultSettings.periodicPlaybackSessionUpdateFrequencySeconds) + defaultValue: + DefaultSettings.periodicPlaybackSessionUpdateFrequencySeconds) int periodicPlaybackSessionUpdateFrequencySeconds; @HiveField(54, defaultValue: DefaultSettings.showArtistsTopSongs) @@ -429,7 +447,8 @@ class FinampSettings { @HiveField(64, defaultValue: DefaultSettings.showProgressOnNowPlayingBar) bool showProgressOnNowPlayingBar; - @HiveField(65, defaultValue: DefaultSettings.startInstantMixForIndividualTracks) + @HiveField(65, + defaultValue: DefaultSettings.startInstantMixForIndividualTracks) bool startInstantMixForIndividualTracks; @HiveField(66, defaultValue: DefaultSettings.showLyricsTimestamps) @@ -438,10 +457,12 @@ class FinampSettings { @HiveField(67, defaultValue: DefaultSettings.lyricsAlignment) LyricsAlignment lyricsAlignment; - @HiveField(68, defaultValue: DefaultSettings.showStopButtonOnMediaNotification) + @HiveField(68, + defaultValue: DefaultSettings.showStopButtonOnMediaNotification) bool showStopButtonOnMediaNotification; - @HiveField(69, defaultValue: DefaultSettings.showSeekControlsOnMediaNotification) + @HiveField(69, + defaultValue: DefaultSettings.showSeekControlsOnMediaNotification) bool showSeekControlsOnMediaNotification; @HiveField(70, defaultValue: DefaultSettings.lyricsFontSize) diff --git a/lib/services/finamp_settings_helper.dart b/lib/services/finamp_settings_helper.dart index 926823828..f556639bf 100644 --- a/lib/services/finamp_settings_helper.dart +++ b/lib/services/finamp_settings_helper.dart @@ -329,9 +329,12 @@ class FinampSettingsHelper { static void resetCustomizationSettings() { FinampSettings finampSettingsTemp = finampSettings; - finampSettingsTemp.playbackSpeedVisibility = DefaultSettings.playbackSpeedVisibility; - finampSettingsTemp.showStopButtonOnMediaNotification = DefaultSettings.showStopButtonOnMediaNotification; - finampSettingsTemp.showSeekControlsOnMediaNotification = DefaultSettings.showSeekControlsOnMediaNotification; + finampSettingsTemp.playbackSpeedVisibility = + DefaultSettings.playbackSpeedVisibility; + finampSettingsTemp.showStopButtonOnMediaNotification = + DefaultSettings.showStopButtonOnMediaNotification; + finampSettingsTemp.showSeekControlsOnMediaNotification = + DefaultSettings.showSeekControlsOnMediaNotification; Hive.box("FinampSettings") .put("FinampSettings", finampSettingsTemp); @@ -340,11 +343,16 @@ class FinampSettingsHelper { static void resetPlayerScreenSettings() { FinampSettings finampSettingsTemp = finampSettings; - finampSettingsTemp.featureChipsConfiguration = DefaultSettings.featureChipsConfiguration; - finampSettingsTemp.playerScreenCoverMinimumPadding = DefaultSettings.playerScreenCoverMinimumPadding; - finampSettingsTemp.suppressPlayerPadding = DefaultSettings.suppressPlayerPadding; - finampSettingsTemp.prioritizeCoverFactor = DefaultSettings.prioritizeCoverFactor; - finampSettingsTemp.hidePlayerBottomActions = DefaultSettings.hidePlayerBottomActions; + finampSettingsTemp.featureChipsConfiguration = + DefaultSettings.featureChipsConfiguration; + finampSettingsTemp.playerScreenCoverMinimumPadding = + DefaultSettings.playerScreenCoverMinimumPadding; + finampSettingsTemp.suppressPlayerPadding = + DefaultSettings.suppressPlayerPadding; + finampSettingsTemp.prioritizeCoverFactor = + DefaultSettings.prioritizeCoverFactor; + finampSettingsTemp.hidePlayerBottomActions = + DefaultSettings.hidePlayerBottomActions; Hive.box("FinampSettings") .put("FinampSettings", finampSettingsTemp); @@ -353,8 +361,10 @@ class FinampSettingsHelper { static void resetLyricsSettings() { FinampSettings finampSettingsTemp = finampSettings; - finampSettingsTemp.showLyricsTimestamps = DefaultSettings.showLyricsTimestamps; - finampSettingsTemp.showLyricsScreenAlbumPrelude = DefaultSettings.showLyricsScreenAlbumPrelude; + finampSettingsTemp.showLyricsTimestamps = + DefaultSettings.showLyricsTimestamps; + finampSettingsTemp.showLyricsScreenAlbumPrelude = + DefaultSettings.showLyricsScreenAlbumPrelude; finampSettingsTemp.lyricsAlignment = DefaultSettings.lyricsAlignment; finampSettingsTemp.lyricsFontSize = DefaultSettings.lyricsFontSize; @@ -365,7 +375,8 @@ class FinampSettingsHelper { static void resetAlbumSettings() { FinampSettings finampSettingsTemp = finampSettings; - finampSettingsTemp.showCoversOnAlbumScreen = DefaultSettings.showCoversOnAlbumScreen; + finampSettingsTemp.showCoversOnAlbumScreen = + DefaultSettings.showCoversOnAlbumScreen; Hive.box("FinampSettings") .put("FinampSettings", finampSettingsTemp); @@ -376,16 +387,22 @@ class FinampSettingsHelper { ThemeModeHelper.setThemeMode(DefaultSettings.theme); setContentViewType(DefaultSettings.contentViewType); - finampSettingsTemp.useFixedSizeGridTiles = DefaultSettings.useFixedSizeGridTiles; - setContentGridViewCrossAxisCountPortrait(DefaultSettings.contentGridViewCrossAxisCountPortrait); - setContentGridViewCrossAxisCountLandscape(DefaultSettings.contentGridViewCrossAxisCountLandscape); + finampSettingsTemp.useFixedSizeGridTiles = + DefaultSettings.useFixedSizeGridTiles; + setContentGridViewCrossAxisCountPortrait( + DefaultSettings.contentGridViewCrossAxisCountPortrait); + setContentGridViewCrossAxisCountLandscape( + DefaultSettings.contentGridViewCrossAxisCountLandscape); finampSettingsTemp.fixedGridTileSize = DefaultSettings.fixedGridTileSize; finampSettingsTemp.showTextOnGridView = DefaultSettings.showTextOnGridView; setUseCoverAsBackground(DefaultSettings.useCoverAsBackground); - finampSettingsTemp.showArtistChipImage = DefaultSettings.showArtistChipImage; - finampSettingsTemp.showArtistsTopSongs = DefaultSettings.showArtistsTopSongs; + finampSettingsTemp.showArtistChipImage = + DefaultSettings.showArtistChipImage; + finampSettingsTemp.showArtistsTopSongs = + DefaultSettings.showArtistsTopSongs; finampSettingsTemp.allowSplitScreen = DefaultSettings.allowSplitScreen; - finampSettingsTemp.showProgressOnNowPlayingBar = DefaultSettings.showProgressOnNowPlayingBar; + finampSettingsTemp.showProgressOnNowPlayingBar = + DefaultSettings.showProgressOnNowPlayingBar; Hive.box("FinampSettings") .put("FinampSettings", finampSettingsTemp); @@ -396,10 +413,14 @@ class FinampSettingsHelper { finampSettingsTemp.shouldTranscode = DefaultSettings.shouldTranscode; setTranscodeBitrate(DefaultSettings.transcodeBitrate); - finampSettingsTemp.transcodingSegmentContainer = DefaultSettings.transcodingSegmentContainer; - finampSettingsTemp.shouldTranscodeDownloads = DefaultSettings.shouldTranscodeDownloads; - finampSettingsTemp.downloadTranscodingCodec = FinampTranscodingCodec.opus; // starts uninitilized, idk what value this should be - finampSettingsTemp.downloadTranscodeBitrate = 128000; // starts uninitilized, idk what value this should be + finampSettingsTemp.transcodingSegmentContainer = + DefaultSettings.transcodingSegmentContainer; + finampSettingsTemp.shouldTranscodeDownloads = + DefaultSettings.shouldTranscodeDownloads; + finampSettingsTemp.downloadTranscodingCodec = FinampTranscodingCodec + .opus; // starts uninitilized, idk what value this should be + finampSettingsTemp.downloadTranscodeBitrate = + 128000; // starts uninitilized, idk what value this should be Hive.box("FinampSettings") .put("FinampSettings", finampSettingsTemp); @@ -408,34 +429,46 @@ class FinampSettingsHelper { static void resetDownloadSettings() { FinampSettings finampSettingsTemp = finampSettings; - finampSettingsTemp.requireWifiForDownloads = DefaultSettings.requireWifiForDownloads; - finampSettingsTemp.trackOfflineFavorites = DefaultSettings.trackOfflineFavorites; + finampSettingsTemp.requireWifiForDownloads = + DefaultSettings.requireWifiForDownloads; + finampSettingsTemp.trackOfflineFavorites = + DefaultSettings.trackOfflineFavorites; finampSettingsTemp.resyncOnStartup = DefaultSettings.resyncOnStartup; finampSettingsTemp.preferQuickSyncs = DefaultSettings.preferQuickSyncs; - finampSettingsTemp.shouldRedownloadTranscodes = DefaultSettings.shouldRedownloadTranscodes; - finampSettingsTemp.showDownloadsWithUnknownLibrary = DefaultSettings.showDownloadsWithUnknownLibrary; + finampSettingsTemp.shouldRedownloadTranscodes = + DefaultSettings.shouldRedownloadTranscodes; + finampSettingsTemp.showDownloadsWithUnknownLibrary = + DefaultSettings.showDownloadsWithUnknownLibrary; finampSettingsTemp.downloadWorkers = DefaultSettings.downloadWorkers; - finampSettingsTemp.maxConcurrentDownloads = DefaultSettings.maxConcurrentDownloads; + finampSettingsTemp.maxConcurrentDownloads = + DefaultSettings.maxConcurrentDownloads; Hive.box("FinampSettings") .put("FinampSettings", finampSettingsTemp); } static void resetAudioServiceSettings() { - setAndroidStopForegroundOnPause(DefaultSettings.settingAndroidStopForegroundOnPause); - setSongShuffleItemCount(DefaultSettings.songShuffleItemCount); // DOES NOT update UI - setBufferDuration(Duration(seconds: DefaultSettings.bufferDurationSeconds)); // DOES NOT update UI + setAndroidStopForegroundOnPause( + DefaultSettings.settingAndroidStopForegroundOnPause); + setSongShuffleItemCount( + DefaultSettings.songShuffleItemCount); // DOES NOT update UI + setBufferDuration(Duration( + seconds: DefaultSettings.bufferDurationSeconds)); // DOES NOT update UI setAutoloadLastQueueOnStartup(DefaultSettings.autoLoadLastQueueOnStartup); - setPeriodicPlaybackSessionUpdateFrequencySeconds(DefaultSettings.periodicPlaybackSessionUpdateFrequencySeconds); // DOES NOT update UI + setPeriodicPlaybackSessionUpdateFrequencySeconds(DefaultSettings + .periodicPlaybackSessionUpdateFrequencySeconds); // DOES NOT update UI setReportQueueToServer(DefaultSettings.reportQueueToServer); } static void resetNormalizationSettings() { FinampSettings finampSettingsTemp = finampSettings; - finampSettingsTemp.volumeNormalizationActive = DefaultSettings.volumeNormalizationActive; - setVolumeNormalizationIOSBaseGain(DefaultSettings.volumeNormalizationIOSBaseGain); // DOES NOT update UI - finampSettingsTemp.volumeNormalizationMode = DefaultSettings.volumeNormalizationMode; + finampSettingsTemp.volumeNormalizationActive = + DefaultSettings.volumeNormalizationActive; + setVolumeNormalizationIOSBaseGain( + DefaultSettings.volumeNormalizationIOSBaseGain); // DOES NOT update UI + finampSettingsTemp.volumeNormalizationMode = + DefaultSettings.volumeNormalizationMode; Hive.box("FinampSettings") .put("FinampSettings", finampSettingsTemp); @@ -445,7 +478,8 @@ class FinampSettingsHelper { FinampSettings finampSettingsTemp = finampSettings; setSwipeInsertQueueNext(DefaultSettings.swipeInsertQueueNext); - finampSettingsTemp.startInstantMixForIndividualTracks = DefaultSettings.startInstantMixForIndividualTracks; + finampSettingsTemp.startInstantMixForIndividualTracks = + DefaultSettings.startInstantMixForIndividualTracks; setShowFastScroller(DefaultSettings.showFastScroller); setDisableGesture(DefaultSettings.disableGesture); setEnableVibration(DefaultSettings.enableVibration); @@ -530,7 +564,8 @@ class FinampSettingsHelper { ? AppLocalizations.of(context)!.resetSettingsPromptGlobal : AppLocalizations.of(context)!.resetSettingsPromptLocal, confirmButtonText: isGlobal - ? AppLocalizations.of(context)!.resetSettingsPromptGlobalConfirm + ? AppLocalizations.of(context)! + .resetSettingsPromptGlobalConfirm : AppLocalizations.of(context)!.reset, abortButtonText: AppLocalizations.of(context)!.genericCancel, onConfirmed: resetFunction, From feb8600777de422cd8d5de440e758c0ddef989b3 Mon Sep 17 00:00:00 2001 From: Chaphasilor Date: Sat, 4 Jan 2025 18:50:26 +0100 Subject: [PATCH 09/10] fixup default settings refactoring, run code generation --- .../AlbumScreen/track_list_tile.dart | 2 +- .../MusicScreen/music_screen_tab_view.dart | 14 +++-- lib/components/favourite_button.dart | 2 +- lib/models/finamp_models.dart | 61 +++++++++++-------- lib/models/finamp_models.g.dart | 29 +++------ lib/screens/music_screen.dart | 8 +-- lib/services/android_auto_helper.dart | 2 +- lib/services/audio_service_helper.dart | 8 +-- lib/services/finamp_settings_helper.dart | 6 +- pubspec.lock | 44 ++++++------- 10 files changed, 87 insertions(+), 89 deletions(-) diff --git a/lib/components/AlbumScreen/track_list_tile.dart b/lib/components/AlbumScreen/track_list_tile.dart index 7389532b0..2b678f932 100644 --- a/lib/components/AlbumScreen/track_list_tile.dart +++ b/lib/components/AlbumScreen/track_list_tile.dart @@ -142,7 +142,7 @@ class TrackListTile extends StatelessWidget { viewFilter: finampUserHelper.currentUser?.currentView?.id, nullableViewFilters: settings.showDownloadsWithUnknownLibrary, onlyFavorites: - settings.onlyShowFavourite && settings.trackOfflineFavorites, + settings.onlyShowFavourites && settings.trackOfflineFavorites, ); var items = diff --git a/lib/components/MusicScreen/music_screen_tab_view.dart b/lib/components/MusicScreen/music_screen_tab_view.dart index c7014568f..47170bfd4 100644 --- a/lib/components/MusicScreen/music_screen_tab_view.dart +++ b/lib/components/MusicScreen/music_screen_tab_view.dart @@ -106,7 +106,7 @@ class _MusicScreenTabViewState extends State : "SortName"), sortOrder: sortOrder, searchTerm: widget.searchTerm?.trim(), - filters: settings.onlyShowFavourite ? "IsFavorite" : null, + filters: settings.onlyShowFavourites ? "IsFavorite" : null, startIndex: pageKey, limit: _pageSize, ); @@ -144,7 +144,7 @@ class _MusicScreenTabViewState extends State viewFilter: widget.view?.id, nullableViewFilters: settings.showDownloadsWithUnknownLibrary, onlyFavorites: - settings.onlyShowFavourite && settings.trackOfflineFavorites); + settings.onlyShowFavourites && settings.trackOfflineFavorites); } else { offlineItems = await _isarDownloader.getAllCollections( nameFilter: widget.searchTerm, @@ -160,7 +160,7 @@ class _MusicScreenTabViewState extends State nullableViewFilters: widget.tabContentType == TabContentType.albums && settings.showDownloadsWithUnknownLibrary, onlyFavorites: - settings.onlyShowFavourite && settings.trackOfflineFavorites); + settings.onlyShowFavourites && settings.trackOfflineFavorites); } var items = offlineItems.map((e) => e.baseItem).whereNotNull().toList(); @@ -302,7 +302,7 @@ class _MusicScreenTabViewState extends State var settings = box.get("FinampSettings")!; var newRefreshHash = Object.hash( widget.searchTerm, - settings.onlyShowFavourite, + settings.onlyShowFavourites, settings.tabSortBy[widget.tabContentType], settings.tabSortOrder[widget.tabContentType], settings.onlyShowFullyDownloaded, @@ -343,8 +343,10 @@ class _MusicScreenTabViewState extends State icon: TablerIcons.filter_x, text: AppLocalizations.of(context)!.resetFiltersButton, onPressed: () { - FinampSettingsHelper.setOnlyShowFavourite(false); - FinampSettingsHelper.setOnlyShowFullyDownloaded(false); + FinampSettingsHelper.setonlyShowFavourites( + DefaultSettings.onlyShowFavourites); + FinampSettingsHelper.setOnlyShowFullyDownloaded( + DefaultSettings.onlyShowFullyDownloaded); }, ) ], diff --git a/lib/components/favourite_button.dart b/lib/components/favourite_button.dart index 7b487fb3b..7cb8613fe 100644 --- a/lib/components/favourite_button.dart +++ b/lib/components/favourite_button.dart @@ -39,7 +39,7 @@ class _FavoriteButtonState extends ConsumerState { bool isFav = ref.watch(isFavoriteProvider(FavoriteRequest(widget.item))); if (widget.onlyIfFav) { - if (isFav && !FinampSettingsHelper.finampSettings.onlyShowFavourite) { + if (isFav && !FinampSettingsHelper.finampSettings.onlyShowFavourites) { return Icon( Icons.favorite, color: Colors.red, diff --git a/lib/models/finamp_models.dart b/lib/models/finamp_models.dart index 8c71d9409..fcd78ea02 100644 --- a/lib/models/finamp_models.dart +++ b/lib/models/finamp_models.dart @@ -63,8 +63,8 @@ class DefaultSettings { static const theme = ThemeMode.system; static const shouldTranscode = false; static const transcodeBitrate = 320000; - static const settingAndroidStopForegroundOnPause = true; - static const settingIsFavourite = false; + static const androidStopForegroundOnPause = true; + static const onlyShowFavourites = false; static const songShuffleItemCount = 250; static const volumeNormalizationActive = true; // 80% volume in dB. In my testing, most tracks were louder than the default target @@ -133,6 +133,7 @@ class DefaultSettings { static const showCoversOnAlbumScreen = false; static const allowSplitScreen = true; static const requireWifiForDownloads = false; + static const onlyShowFullyDownloaded = false; static const preferQuickSyncs = true; static const showDownloadsWithUnknownLibrary = true; static const downloadWorkers = 5; @@ -150,9 +151,9 @@ class FinampSettings { // downloadLocations. required this.downloadLocations, this.androidStopForegroundOnPause = - DefaultSettings.settingAndroidStopForegroundOnPause, + DefaultSettings.androidStopForegroundOnPause, required this.showTabs, - this.onlyShowFavourite = DefaultSettings.settingIsFavourite, + this.onlyShowFavourites = DefaultSettings.onlyShowFavourites, this.sortBy = SortBy.sortName, this.sortOrder = SortOrder.ascending, this.songShuffleItemCount = DefaultSettings.songShuffleItemCount, @@ -182,18 +183,22 @@ class FinampSettings { this.tabOrder = DefaultSettings.tabOrder, this.autoloadLastQueueOnStartup = DefaultSettings.autoLoadLastQueueOnStartup, - this.hasCompletedBlurhashImageMigration = true, - this.hasCompletedBlurhashImageMigrationIdFix = true, - this.hasCompletedDownloadsServiceMigration = true, + this.hasCompletedBlurhashImageMigration = + true, //!!! don't touch this default value, it's supposed to be hard coded to run the migration only once + this.hasCompletedBlurhashImageMigrationIdFix = + true, //!!! don't touch this default value, it's supposed to be hard coded to run the migration only once + this.hasCompletedDownloadsServiceMigration = + true, //!!! don't touch this default value, it's supposed to be hard coded to run the migration only once this.requireWifiForDownloads = DefaultSettings.requireWifiForDownloads, - this.onlyShowFullyDownloaded = false, + this.onlyShowFullyDownloaded = DefaultSettings.onlyShowFullyDownloaded, this.showDownloadsWithUnknownLibrary = DefaultSettings.showDownloadsWithUnknownLibrary, this.maxConcurrentDownloads = DefaultSettings.maxConcurrentDownloads, this.downloadWorkers = DefaultSettings.downloadWorkers, this.resyncOnStartup = DefaultSettings.resyncOnStartup, this.preferQuickSyncs = DefaultSettings.preferQuickSyncs, - this.hasCompletedIsarUserMigration = true, + this.hasCompletedIsarUserMigration = + true, //!!! don't touch this default value, it's supposed to be hard coded to run the migration only once this.downloadTranscodingCodec, this.downloadTranscodeBitrate, this.shouldTranscodeDownloads = DefaultSettings.shouldTranscodeDownloads, @@ -249,15 +254,15 @@ class FinampSettings { List downloadLocations; @HiveField(4, - defaultValue: DefaultSettings.settingAndroidStopForegroundOnPause) + defaultValue: DefaultSettings.androidStopForegroundOnPause) bool androidStopForegroundOnPause; @HiveField(5) Map showTabs; /// Used to remember if the user has set their music screen to favourites /// mode. - @HiveField(6, defaultValue: DefaultSettings.settingIsFavourite) - bool onlyShowFavourite; + @HiveField(6, defaultValue: DefaultSettings.onlyShowFavourites) + bool onlyShowFavourites; /// Current sort by setting. @Deprecated("Use per-tab sort by instead") @@ -320,10 +325,14 @@ class FinampSettings { @HiveField(22, defaultValue: DefaultSettings.tabOrder) List tabOrder; - @HiveField(23, defaultValue: false) + @HiveField(23, + defaultValue: + true) //!!! don't touch this default value, it's supposed to be hard coded to run the migration only once bool hasCompletedBlurhashImageMigration; - @HiveField(24, defaultValue: false) + @HiveField(24, + defaultValue: + true) //!!! don't touch this default value, it's supposed to be hard coded to run the migration only once bool hasCompletedBlurhashImageMigrationIdFix; @HiveField(25, defaultValue: DefaultSettings.showFastScroller) @@ -347,34 +356,34 @@ class FinampSettings { @HiveField(33, defaultValue: DefaultSettings.volumeNormalizationMode) VolumeNormalizationMode volumeNormalizationMode; - @HiveField(34, defaultValue: false) + @HiveField(34, + defaultValue: + true) //!!! don't touch this default value, it's supposed to be hard coded to run the migration only once bool hasCompletedDownloadsServiceMigration; - @HiveField(35, defaultValue: false) + @HiveField(35, defaultValue: DefaultSettings.requireWifiForDownloads) bool requireWifiForDownloads; - @HiveField(36, defaultValue: false) + @HiveField(36, defaultValue: DefaultSettings.onlyShowFullyDownloaded) bool onlyShowFullyDownloaded; - @HiveField(37, defaultValue: true) + @HiveField(37, defaultValue: DefaultSettings.showDownloadsWithUnknownLibrary) bool showDownloadsWithUnknownLibrary; - @HiveField(38, defaultValue: 10) + @HiveField(38, defaultValue: DefaultSettings.maxConcurrentDownloads) int maxConcurrentDownloads; - @HiveField(39, defaultValue: 5) + @HiveField(39, defaultValue: DefaultSettings.downloadWorkers) int downloadWorkers; @HiveField(40, defaultValue: DefaultSettings.resyncOnStartup) bool resyncOnStartup; - @HiveField(41, defaultValue: true) + @HiveField(41, defaultValue: DefaultSettings.preferQuickSyncs) bool preferQuickSyncs; - @HiveField(42, defaultValue: false) + @HiveField(42, defaultValue: true) bool hasCompletedIsarUserMigration; - - @HiveField(43) FinampTranscodingCodec? downloadTranscodingCodec; @HiveField(44, defaultValue: DefaultSettings.shouldTranscodeDownloads) @@ -429,13 +438,13 @@ class FinampSettings { @HiveField(58, defaultValue: null) String? defaultDownloadLocation; - @HiveField(59, defaultValue: false) + @HiveField(59, defaultValue: DefaultSettings.useFixedSizeGridTiles) bool useFixedSizeGridTiles; @HiveField(60, defaultValue: DefaultSettings.fixedGridTileSize) int fixedGridTileSize; - @HiveField(61, defaultValue: true) + @HiveField(61, defaultValue: DefaultSettings.allowSplitScreen) bool allowSplitScreen; @HiveField(62, defaultValue: DefaultSettings.splitScreenPlayerWidth) diff --git a/lib/models/finamp_models.g.dart b/lib/models/finamp_models.g.dart index 1919d6b32..5643366c2 100644 --- a/lib/models/finamp_models.g.dart +++ b/lib/models/finamp_models.g.dart @@ -73,7 +73,7 @@ class FinampSettingsAdapter extends TypeAdapter { androidStopForegroundOnPause: fields[4] == null ? true : fields[4] as bool, showTabs: (fields[5] as Map).cast(), - onlyShowFavourite: fields[6] == null ? false : fields[6] as bool, + onlyShowFavourites: fields[6] == null ? false : fields[6] as bool, sortBy: fields[7] as SortBy, sortOrder: fields[8] as SortOrder, songShuffleItemCount: fields[9] == null ? 250 : fields[9] as int, @@ -125,11 +125,11 @@ class FinampSettingsAdapter extends TypeAdapter { autoloadLastQueueOnStartup: fields[28] == null ? true : fields[28] as bool, hasCompletedBlurhashImageMigration: - fields[23] == null ? false : fields[23] as bool, + fields[23] == null ? true : fields[23] as bool, hasCompletedBlurhashImageMigrationIdFix: - fields[24] == null ? false : fields[24] as bool, + fields[24] == null ? true : fields[24] as bool, hasCompletedDownloadsServiceMigration: - fields[34] == null ? false : fields[34] as bool, + fields[34] == null ? true : fields[34] as bool, requireWifiForDownloads: fields[35] == null ? false : fields[35] as bool, onlyShowFullyDownloaded: fields[36] == null ? false : fields[36] as bool, showDownloadsWithUnknownLibrary: @@ -139,8 +139,7 @@ class FinampSettingsAdapter extends TypeAdapter { resyncOnStartup: fields[40] == null ? true : fields[40] as bool, preferQuickSyncs: fields[41] == null ? true : fields[41] as bool, hasCompletedIsarUserMigration: - fields[42] == null ? false : fields[42] as bool, - downloadTranscodingCodec: fields[43] as FinampTranscodingCodec?, + fields[42] == null ? true : fields[42] as bool, downloadTranscodeBitrate: fields[45] as int?, shouldTranscodeDownloads: fields[44] == null ? TranscodeDownloadsSetting.ask @@ -184,17 +183,7 @@ class FinampSettingsAdapter extends TypeAdapter { keepScreenOnWhilePluggedIn: fields[73] == null ? true : fields[73] as bool, featureChipsConfiguration: fields[76] == null - ? const FinampFeatureChipsConfiguration(enabled: true, features: [ - FinampFeatureChipType.playCount, - FinampFeatureChipType.additionalPeople, - FinampFeatureChipType.playbackMode, - FinampFeatureChipType.codec, - FinampFeatureChipType.bitRate, - FinampFeatureChipType.bitDepth, - FinampFeatureChipType.sampleRate, - FinampFeatureChipType.size, - FinampFeatureChipType.normalizationGain - ]) + ? DefaultSettings.featureChipsConfiguration : fields[76] as FinampFeatureChipsConfiguration, showCoversOnAlbumScreen: fields[77] == null ? false : fields[77] as bool, hasDownloadedPlaylistInfo: @@ -211,7 +200,7 @@ class FinampSettingsAdapter extends TypeAdapter { @override void write(BinaryWriter writer, FinampSettings obj) { writer - ..writeByte(75) + ..writeByte(74) ..writeByte(0) ..write(obj.isOffline) ..writeByte(1) @@ -225,7 +214,7 @@ class FinampSettingsAdapter extends TypeAdapter { ..writeByte(5) ..write(obj.showTabs) ..writeByte(6) - ..write(obj.onlyShowFavourite) + ..write(obj.onlyShowFavourites) ..writeByte(7) ..write(obj.sortBy) ..writeByte(8) @@ -292,8 +281,6 @@ class FinampSettingsAdapter extends TypeAdapter { ..write(obj.preferQuickSyncs) ..writeByte(42) ..write(obj.hasCompletedIsarUserMigration) - ..writeByte(43) - ..write(obj.downloadTranscodingCodec) ..writeByte(44) ..write(obj.shouldTranscodeDownloads) ..writeByte(45) diff --git a/lib/screens/music_screen.dart b/lib/screens/music_screen.dart index 5ca5f1e4f..77afe53d2 100644 --- a/lib/screens/music_screen.dart +++ b/lib/screens/music_screen.dart @@ -131,7 +131,7 @@ class _MusicScreenState extends ConsumerState onPressed: () async { try { await _audioServiceHelper.shuffleAll( - FinampSettingsHelper.finampSettings.onlyShowFavourite); + FinampSettingsHelper.finampSettings.onlyShowFavourites); } catch (e) { GlobalSnackbar.error(e); } @@ -325,12 +325,12 @@ class _MusicScreenState extends ConsumerState if (!finampSettings.isOffline || finampSettings.trackOfflineFavorites) IconButton( - icon: finampSettings.onlyShowFavourite + icon: finampSettings.onlyShowFavourites ? const Icon(Icons.favorite) : const Icon(Icons.favorite_outline), onPressed: () => - FinampSettingsHelper.setOnlyShowFavourite( - !finampSettings.onlyShowFavourite), + FinampSettingsHelper.setonlyShowFavourites( + !finampSettings.onlyShowFavourites), tooltip: AppLocalizations.of(context)!.favourites, ), IconButton( diff --git a/lib/services/android_auto_helper.dart b/lib/services/android_auto_helper.dart index 5b4aa79e8..ead139f11 100644 --- a/lib/services/android_auto_helper.dart +++ b/lib/services/android_auto_helper.dart @@ -567,7 +567,7 @@ class AndroidAutoHelper { try { await audioServiceHelper - .shuffleAll(FinampSettingsHelper.finampSettings.onlyShowFavourite); + .shuffleAll(FinampSettingsHelper.finampSettings.onlyShowFavourites); } catch (err) { _androidAutoHelperLogger.severe("Error while shuffling all songs", err); } diff --git a/lib/services/audio_service_helper.dart b/lib/services/audio_service_helper.dart index d00b50c9d..88438751d 100644 --- a/lib/services/audio_service_helper.dart +++ b/lib/services/audio_service_helper.dart @@ -19,7 +19,7 @@ class AudioServiceHelper { final audioServiceHelperLogger = Logger("AudioServiceHelper"); /// Shuffles every song in the user's current view. - Future shuffleAll(bool isFavourite) async { + Future shuffleAll(bool onlyShowFavourites) async { List? items; if (FinampSettingsHelper.finampSettings.isOffline) { @@ -44,7 +44,7 @@ class AudioServiceHelper { items = await _jellyfinApiHelper.getItems( parentItem: _finampUserHelper.currentUser!.currentView, includeItemTypes: "Audio", - filters: isFavourite ? "IsFavorite" : null, + filters: onlyShowFavourites ? "IsFavorite" : null, limit: FinampSettingsHelper.finampSettings.songShuffleItemCount, sortBy: "Random", ); @@ -54,11 +54,11 @@ class AudioServiceHelper { await _queueService.startPlayback( items: items, source: QueueItemSource( - type: isFavourite + type: onlyShowFavourites ? QueueItemSourceType.favorites : QueueItemSourceType.allSongs, name: QueueItemSourceName( - type: isFavourite + type: onlyShowFavourites ? QueueItemSourceNameType.yourLikes : QueueItemSourceNameType.shuffleAll, ), diff --git a/lib/services/finamp_settings_helper.dart b/lib/services/finamp_settings_helper.dart index f556639bf..604720849 100644 --- a/lib/services/finamp_settings_helper.dart +++ b/lib/services/finamp_settings_helper.dart @@ -79,9 +79,9 @@ class FinampSettingsHelper { .put("FinampSettings", finampSettingsTemp); } - static void setOnlyShowFavourite(bool onlyShowFavourite) { + static void setonlyShowFavourites(bool onlyShowFavourites) { FinampSettings finampSettingsTemp = finampSettings; - finampSettingsTemp.onlyShowFavourite = onlyShowFavourite; + finampSettingsTemp.onlyShowFavourites = onlyShowFavourites; Hive.box("FinampSettings") .put("FinampSettings", finampSettingsTemp); } @@ -449,7 +449,7 @@ class FinampSettingsHelper { static void resetAudioServiceSettings() { setAndroidStopForegroundOnPause( - DefaultSettings.settingAndroidStopForegroundOnPause); + DefaultSettings.androidStopForegroundOnPause); setSongShuffleItemCount( DefaultSettings.songShuffleItemCount); // DOES NOT update UI setBufferDuration(Duration( diff --git a/pubspec.lock b/pubspec.lock index a46344728..e78388690 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -5,23 +5,23 @@ packages: dependency: transitive description: name: _fe_analyzer_shared - sha256: "16e298750b6d0af7ce8a3ba7c18c69c3785d11b15ec83f6dcd0ad2a0009b3cab" + sha256: f256b0c0ba6c7577c15e2e4e114755640a875e885099367bf6e012b19314c834 url: "https://pub.dev" source: hosted - version: "76.0.0" + version: "72.0.0" _macros: dependency: transitive description: dart source: sdk - version: "0.3.3" + version: "0.3.2" analyzer: dependency: "direct overridden" description: name: analyzer - sha256: "1f14db053a8c23e260789e9b0980fa27f2680dd640932cae5e1137cce0e46e1e" + sha256: b652861553cd3990d8ed361f7979dc6d7053a9ac8843fa73820ab68ce5410139 url: "https://pub.dev" source: hosted - version: "6.11.0" + version: "6.7.0" analyzer_plugin: dependency: transitive description: @@ -299,10 +299,10 @@ packages: dependency: "direct main" description: name: collection - sha256: a1ace0a119f20aabc852d165077c036cd864315bd99b7eaa10a60100341941bf + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a url: "https://pub.dev" source: hosted - version: "1.19.0" + version: "1.18.0" color: dependency: transitive description: @@ -847,18 +847,18 @@ packages: dependency: transitive description: name: leak_tracker - sha256: "7bb2830ebd849694d1ec25bf1f44582d6ac531a57a365a803a6034ff751d2d06" + sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05" url: "https://pub.dev" source: hosted - version: "10.0.7" + version: "10.0.5" leak_tracker_flutter_testing: dependency: transitive description: name: leak_tracker_flutter_testing - sha256: "9491a714cca3667b60b5c420da8217e6de0d1ba7a5ec322fab01758f6998f379" + sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806" url: "https://pub.dev" source: hosted - version: "3.0.8" + version: "3.0.5" leak_tracker_testing: dependency: transitive description: @@ -895,10 +895,10 @@ packages: dependency: transitive description: name: macros - sha256: "1d9e801cd66f7ea3663c45fc708450db1fa57f988142c64289142c9b7ee80656" + sha256: "0acaed5d6b7eab89f63350bccd82119e6c602df0f391260d0e32b5e23db79536" url: "https://pub.dev" source: hosted - version: "0.1.3-main.0" + version: "0.1.2-main.4" marquee: dependency: "direct main" description: @@ -1353,7 +1353,7 @@ packages: dependency: transitive description: flutter source: sdk - version: "0.0.0" + version: "0.0.99" sliver_tools: dependency: transitive description: @@ -1431,10 +1431,10 @@ packages: dependency: transitive description: name: stack_trace - sha256: "9f47fd3630d76be3ab26f0ee06d213679aa425996925ff3feffdec504931c377" + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" url: "https://pub.dev" source: hosted - version: "1.12.0" + version: "1.11.1" state_notifier: dependency: transitive description: @@ -1463,10 +1463,10 @@ packages: dependency: transitive description: name: string_scanner - sha256: "688af5ed3402a4bde5b3a6c15fd768dbf2621a614950b17f04626c431ab3c4c3" + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "1.2.0" synchronized: dependency: transitive description: @@ -1487,10 +1487,10 @@ packages: dependency: transitive description: name: test_api - sha256: "664d3a9a64782fcdeb83ce9c6b39e78fd2971d4e37827b9b06c3aa1edc5e760c" + sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb" url: "https://pub.dev" source: hosted - version: "0.7.3" + version: "0.7.2" time: dependency: transitive description: @@ -1671,10 +1671,10 @@ packages: dependency: transitive description: name: vm_service - sha256: f6be3ed8bd01289b34d679c2b62226f63c0e69f9fd2e50a6b3c1c729a961041b + sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d" url: "https://pub.dev" source: hosted - version: "14.3.0" + version: "14.2.5" wakelock_plus: dependency: "direct main" description: From 1852b0874c5e333bea1a54bae769b158cb78508b Mon Sep 17 00:00:00 2001 From: Chaphasilor Date: Sat, 4 Jan 2025 18:55:00 +0100 Subject: [PATCH 10/10] update reset confirmation prompt wording, remove duplicate translations --- lib/components/AlbumScreen/download_button.dart | 2 +- lib/components/DownloadsScreen/downloaded_items_list.dart | 2 +- lib/components/PlayerScreen/queue_source_helper.dart | 2 +- lib/l10n/app_en.arb | 8 +++----- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/components/AlbumScreen/download_button.dart b/lib/components/AlbumScreen/download_button.dart index f03a54ac1..b22e0ceb2 100644 --- a/lib/components/AlbumScreen/download_button.dart +++ b/lib/components/AlbumScreen/download_button.dart @@ -94,7 +94,7 @@ class DownloadButton extends ConsumerWidget { confirmButtonText: AppLocalizations.of(context)!.deleteDownloadsConfirmButtonText, abortButtonText: - AppLocalizations.of(context)!.deleteDownloadsAbortButtonText, + AppLocalizations.of(context)!.genericCancel, onConfirmed: () async { try { await downloadsService.deleteDownload(stub: item); diff --git a/lib/components/DownloadsScreen/downloaded_items_list.dart b/lib/components/DownloadsScreen/downloaded_items_list.dart index 830289a13..ee62ff19e 100644 --- a/lib/components/DownloadsScreen/downloaded_items_list.dart +++ b/lib/components/DownloadsScreen/downloaded_items_list.dart @@ -61,7 +61,7 @@ class _DownloadedItemsListState extends State { confirmButtonText: AppLocalizations.of(context)! .deleteDownloadsConfirmButtonText, abortButtonText: AppLocalizations.of(context)! - .deleteDownloadsAbortButtonText, + .genericCancel, onConfirmed: () async { await downloadsService.deleteDownload(stub: album); if (mounted) { diff --git a/lib/components/PlayerScreen/queue_source_helper.dart b/lib/components/PlayerScreen/queue_source_helper.dart index 874f13318..727610942 100644 --- a/lib/components/PlayerScreen/queue_source_helper.dart +++ b/lib/components/PlayerScreen/queue_source_helper.dart @@ -84,7 +84,7 @@ Future removeFromPlaylist(BuildContext context, BaseItemDto item, item.name ?? "item", parent.name ?? "playlist"), confirmButtonText: AppLocalizations.of(context)!.removeFromPlaylistConfirm, - abortButtonText: AppLocalizations.of(context)!.removeFromPlaylistCancel, + abortButtonText: AppLocalizations.of(context)!.genericCancel, onConfirmed: () { isConfirmed = true; }, diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index d07659bc0..5756f49c8 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -350,7 +350,6 @@ "@deleteDownloadsConfirmButtonText": { "description": "Shown in the confirmation dialog for deleting downloaded media from the local device." }, - "deleteDownloadsAbortButtonText": "Cancel", "error": "Error", "@error": {}, "discNumber": "Disc {number}", @@ -1582,7 +1581,6 @@ } }, "removeFromPlaylistConfirm": "Remove", - "removeFromPlaylistCancel": "Cancel", "removeFromPlaylistPrompt": "Remove '{itemName}' from playlist '{playlistName}'?", "@removeFromPlaylistPrompt": { "placeholders": { @@ -1814,15 +1812,15 @@ "@resetFiltersButton": { "description": "Button to reset filters on a list of items" }, - "resetSettingsPromptGlobal": "Are you sure you want to reset ALL settings?", + "resetSettingsPromptGlobal": "Are you sure you want to reset ALL settings to their defaults?", "@resetSettingsPromptGlobal": { "description": "Prompt which gets shown when the user is about to reset all settings to their default values" }, - "resetSettingsPromptGlobalConfirm": "Yes I am!", + "resetSettingsPromptGlobalConfirm": "Reset ALL settings", "@resetSettingsPromptGlobalConfirm": { "description": "A differently worded Confirm button to prevent the user from instandly clicking confirm because they are about to reset all settings to their default value" }, - "resetSettingsPromptLocal": "Do you want to reset these settings back to default?", + "resetSettingsPromptLocal": "Do you want to reset these settings back to their defaults?", "@resetSettingsPromptLocal": { "description": "Prompt which gets shown when the user is about to reset all settings in the current settings window to their default values" },