Compare commits

..

No commits in common. "main" and "v2.0.0-alpha.1" have entirely different histories.

36 changed files with 1668 additions and 2516 deletions

View File

@ -23,14 +23,10 @@ A clear and concise description of what you expected to happen.
**Screenshots** **Screenshots**
If applicable, add screenshots to help explain your problem. If applicable, add screenshots to help explain your problem.
**Device** **Smartphone (please complete the following information):**
- Model: [e.g. Pixel 4] - Device: [e.g. Pixel 4]
- OS: [e.g. Android 12] - OS: [e.g. Android 12]
- Subtracks version [e.g. 1.2.0] - Subtracks version [e.g. 1.2.0]
**Server**
- Software: [e.g. Navidrome]
- Version: [e.g. 0.49.3]
**Additional context** **Additional context**
Add any other context about the problem here. Add any other context about the problem here.

View File

@ -22,8 +22,6 @@
"resourcesSortByTitle", "resourcesSortByTitle",
"resourcesSortByUpdated", "resourcesSortByUpdated",
"settingsAboutActionsSupport", "settingsAboutActionsSupport",
"settingsAboutShareLogs",
"settingsAboutChooseLog",
"settingsNetworkOptionsOfflineMode", "settingsNetworkOptionsOfflineMode",
"settingsNetworkOptionsOfflineModeOff", "settingsNetworkOptionsOfflineModeOff",
"settingsNetworkOptionsOfflineModeOn", "settingsNetworkOptionsOfflineModeOn",
@ -55,8 +53,6 @@
"resourcesSortByTitle", "resourcesSortByTitle",
"resourcesSortByUpdated", "resourcesSortByUpdated",
"settingsAboutActionsSupport", "settingsAboutActionsSupport",
"settingsAboutShareLogs",
"settingsAboutChooseLog",
"settingsNetworkOptionsOfflineMode", "settingsNetworkOptionsOfflineMode",
"settingsNetworkOptionsOfflineModeOff", "settingsNetworkOptionsOfflineModeOff",
"settingsNetworkOptionsOfflineModeOn", "settingsNetworkOptionsOfflineModeOn",
@ -66,12 +62,32 @@
], ],
"cs": [ "cs": [
"actionsCancel",
"actionsDelete",
"actionsDownload",
"actionsDownloadCancel",
"actionsDownloadDelete",
"actionsOk",
"controlsShuffle",
"resourcesAlbumCount", "resourcesAlbumCount",
"resourcesArtistCount", "resourcesArtistCount",
"resourcesFilterAlbum",
"resourcesFilterArtist",
"resourcesFilterOwner",
"resourcesFilterYear",
"resourcesPlaylistCount", "resourcesPlaylistCount",
"resourcesSongCount", "resourcesSongCount",
"settingsAboutShareLogs", "resourcesSongListDeleteAllContent",
"settingsAboutChooseLog", "resourcesSongListDeleteAllTitle",
"resourcesSortByAlbum",
"resourcesSortByAlbumCount",
"resourcesSortByTitle",
"resourcesSortByUpdated",
"settingsAboutActionsLicenses",
"settingsAboutActionsProjectHomepage",
"settingsAboutActionsSupport",
"settingsAboutName",
"settingsAboutVersion",
"settingsMusicName", "settingsMusicName",
"settingsMusicOptionsScrobbleDescriptionOff", "settingsMusicOptionsScrobbleDescriptionOff",
"settingsMusicOptionsScrobbleDescriptionOn", "settingsMusicOptionsScrobbleDescriptionOn",
@ -80,7 +96,12 @@
"settingsNetworkOptionsMinBufferTitle", "settingsNetworkOptionsMinBufferTitle",
"settingsNetworkOptionsOfflineMode", "settingsNetworkOptionsOfflineMode",
"settingsNetworkOptionsOfflineModeOff", "settingsNetworkOptionsOfflineModeOff",
"settingsNetworkOptionsOfflineModeOn" "settingsNetworkOptionsOfflineModeOn",
"settingsNetworkOptionsStreamFormat",
"settingsNetworkOptionsStreamFormatServerDefault",
"settingsResetActionsClearImageCache",
"settingsResetName",
"settingsServersFieldsName"
], ],
"da": [ "da": [
@ -112,8 +133,6 @@
"resourcesSortByTitle", "resourcesSortByTitle",
"resourcesSortByUpdated", "resourcesSortByUpdated",
"settingsAboutActionsSupport", "settingsAboutActionsSupport",
"settingsAboutShareLogs",
"settingsAboutChooseLog",
"settingsMusicOptionsScrobbleDescriptionOff", "settingsMusicOptionsScrobbleDescriptionOff",
"settingsNetworkOptionsOfflineMode", "settingsNetworkOptionsOfflineMode",
"settingsNetworkOptionsOfflineModeOff", "settingsNetworkOptionsOfflineModeOff",
@ -127,11 +146,44 @@
], ],
"de": [ "de": [
"settingsAboutShareLogs", "actionsCancel",
"settingsAboutChooseLog" "actionsDelete",
], "actionsDownload",
"actionsDownloadCancel",
"es": [ "actionsDownloadDelete",
"actionsOk",
"controlsShuffle",
"resourcesAlbumCount",
"resourcesArtistCount",
"resourcesFilterAlbum",
"resourcesFilterArtist",
"resourcesFilterOwner",
"resourcesFilterYear",
"resourcesPlaylistCount",
"resourcesSongCount",
"resourcesSongListDeleteAllContent",
"resourcesSongListDeleteAllTitle",
"resourcesSortByAlbum",
"resourcesSortByAlbumCount",
"resourcesSortByTitle",
"resourcesSortByUpdated",
"settingsAboutActionsSupport",
"settingsNetworkOptionsOfflineMode",
"settingsNetworkOptionsOfflineModeOff",
"settingsNetworkOptionsOfflineModeOn",
"settingsNetworkOptionsStreamFormat",
"settingsNetworkOptionsStreamFormatServerDefault",
"settingsServersFieldsName"
],
"es": [
"actionsCancel",
"actionsDelete",
"actionsDownload",
"actionsDownloadCancel",
"actionsDownloadDelete",
"actionsOk",
"controlsShuffle",
"resourcesAlbumCount", "resourcesAlbumCount",
"resourcesArtistCount", "resourcesArtistCount",
"resourcesFilterAlbum", "resourcesFilterAlbum",
@ -147,8 +199,6 @@
"resourcesSortByTitle", "resourcesSortByTitle",
"resourcesSortByUpdated", "resourcesSortByUpdated",
"settingsAboutActionsSupport", "settingsAboutActionsSupport",
"settingsAboutShareLogs",
"settingsAboutChooseLog",
"settingsNetworkOptionsOfflineMode", "settingsNetworkOptionsOfflineMode",
"settingsNetworkOptionsOfflineModeOff", "settingsNetworkOptionsOfflineModeOff",
"settingsNetworkOptionsOfflineModeOn", "settingsNetworkOptionsOfflineModeOn",
@ -180,8 +230,37 @@
"resourcesSortByTitle", "resourcesSortByTitle",
"resourcesSortByUpdated", "resourcesSortByUpdated",
"settingsAboutActionsSupport", "settingsAboutActionsSupport",
"settingsAboutShareLogs", "settingsNetworkOptionsOfflineMode",
"settingsAboutChooseLog", "settingsNetworkOptionsOfflineModeOff",
"settingsNetworkOptionsOfflineModeOn",
"settingsNetworkOptionsStreamFormat",
"settingsNetworkOptionsStreamFormatServerDefault",
"settingsServersFieldsName"
],
"gl": [
"actionsCancel",
"actionsDelete",
"actionsDownload",
"actionsDownloadCancel",
"actionsDownloadDelete",
"actionsOk",
"controlsShuffle",
"resourcesAlbumCount",
"resourcesArtistCount",
"resourcesFilterAlbum",
"resourcesFilterArtist",
"resourcesFilterOwner",
"resourcesFilterYear",
"resourcesPlaylistCount",
"resourcesSongCount",
"resourcesSongListDeleteAllContent",
"resourcesSongListDeleteAllTitle",
"resourcesSortByAlbum",
"resourcesSortByAlbumCount",
"resourcesSortByTitle",
"resourcesSortByUpdated",
"settingsAboutActionsSupport",
"settingsNetworkOptionsOfflineMode", "settingsNetworkOptionsOfflineMode",
"settingsNetworkOptionsOfflineModeOff", "settingsNetworkOptionsOfflineModeOff",
"settingsNetworkOptionsOfflineModeOn", "settingsNetworkOptionsOfflineModeOn",
@ -213,8 +292,6 @@
"resourcesSortByTitle", "resourcesSortByTitle",
"resourcesSortByUpdated", "resourcesSortByUpdated",
"settingsAboutActionsSupport", "settingsAboutActionsSupport",
"settingsAboutShareLogs",
"settingsAboutChooseLog",
"settingsNetworkOptionsOfflineMode", "settingsNetworkOptionsOfflineMode",
"settingsNetworkOptionsOfflineModeOff", "settingsNetworkOptionsOfflineModeOff",
"settingsNetworkOptionsOfflineModeOn", "settingsNetworkOptionsOfflineModeOn",
@ -266,8 +343,6 @@
"settingsAboutActionsLicenses", "settingsAboutActionsLicenses",
"settingsAboutActionsSupport", "settingsAboutActionsSupport",
"settingsAboutName", "settingsAboutName",
"settingsAboutShareLogs",
"settingsAboutChooseLog",
"settingsAboutVersion", "settingsAboutVersion",
"settingsMusicOptionsScrobbleDescriptionOff", "settingsMusicOptionsScrobbleDescriptionOff",
"settingsMusicOptionsScrobbleDescriptionOn", "settingsMusicOptionsScrobbleDescriptionOn",
@ -324,8 +399,6 @@
"resourcesSortByTitle", "resourcesSortByTitle",
"resourcesSortByUpdated", "resourcesSortByUpdated",
"settingsAboutActionsSupport", "settingsAboutActionsSupport",
"settingsAboutShareLogs",
"settingsAboutChooseLog",
"settingsNetworkOptionsOfflineMode", "settingsNetworkOptionsOfflineMode",
"settingsNetworkOptionsOfflineModeOff", "settingsNetworkOptionsOfflineModeOff",
"settingsNetworkOptionsOfflineModeOn", "settingsNetworkOptionsOfflineModeOn",
@ -357,8 +430,6 @@
"resourcesSortByTitle", "resourcesSortByTitle",
"resourcesSortByUpdated", "resourcesSortByUpdated",
"settingsAboutActionsSupport", "settingsAboutActionsSupport",
"settingsAboutShareLogs",
"settingsAboutChooseLog",
"settingsNetworkOptionsOfflineMode", "settingsNetworkOptionsOfflineMode",
"settingsNetworkOptionsOfflineModeOff", "settingsNetworkOptionsOfflineModeOff",
"settingsNetworkOptionsOfflineModeOn", "settingsNetworkOptionsOfflineModeOn",
@ -390,8 +461,6 @@
"resourcesSortByTitle", "resourcesSortByTitle",
"resourcesSortByUpdated", "resourcesSortByUpdated",
"settingsAboutActionsSupport", "settingsAboutActionsSupport",
"settingsAboutShareLogs",
"settingsAboutChooseLog",
"settingsNetworkOptionsOfflineMode", "settingsNetworkOptionsOfflineMode",
"settingsNetworkOptionsOfflineModeOff", "settingsNetworkOptionsOfflineModeOff",
"settingsNetworkOptionsOfflineModeOn", "settingsNetworkOptionsOfflineModeOn",
@ -401,17 +470,63 @@
], ],
"pt": [ "pt": [
"actionsCancel",
"actionsDelete",
"actionsDownload",
"actionsDownloadCancel",
"actionsDownloadDelete",
"actionsOk",
"controlsShuffle",
"resourcesAlbumCount", "resourcesAlbumCount",
"resourcesArtistCount", "resourcesArtistCount",
"resourcesFilterAlbum",
"resourcesFilterArtist",
"resourcesFilterOwner", "resourcesFilterOwner",
"resourcesFilterYear",
"resourcesPlaylistCount", "resourcesPlaylistCount",
"resourcesSongCount", "resourcesSongCount",
"resourcesSongListDeleteAllContent", "resourcesSongListDeleteAllContent",
"resourcesSongListDeleteAllTitle", "resourcesSongListDeleteAllTitle",
"resourcesSortByAlbum",
"resourcesSortByAlbumCount", "resourcesSortByAlbumCount",
"resourcesSortByTitle",
"resourcesSortByUpdated", "resourcesSortByUpdated",
"settingsAboutShareLogs", "settingsAboutActionsSupport",
"settingsAboutChooseLog", "settingsNetworkOptionsOfflineMode",
"settingsNetworkOptionsOfflineModeOff",
"settingsNetworkOptionsOfflineModeOn",
"settingsNetworkOptionsStreamFormat",
"settingsNetworkOptionsStreamFormatServerDefault",
"settingsServersFieldsName"
],
"ru": [
"actionsCancel",
"actionsDelete",
"actionsDownload",
"actionsDownloadCancel",
"actionsDownloadDelete",
"actionsOk",
"controlsShuffle",
"resourcesAlbumCount",
"resourcesArtistCount",
"resourcesFilterAlbum",
"resourcesFilterArtist",
"resourcesFilterOwner",
"resourcesFilterYear",
"resourcesPlaylistCount",
"resourcesSongCount",
"resourcesSongListDeleteAllContent",
"resourcesSongListDeleteAllTitle",
"resourcesSortByAlbum",
"resourcesSortByAlbumCount",
"resourcesSortByTitle",
"resourcesSortByUpdated",
"settingsAboutActionsSupport",
"settingsNetworkOptionsOfflineMode",
"settingsNetworkOptionsOfflineModeOff",
"settingsNetworkOptionsOfflineModeOn",
"settingsNetworkOptionsStreamFormat",
"settingsNetworkOptionsStreamFormatServerDefault", "settingsNetworkOptionsStreamFormatServerDefault",
"settingsServersFieldsName" "settingsServersFieldsName"
], ],
@ -439,8 +554,6 @@
"resourcesSortByTitle", "resourcesSortByTitle",
"resourcesSortByUpdated", "resourcesSortByUpdated",
"settingsAboutActionsSupport", "settingsAboutActionsSupport",
"settingsAboutShareLogs",
"settingsAboutChooseLog",
"settingsNetworkOptionsOfflineMode", "settingsNetworkOptionsOfflineMode",
"settingsNetworkOptionsOfflineModeOff", "settingsNetworkOptionsOfflineModeOff",
"settingsNetworkOptionsOfflineModeOn", "settingsNetworkOptionsOfflineModeOn",
@ -472,8 +585,6 @@
"resourcesSortByTitle", "resourcesSortByTitle",
"resourcesSortByUpdated", "resourcesSortByUpdated",
"settingsAboutActionsSupport", "settingsAboutActionsSupport",
"settingsAboutShareLogs",
"settingsAboutChooseLog",
"settingsNetworkOptionsOfflineMode", "settingsNetworkOptionsOfflineMode",
"settingsNetworkOptionsOfflineModeOff", "settingsNetworkOptionsOfflineModeOff",
"settingsNetworkOptionsOfflineModeOn", "settingsNetworkOptionsOfflineModeOn",
@ -483,13 +594,28 @@
], ],
"zh": [ "zh": [
"actionsCancel",
"actionsDelete",
"actionsDownload",
"actionsDownloadCancel",
"actionsDownloadDelete",
"actionsOk",
"controlsShuffle", "controlsShuffle",
"resourcesAlbumCount", "resourcesAlbumCount",
"resourcesArtistCount", "resourcesArtistCount",
"resourcesFilterAlbum",
"resourcesFilterArtist",
"resourcesFilterOwner",
"resourcesFilterYear",
"resourcesPlaylistCount", "resourcesPlaylistCount",
"resourcesSongCount", "resourcesSongCount",
"settingsAboutShareLogs", "resourcesSongListDeleteAllContent",
"settingsAboutChooseLog", "resourcesSongListDeleteAllTitle",
"resourcesSortByAlbum",
"resourcesSortByAlbumCount",
"resourcesSortByTitle",
"resourcesSortByUpdated",
"settingsAboutActionsSupport",
"settingsNetworkOptionsOfflineMode", "settingsNetworkOptionsOfflineMode",
"settingsNetworkOptionsOfflineModeOff", "settingsNetworkOptionsOfflineModeOff",
"settingsNetworkOptionsOfflineModeOn", "settingsNetworkOptionsOfflineModeOn",

62
TODO.md
View File

@ -1,30 +1,34 @@
## To-do ## To-do
- Star/unstar - [ ] Star/unstar
- Context menus - [ ] Context menus
- Download actions for song - [ ] Download actions for song
- Playlist management - [ ] Playlist management
- Add to playlist (from context) - [ ] Add to playlist (from context)
- Queue management - [ ] Queue management
- View playing queue - [ ] View playing queue
- Re-order queue - [ ] Re-order queue
- Add to queue (from context) - [ ] Add to queue (from context)
- Remove from queue - [ ] Remove from queue
- Scrobbling - [ ] Scrobbling
- Library filters (year/genre/etc) - [ ] Library filters (year/genre/etc)
- Library list display modes - [ ] Library list display modes
- Search - [ ] Search
- Individual "more" results pages - [ ] Individual "more" results pages
- Now playing gestures - [ ] Radio modes
- Swipe bar/album to skip - [ ] Artist
- Double-tap to seek forward/back (bar only) - [ ] Now playing gestures
- Settings - [ ] Swipe bar/album to skip
- Music - [ ] Double-tap to seek forward/back (bar only)
- Scrobble - [ ] Settings
- Downloads - [ ] Sources
- Used/available space - [ ] Use plaintext password
- Clear downloads - [ ] Music
- Clear images - [ ] Scrobble
- About - [ ] Downloads
- Licenses - [ ] Used/available space
- Welcome/setup flow - [ ] Clear downloads
- Proper loading screen/animation - [ ] Clear images
- [ ] About
- [ ] Licenses
- [ ] Welcome/setup flow
- [ ] Proper loading screen/animation

View File

@ -1,4 +1,3 @@
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart';
@ -78,8 +77,7 @@ class App extends HookConsumerWidget {
), ),
routeInformationParser: appRouter.defaultRouteParser(), routeInformationParser: appRouter.defaultRouteParser(),
localizationsDelegates: AppLocalizations.localizationsDelegates, localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: [...AppLocalizations.supportedLocales] supportedLocales: AppLocalizations.supportedLocales,
..moveToTheFront(const Locale('en')),
); );
} }
} }

View File

@ -4,7 +4,6 @@ import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart';
import '../services/sync_service.dart'; import '../services/sync_service.dart';
import 'items.dart'; import 'items.dart';
import 'snackbars.dart';
class PagedListQueryView<T> extends HookConsumerWidget { class PagedListQueryView<T> extends HookConsumerWidget {
final PagingController<int, T> pagingController; final PagingController<int, T> pagingController;
@ -123,13 +122,7 @@ class SyncAllRefresh extends HookConsumerWidget {
@override @override
Widget build(BuildContext context, WidgetRef ref) { Widget build(BuildContext context, WidgetRef ref) {
return RefreshIndicator( return RefreshIndicator(
onRefresh: () async { onRefresh: () => ref.read(syncServiceProvider.notifier).syncAll(),
try {
await ref.read(syncServiceProvider.notifier).syncAll();
} catch (e) {
showErrorSnackbar(context, e.toString());
}
},
child: child, child: child,
); );
} }

View File

@ -1,19 +1,13 @@
import 'dart:math'; import 'dart:math';
import 'package:auto_route/auto_route.dart'; import 'package:auto_route/auto_route.dart';
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart'; import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart';
import '../../database/database.dart';
import '../../models/query.dart';
import '../../models/support.dart';
import '../../services/audio_service.dart';
import '../../state/music.dart'; import '../../state/music.dart';
import '../../state/settings.dart'; import '../../state/settings.dart';
import '../app_router.dart'; import '../app_router.dart';
import '../buttons.dart';
import '../images.dart'; import '../images.dart';
import '../items.dart'; import '../items.dart';
@ -33,26 +27,6 @@ class ArtistPage extends HookConsumerWidget {
final albums = ref.watch(albumsByArtistIdProvider(id)); final albums = ref.watch(albumsByArtistIdProvider(id));
return Scaffold( return Scaffold(
floatingActionButton: RadioPlayFab(
onPressed: () => artist.hasValue
? ref.read(audioControlProvider).playRadio(
context: QueueContextType.artist,
contextId: artist.valueOrNull!.id,
query: ListQuery(
filters: IList([
FilterWith.equals(
column: 'artist_id',
value: artist.valueOrNull!.id,
)
]),
),
getSongs: (query) => ref
.read(databaseProvider)
.songsList(ref.read(sourceIdProvider), query)
.get(),
)
: null,
),
body: CustomScrollView( body: CustomScrollView(
slivers: [ slivers: [
SliverToBoxAdapter( SliverToBoxAdapter(

View File

@ -1,16 +1,11 @@
import 'dart:math';
import 'package:auto_route/auto_route.dart'; import 'package:auto_route/auto_route.dart';
import 'package:fast_immutable_collections/fast_immutable_collections.dart'; import 'package:fast_immutable_collections/fast_immutable_collections.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:path/path.dart' as p;
import 'package:share_plus/share_plus.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
import '../../log.dart';
import '../../models/support.dart'; import '../../models/support.dart';
import '../../services/settings_service.dart'; import '../../services/settings_service.dart';
import '../../state/init.dart'; import '../../state/init.dart';
@ -167,54 +162,6 @@ class _About extends HookConsumerWidget {
mode: LaunchMode.externalApplication, mode: LaunchMode.externalApplication,
), ),
), ),
const SizedBox(height: 12),
const _ShareLogsButton(),
],
);
}
}
class _ShareLogsButton extends StatelessWidget {
const _ShareLogsButton();
@override
Widget build(BuildContext context) {
final l = AppLocalizations.of(context);
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
OutlinedButton.icon(
icon: const Icon(Icons.share),
label: Text(l.settingsAboutShareLogs),
onPressed: () async {
final files = await logFiles();
if (files.isEmpty) return;
// ignore: use_build_context_synchronously
final value = await showDialog<String>(
context: context,
builder: (context) => MultipleChoiceDialog<String>(
title: l.settingsAboutChooseLog,
current: files.first.path,
options: files
.map((e) => MultiChoiceOption.string(
title: p.basename(e.path),
option: e.path,
))
.toIList(),
),
);
if (value == null) return;
Share.shareXFiles(
[XFile(value, mimeType: 'text/plain')],
subject: 'Logs from subtracks: ${String.fromCharCodes(
List.generate(8, (_) => Random().nextInt(26) + 65),
)}',
);
},
),
], ],
); );
} }

View File

@ -8,11 +8,9 @@ import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart';
import '../../database/database.dart'; import '../../database/database.dart';
import '../../log.dart';
import '../../models/settings.dart'; import '../../models/settings.dart';
import '../../services/settings_service.dart'; import '../../services/settings_service.dart';
import '../items.dart'; import '../items.dart';
import '../snackbars.dart';
class SourcePage extends HookConsumerWidget { class SourcePage extends HookConsumerWidget {
final int? id; final int? id;
@ -43,10 +41,9 @@ class SourcePage extends HookConsumerWidget {
label: l.settingsServersFieldsAddress, label: l.settingsServersFieldsAddress,
initialValue: source?.address.toString(), initialValue: source?.address.toString(),
keyboardType: TextInputType.url, keyboardType: TextInputType.url,
autofillHints: const [AutofillHints.url],
required: true, required: true,
validator: (value, label) { validator: (value, label) {
if (!value!.contains(RegExp(r'https?:\/\/'))) { if (Uri.tryParse(value!) == null) {
return '$label must be a valid URL'; return '$label must be a valid URL';
} }
return null; return null;
@ -55,27 +52,15 @@ class SourcePage extends HookConsumerWidget {
final username = LabeledTextField( final username = LabeledTextField(
label: l.settingsServersFieldsUsername, label: l.settingsServersFieldsUsername,
initialValue: source?.username, initialValue: source?.username,
autofillHints: const [AutofillHints.username],
required: true, required: true,
); );
final password = LabeledTextField( final password = LabeledTextField(
label: l.settingsServersFieldsPassword, label: l.settingsServersFieldsPassword,
initialValue: source?.password, initialValue: source?.password,
obscureText: true, obscureText: true,
autofillHints: const [AutofillHints.password],
required: true, required: true,
); );
final forcePlaintextPassword = useState(!(source?.useTokenAuth ?? true));
final forcePlaintextSwitch = SwitchListTile(
value: forcePlaintextPassword.value,
title: Text(l.settingsServersOptionsForcePlaintextPasswordTitle),
subtitle: forcePlaintextPassword.value
? Text(l.settingsServersOptionsForcePlaintextPasswordDescriptionOn)
: Text(l.settingsServersOptionsForcePlaintextPasswordDescriptionOff),
onChanged: (value) => forcePlaintextPassword.value = value,
);
return WillPopScope( return WillPopScope(
onWillPop: () async => !isSaving.value && !isDeleting.value, onWillPop: () async => !isSaving.value && !isDeleting.value,
child: Scaffold( child: Scaffold(
@ -143,7 +128,6 @@ class SourcePage extends HookConsumerWidget {
address: Uri.parse(address.value), address: Uri.parse(address.value),
username: username.value, username: username.value,
password: password.value, password: password.value,
useTokenAuth: !forcePlaintextPassword.value,
), ),
); );
} else { } else {
@ -158,14 +142,12 @@ class SourcePage extends HookConsumerWidget {
features: IList(), features: IList(),
username: username.value, username: username.value,
password: password.value, password: password.value,
useTokenAuth: useTokenAuth: const Value(true),
Value(!forcePlaintextPassword.value),
), ),
); );
} }
} catch (e, st) { } catch (err) {
showErrorSnackbar(context, e.toString()); // TOOD: toast the error or whatever
log.severe('Saving source', e, st);
error = true; error = true;
} finally { } finally {
isSaving.value = false; isSaving.value = false;
@ -181,25 +163,21 @@ class SourcePage extends HookConsumerWidget {
), ),
body: Form( body: Form(
key: form, key: form,
child: AutofillGroup( child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: ListView( child: ListView(
children: [ children: [
const SizedBox(height: 96 - kToolbarHeight), const SizedBox(height: 96 - kToolbarHeight),
Padding( Text(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Text(
source == null source == null
? l.settingsServersActionsAdd ? l.settingsServersActionsAdd
: l.settingsServersActionsEdit, : l.settingsServersActionsEdit,
style: theme.textTheme.displaySmall, style: theme.textTheme.displaySmall,
), ),
),
name, name,
address, address,
username, username,
password, password,
const SizedBox(height: 24),
forcePlaintextSwitch,
const FabPadding(), const FabPadding(),
], ],
), ),
@ -216,7 +194,6 @@ class LabeledTextField extends HookConsumerWidget {
final bool obscureText; final bool obscureText;
final bool required; final bool required;
final TextInputType? keyboardType; final TextInputType? keyboardType;
final Iterable<String>? autofillHints;
final String? Function(String? value, String label)? validator; final String? Function(String? value, String label)? validator;
// ignore: prefer_const_constructors_in_immutables // ignore: prefer_const_constructors_in_immutables
@ -227,7 +204,6 @@ class LabeledTextField extends HookConsumerWidget {
this.obscureText = false, this.obscureText = false,
this.keyboardType, this.keyboardType,
this.validator, this.validator,
this.autofillHints,
this.required = false, this.required = false,
}); });
@ -248,18 +224,18 @@ class LabeledTextField extends HookConsumerWidget {
final theme = Theme.of(context); final theme = Theme.of(context);
_controller = useTextEditingController(text: initialValue); _controller = useTextEditingController(text: initialValue);
return Padding( return Column(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: [
const SizedBox(height: 24), const SizedBox(height: 24),
Text(label, style: theme.textTheme.titleMedium), Text(
label,
style: theme.textTheme.titleMedium,
),
TextFormField( TextFormField(
controller: _controller, controller: _controller,
obscureText: obscureText, obscureText: obscureText,
keyboardType: keyboardType, keyboardType: keyboardType,
autofillHints: autofillHints,
validator: (value) { validator: (value) {
String? error; String? error;
@ -277,7 +253,6 @@ class LabeledTextField extends HookConsumerWidget {
}, },
), ),
], ],
),
); );
} }
} }

View File

@ -1,14 +0,0 @@
import 'package:flutter/material.dart';
void showErrorSnackbar(BuildContext context, String message) {
final colors = Theme.of(context).colorScheme;
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(message, style: TextStyle(color: colors.onErrorContainer)),
backgroundColor: colors.errorContainer,
showCloseIcon: true,
closeIconColor: colors.onErrorContainer,
behavior: SnackBarBehavior.floating,
duration: const Duration(seconds: 10),
));
}

View File

@ -9,20 +9,14 @@ import 'package:path/path.dart' as p;
import 'package:path_provider/path_provider.dart'; import 'package:path_provider/path_provider.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart'; import 'package:riverpod_annotation/riverpod_annotation.dart';
import '../log.dart';
import '../models/music.dart'; import '../models/music.dart';
import '../models/query.dart'; import '../models/query.dart';
import '../models/settings.dart'; import '../models/settings.dart';
import '../models/support.dart'; import '../models/support.dart';
import 'converters.dart'; import 'converters.dart';
import 'error_logging_database.dart';
part 'database.g.dart'; part 'database.g.dart';
// don't exceed SQLITE_MAX_VARIABLE_NUMBER (32766 for version >= 3.32.0)
// https://www.sqlite.org/limits.html
const kSqliteMaxVariableNumber = 32766;
@DriftDatabase(include: {'tables.drift'}) @DriftDatabase(include: {'tables.drift'})
class SubtracksDatabase extends _$SubtracksDatabase { class SubtracksDatabase extends _$SubtracksDatabase {
SubtracksDatabase() : super(_openConnection()); SubtracksDatabase() : super(_openConnection());
@ -175,28 +169,13 @@ class SubtracksDatabase extends _$SubtracksDatabase {
}); });
} }
Future<void> deleteArtistsNotIn(int sourceId, Set<String> ids) { Future<void> deleteArtistsNotIn(int sourceId, Iterable<String> ids) async {
return transaction(() async {
final allIds = (await (selectOnly(artists)
..addColumns([artists.id])
..where(artists.sourceId.equals(sourceId)))
.map((row) => row.read(artists.id))
.get())
.whereNotNull()
.toSet();
final downloadIds = (await artistIdsWithDownloadStatus(sourceId).get())
.whereNotNull()
.toSet();
final diff = allIds.difference(downloadIds).difference(ids);
for (var slice in diff.slices(kSqliteMaxVariableNumber)) {
await (delete(artists) await (delete(artists)
..where( ..where(
(tbl) => tbl.sourceId.equals(sourceId) & tbl.id.isIn(slice))) (tbl) => tbl.sourceId.equals(sourceId) & tbl.id.isNotIn(ids),
))
.go(); .go();
} }
});
}
Future<void> saveAlbums(Iterable<AlbumsCompanion> albums) async { Future<void> saveAlbums(Iterable<AlbumsCompanion> albums) async {
await batch((batch) { await batch((batch) {
@ -204,28 +183,16 @@ class SubtracksDatabase extends _$SubtracksDatabase {
}); });
} }
Future<void> deleteAlbumsNotIn(int sourceId, Set<String> ids) { Future<void> deleteAlbumsNotIn(int sourceId, Iterable<String> ids) async {
return transaction(() async { final alsoKeep = (await albumIdsWithDownloaded(sourceId).get()).toSet();
final allIds = (await (selectOnly(albums)
..addColumns([albums.id])
..where(albums.sourceId.equals(sourceId)))
.map((row) => row.read(albums.id))
.get())
.whereNotNull()
.toSet();
final downloadIds = (await albumIdsWithDownloadStatus(sourceId).get())
.whereNotNull()
.toSet();
final diff = allIds.difference(downloadIds).difference(ids); ids = ids.toList()..addAll(alsoKeep);
for (var slice in diff.slices(kSqliteMaxVariableNumber)) {
await (delete(albums) await (delete(albums)
..where( ..where(
(tbl) => tbl.sourceId.equals(sourceId) & tbl.id.isIn(slice))) (tbl) => tbl.sourceId.equals(sourceId) & tbl.id.isNotIn(ids),
))
.go(); .go();
} }
});
}
Future<void> savePlaylists( Future<void> savePlaylists(
Iterable<PlaylistWithSongsCompanion> playlistsWithSongs, Iterable<PlaylistWithSongsCompanion> playlistsWithSongs,
@ -248,32 +215,19 @@ class SubtracksDatabase extends _$SubtracksDatabase {
}); });
} }
Future<void> deletePlaylistsNotIn(int sourceId, Set<String> ids) { Future<void> deletePlaylistsNotIn(int sourceId, Iterable<String> ids) async {
return transaction(() async {
final allIds = (await (selectOnly(playlists)
..addColumns([playlists.id])
..where(playlists.sourceId.equals(sourceId)))
.map((row) => row.read(playlists.id))
.get())
.whereNotNull()
.toSet();
final downloadIds = (await playlistIdsWithDownloadStatus(sourceId).get())
.whereNotNull()
.toSet();
final diff = allIds.difference(downloadIds).difference(ids);
for (var slice in diff.slices(kSqliteMaxVariableNumber)) {
await (delete(playlists) await (delete(playlists)
..where( ..where(
(tbl) => tbl.sourceId.equals(sourceId) & tbl.id.isIn(slice))) (tbl) => tbl.sourceId.equals(sourceId) & tbl.id.isNotIn(ids),
))
.go(); .go();
await (delete(playlistSongs) await (delete(playlistSongs)
..where((tbl) => ..where(
tbl.sourceId.equals(sourceId) & tbl.playlistId.isIn(slice))) (tbl) =>
tbl.sourceId.equals(sourceId) & tbl.playlistId.isNotIn(ids),
))
.go(); .go();
} }
});
}
Future<void> savePlaylistSongs( Future<void> savePlaylistSongs(
int sourceId, int sourceId,
@ -296,33 +250,29 @@ class SubtracksDatabase extends _$SubtracksDatabase {
}); });
} }
Future<void> deleteSongsNotIn(int sourceId, Set<String> ids) { Future<void> deleteSongsNotIn(int sourceId, Iterable<String> ids) async {
return transaction(() async {
final allIds = (await (selectOnly(songs)
..addColumns([songs.id])
..where(
songs.sourceId.equals(sourceId) &
songs.downloadFilePath.isNull() &
songs.downloadTaskId.isNull(),
))
.map((row) => row.read(songs.id))
.get())
.whereNotNull()
.toSet();
final diff = allIds.difference(ids);
for (var slice in diff.slices(kSqliteMaxVariableNumber)) {
await (delete(songs) await (delete(songs)
..where( ..where(
(tbl) => tbl.sourceId.equals(sourceId) & tbl.id.isIn(slice))) (tbl) =>
.go(); tbl.sourceId.equals(sourceId) &
await (delete(playlistSongs) tbl.id.isNotIn(ids) &
..where( tbl.downloadFilePath.isNull() &
(tbl) => tbl.sourceId.equals(sourceId) & tbl.songId.isIn(slice), tbl.downloadTaskId.isNull(),
))
.go();
final remainingIds = (await (selectOnly(songs)
..addColumns([songs.id])
..where(songs.sourceId.equals(sourceId)))
.map((row) => row.read(songs.id))
.get())
.whereNotNull();
await (delete(playlistSongs)
..where(
(tbl) =>
tbl.sourceId.equals(sourceId) &
tbl.songId.isNotIn(remainingIds),
)) ))
.go(); .go();
}
});
} }
Selectable<LastBottomNavStateData> getLastBottomNavState() { Selectable<LastBottomNavStateData> getLastBottomNavState() {
@ -437,11 +387,7 @@ LazyDatabase _openConnection() {
final dbFolder = await getApplicationDocumentsDirectory(); final dbFolder = await getApplicationDocumentsDirectory();
final file = File(p.join(dbFolder.path, 'subtracks.sqlite')); final file = File(p.join(dbFolder.path, 'subtracks.sqlite'));
// return NativeDatabase.createInBackground(file, logStatements: true); // return NativeDatabase.createInBackground(file, logStatements: true);
return NativeDatabase.createInBackground(file);
return ErrorLoggingDatabase(
NativeDatabase.createInBackground(file),
(e, s) => log.severe('SQL error', e, s),
);
}); });
} }

View File

@ -4596,7 +4596,7 @@ abstract class _$SubtracksDatabase extends GeneratedDatabase {
)); ));
} }
Selectable<String> albumIdsWithDownloadStatus(int sourceId) { Selectable<String> albumIdsWithDownloaded(int sourceId) {
return customSelect( return customSelect(
'SELECT albums.id FROM albums JOIN songs ON songs.source_id = albums.source_id AND songs.album_id = albums.id WHERE albums.source_id = ?1 AND(songs.download_file_path IS NOT NULL OR songs.download_task_id IS NOT NULL)GROUP BY albums.id', 'SELECT albums.id FROM albums JOIN songs ON songs.source_id = albums.source_id AND songs.album_id = albums.id WHERE albums.source_id = ?1 AND(songs.download_file_path IS NOT NULL OR songs.download_task_id IS NOT NULL)GROUP BY albums.id',
variables: [ variables: [
@ -4608,32 +4608,6 @@ abstract class _$SubtracksDatabase extends GeneratedDatabase {
}).map((QueryRow row) => row.read<String>('id')); }).map((QueryRow row) => row.read<String>('id'));
} }
Selectable<String> artistIdsWithDownloadStatus(int sourceId) {
return customSelect(
'SELECT artists.id FROM artists LEFT JOIN albums ON artists.source_id = albums.source_id AND artists.id = albums.artist_id LEFT JOIN songs ON albums.source_id = songs.source_id AND albums.id = songs.album_id WHERE artists.source_id = ?1 AND(songs.download_file_path IS NOT NULL OR songs.download_task_id IS NOT NULL)GROUP BY artists.id',
variables: [
Variable<int>(sourceId)
],
readsFrom: {
artists,
albums,
songs,
}).map((QueryRow row) => row.read<String>('id'));
}
Selectable<String> playlistIdsWithDownloadStatus(int sourceId) {
return customSelect(
'SELECT playlists.id FROM playlists LEFT JOIN playlist_songs ON playlist_songs.source_id = playlists.source_id AND playlist_songs.playlist_id = playlists.id LEFT JOIN songs ON playlist_songs.source_id = songs.source_id AND playlist_songs.song_id = songs.id WHERE playlists.source_id = ?1 AND(songs.download_file_path IS NOT NULL OR songs.download_task_id IS NOT NULL)GROUP BY playlists.id',
variables: [
Variable<int>(sourceId)
],
readsFrom: {
playlists,
playlistSongs,
songs,
}).map((QueryRow row) => row.read<String>('id'));
}
Selectable<int> searchArtists(String query, int limit, int offset) { Selectable<int> searchArtists(String query, int limit, int offset) {
return customSelect( return customSelect(
'SELECT "rowid" FROM artists_fts WHERE artists_fts MATCH ?1 ORDER BY rank LIMIT ?2 OFFSET ?3', 'SELECT "rowid" FROM artists_fts WHERE artists_fts MATCH ?1 ORDER BY rank LIMIT ?2 OFFSET ?3',

View File

@ -1,94 +0,0 @@
import 'dart:async';
import 'package:drift/drift.dart';
import 'package:drift/isolate.dart';
/// https://github.com/simolus3/drift/issues/2326#issuecomment-1445138730
class ErrorLoggingDatabase implements QueryExecutor {
final QueryExecutor inner;
final void Function(Object, StackTrace) onError;
ErrorLoggingDatabase(this.inner, this.onError);
Future<T> _handleErrors<T>(Future<T> Function() body) {
return Future.sync(body)
.onError<DriftWrappedException>((error, stackTrace) {
onError(error, error.trace ?? stackTrace);
throw error;
}).onError<DriftRemoteException>((error, stackTrace) {
onError(error, error.remoteStackTrace ?? stackTrace);
throw error;
});
}
@override
TransactionExecutor beginTransaction() {
return _ErrorLoggingTransactionExecutor(inner.beginTransaction(), onError);
}
@override
Future<void> close() {
return _handleErrors(inner.close);
}
@override
SqlDialect get dialect => inner.dialect;
@override
Future<bool> ensureOpen(QueryExecutorUser user) {
return _handleErrors(() => inner.ensureOpen(user));
}
@override
Future<void> runBatched(BatchedStatements statements) {
return _handleErrors(() => inner.runBatched(statements));
}
@override
Future<void> runCustom(String statement, [List<Object?>? args]) {
return _handleErrors(() => inner.runCustom(statement, args));
}
@override
Future<int> runDelete(String statement, List<Object?> args) {
return _handleErrors(() => inner.runDelete(statement, args));
}
@override
Future<int> runInsert(String statement, List<Object?> args) {
return _handleErrors(() => inner.runInsert(statement, args));
}
@override
Future<List<Map<String, Object?>>> runSelect(
String statement, List<Object?> args) {
return _handleErrors(() => inner.runSelect(statement, args));
}
@override
Future<int> runUpdate(String statement, List<Object?> args) {
return _handleErrors(() => inner.runUpdate(statement, args));
}
}
class _ErrorLoggingTransactionExecutor extends ErrorLoggingDatabase
implements TransactionExecutor {
final TransactionExecutor transaction;
_ErrorLoggingTransactionExecutor(
this.transaction, void Function(Object, StackTrace) onError)
: super(transaction, onError);
@override
Future<void> rollback() {
return _handleErrors(transaction.rollback);
}
@override
Future<void> send() {
return _handleErrors(transaction.send);
}
@override
bool get supportsNestedTransactions => transaction.supportsNestedTransactions;
}

View File

@ -244,7 +244,7 @@ allSubsonicSources WITH SubsonicSettings:
FROM sources FROM sources
JOIN subsonic_sources ON subsonic_sources.source_id = sources.id; JOIN subsonic_sources ON subsonic_sources.source_id = sources.id;
albumIdsWithDownloadStatus: albumIdsWithDownloaded:
SELECT albums.id SELECT albums.id
FROM albums FROM albums
JOIN songs on songs.source_id = albums.source_id AND songs.album_id = albums.id JOIN songs on songs.source_id = albums.source_id AND songs.album_id = albums.id
@ -253,26 +253,6 @@ albumIdsWithDownloadStatus:
AND (songs.download_file_path IS NOT NULL OR songs.download_task_id IS NOT NULL) AND (songs.download_file_path IS NOT NULL OR songs.download_task_id IS NOT NULL)
GROUP BY albums.id; GROUP BY albums.id;
artistIdsWithDownloadStatus:
SELECT artists.id
FROM artists
LEFT JOIN albums ON artists.source_id = albums.source_id AND artists.id = albums.artist_id
LEFT JOIN songs ON albums.source_id = songs.source_id AND albums.id = songs.album_id
WHERE
artists.source_id = :source_id
AND (songs.download_file_path IS NOT NULL OR songs.download_task_id IS NOT NULL)
GROUP BY artists.id;
playlistIdsWithDownloadStatus:
SELECT playlists.id
FROM playlists
LEFT JOIN playlist_songs ON playlist_songs.source_id = playlists.source_id AND playlist_songs.playlist_id = playlists.id
LEFT JOIN songs ON playlist_songs.source_id = songs.source_id AND playlist_songs.song_id = songs.id
WHERE
playlists.source_id = :source_id
AND (songs.download_file_path IS NOT NULL OR songs.download_task_id IS NOT NULL)
GROUP BY playlists.id;
searchArtists: searchArtists:
SELECT rowid SELECT rowid
FROM artists_fts FROM artists_fts

View File

@ -1,8 +1,7 @@
import 'package:flutter/foundation.dart';
import 'package:http/http.dart'; import 'package:http/http.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart'; import 'package:riverpod_annotation/riverpod_annotation.dart';
import '../log.dart';
part 'client.g.dart'; part 'client.g.dart';
const Map<String, String> subtracksHeaders = { const Map<String, String> subtracksHeaders = {
@ -15,14 +14,8 @@ class SubtracksHttpClient extends BaseClient {
@override @override
Future<StreamedResponse> send(BaseRequest request) { Future<StreamedResponse> send(BaseRequest request) {
request.headers.addAll(subtracksHeaders); request.headers.addAll(subtracksHeaders);
log.info('${request.method} ${request.url}'); if (kDebugMode) print('${request.method} ${request.url}');
try {
return request.send(); return request.send();
} catch (e, st) {
log.severe('HTTP client: ${request.method} ${request.url}', e, st);
rethrow;
}
} }
} }

View File

@ -73,17 +73,17 @@
}, },
"resourcesSortByAdded": "Nedávno přidané", "resourcesSortByAdded": "Nedávno přidané",
"@resourcesSortByAdded": {}, "@resourcesSortByAdded": {},
"resourcesSortByArtist": "Umělce", "resourcesSortByArtist": "Podle umělce",
"@resourcesSortByArtist": {}, "@resourcesSortByArtist": {},
"resourcesSortByFrequentlyPlayed": "Často přehrávané", "resourcesSortByFrequentlyPlayed": "Často přehrávané",
"@resourcesSortByFrequentlyPlayed": {}, "@resourcesSortByFrequentlyPlayed": {},
"resourcesSortByName": "Názvu", "resourcesSortByName": "Podle názvu",
"@resourcesSortByName": {}, "@resourcesSortByName": {},
"resourcesSortByRandom": "Náhodně", "resourcesSortByRandom": "Náhodně",
"@resourcesSortByRandom": {}, "@resourcesSortByRandom": {},
"resourcesSortByRecentlyPlayed": "Často přehrávané", "resourcesSortByRecentlyPlayed": "Často přehrávané",
"@resourcesSortByRecentlyPlayed": {}, "@resourcesSortByRecentlyPlayed": {},
"resourcesSortByYear": "Roku", "resourcesSortByYear": "Podle roku",
"@resourcesSortByYear": {}, "@resourcesSortByYear": {},
"searchHeaderTitle": "Hledat: {query}", "searchHeaderTitle": "Hledat: {query}",
"@searchHeaderTitle": { "@searchHeaderTitle": {
@ -162,65 +162,5 @@
"settingsServersOptionsForcePlaintextPasswordDescriptionOn": "Posílat heslo v prostém textu (zastaralé, ujistěte se, že je vaše připojení zabezpečené!)", "settingsServersOptionsForcePlaintextPasswordDescriptionOn": "Posílat heslo v prostém textu (zastaralé, ujistěte se, že je vaše připojení zabezpečené!)",
"@settingsServersOptionsForcePlaintextPasswordDescriptionOn": {}, "@settingsServersOptionsForcePlaintextPasswordDescriptionOn": {},
"settingsServersOptionsForcePlaintextPasswordTitle": "Vynutit heslo ve formátu prostého textu", "settingsServersOptionsForcePlaintextPasswordTitle": "Vynutit heslo ve formátu prostého textu",
"@settingsServersOptionsForcePlaintextPasswordTitle": {}, "@settingsServersOptionsForcePlaintextPasswordTitle": {}
"actionsDownloadDelete": "Smazat stažené",
"@actionsDownloadDelete": {},
"actionsOk": "OK",
"@actionsOk": {},
"actionsCancel": "Zrušit",
"@actionsCancel": {},
"actionsDownload": "Stáhnout",
"@actionsDownload": {},
"controlsShuffle": "Náhodně",
"@controlsShuffle": {},
"resourcesFilterAlbum": "Album",
"@resourcesFilterAlbum": {},
"resourcesFilterArtist": "Umělec",
"@resourcesFilterArtist": {},
"resourcesFilterYear": "Rok",
"@resourcesFilterYear": {},
"resourcesFilterOwner": "Majitele",
"@resourcesFilterOwner": {},
"resourcesSongListDeleteAllTitle": "Smazat stažené?",
"@resourcesSongListDeleteAllTitle": {},
"resourcesSongListDeleteAllContent": "Toto odstraní všechny stažené soubory s hudbou.",
"@resourcesSongListDeleteAllContent": {},
"resourcesSortByUpdated": "Naposledy upravené",
"@resourcesSortByUpdated": {},
"resourcesSortByAlbum": "Alba",
"@resourcesSortByAlbum": {},
"resourcesSortByAlbumCount": "Počtu alb",
"@resourcesSortByAlbumCount": {},
"resourcesSortByTitle": "Názvu",
"@resourcesSortByTitle": {},
"settingsAboutActionsLicenses": "Licence",
"@settingsAboutActionsLicenses": {},
"settingsAboutActionsProjectHomepage": "Stránka projektu",
"@settingsAboutActionsProjectHomepage": {},
"settingsAboutActionsSupport": "Podpořit vývojáře 💜",
"@settingsAboutActionsSupport": {},
"settingsAboutVersion": "verze {version}",
"@settingsAboutVersion": {
"placeholders": {
"version": {
"type": "String"
}
}
},
"settingsNetworkOptionsStreamFormat": "Preferovaný formát pro streamování",
"@settingsNetworkOptionsStreamFormat": {},
"settingsNetworkOptionsStreamFormatServerDefault": "Použít nastavení serveru",
"@settingsNetworkOptionsStreamFormatServerDefault": {},
"settingsResetActionsClearImageCache": "Smazat mezipaměť obrázků",
"@settingsResetActionsClearImageCache": {},
"settingsResetName": "Resetovat",
"@settingsResetName": {},
"settingsServersFieldsName": "Jméno",
"@settingsServersFieldsName": {},
"settingsAboutName": "O aplikaci",
"@settingsAboutName": {},
"actionsDownloadCancel": "Zrušit stahování",
"@actionsDownloadCancel": {},
"actionsDelete": "Smazat",
"@actionsDelete": {}
} }

View File

@ -192,85 +192,5 @@
"settingsServersOptionsForcePlaintextPasswordDescriptionOn": "Passwort als Klartext senden (Veraltet, stellen Sie sicher, dass Ihre Verbindung sicher ist!)", "settingsServersOptionsForcePlaintextPasswordDescriptionOn": "Passwort als Klartext senden (Veraltet, stellen Sie sicher, dass Ihre Verbindung sicher ist!)",
"@settingsServersOptionsForcePlaintextPasswordDescriptionOn": {}, "@settingsServersOptionsForcePlaintextPasswordDescriptionOn": {},
"settingsServersOptionsForcePlaintextPasswordTitle": "Erzwinge Klartextpasswort", "settingsServersOptionsForcePlaintextPasswordTitle": "Erzwinge Klartextpasswort",
"@settingsServersOptionsForcePlaintextPasswordTitle": {}, "@settingsServersOptionsForcePlaintextPasswordTitle": {}
"actionsDelete": "Löschen",
"@actionsDelete": {},
"actionsDownload": "Herunterladen",
"@actionsDownload": {},
"actionsDownloadCancel": "Download abbrechen",
"@actionsDownloadCancel": {},
"controlsShuffle": "Zufall",
"@controlsShuffle": {},
"actionsCancel": "Abbrechen",
"@actionsCancel": {},
"actionsDownloadDelete": "Heruntergeladene Inhalte löschen",
"@actionsDownloadDelete": {},
"actionsOk": "OK",
"@actionsOk": {},
"resourcesAlbumCount": "{count,plural, =1{{count} Album} other{{count} Alben}}",
"@resourcesAlbumCount": {
"placeholders": {
"count": {
"type": "int"
}
}
},
"resourcesFilterAlbum": "Album",
"@resourcesFilterAlbum": {},
"resourcesArtistCount": "{count,plural, =1{{count} Künstler} other{{count} Künstler}}",
"@resourcesArtistCount": {
"placeholders": {
"count": {
"type": "int"
}
}
},
"resourcesFilterArtist": "Künstler",
"@resourcesFilterArtist": {},
"resourcesFilterOwner": "Besitzer",
"@resourcesFilterOwner": {},
"resourcesFilterYear": "Jahr",
"@resourcesFilterYear": {},
"resourcesPlaylistCount": "{count,plural, =1{{count} Playlist} other{{count} Playlists}}",
"@resourcesPlaylistCount": {
"placeholders": {
"count": {
"type": "int"
}
}
},
"resourcesSongCount": "{count,plural, =1{{count} Song} other{{count} Songs}}",
"@resourcesSongCount": {
"placeholders": {
"count": {
"type": "int"
}
}
},
"resourcesSongListDeleteAllContent": "Hierdurch werden alle heruntergeladenen Inhalte entfernt.",
"@resourcesSongListDeleteAllContent": {},
"resourcesSortByAlbum": "Album",
"@resourcesSortByAlbum": {},
"resourcesSortByAlbumCount": "Albenanzahl",
"@resourcesSortByAlbumCount": {},
"resourcesSortByTitle": "Titel",
"@resourcesSortByTitle": {},
"resourcesSortByUpdated": "Kürzlich hinzugefügt",
"@resourcesSortByUpdated": {},
"settingsAboutActionsSupport": "Den Entwickler unterstützen",
"@settingsAboutActionsSupport": {},
"settingsNetworkOptionsOfflineMode": "Offline Modus",
"@settingsNetworkOptionsOfflineMode": {},
"settingsNetworkOptionsOfflineModeOff": "Nutze das Internet um Musik zu synchronisieren.",
"@settingsNetworkOptionsOfflineModeOff": {},
"settingsNetworkOptionsOfflineModeOn": "Nutze nicht das Internet um Musik zu synchronisieren.",
"@settingsNetworkOptionsOfflineModeOn": {},
"settingsNetworkOptionsStreamFormat": "Bevorzugtes Streaming-Format",
"@settingsNetworkOptionsStreamFormat": {},
"settingsServersFieldsName": "Name",
"@settingsServersFieldsName": {},
"resourcesSongListDeleteAllTitle": "Downloads löschen?",
"@resourcesSongListDeleteAllTitle": {},
"settingsNetworkOptionsStreamFormatServerDefault": "Server-Standard verwenden",
"@settingsNetworkOptionsStreamFormatServerDefault": {}
} }

View File

@ -173,10 +173,6 @@
"@settingsAboutActionsSupport": {}, "@settingsAboutActionsSupport": {},
"settingsAboutName": "About", "settingsAboutName": "About",
"@settingsAboutName": {}, "@settingsAboutName": {},
"settingsAboutShareLogs": "Share logs",
"@settingsAboutShareLogs": {},
"settingsAboutChooseLog": "Choose a log file",
"@settingsAboutChooseLog": {},
"settingsAboutVersion": "version {version}", "settingsAboutVersion": "version {version}",
"@settingsAboutVersion": { "@settingsAboutVersion": {
"placeholders": { "placeholders": {

View File

@ -1,7 +1,7 @@
{ {
"actionsStar": "Favorito", "actionsStar": "Estrella",
"@actionsStar": {}, "@actionsStar": {},
"actionsUnstar": "Retirar favorito", "actionsUnstar": "Retirar estrella",
"@actionsUnstar": {}, "@actionsUnstar": {},
"messagesNothingHere": "Nada aquí…", "messagesNothingHere": "Nada aquí…",
"@messagesNothingHere": {}, "@messagesNothingHere": {},
@ -192,19 +192,5 @@
"settingsServersOptionsForcePlaintextPasswordDescriptionOn": "Enviar contraseña en texto plano (¡legado, asegúrese de que su conexión sea segura!)", "settingsServersOptionsForcePlaintextPasswordDescriptionOn": "Enviar contraseña en texto plano (¡legado, asegúrese de que su conexión sea segura!)",
"@settingsServersOptionsForcePlaintextPasswordDescriptionOn": {}, "@settingsServersOptionsForcePlaintextPasswordDescriptionOn": {},
"settingsServersOptionsForcePlaintextPasswordTitle": "Forzar contraseña de texto sin formato", "settingsServersOptionsForcePlaintextPasswordTitle": "Forzar contraseña de texto sin formato",
"@settingsServersOptionsForcePlaintextPasswordTitle": {}, "@settingsServersOptionsForcePlaintextPasswordTitle": {}
"actionsDelete": "Borrar",
"@actionsDelete": {},
"actionsOk": "Ok",
"@actionsOk": {},
"actionsDownload": "Descargar",
"@actionsDownload": {},
"actionsDownloadCancel": "Anular descargar",
"@actionsDownloadCancel": {},
"controlsShuffle": "Reproducir aleatoriamente",
"@controlsShuffle": {},
"actionsCancel": "Cancelar",
"@actionsCancel": {},
"actionsDownloadDelete": "Eliminar descargado",
"@actionsDownloadDelete": {}
} }

View File

@ -192,89 +192,5 @@
"settingsServersOptionsForcePlaintextPasswordDescriptionOn": "Enviar contrasinal en texto plano (herdado, pon coidado en que a conexión sexa segura!)", "settingsServersOptionsForcePlaintextPasswordDescriptionOn": "Enviar contrasinal en texto plano (herdado, pon coidado en que a conexión sexa segura!)",
"@settingsServersOptionsForcePlaintextPasswordDescriptionOn": {}, "@settingsServersOptionsForcePlaintextPasswordDescriptionOn": {},
"settingsServersOptionsForcePlaintextPasswordTitle": "Forzar contrasinal en texto plano", "settingsServersOptionsForcePlaintextPasswordTitle": "Forzar contrasinal en texto plano",
"@settingsServersOptionsForcePlaintextPasswordTitle": {}, "@settingsServersOptionsForcePlaintextPasswordTitle": {}
"actionsCancel": "Cancelar",
"@actionsCancel": {},
"actionsDelete": "Eliminar",
"@actionsDelete": {},
"actionsDownload": "Descargar",
"@actionsDownload": {},
"actionsDownloadCancel": "Cancelar a descarga",
"@actionsDownloadCancel": {},
"actionsDownloadDelete": "Eliminar o descargado",
"@actionsDownloadDelete": {},
"actionsOk": "OK",
"@actionsOk": {},
"controlsShuffle": "Barallar",
"@controlsShuffle": {},
"resourcesAlbumCount": "{count,plural, =1{{count} álbum} other{{count} álbums}}",
"@resourcesAlbumCount": {
"placeholders": {
"count": {
"type": "int"
}
}
},
"resourcesArtistCount": "{count,plural, =1{{count} artista} other{{count} artistas}}",
"@resourcesArtistCount": {
"placeholders": {
"count": {
"type": "int"
}
}
},
"resourcesFilterAlbum": "Álbum",
"@resourcesFilterAlbum": {},
"resourcesFilterArtist": "Artista",
"@resourcesFilterArtist": {},
"resourcesFilterOwner": "Dono",
"@resourcesFilterOwner": {},
"resourcesFilterYear": "Ano",
"@resourcesFilterYear": {},
"resourcesPlaylistCount": "{count,plural, =1{{count} lista} other{{count} listas}}",
"@resourcesPlaylistCount": {
"placeholders": {
"count": {
"type": "int"
}
}
},
"resourcesSongCount": "{count,plural, =1{{count} canción} other{{count} cancións}}",
"@resourcesSongCount": {
"placeholders": {
"count": {
"type": "int"
}
}
},
"resourcesSongListDeleteAllContent": "Vas eliminar todas as cancións descargadas.",
"@resourcesSongListDeleteAllContent": {},
"resourcesSongListDeleteAllTitle": "Eliminar descargas?",
"@resourcesSongListDeleteAllTitle": {},
"resourcesSortByAlbum": "Álbum",
"@resourcesSortByAlbum": {},
"resourcesSortByAlbumCount": "Número de álbums",
"@resourcesSortByAlbumCount": {},
"settingsAboutActionsSupport": "Axuda ao desenvolvemento 💜",
"@settingsAboutActionsSupport": {},
"settingsNetworkOptionsOfflineMode": "Modo sen conexión",
"@settingsNetworkOptionsOfflineMode": {},
"settingsNetworkOptionsOfflineModeOff": "Usa internet para sincr. música.",
"@settingsNetworkOptionsOfflineModeOff": {},
"settingsNetworkOptionsOfflineModeOn": "Non usar internet para sincr. ou reproducir música.",
"@settingsNetworkOptionsOfflineModeOn": {},
"settingsNetworkOptionsStreamFormat": "Modo de reprodución preferido",
"@settingsNetworkOptionsStreamFormat": {},
"settingsNetworkOptionsStreamFormatServerDefault": "Usar por defecto do servidor",
"@settingsNetworkOptionsStreamFormatServerDefault": {},
"settingsServersFieldsName": "Nome",
"@settingsServersFieldsName": {},
"resourcesSortByTitle": "Título",
"@resourcesSortByTitle": {},
"resourcesSortByUpdated": "Actualizado recentemente",
"@resourcesSortByUpdated": {},
"settingsAboutShareLogs": "Compartir rexistros",
"@settingsAboutShareLogs": {},
"settingsAboutChooseLog": "Escolle un ficheiro de rexistro",
"@settingsAboutChooseLog": {}
} }

View File

@ -192,39 +192,5 @@
"settingsServersOptionsForcePlaintextPasswordDescriptionOn": "Enviar senha em texto simples (antigo, certifique-se que a sua ligação é segura!)", "settingsServersOptionsForcePlaintextPasswordDescriptionOn": "Enviar senha em texto simples (antigo, certifique-se que a sua ligação é segura!)",
"@settingsServersOptionsForcePlaintextPasswordDescriptionOn": {}, "@settingsServersOptionsForcePlaintextPasswordDescriptionOn": {},
"settingsServersOptionsForcePlaintextPasswordTitle": "Forçar password em texto simples", "settingsServersOptionsForcePlaintextPasswordTitle": "Forçar password em texto simples",
"@settingsServersOptionsForcePlaintextPasswordTitle": {}, "@settingsServersOptionsForcePlaintextPasswordTitle": {}
"actionsCancel": "Cancelar",
"@actionsCancel": {},
"actionsDelete": "Apagar",
"@actionsDelete": {},
"actionsDownload": "Descarregar",
"@actionsDownload": {},
"actionsDownloadCancel": "Cancelar descarga",
"@actionsDownloadCancel": {},
"actionsDownloadDelete": "Apagar descarga",
"@actionsDownloadDelete": {},
"resourcesFilterAlbum": "Álbum",
"@resourcesFilterAlbum": {},
"resourcesFilterArtist": "Artista",
"@resourcesFilterArtist": {},
"resourcesFilterYear": "Ano",
"@resourcesFilterYear": {},
"resourcesSortByAlbum": "Álbum",
"@resourcesSortByAlbum": {},
"settingsAboutActionsSupport": "Apoie o programador 💜",
"@settingsAboutActionsSupport": {},
"settingsNetworkOptionsOfflineMode": "Modo offline",
"@settingsNetworkOptionsOfflineMode": {},
"settingsNetworkOptionsOfflineModeOff": "Usar a internet para sincronizar música.",
"@settingsNetworkOptionsOfflineModeOff": {},
"settingsNetworkOptionsOfflineModeOn": "Não usar a internet para sincronizar ou tocar música.",
"@settingsNetworkOptionsOfflineModeOn": {},
"settingsNetworkOptionsStreamFormat": "Formato preferido de streaming",
"@settingsNetworkOptionsStreamFormat": {},
"resourcesSortByTitle": "Título",
"@resourcesSortByTitle": {},
"actionsOk": "OK",
"@actionsOk": {},
"controlsShuffle": "Aleatório",
"@controlsShuffle": {}
} }

View File

@ -73,7 +73,7 @@
}, },
"resourcesSortByAdded": "Недавно добавленные", "resourcesSortByAdded": "Недавно добавленные",
"@resourcesSortByAdded": {}, "@resourcesSortByAdded": {},
"resourcesSortByArtist": "По исполнителям", "resourcesSortByArtist": "По исполнителю",
"@resourcesSortByArtist": {}, "@resourcesSortByArtist": {},
"resourcesSortByFrequentlyPlayed": "Часто проигрываемые", "resourcesSortByFrequentlyPlayed": "Часто проигрываемые",
"@resourcesSortByFrequentlyPlayed": {}, "@resourcesSortByFrequentlyPlayed": {},
@ -192,89 +192,5 @@
"settingsServersOptionsForcePlaintextPasswordDescriptionOn": "Отправить пароль в виде текста (устарело, убедитесь, что ваше соединение безопасно!)", "settingsServersOptionsForcePlaintextPasswordDescriptionOn": "Отправить пароль в виде текста (устарело, убедитесь, что ваше соединение безопасно!)",
"@settingsServersOptionsForcePlaintextPasswordDescriptionOn": {}, "@settingsServersOptionsForcePlaintextPasswordDescriptionOn": {},
"settingsServersOptionsForcePlaintextPasswordTitle": "Принудительно использовать текстовой пароль", "settingsServersOptionsForcePlaintextPasswordTitle": "Принудительно использовать текстовой пароль",
"@settingsServersOptionsForcePlaintextPasswordTitle": {}, "@settingsServersOptionsForcePlaintextPasswordTitle": {}
"settingsAboutShareLogs": "Поделиться журналами",
"@settingsAboutShareLogs": {},
"settingsAboutChooseLog": "Выбрать файл журнала",
"@settingsAboutChooseLog": {},
"settingsNetworkOptionsStreamFormatServerDefault": "Использовать сервер по умолчанию",
"@settingsNetworkOptionsStreamFormatServerDefault": {},
"actionsDownload": "Скачать",
"@actionsDownload": {},
"actionsDownloadCancel": "Отменить загрузку",
"@actionsDownloadCancel": {},
"actionsCancel": "Отменить",
"@actionsCancel": {},
"resourcesSongCount": "{count,plural, =1{{count} трек} other{{count} треки}}",
"@resourcesSongCount": {
"placeholders": {
"count": {
"type": "int"
}
}
},
"resourcesSortByAlbum": "По альбомам",
"@resourcesSortByAlbum": {},
"resourcesSortByTitle": "По заголовку",
"@resourcesSortByTitle": {},
"resourcesSortByUpdated": "По недавно обновленному",
"@resourcesSortByUpdated": {},
"resourcesSortByAlbumCount": "По количеству альбомов",
"@resourcesSortByAlbumCount": {},
"settingsNetworkOptionsOfflineMode": "Автономный режим",
"@settingsNetworkOptionsOfflineMode": {},
"settingsNetworkOptionsOfflineModeOff": "Использовать интернет для синхронизации музыки.",
"@settingsNetworkOptionsOfflineModeOff": {},
"settingsServersFieldsName": "Имя",
"@settingsServersFieldsName": {},
"actionsDelete": "Удалить",
"@actionsDelete": {},
"actionsDownloadDelete": "Удалить загруженное",
"@actionsDownloadDelete": {},
"actionsOk": "ОК",
"@actionsOk": {},
"controlsShuffle": "Перемешать",
"@controlsShuffle": {},
"resourcesFilterArtist": "По исполнителю",
"@resourcesFilterArtist": {},
"resourcesFilterAlbum": "По альбомам",
"@resourcesFilterAlbum": {},
"resourcesFilterYear": "По годам",
"@resourcesFilterYear": {},
"resourcesFilterOwner": "По владельцу",
"@resourcesFilterOwner": {},
"resourcesSongListDeleteAllContent": "Это удалит все загруженные файлы песен.",
"@resourcesSongListDeleteAllContent": {},
"settingsNetworkOptionsStreamFormat": "Предпочтительный формат потока",
"@settingsNetworkOptionsStreamFormat": {},
"resourcesSongListDeleteAllTitle": "Удалить загрузки?",
"@resourcesSongListDeleteAllTitle": {},
"settingsNetworkOptionsOfflineModeOn": "Не использовать интернет для синхронизации или воспроизведения музыки.",
"@settingsNetworkOptionsOfflineModeOn": {},
"settingsAboutActionsSupport": "Поддержать разработчика",
"@settingsAboutActionsSupport": {},
"resourcesArtistCount": "{count,plural, =1{{count} исполнитель} other{{count} исполнители}}",
"@resourcesArtistCount": {
"placeholders": {
"count": {
"type": "int"
}
}
},
"resourcesPlaylistCount": "{count,plural, =1{{count} плейлист} other{{count} плейлисты}}",
"@resourcesPlaylistCount": {
"placeholders": {
"count": {
"type": "int"
}
}
},
"resourcesAlbumCount": "{count,plural, =1{{count} альбом} other{{count} альбомы}}",
"@resourcesAlbumCount": {
"placeholders": {
"count": {
"type": "int"
}
}
}
} }

View File

@ -192,39 +192,5 @@
"settingsServersOptionsForcePlaintextPasswordDescriptionOn": "密码以明文发送(不推荐,注意链接安全!)", "settingsServersOptionsForcePlaintextPasswordDescriptionOn": "密码以明文发送(不推荐,注意链接安全!)",
"@settingsServersOptionsForcePlaintextPasswordDescriptionOn": {}, "@settingsServersOptionsForcePlaintextPasswordDescriptionOn": {},
"settingsServersOptionsForcePlaintextPasswordTitle": "强制使用明文密码", "settingsServersOptionsForcePlaintextPasswordTitle": "强制使用明文密码",
"@settingsServersOptionsForcePlaintextPasswordTitle": {}, "@settingsServersOptionsForcePlaintextPasswordTitle": {}
"actionsDownload": "下载",
"@actionsDownload": {},
"actionsDownloadCancel": "取消下载",
"@actionsDownloadCancel": {},
"actionsDownloadDelete": "删除已下载",
"@actionsDownloadDelete": {},
"actionsOk": "确定",
"@actionsOk": {},
"resourcesFilterArtist": "歌手",
"@resourcesFilterArtist": {},
"resourcesFilterOwner": "所有者",
"@resourcesFilterOwner": {},
"resourcesSongListDeleteAllTitle": "删除下载?",
"@resourcesSongListDeleteAllTitle": {},
"resourcesSortByAlbum": "专辑",
"@resourcesSortByAlbum": {},
"resourcesSortByAlbumCount": "专辑数量",
"@resourcesSortByAlbumCount": {},
"resourcesSortByUpdated": "最近添加",
"@resourcesSortByUpdated": {},
"settingsAboutActionsSupport": "支持开发者",
"@settingsAboutActionsSupport": {},
"resourcesFilterAlbum": "专辑",
"@resourcesFilterAlbum": {},
"resourcesSortByTitle": "标题",
"@resourcesSortByTitle": {},
"actionsCancel": "取消",
"@actionsCancel": {},
"actionsDelete": "删除",
"@actionsDelete": {},
"resourcesFilterYear": "年份",
"@resourcesFilterYear": {},
"resourcesSongListDeleteAllContent": "该操作会删除所有已下载的歌曲文件。",
"@resourcesSongListDeleteAllContent": {}
} }

View File

@ -1,209 +0,0 @@
// import 'dart:convert';
import 'dart:io';
import 'package:collection/collection.dart';
import 'package:flutter/foundation.dart';
import 'package:logging/logging.dart';
import 'package:path/path.dart' as p;
import 'package:path_provider/path_provider.dart';
class AnsiColor {
/// ANSI Control Sequence Introducer, signals the terminal for new settings.
static const ansiEsc = '\x1B[';
/// Reset all colors and options for current SGRs to terminal defaults.
static const ansiDefault = '${ansiEsc}0m';
final int? fg;
final int? bg;
final bool color;
AnsiColor.none()
: fg = null,
bg = null,
color = false;
AnsiColor.fg(this.fg)
: bg = null,
color = true;
AnsiColor.bg(this.bg)
: fg = null,
color = true;
@override
String toString() {
if (fg != null) {
return '${ansiEsc}38;5;${fg}m';
} else if (bg != null) {
return '${ansiEsc}48;5;${bg}m';
} else {
return '';
}
}
String call(String msg) {
if (color) {
// ignore: unnecessary_brace_in_string_interps
return '${this}$msg$ansiDefault';
} else {
return msg;
}
}
AnsiColor toFg() => AnsiColor.fg(bg);
AnsiColor toBg() => AnsiColor.bg(fg);
/// Defaults the terminal's foreground color without altering the background.
String get resetForeground => color ? '${ansiEsc}39m' : '';
/// Defaults the terminal's background color without altering the foreground.
String get resetBackground => color ? '${ansiEsc}49m' : '';
static int grey(double level) => 232 + (level.clamp(0.0, 1.0) * 23).round();
}
final levelColors = {
Level.FINEST: AnsiColor.fg(AnsiColor.grey(0.5)),
Level.FINER: AnsiColor.fg(AnsiColor.grey(0.5)),
Level.FINE: AnsiColor.fg(AnsiColor.grey(0.5)),
Level.CONFIG: AnsiColor.fg(81),
Level.INFO: AnsiColor.fg(12),
Level.WARNING: AnsiColor.fg(208),
Level.SEVERE: AnsiColor.fg(196),
Level.SHOUT: AnsiColor.fg(199),
};
class LogData {
final String? message;
final Object? data;
const LogData(this.message, this.data);
}
String _format(
LogRecord event, {
bool color = false,
bool time = true,
bool level = true,
bool redact = true,
}) {
var message = '';
if (time) message += '${event.time.toIso8601String()} ';
if (level) message += '${event.level.name} ';
final object = event.object;
if (object is LogData) {
message += '${object.message}';
message += '\n${object.data}';
} else if (object != null) {
message += 'Object';
message += '\n$object';
} else {
message += event.message;
}
if (event.error != null) {
message += '\n${event.error}';
}
if (redact) {
message = _redactUrl(message);
}
if (event.stackTrace != null) {
message += '\n${event.stackTrace}';
}
return color
? message.split('\n').map((e) => levelColors[event.level]!(e)).join('\n')
: message;
}
String _redactUrl(String message) {
if (!_queryReplace('u').hasMatch(message)) {
return message;
}
message = _redactParam(message, 'u');
message = _redactParam(message, 'p');
message = _redactParam(message, 's');
message = _redactParam(message, 't');
return message;
}
RegExp _queryReplace(String key) => RegExp('$key=([^&|\\n|\\t\\s]+)');
String _redactParam(String url, String key) =>
url.replaceAll(_queryReplace(key), '$key=REDACTED');
Future<Directory> logDirectory() async {
return Directory(
p.join((await getApplicationDocumentsDirectory()).path, 'logs'),
);
}
Future<List<File>> logFiles() async {
final dir = await logDirectory();
return dir.listSync().whereType<File>().toList()
..sort(
(a, b) => b.statSync().modified.compareTo(a.statSync().modified),
);
}
File _currentLogFile(String logDir) {
final now = DateTime.now();
return File(p.join(logDir, '${now.year}-${now.month}-${now.day}.txt'));
}
Future<void> _printFile(String event, String logDir) async {
final file = _currentLogFile(logDir);
if (!event.endsWith('\n')) {
event += '\n';
}
await file.writeAsString(event, mode: FileMode.writeOnlyAppend, flush: true);
}
void _printDebug(LogRecord event) {
// ignore: avoid_print
print(_format(event, color: true, time: false, level: false, redact: false));
}
Future<void> _printRelease(LogRecord event, String logDir) async {
await _printFile(
_format(event, color: false, time: true, level: true, redact: true),
logDir,
);
}
final log = Logger('default');
Future<void> initLogging() async {
final dir = (await logDirectory())..create();
final file = _currentLogFile(dir.path);
if (!(await file.exists())) {
await file.create();
}
final files = await logFiles();
if (files.length > 7) {
for (var file in files.slice(7)) {
await file.delete();
}
}
Logger.root.level = kDebugMode ? Level.ALL : Level.INFO;
Logger.root.onRecord.asyncMap((event) async {
if (kDebugMode) {
_printDebug(event);
} else {
await _printRelease(event, dir.path);
}
}).listen((_) {}, cancelOnError: false);
}

View File

@ -4,7 +4,6 @@ import 'package:stack_trace/stack_trace.dart' as stack_trace;
import 'package:worker_manager/worker_manager.dart'; import 'package:worker_manager/worker_manager.dart';
import 'app/app.dart'; import 'app/app.dart';
import 'log.dart';
void main() async { void main() async {
// TOOD: probably remove before live // TOOD: probably remove before live
@ -19,8 +18,5 @@ void main() async {
await Executor().warmUp(); await Executor().warmUp();
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
await initLogging();
runApp(const ProviderScope(child: MyApp())); runApp(const ProviderScope(child: MyApp()));
} }

View File

@ -68,8 +68,7 @@ enum QueueContextType {
album('album'), album('album'),
playlist('playlist'), playlist('playlist'),
library('library'), library('library'),
genre('genre'), genre('genre');
artist('artist');
const QueueContextType(this.value); const QueueContextType(this.value);
final String value; final String value;

View File

@ -28,7 +28,6 @@ const _$QueueContextTypeEnumMap = {
QueueContextType.playlist: 'playlist', QueueContextType.playlist: 'playlist',
QueueContextType.library: 'library', QueueContextType.library: 'library',
QueueContextType.genre: 'genre', QueueContextType.genre: 'genre',
QueueContextType.artist: 'artist',
}; };
_$_MediaItemData _$$_MediaItemDataFromJson(Map<String, dynamic> json) => _$_MediaItemData _$$_MediaItemDataFromJson(Map<String, dynamic> json) =>

View File

@ -4,6 +4,7 @@ import 'dart:math';
import 'package:audio_service/audio_service.dart'; import 'package:audio_service/audio_service.dart';
import 'package:collection/collection.dart'; import 'package:collection/collection.dart';
import 'package:drift/drift.dart' show Value; import 'package:drift/drift.dart' show Value;
import 'package:flutter/foundation.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:just_audio/just_audio.dart'; import 'package:just_audio/just_audio.dart';
import 'package:pool/pool.dart'; import 'package:pool/pool.dart';
@ -13,7 +14,6 @@ import 'package:synchronized/synchronized.dart';
import '../cache/image_cache.dart'; import '../cache/image_cache.dart';
import '../database/database.dart'; import '../database/database.dart';
import '../log.dart';
import '../models/music.dart'; import '../models/music.dart';
import '../models/query.dart'; import '../models/query.dart';
import '../models/support.dart'; import '../models/support.dart';
@ -122,10 +122,6 @@ class AudioControl extends BaseAudioHandler with QueueHandler, SeekHandler {
)); ));
}); });
_player.playbackEventStream.doOnError((e, st) async {
log.warning('playbackEventStream', e, st);
});
shuffleIndicies.listen((value) { shuffleIndicies.listen((value) {
playbackState.add(playbackState.value.copyWith( playbackState.add(playbackState.value.copyWith(
shuffleMode: value != null shuffleMode: value != null
@ -141,7 +137,7 @@ class AudioControl extends BaseAudioHandler with QueueHandler, SeekHandler {
_player.processingStateStream.listen((event) async { _player.processingStateStream.listen((event) async {
if (event == ProcessingState.completed) { if (event == ProcessingState.completed) {
if (_audioSource.length > 0) { if (_audioSource.length > 0) {
log.fine('completed'); yell('completed');
await stop(); await stop();
await seek(Duration.zero); await seek(Duration.zero);
} }
@ -390,7 +386,7 @@ class AudioControl extends BaseAudioHandler with QueueHandler, SeekHandler {
mediaItem.add(slice.current!.mediaItem); mediaItem.add(slice.current!.mediaItem);
queue.add(list.map((e) => e.mediaItem).toList()); queue.add(list.map((e) => e.mediaItem).toList());
log.fine('addAll'); yell('addAll');
await _audioSource.addAll(list.map((e) => e.audioSource).toList()); await _audioSource.addAll(list.map((e) => e.audioSource).toList());
await _player.seek(Duration.zero, index: list.indexOf(slice.current!)); await _player.seek(Duration.zero, index: list.indexOf(slice.current!));
} }
@ -414,7 +410,7 @@ class AudioControl extends BaseAudioHandler with QueueHandler, SeekHandler {
final sourceNeedsPrev = sourceIndex == 0; final sourceNeedsPrev = sourceIndex == 0;
if (sourceNeedsNext && slice.next != null) { if (sourceNeedsNext && slice.next != null) {
log.fine('add'); yell('add');
await _audioSource.add(slice.next!.audioSource); await _audioSource.add(slice.next!.audioSource);
} }
if (sourceNeedsPrev && slice.prev != null) { if (sourceNeedsPrev && slice.prev != null) {
@ -501,7 +497,7 @@ class AudioControl extends BaseAudioHandler with QueueHandler, SeekHandler {
} }
Future<void> _insertFirstAudioSource(AudioSource source) { Future<void> _insertFirstAudioSource(AudioSource source) {
log.fine('insert'); yell('insert');
final wait = _audioSource.insert(0, source); final wait = _audioSource.insert(0, source);
_currentIndexIgnore.add(1); _currentIndexIgnore.add(1);
return wait; return wait;
@ -509,20 +505,20 @@ class AudioControl extends BaseAudioHandler with QueueHandler, SeekHandler {
Future<void> _pruneAudioSources(int keepIndex) async { Future<void> _pruneAudioSources(int keepIndex) async {
if (keepIndex > 0) { if (keepIndex > 0) {
log.fine('removeRange 0'); yell('removeRange 0');
final wait = _audioSource.removeRange(0, keepIndex); final wait = _audioSource.removeRange(0, keepIndex);
_currentIndexIgnore.add(0); _currentIndexIgnore.add(0);
await wait; await wait;
} }
if (_audioSource.length > 1) { if (_audioSource.length > 1) {
log.fine('removeRange 1'); yell('removeRange 1');
await _audioSource.removeRange(1, _audioSource.length); await _audioSource.removeRange(1, _audioSource.length);
} }
} }
Future<void> _clearAudioSource([bool clearMetadata = false]) async { Future<void> _clearAudioSource([bool clearMetadata = false]) async {
// await _player.stop(); // await _player.stop();
log.fine('_clearAudioSource'); yell('_clearAudioSource');
await _audioSource.clear(); await _audioSource.clear();
if (clearMetadata) { if (clearMetadata) {
@ -701,3 +697,11 @@ class AudioControl extends BaseAudioHandler with QueueHandler, SeekHandler {
} }
} }
} }
void yell(String msg) {
if (kDebugMode) {
print('=================================================================<');
print(msg);
print('=================================================================>');
}
}

View File

@ -214,7 +214,7 @@ class DownloadService extends _$DownloadService {
Future<void> deleteAll(int sourceId) async { Future<void> deleteAll(int sourceId) async {
final db = ref.read(databaseProvider); final db = ref.read(databaseProvider);
final albumIds = await db.albumIdsWithDownloadStatus(sourceId).get(); final albumIds = await db.albumIdsWithDownloaded(sourceId).get();
for (var id in albumIds) { for (var id in albumIds) {
await deleteAlbum(await (db.albumById(sourceId, id)).getSingle()); await deleteAlbum(await (db.albumById(sourceId, id)).getSingle());
} }

View File

@ -6,7 +6,7 @@ part of 'download_service.dart';
// RiverpodGenerator // RiverpodGenerator
// ************************************************************************** // **************************************************************************
String _$downloadServiceHash() => r'c72c49f980e307f3013467e76b6564d14a34a736'; String _$downloadServiceHash() => r'92e963b5c070f4d1edb0cd81899b16393c2b9a70';
/// See also [DownloadService]. /// See also [DownloadService].
@ProviderFor(DownloadService) @ProviderFor(DownloadService)

View File

@ -46,15 +46,13 @@ class SettingsService extends _$SettingsService {
features: IList(), features: IList(),
username: subsonic.username.value, username: subsonic.username.value,
password: subsonic.password.value, password: subsonic.password.value,
useTokenAuth: subsonic.useTokenAuth.value, useTokenAuth: true,
isActive: true, isActive: true,
createdAt: DateTime.now(), createdAt: DateTime.now(),
), ),
ref.read(httpClientProvider), ref.read(httpClientProvider),
); );
await client.test();
final features = IList([ final features = IList([
if (await client.testFeature(SubsonicFeature.emptyQuerySearch)) if (await client.testFeature(SubsonicFeature.emptyQuerySearch))
SubsonicFeature.emptyQuerySearch, SubsonicFeature.emptyQuerySearch,
@ -68,10 +66,6 @@ class SettingsService extends _$SettingsService {
} }
Future<void> updateSource(SubsonicSettings source) async { Future<void> updateSource(SubsonicSettings source) async {
final client = SubsonicClient(source, ref.read(httpClientProvider));
await client.test();
await _db.updateSource(source); await _db.updateSource(source);
await init(); await init();
} }

View File

@ -31,7 +31,7 @@ class SyncService extends _$SyncService {
final source = ref.read(musicSourceProvider); final source = ref.read(musicSourceProvider);
final db = ref.read(databaseProvider); final db = ref.read(databaseProvider);
final ids = <String>{}; final ids = <String>[];
await for (var artists in source.allArtists()) { await for (var artists in source.allArtists()) {
ids.addAll(artists.map((e) => e.id.value)); ids.addAll(artists.map((e) => e.id.value));
await db.saveArtists(artists); await db.saveArtists(artists);
@ -44,7 +44,7 @@ class SyncService extends _$SyncService {
final source = ref.read(musicSourceProvider); final source = ref.read(musicSourceProvider);
final db = ref.read(databaseProvider); final db = ref.read(databaseProvider);
final ids = <String>{}; final ids = <String>[];
await for (var albums in source.allAlbums()) { await for (var albums in source.allAlbums()) {
ids.addAll(albums.map((e) => e.id.value)); ids.addAll(albums.map((e) => e.id.value));
await db.saveAlbums(albums); await db.saveAlbums(albums);
@ -57,7 +57,7 @@ class SyncService extends _$SyncService {
final source = ref.read(musicSourceProvider); final source = ref.read(musicSourceProvider);
final db = ref.read(databaseProvider); final db = ref.read(databaseProvider);
final ids = <String>{}; final ids = <String>[];
await for (var playlists in source.allPlaylists()) { await for (var playlists in source.allPlaylists()) {
ids.addAll(playlists.map((e) => e.playist.id.value)); ids.addAll(playlists.map((e) => e.playist.id.value));
await db.savePlaylists(playlists); await db.savePlaylists(playlists);
@ -70,7 +70,7 @@ class SyncService extends _$SyncService {
final source = ref.read(musicSourceProvider); final source = ref.read(musicSourceProvider);
final db = ref.read(databaseProvider); final db = ref.read(databaseProvider);
final ids = <String>{}; final ids = <String>[];
await for (var songs in source.allSongs()) { await for (var songs in source.allSongs()) {
ids.addAll(songs.map((e) => e.id.value)); ids.addAll(songs.map((e) => e.id.value));
await db.saveSongs(songs); await db.saveSongs(songs);

View File

@ -6,7 +6,7 @@ part of 'sync_service.dart';
// RiverpodGenerator // RiverpodGenerator
// ************************************************************************** // **************************************************************************
String _$syncServiceHash() => r'58ebee4e6f055b64ee6789ae43d63c0e15c679e0'; String _$syncServiceHash() => r'2b8da374c3143bc56f17115440d57bc70468a17e';
/// See also [SyncService]. /// See also [SyncService].
@ProviderFor(SyncService) @ProviderFor(SyncService)

View File

@ -1,8 +1,6 @@
import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:rxdart/rxdart.dart';
import '../database/database.dart'; import '../database/database.dart';
import '../log.dart';
import '../state/settings.dart'; import '../state/settings.dart';
abstract class BaseMusicSource { abstract class BaseMusicSource {
@ -42,33 +40,25 @@ class MusicSource implements BaseMusicSource {
@override @override
Stream<Iterable<AlbumsCompanion>> allAlbums() { Stream<Iterable<AlbumsCompanion>> allAlbums() {
_testOnline(); _testOnline();
return _source return _source.allAlbums();
.allAlbums()
.doOnError((e, st) => log.severe('allAlbums', e, st));
} }
@override @override
Stream<Iterable<ArtistsCompanion>> allArtists() { Stream<Iterable<ArtistsCompanion>> allArtists() {
_testOnline(); _testOnline();
return _source return _source.allArtists();
.allArtists()
.doOnError((e, st) => log.severe('allArtists', e, st));
} }
@override @override
Stream<Iterable<PlaylistWithSongsCompanion>> allPlaylists() { Stream<Iterable<PlaylistWithSongsCompanion>> allPlaylists() {
_testOnline(); _testOnline();
return _source return _source.allPlaylists();
.allPlaylists()
.doOnError((e, st) => log.severe('allPlaylists', e, st));
} }
@override @override
Stream<Iterable<SongsCompanion>> allSongs() { Stream<Iterable<SongsCompanion>> allSongs() {
_testOnline(); _testOnline();
return _source return _source.allSongs();
.allSongs()
.doOnError((e, st) => log.severe('allSongs', e, st));
} }
@override @override
@ -92,4 +82,10 @@ class MusicSource implements BaseMusicSource {
@override @override
Uri streamUri(String songId) => _source.streamUri(songId); Uri streamUri(String songId) => _source.streamUri(songId);
@override
bool operator ==(other) => other is BaseMusicSource && (other.id == id);
@override
int get hashCode => id;
} }

View File

@ -6,7 +6,6 @@ import 'package:crypto/crypto.dart';
import 'package:http/http.dart'; import 'package:http/http.dart';
import 'package:xml/xml.dart'; import 'package:xml/xml.dart';
import '../../log.dart';
import '../../models/settings.dart'; import '../../models/settings.dart';
import 'xml.dart'; import 'xml.dart';
@ -90,16 +89,12 @@ class SubsonicClient {
final subsonicResponse = final subsonicResponse =
SubsonicResponse(XmlDocument.parse(utf8.decode(res.bodyBytes))); SubsonicResponse(XmlDocument.parse(utf8.decode(res.bodyBytes)));
if (subsonicResponse.status == Status.failed) { if (subsonicResponse.status == Status.failed) {
final error = SubsonicException(subsonicResponse.xml); throw SubsonicException(subsonicResponse.xml);
log.severe('Subsonic error', error);
throw error;
} }
return subsonicResponse; return subsonicResponse;
} }
Future<void> test() => get('ping');
Future<bool> testFeature(SubsonicFeature feature) async { Future<bool> testFeature(SubsonicFeature feature) async {
switch (feature) { switch (feature) {
case SubsonicFeature.emptyQuerySearch: case SubsonicFeature.emptyQuerySearch:

View File

@ -290,14 +290,6 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.6.3" version: "1.6.3"
cross_file:
dependency: transitive
description:
name: cross_file
sha256: "0b0036e8cccbfbe0555fd83c1d31a6f30b77a96b598b35a5d36dd41f718695e9"
url: "https://pub.dev"
source: hosted
version: "0.3.3+4"
crypto: crypto:
dependency: "direct main" dependency: "direct main"
description: description:
@ -687,7 +679,7 @@ packages:
source: hosted source: hosted
version: "2.0.1" version: "2.0.1"
logging: logging:
dependency: "direct main" dependency: transitive
description: description:
name: logging name: logging
sha256: "04094f2eb032cbb06c6f6e8d3607edcfcb0455e2bb6cbc010cb01171dcb64e6d" sha256: "04094f2eb032cbb06c6f6e8d3607edcfcb0455e2bb6cbc010cb01171dcb64e6d"
@ -842,10 +834,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: path_provider_windows name: path_provider_windows
sha256: d3f80b32e83ec208ac95253e0cd4d298e104fbc63cb29c5c69edaed43b0c69d6 sha256: f53720498d5a543f9607db4b0e997c4b5438884de25b0f73098cc2671a51b130
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.1.6" version: "2.1.5"
pedantic: pedantic:
dependency: transitive dependency: transitive
description: description:
@ -958,22 +950,6 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.27.7" version: "0.27.7"
share_plus:
dependency: "direct main"
description:
name: share_plus
sha256: "322a1ec9d9fe07e2e2252c098ce93d12dbd06133cc4c00ffe6a4ef505c295c17"
url: "https://pub.dev"
source: hosted
version: "7.0.0"
share_plus_platform_interface:
dependency: transitive
description:
name: share_plus_platform_interface
sha256: "0c6e61471bd71b04a138b8b588fa388e66d8b005e6f2deda63371c5c505a0981"
url: "https://pub.dev"
source: hosted
version: "3.2.1"
shelf: shelf:
dependency: transitive dependency: transitive
description: description:
@ -1343,10 +1319,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: win32 name: win32
sha256: "5a751eddf9db89b3e5f9d50c20ab8612296e4e8db69009788d6c8b060a84191c" sha256: a6f0236dbda0f63aa9a25ad1ff9a9d8a4eaaa5012da0dc59d21afdb1dc361ca4
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "4.1.4" version: "3.1.4"
worker_manager: worker_manager:
dependency: "direct main" dependency: "direct main"
description: description:

View File

@ -4,7 +4,7 @@ homepage: https://github.com/austinried/subtracks
repository: https://github.com/austinried/subtracks repository: https://github.com/austinried/subtracks
issue_tracker: https://github.com/austinried/subtracks/issues issue_tracker: https://github.com/austinried/subtracks/issues
publish_to: 'none' publish_to: 'none'
version: 2.0.0-alpha.3+12 version: 2.0.0-alpha.1+10
environment: environment:
sdk: '>=2.19.2 <3.0.0' sdk: '>=2.19.2 <3.0.0'
@ -57,8 +57,6 @@ dependencies:
connectivity_plus: ^3.0.4 connectivity_plus: ^3.0.4
package_info_plus: ^3.1.1 package_info_plus: ^3.1.1
url_launcher: ^6.1.10 url_launcher: ^6.1.10
logging: ^1.1.1
share_plus: ^7.0.0
# https://github.com/dart-lang/intl/issues/522#issuecomment-1469961807 # https://github.com/dart-lang/intl/issues/522#issuecomment-1469961807
dependency_overrides: dependency_overrides: