refactor: remove redundant comments and fix setMetadataSource bug

- Fix setMetadataSource always returning 'deezer' regardless of input parameter
- Remove self-evident doc comments that restate method/class names across
  app_theme, dynamic_color_wrapper, cover_cache_manager, history_database,
  library_database, and download_service_picker
- Remove stale migration inline notes (// 12 -> 16, // 20 -> 16, etc.) from app_theme
- Remove trivial section-label comments in queue_tab batch conversion method
- Remove duplicate 'wait up to 5 seconds' comment in main_shell
This commit is contained in:
zarzet
2026-03-18 01:12:16 +07:00
parent 75db2f162b
commit eb143a41fc
9 changed files with 14 additions and 50 deletions
+1 -2
View File
@@ -406,8 +406,7 @@ class SettingsNotifier extends Notifier<AppSettings> {
}
void setMetadataSource(String source) {
final normalized = source == 'deezer' ? 'deezer' : 'deezer';
state = state.copyWith(metadataSource: normalized);
state = state.copyWith(metadataSource: source);
_saveSettings();
}
-1
View File
@@ -83,7 +83,6 @@ class _MainShellState extends ConsumerState<MainShell> {
final extState = ref.read(extensionProvider);
if (!extState.isInitialized) {
_log.d('Waiting for extensions to initialize before handling URL...');
// Wait up to 5 seconds for extensions to initialize
for (int i = 0; i < 50; i++) {
await Future.delayed(const Duration(milliseconds: 100));
if (!mounted) return;
-5
View File
@@ -5082,7 +5082,6 @@ class _QueueTabState extends ConsumerState<QueueTab> {
);
try {
// Read metadata from file
final metadata = <String, String>{
'TITLE': item.trackName,
'ARTIST': item.artistName,
@@ -5111,7 +5110,6 @@ class _QueueTabState extends ConsumerState<QueueTab> {
1000,
);
// Extract cover art
String? coverPath;
try {
final tempDir = await getTemporaryDirectory();
@@ -5126,7 +5124,6 @@ class _QueueTabState extends ConsumerState<QueueTab> {
}
} catch (_) {}
// Handle SAF vs regular file
String workingPath = item.filePath;
final isSaf = isContentUri(item.filePath);
String? safTempPath;
@@ -5139,7 +5136,6 @@ class _QueueTabState extends ConsumerState<QueueTab> {
workingPath = safTempPath;
}
// Convert
final newPath = await FFmpegService.convertAudioFormat(
inputPath: workingPath,
targetFormat: targetFormat.toLowerCase(),
@@ -5149,7 +5145,6 @@ class _QueueTabState extends ConsumerState<QueueTab> {
deleteOriginal: !isSaf,
);
// Cleanup cover temp
if (coverPath != null) {
try {
await File(coverPath).delete();
-2
View File
@@ -37,7 +37,6 @@ class CoverCacheManager {
final appDir = await getApplicationSupportDirectory();
_cachePath = p.join(appDir.path, 'cover_cache');
// Ensure cache directory exists
await Directory(_cachePath!).create(recursive: true);
debugPrint('CoverCacheManager: Initializing at $_cachePath');
@@ -48,7 +47,6 @@ class CoverCacheManager {
debugPrint('CoverCacheManager: Initialized successfully');
} catch (e) {
debugPrint('CoverCacheManager: Failed to initialize: $e');
// Will fallback to DefaultCacheManager
}
}
-11
View File
@@ -12,7 +12,6 @@ final Future<SharedPreferences> _prefs = SharedPreferences.getInstance();
/// Cached current iOS container path for path normalization
String? _currentContainerPath;
/// SQLite database service for download history
/// Provides O(1) lookups by spotify_id and isrc with proper indexing
class HistoryDatabase {
static final HistoryDatabase instance = HistoryDatabase._init();
@@ -78,7 +77,6 @@ class HistoryDatabase {
)
''');
// Indexes for fast lookups
await db.execute('CREATE INDEX idx_spotify_id ON history(spotify_id)');
await db.execute('CREATE INDEX idx_isrc ON history(isrc)');
await db.execute(
@@ -171,7 +169,6 @@ class HistoryDatabase {
try {
final db = await database;
// Get all items with iOS paths
final rows = await db.query('history', columns: ['id', 'file_path']);
int updatedCount = 0;
final batch = db.batch();
@@ -198,7 +195,6 @@ class HistoryDatabase {
await batch.commit(noResult: true);
}
// Save current container path
await prefs.setString('ios_last_container_path', _currentContainerPath!);
_log.i('iOS path migration complete: $updatedCount paths updated');
@@ -323,7 +319,6 @@ class HistoryDatabase {
};
}
/// Insert or update a history item
Future<void> upsert(Map<String, dynamic> json) async {
final db = await database;
await db.insert(
@@ -345,7 +340,6 @@ class HistoryDatabase {
return rows.map(_dbRowToJson).toList();
}
/// Get item by ID
Future<Map<String, dynamic>?> getById(String id) async {
final db = await database;
final rows = await db.query(
@@ -403,26 +397,22 @@ class HistoryDatabase {
return rows.map((r) => r['spotify_id'] as String).toSet();
}
/// Delete by ID
Future<void> deleteById(String id) async {
final db = await database;
await db.delete('history', where: 'id = ?', whereArgs: [id]);
}
/// Delete by Spotify ID
Future<void> deleteBySpotifyId(String spotifyId) async {
final db = await database;
await db.delete('history', where: 'spotify_id = ?', whereArgs: [spotifyId]);
}
/// Clear all history
Future<void> clearAll() async {
final db = await database;
await db.delete('history');
_log.i('Cleared all history');
}
/// Get total count
Future<int> getCount() async {
final db = await database;
final result = await db.rawQuery('SELECT COUNT(*) as count FROM history');
@@ -459,7 +449,6 @@ class HistoryDatabase {
return null;
}
/// Close database
Future<void> close() async {
final db = await database;
await db.close();
+1 -4
View File
@@ -123,7 +123,7 @@ class LibraryDatabase {
return await openDatabase(
path,
version: 4, // Bumped version for bitrate column
version: 4,
onConfigure: (db) async {
await db.rawQuery('PRAGMA journal_mode = WAL');
await db.execute('PRAGMA synchronous = NORMAL');
@@ -331,13 +331,11 @@ class LibraryDatabase {
String? trackName,
String? artistName,
}) async {
// First try ISRC if available
if (isrc != null && isrc.isNotEmpty) {
final byIsrc = await getByIsrc(isrc);
if (byIsrc != null) return byIsrc;
}
// Then try name matching
if (trackName != null && artistName != null) {
final matches = await findByTrackAndArtist(trackName, artistName);
if (matches.isNotEmpty) return matches.first;
@@ -523,7 +521,6 @@ class LibraryDatabase {
return rows.map((r) => r['file_path'] as String).toSet();
}
/// Delete multiple items by their file paths
Future<int> deleteByPaths(List<String> filePaths) async {
if (filePaths.isEmpty) return 0;
final db = await database;
+12 -20
View File
@@ -35,7 +35,6 @@ class AppTheme {
);
}
/// Create dark theme
static ThemeData dark({
ColorScheme? dynamicScheme,
Color? seedColor,
@@ -88,12 +87,11 @@ class AppTheme {
),
);
/// Card theme
static CardThemeData _cardTheme(ColorScheme scheme) => CardThemeData(
elevation: 0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
), // 12 -> 16
),
color: scheme.surfaceContainerLow,
surfaceTintColor: scheme.surfaceTint,
);
@@ -104,18 +102,17 @@ class AppTheme {
elevation: 1,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
), // 20 -> 16
),
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12),
),
);
/// Filled button theme
static FilledButtonThemeData _filledButtonTheme(ColorScheme scheme) =>
FilledButtonThemeData(
style: FilledButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
), // 20 -> 16
),
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12),
),
);
@@ -125,18 +122,17 @@ class AppTheme {
style: OutlinedButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
), // 20 -> 16
),
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12),
),
);
/// Text button theme
static TextButtonThemeData _textButtonTheme(ColorScheme scheme) =>
TextButtonThemeData(
style: TextButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
), // 20 -> 16
),
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
),
);
@@ -149,40 +145,39 @@ class AppTheme {
foregroundColor: scheme.onPrimaryContainer,
);
/// Input decoration theme
static InputDecorationTheme _inputDecorationTheme(ColorScheme scheme) =>
InputDecorationTheme(
filled: true,
fillColor: scheme.surfaceContainerHighest.withValues(
alpha: 0.3,
), // Added transparency
),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(16), // 12 -> 16
borderRadius: BorderRadius.circular(16),
borderSide: BorderSide.none,
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(16), // 12 -> 16
borderRadius: BorderRadius.circular(16),
borderSide: BorderSide.none,
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(16), // 12 -> 16
borderRadius: BorderRadius.circular(16),
borderSide: BorderSide(color: scheme.primary, width: 2),
),
errorBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(16), // 12 -> 16
borderRadius: BorderRadius.circular(16),
borderSide: BorderSide(color: scheme.error, width: 1),
),
contentPadding: const EdgeInsets.symmetric(
horizontal: 20,
vertical: 16,
), // consistent padding
),
);
static ListTileThemeData _listTileTheme(ColorScheme scheme) =>
ListTileThemeData(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
), // 12 -> 16
),
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
);
@@ -193,7 +188,6 @@ class AppTheme {
surfaceTintColor: scheme.surfaceTint,
);
/// Navigation bar theme
static NavigationBarThemeData _navigationBarTheme(
ColorScheme scheme, {
bool isAmoled = false,
@@ -213,7 +207,6 @@ class AppTheme {
contentTextStyle: TextStyle(color: scheme.onInverseSurface),
);
/// Progress indicator theme
static ProgressIndicatorThemeData _progressIndicatorTheme(
ColorScheme scheme,
) => ProgressIndicatorThemeData(
@@ -243,7 +236,6 @@ class AppTheme {
}),
);
/// Chip theme
static ChipThemeData _chipTheme(ColorScheme scheme) => ChipThemeData(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
backgroundColor: scheme.surfaceContainerLow,
-3
View File
@@ -4,7 +4,6 @@ import 'package:dynamic_color/dynamic_color.dart';
import 'package:spotiflac_android/providers/theme_provider.dart';
import 'package:spotiflac_android/theme/app_theme.dart';
/// Wrapper widget that provides dynamic color support from device wallpaper
class DynamicColorWrapper extends ConsumerWidget {
final Widget Function(ThemeData light, ThemeData dark, ThemeMode mode) builder;
@@ -23,7 +22,6 @@ class DynamicColorWrapper extends ConsumerWidget {
ColorScheme darkScheme;
if (themeSettings.useDynamicColor && lightDynamic != null && darkDynamic != null) {
// Use dynamic colors from wallpaper (Android 12+)
lightScheme = lightDynamic;
darkScheme = darkDynamic;
} else {
@@ -38,7 +36,6 @@ class DynamicColorWrapper extends ConsumerWidget {
);
}
// Apply AMOLED mode if enabled (pure black background)
if (themeSettings.useAmoled) {
darkScheme = _applyAmoledColors(darkScheme);
}
-2
View File
@@ -22,7 +22,6 @@ class BuiltInService {
});
}
/// Default quality options for built-in services
/// Default quality options for each built-in service
const _builtInServices = [
BuiltInService(
@@ -98,7 +97,6 @@ const _builtInServices = [
),
];
/// A reusable widget for selecting download service (built-in + extensions)
class DownloadServicePicker extends ConsumerStatefulWidget {
final String? trackName;
final String? artistName;