mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-08-02 17:18:36 +02:00
feat(library): add quality label display modes
This commit is contained in:
@@ -6,6 +6,8 @@ part 'settings.g.dart';
|
||||
@JsonSerializable()
|
||||
class AppSettings {
|
||||
static const String homeFeedProviderOff = '__off__';
|
||||
static const String libraryQualityLabelBitrate = 'bitrate';
|
||||
static const String libraryQualityLabelBitDepth = 'bit_depth';
|
||||
|
||||
final String defaultService;
|
||||
final String audioQuality;
|
||||
@@ -38,6 +40,9 @@ class AppSettings {
|
||||
/// Library view opened when switching to the Library tab:
|
||||
/// 'last' (keep last used), 'all', 'albums', 'singles', or 'playlists'.
|
||||
final String defaultLibraryView;
|
||||
|
||||
/// Library badge text: measured bitrate or the legacy bit depth/sample rate.
|
||||
final String libraryQualityLabelMode;
|
||||
final bool askQualityBeforeDownload;
|
||||
final bool enableLogging;
|
||||
final bool useExtensionProviders;
|
||||
@@ -137,6 +142,7 @@ class AppSettings {
|
||||
this.historyViewMode = 'grid',
|
||||
this.historyFilterMode = 'all',
|
||||
this.defaultLibraryView = 'last',
|
||||
this.libraryQualityLabelMode = libraryQualityLabelBitrate,
|
||||
this.askQualityBeforeDownload = true,
|
||||
this.enableLogging = false,
|
||||
this.useExtensionProviders = true,
|
||||
@@ -208,6 +214,7 @@ class AppSettings {
|
||||
String? historyViewMode,
|
||||
String? historyFilterMode,
|
||||
String? defaultLibraryView,
|
||||
String? libraryQualityLabelMode,
|
||||
bool? askQualityBeforeDownload,
|
||||
bool? enableLogging,
|
||||
bool? useExtensionProviders,
|
||||
@@ -286,6 +293,8 @@ class AppSettings {
|
||||
historyViewMode: historyViewMode ?? this.historyViewMode,
|
||||
historyFilterMode: historyFilterMode ?? this.historyFilterMode,
|
||||
defaultLibraryView: defaultLibraryView ?? this.defaultLibraryView,
|
||||
libraryQualityLabelMode:
|
||||
libraryQualityLabelMode ?? this.libraryQualityLabelMode,
|
||||
askQualityBeforeDownload:
|
||||
askQualityBeforeDownload ?? this.askQualityBeforeDownload,
|
||||
enableLogging: enableLogging ?? this.enableLogging,
|
||||
|
||||
@@ -34,6 +34,9 @@ AppSettings _$AppSettingsFromJson(Map<String, dynamic> json) => AppSettings(
|
||||
historyViewMode: json['historyViewMode'] as String? ?? 'grid',
|
||||
historyFilterMode: json['historyFilterMode'] as String? ?? 'all',
|
||||
defaultLibraryView: json['defaultLibraryView'] as String? ?? 'last',
|
||||
libraryQualityLabelMode:
|
||||
json['libraryQualityLabelMode'] as String? ??
|
||||
AppSettings.libraryQualityLabelBitrate,
|
||||
askQualityBeforeDownload: json['askQualityBeforeDownload'] as bool? ?? true,
|
||||
enableLogging: json['enableLogging'] as bool? ?? false,
|
||||
useExtensionProviders: json['useExtensionProviders'] as bool? ?? true,
|
||||
@@ -124,6 +127,7 @@ Map<String, dynamic> _$AppSettingsToJson(
|
||||
'historyViewMode': instance.historyViewMode,
|
||||
'historyFilterMode': instance.historyFilterMode,
|
||||
'defaultLibraryView': instance.defaultLibraryView,
|
||||
'libraryQualityLabelMode': instance.libraryQualityLabelMode,
|
||||
'askQualityBeforeDownload': instance.askQualityBeforeDownload,
|
||||
'enableLogging': instance.enableLogging,
|
||||
'useExtensionProviders': instance.useExtensionProviders,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:spotiflac_android/models/track.dart';
|
||||
import 'package:spotiflac_android/providers/download_history_provider.dart';
|
||||
import 'package:spotiflac_android/services/library_database.dart';
|
||||
import 'package:spotiflac_android/utils/audio_quality_badge_policy.dart';
|
||||
import 'package:spotiflac_android/utils/string_utils.dart';
|
||||
|
||||
enum LibraryItemSource { downloaded, local }
|
||||
@@ -103,6 +104,34 @@ class UnifiedLibraryItem {
|
||||
coverUrl != null ||
|
||||
(localCoverPath != null && localCoverPath!.isNotEmpty);
|
||||
|
||||
String? qualityForMode(String mode) {
|
||||
final history = historyItem;
|
||||
if (history != null) {
|
||||
return buildLibraryAudioQualityLabel(
|
||||
mode: mode,
|
||||
format: history.format,
|
||||
bitrateKbps: history.bitrate,
|
||||
bitDepth: history.bitDepth,
|
||||
sampleRate: history.sampleRate,
|
||||
storedQuality: history.quality ?? quality,
|
||||
);
|
||||
}
|
||||
|
||||
final local = localItem;
|
||||
if (local != null) {
|
||||
return buildLibraryAudioQualityLabel(
|
||||
mode: mode,
|
||||
format: local.format,
|
||||
bitrateKbps: local.bitrate,
|
||||
bitDepth: local.bitDepth,
|
||||
sampleRate: local.sampleRate,
|
||||
storedQuality: quality,
|
||||
);
|
||||
}
|
||||
|
||||
return quality;
|
||||
}
|
||||
|
||||
String? get albumArtist => historyItem?.albumArtist ?? localItem?.albumArtist;
|
||||
|
||||
String? get releaseDate => historyItem?.releaseDate ?? localItem?.releaseDate;
|
||||
|
||||
Reference in New Issue
Block a user