♻️ Moved player state from shared_prefs to drift
🍱 Update icons
This commit is contained in:
@@ -27,7 +27,7 @@ class AudioServices with WidgetsBindingObserver {
|
||||
: 'dev.solsynth.rhythmBox',
|
||||
androidNotificationChannelName: 'RhythmBox',
|
||||
androidNotificationOngoing: false,
|
||||
androidNotificationIcon: 'drawable/ic_launcher_monochrome',
|
||||
androidNotificationIcon: 'drawable/ic_stat_name',
|
||||
androidStopForegroundOnPause: false,
|
||||
androidNotificationChannelDescription: 'RhythmBox Music',
|
||||
),
|
||||
|
@@ -5,6 +5,7 @@ import 'dart:io';
|
||||
|
||||
import 'package:drift/drift.dart';
|
||||
import 'package:encrypt/encrypt.dart';
|
||||
import 'package:media_kit/media_kit.dart' hide Track;
|
||||
import 'package:path/path.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:rhythm_box/services/color.dart';
|
||||
@@ -27,6 +28,7 @@ part 'tables/skip_segment.dart';
|
||||
part 'tables/source_match.dart';
|
||||
part 'tables/history.dart';
|
||||
part 'tables/lyrics.dart';
|
||||
part 'tables/audio_player_state.dart';
|
||||
|
||||
part 'typeconverters/color.dart';
|
||||
part 'typeconverters/locale.dart';
|
||||
@@ -44,6 +46,9 @@ part 'typeconverters/subtitle.dart';
|
||||
SourceMatchTable,
|
||||
HistoryTable,
|
||||
LyricsTable,
|
||||
AudioPlayerStateTable,
|
||||
PlaylistTable,
|
||||
PlaylistMediaTable,
|
||||
],
|
||||
)
|
||||
class AppDatabase extends _$AppDatabase {
|
||||
|
File diff suppressed because it is too large
Load Diff
27
lib/services/database/tables/audio_player_state.dart
Executable file
27
lib/services/database/tables/audio_player_state.dart
Executable file
@@ -0,0 +1,27 @@
|
||||
part of '../database.dart';
|
||||
|
||||
class AudioPlayerStateTable extends Table {
|
||||
IntColumn get id => integer().autoIncrement()();
|
||||
BoolColumn get playing => boolean()();
|
||||
TextColumn get loopMode => textEnum<PlaylistMode>()();
|
||||
BoolColumn get shuffled => boolean()();
|
||||
TextColumn get collections => text().map(const StringListConverter())();
|
||||
}
|
||||
|
||||
class PlaylistTable extends Table {
|
||||
IntColumn get id => integer().autoIncrement()();
|
||||
IntColumn get audioPlayerStateId =>
|
||||
integer().references(AudioPlayerStateTable, #id)();
|
||||
IntColumn get index => integer()();
|
||||
}
|
||||
|
||||
class PlaylistMediaTable extends Table {
|
||||
IntColumn get id => integer().autoIncrement()();
|
||||
IntColumn get playlistId => integer().references(PlaylistTable, #id)();
|
||||
|
||||
TextColumn get uri => text()();
|
||||
TextColumn get extras =>
|
||||
text().nullable().map(const MapTypeConverter<String, dynamic>())();
|
||||
TextColumn get httpHeaders =>
|
||||
text().nullable().map(const MapTypeConverter<String, String>())();
|
||||
}
|
@@ -13,24 +13,18 @@ abstract class KVStoreService {
|
||||
_sharedPreferences = await SharedPreferences.getInstance();
|
||||
}
|
||||
|
||||
static bool get doneGettingStarted =>
|
||||
sharedPreferences.getBool('doneGettingStarted') ?? false;
|
||||
static Future<void> setDoneGettingStarted(bool value) async =>
|
||||
await sharedPreferences.setBool('doneGettingStarted', value);
|
||||
|
||||
static bool get askedForBatteryOptimization =>
|
||||
sharedPreferences.getBool('askedForBatteryOptimization') ?? false;
|
||||
sharedPreferences.getBool('asked_for_battery_optimization') ?? false;
|
||||
static Future<void> setAskedForBatteryOptimization(bool value) async =>
|
||||
await sharedPreferences.setBool('askedForBatteryOptimization', value);
|
||||
await sharedPreferences.setBool('asked_for_battery_optimization', value);
|
||||
|
||||
static List<String> get recentSearches =>
|
||||
sharedPreferences.getStringList('recentSearches') ?? [];
|
||||
|
||||
sharedPreferences.getStringList('recent_searches') ?? [];
|
||||
static Future<void> setRecentSearches(List<String> value) async =>
|
||||
await sharedPreferences.setStringList('recentSearches', value);
|
||||
await sharedPreferences.setStringList('recent_searches', value);
|
||||
|
||||
static WindowSize? get windowSize {
|
||||
final raw = sharedPreferences.getString('windowSize');
|
||||
final raw = sharedPreferences.getString('window_size');
|
||||
|
||||
if (raw == null) {
|
||||
return null;
|
||||
@@ -40,7 +34,7 @@ abstract class KVStoreService {
|
||||
|
||||
static Future<void> setWindowSize(WindowSize value) async =>
|
||||
await sharedPreferences.setString(
|
||||
'windowSize',
|
||||
'window_size',
|
||||
jsonEncode(
|
||||
value.toJson(),
|
||||
),
|
||||
@@ -82,9 +76,4 @@ abstract class KVStoreService {
|
||||
static double get volume => sharedPreferences.getDouble('volume') ?? 1.0;
|
||||
static Future<void> setVolume(double value) async =>
|
||||
await sharedPreferences.setDouble('volume', value);
|
||||
|
||||
static bool get hasMigratedToDrift =>
|
||||
sharedPreferences.getBool('hasMigratedToDrift') ?? false;
|
||||
static Future<void> setHasMigratedToDrift(bool value) async =>
|
||||
await sharedPreferences.setBool('hasMigratedToDrift', value);
|
||||
}
|
||||
|
Reference in New Issue
Block a user