summaryrefslogtreecommitdiff
path: root/lib/widgets/debug
diff options
context:
space:
mode:
Diffstat (limited to 'lib/widgets/debug')
-rw-r--r--lib/widgets/debug/app_debug_action.dart7
-rw-r--r--lib/widgets/debug/app_debug_page.dart136
-rw-r--r--lib/widgets/debug/cache.dart116
-rw-r--r--lib/widgets/debug/capabilities.dart136
-rw-r--r--lib/widgets/debug/colors.dart99
-rw-r--r--lib/widgets/debug/database.dart343
-rw-r--r--lib/widgets/debug/general.dart136
-rw-r--r--lib/widgets/debug/leaking.dart180
-rw-r--r--lib/widgets/debug/media_store_scan_dialog.dart51
-rw-r--r--lib/widgets/debug/os_apps.dart122
-rw-r--r--lib/widgets/debug/os_codecs.dart87
-rw-r--r--lib/widgets/debug/os_paths.dart49
-rw-r--r--lib/widgets/debug/os_storage.dart64
-rw-r--r--lib/widgets/debug/report.dart69
-rw-r--r--lib/widgets/debug/settings.dart95
15 files changed, 1690 insertions, 0 deletions
diff --git a/lib/widgets/debug/app_debug_action.dart b/lib/widgets/debug/app_debug_action.dart
new file mode 100644
index 0000000..d126cce
--- /dev/null
+++ b/lib/widgets/debug/app_debug_action.dart
@@ -0,0 +1,7 @@
+enum AppDebugAction {
+ prepScreenshotThumbnails,
+ prepScreenshotStats,
+ prepScreenshotCountries,
+ mediaStoreScanDir,
+ greenScreen,
+}
diff --git a/lib/widgets/debug/app_debug_page.dart b/lib/widgets/debug/app_debug_page.dart
new file mode 100644
index 0000000..3678b6b
--- /dev/null
+++ b/lib/widgets/debug/app_debug_page.dart
@@ -0,0 +1,136 @@
+import 'dart:async';
+
+import 'package:aves/model/favourites.dart';
+import 'package:aves/model/filters/covered/location.dart';
+import 'package:aves/model/filters/covered/tag.dart';
+import 'package:aves/model/filters/path.dart';
+import 'package:aves/model/settings/enums/accessibility_animations.dart';
+import 'package:aves/model/settings/settings.dart';
+import 'package:aves/model/source/collection_source.dart';
+import 'package:aves/widgets/common/basic/font_size_icon_theme.dart';
+import 'package:aves/widgets/common/basic/popup/menu_row.dart';
+import 'package:aves/widgets/common/basic/scaffold.dart';
+import 'package:aves/widgets/common/behaviour/pop/scope.dart';
+import 'package:aves/widgets/common/behaviour/pop/tv_navigation.dart';
+import 'package:aves/widgets/debug/app_debug_action.dart';
+import 'package:aves/widgets/debug/cache.dart';
+import 'package:aves/widgets/debug/capabilities.dart';
+import 'package:aves/widgets/debug/colors.dart';
+import 'package:aves/widgets/debug/database.dart';
+import 'package:aves/widgets/debug/general.dart';
+import 'package:aves/widgets/debug/leaking.dart';
+import 'package:aves/widgets/debug/media_store_scan_dialog.dart';
+import 'package:aves/widgets/debug/os_apps.dart';
+import 'package:aves/widgets/debug/os_codecs.dart';
+import 'package:aves/widgets/debug/os_paths.dart';
+import 'package:aves/widgets/debug/os_storage.dart';
+import 'package:aves/widgets/debug/report.dart';
+import 'package:aves/widgets/debug/settings.dart';
+import 'package:aves_model/aves_model.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter/scheduler.dart';
+import 'package:provider/provider.dart';
+
+class AppDebugPage extends StatelessWidget {
+ static const routeName = '/debug';
+
+ const AppDebugPage({super.key});
+
+ @override
+ Widget build(BuildContext context) {
+ final animations = context.select<Settings, AccessibilityAnimations>((v) => v.accessibilityAnimations);
+ return Directionality(
+ textDirection: TextDirection.ltr,
+ child: AvesScaffold(
+ appBar: AppBar(
+ title: const Text('Debug'),
+ actions: [
+ FontSizeIconTheme(
+ child: PopupMenuButton<AppDebugAction>(
+ // key is expected by test driver
+ key: const Key('appbar-menu-button'),
+ itemBuilder: (context) => AppDebugAction.values
+ .map((v) => PopupMenuItem(
+ // key is expected by test driver
+ key: Key('menu-${v.name}'),
+ value: v,
+ child: MenuRow(text: v.name),
+ ))
+ .toList(),
+ onSelected: (action) async {
+ // wait for the popup menu to hide before proceeding with the action
+ await Future.delayed(animations.popUpAnimationDelay * timeDilation);
+ unawaited(_onActionSelected(context, action));
+ },
+ popUpAnimationStyle: animations.popUpAnimationStyle,
+ ),
+ ),
+ ],
+ ),
+ body: AvesPopScope(
+ handlers: [tvNavigationPopHandler],
+ child: SafeArea(
+ child: ListView(
+ padding: const EdgeInsets.all(8),
+ children: const [
+ DebugGeneralSection(),
+ DebugLeakingSection(),
+ DebugCacheSection(),
+ DebugCapabilitiesSection(),
+ DebugColorSection(),
+ DebugAppDatabaseSection(),
+ DebugErrorReportingSection(),
+ DebugSettingsSection(),
+ DebugOSAppSection(),
+ DebugOSCodecSection(),
+ DebugOSPathSection(),
+ DebugOSStorageSection(),
+ ],
+ ),
+ ),
+ ),
+ ),
+ );
+ }
+
+ Future<void> _onActionSelected(BuildContext context, AppDebugAction action) async {
+ switch (action) {
+ case AppDebugAction.prepScreenshotThumbnails:
+ // get source beforehand, as widget may be unmounted during action handling
+ final source = context.read<CollectionSource>();
+ settings.changeFilterVisibility(settings.hiddenFilters, true);
+ settings.changeFilterVisibility({
+ TagFilter('aves-thumbnail', reversed: true),
+ }, false);
+ await favourites.clear();
+ await favourites.add(source.visibleEntries);
+ case AppDebugAction.prepScreenshotStats:
+ settings.changeFilterVisibility(settings.hiddenFilters, true);
+ settings.changeFilterVisibility({
+ PathFilter('/storage/emulated/0/Pictures/Dev'),
+ }, false);
+ case AppDebugAction.prepScreenshotCountries:
+ settings.changeFilterVisibility({
+ LocationFilter(LocationLevel.country, 'Belgium;BE'),
+ LocationFilter(LocationLevel.country, 'Croatia;HR'),
+ }, false);
+ case AppDebugAction.mediaStoreScanDir:
+ // scan files copied from test assets
+ // we do it via the app instead of broadcasting via ADB
+ // because `MEDIA_SCANNER_SCAN_FILE` intent got deprecated in API 29
+ await showDialog<String>(
+ context: context,
+ builder: (context) => const MediaStoreScanDirDialog(),
+ );
+ case AppDebugAction.greenScreen:
+ await Navigator.maybeOf(context)?.push(
+ MaterialPageRoute(
+ builder: (context) => const Scaffold(
+ backgroundColor: Colors.green,
+ body: SizedBox(),
+ ),
+ ),
+ );
+ }
+ }
+}
diff --git a/lib/widgets/debug/cache.dart b/lib/widgets/debug/cache.dart
new file mode 100644
index 0000000..419e3c0
--- /dev/null
+++ b/lib/widgets/debug/cache.dart
@@ -0,0 +1,116 @@
+import 'package:aves/ref/locales.dart';
+import 'package:aves/services/common/services.dart';
+import 'package:aves/utils/file_utils.dart';
+import 'package:aves/widgets/common/identity/aves_expansion_tile.dart';
+import 'package:flutter/material.dart';
+
+class DebugCacheSection extends StatefulWidget {
+ const DebugCacheSection({super.key});
+
+ @override
+ State<DebugCacheSection> createState() => _DebugCacheSectionState();
+}
+
+class _DebugCacheSectionState extends State<DebugCacheSection> with AutomaticKeepAliveClientMixin {
+ final TextEditingController _imageCacheSizeTextController = TextEditingController();
+
+ @override
+ void initState() {
+ super.initState();
+ _imageCacheSizeTextController.text = '${imageCache.maximumSizeBytes}';
+ }
+
+ @override
+ void dispose() {
+ _imageCacheSizeTextController.dispose();
+ super.dispose();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ super.build(context);
+
+ final currentSizeBytes = formatFileSize(asciiLocale, imageCache.currentSizeBytes);
+ final maxSizeBytes = formatFileSize(asciiLocale, imageCache.maximumSizeBytes);
+ return AvesExpansionTile(
+ title: 'Cache',
+ children: [
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 8),
+ child: Column(
+ children: [
+ Row(
+ children: [
+ Expanded(
+ child: Text('Image cache:\n\t${imageCache.currentSize}/${imageCache.maximumSize} items\n\t$currentSizeBytes/$maxSizeBytes'),
+ ),
+ const SizedBox(width: 8),
+ ElevatedButton(
+ onPressed: () {
+ imageCache.clear();
+
+ setState(() {});
+ },
+ child: const Text('Clear'),
+ ),
+ ],
+ ),
+ Row(
+ children: [
+ Expanded(
+ child: TextField(
+ controller: _imageCacheSizeTextController,
+ decoration: const InputDecoration(labelText: 'imageCache size bytes'),
+ keyboardType: TextInputType.number,
+ ),
+ ),
+ const SizedBox(width: 8),
+ ElevatedButton(
+ onPressed: () {
+ final size = int.tryParse(_imageCacheSizeTextController.text);
+ if (size != null) {
+ imageCache.maximumSizeBytes = size;
+ } else {
+ _imageCacheSizeTextController.text = '${imageCache.maximumSizeBytes}';
+ }
+ setState(() {});
+ },
+ child: const Text('Apply'),
+ ),
+ ],
+ ),
+ const Divider(),
+ Row(
+ children: [
+ const Expanded(
+ child: Text('Glide disk cache: ?'),
+ ),
+ const SizedBox(width: 8),
+ ElevatedButton(
+ onPressed: mediaFetchService.clearImageDiskCache,
+ child: const Text('Clear'),
+ ),
+ ],
+ ),
+ Row(
+ children: [
+ const Expanded(
+ child: Text('Glide memory cache: ?'),
+ ),
+ const SizedBox(width: 8),
+ ElevatedButton(
+ onPressed: mediaFetchService.clearImageMemoryCache,
+ child: const Text('Clear'),
+ ),
+ ],
+ ),
+ ],
+ ),
+ ),
+ ],
+ );
+ }
+
+ @override
+ bool get wantKeepAlive => true;
+}
diff --git a/lib/widgets/debug/capabilities.dart b/lib/widgets/debug/capabilities.dart
new file mode 100644
index 0000000..449d8f2
--- /dev/null
+++ b/lib/widgets/debug/capabilities.dart
@@ -0,0 +1,136 @@
+import 'package:aves/model/device.dart';
+import 'package:aves/services/common/services.dart';
+import 'package:aves/widgets/common/identity/aves_expansion_tile.dart';
+import 'package:aves/widgets/common/identity/highlight_title.dart';
+import 'package:aves/widgets/viewer/info/common.dart';
+import 'package:flutter/material.dart';
+
+class DebugCapabilitiesSection extends StatefulWidget {
+ const DebugCapabilitiesSection({super.key});
+
+ @override
+ State<DebugCapabilitiesSection> createState() => _DebugCapabilitiesSectionState();
+}
+
+class _DebugCapabilitiesSectionState extends State<DebugCapabilitiesSection> with AutomaticKeepAliveClientMixin {
+ late final Future<List<dynamic>> _appFuture, _windowFuture;
+
+ @override
+ void initState() {
+ super.initState();
+ _appFuture = Future.wait([
+ appProfileService.canInteractAcrossProfiles(),
+ appProfileService.canRequestInteractAcrossProfiles(),
+ appProfileService.getTargetUserProfiles(),
+ ]);
+ _windowFuture = Future.wait([
+ windowService.isCutoutAware(),
+ windowService.isRotationLocked(),
+ windowService.supportsHdr(),
+ windowService.supportsWideGamut(),
+ ]);
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ super.build(context);
+ return AvesExpansionTile(
+ title: 'Capabilities',
+ children: [
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 8),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ const HighlightTitle(title: 'Device'),
+ InfoRowGroup(
+ info: {
+ 'canAuthenticateUser': '${device.canAuthenticateUser}',
+ 'canPinShortcut': '${device.canPinShortcut}',
+ 'canRenderFlagEmojis': '${device.canRenderFlagEmojis}',
+ 'canRenderSubdivisionFlagEmojis': '${device.canRenderSubdivisionFlagEmojis}',
+ 'canRequestManageMedia': '${device.canRequestManageMedia}',
+ 'canSetLockScreenWallpaper': '${device.canSetLockScreenWallpaper}',
+ 'hasGeocoder': '${device.hasGeocoder}',
+ 'isDynamicColorAvailable': '${device.isDynamicColorAvailable}',
+ 'isTelevision': '${device.isTelevision}',
+ 'showPinShortcutFeedback': '${device.showPinShortcutFeedback}',
+ 'supportEdgeToEdgeUIMode': '${device.supportEdgeToEdgeUIMode}',
+ 'supportPictureInPicture': '${device.supportPictureInPicture}',
+ },
+ ),
+ ],
+ ),
+ ),
+ FutureBuilder<List<dynamic>>(
+ future: _windowFuture,
+ builder: (context, snapshot) {
+ final data = snapshot.data;
+ if (data == null) {
+ return const SizedBox();
+ }
+ final [
+ bool isCutoutAware,
+ bool isRotationLocked,
+ bool supportsHdr,
+ bool supportsWideGamut,
+ ] = data;
+
+ return Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 8),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ const HighlightTitle(title: 'Window'),
+ InfoRowGroup(
+ info: {
+ 'isCutoutAware': '$isCutoutAware',
+ 'isRotationLocked': '$isRotationLocked',
+ 'supportsHdr': '$supportsHdr',
+ 'supportsWideGamut': '$supportsWideGamut',
+ },
+ ),
+ ],
+ ),
+ );
+ },
+ ),
+ FutureBuilder<List<dynamic>>(
+ future: _appFuture,
+ builder: (context, snapshot) {
+ final data = snapshot.data;
+ if (data == null) {
+ return const SizedBox();
+ }
+ final [
+ bool canInteractAcrossProfiles,
+ bool canRequestInteractAcrossProfiles,
+ List<String> targetUserProfiles,
+ ] = data;
+
+ return Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 8),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ const HighlightTitle(title: 'App'),
+ InfoRowGroup(
+ info: {
+ 'userAgent': device.userAgent,
+ 'canInteractAcrossProfiles': '$canInteractAcrossProfiles',
+ 'canRequestInteractAcrossProfiles': '$canRequestInteractAcrossProfiles',
+ 'targetUserProfiles': '$targetUserProfiles',
+ },
+ ),
+ ],
+ ),
+ );
+ },
+ ),
+ ],
+ );
+ }
+
+ @override
+ bool get wantKeepAlive => true;
+}
diff --git a/lib/widgets/debug/colors.dart b/lib/widgets/debug/colors.dart
new file mode 100644
index 0000000..52bebdc
--- /dev/null
+++ b/lib/widgets/debug/colors.dart
@@ -0,0 +1,99 @@
+import 'package:aves/widgets/common/identity/aves_expansion_tile.dart';
+import 'package:flex_color_picker/flex_color_picker.dart';
+import 'package:flutter/material.dart';
+
+class DebugColorSection extends StatefulWidget {
+ const DebugColorSection({super.key});
+
+ @override
+ State<DebugColorSection> createState() => _DebugColorSectionState();
+}
+
+class _DebugColorSectionState extends State<DebugColorSection> with AutomaticKeepAliveClientMixin {
+ @override
+ Widget build(BuildContext context) {
+ super.build(context);
+
+ final scheme = Theme.of(context).colorScheme;
+ final List<(String, Color)> colors = [
+ ('primary', scheme.primary),
+ ('onPrimary', scheme.onPrimary),
+ ('primaryContainer', scheme.primaryContainer),
+ ('onPrimaryContainer', scheme.onPrimaryContainer),
+ ('primaryFixed', scheme.primaryFixed),
+ ('primaryFixedDim', scheme.primaryFixedDim),
+ ('onPrimaryFixed', scheme.onPrimaryFixed),
+ ('onPrimaryFixedVariant', scheme.onPrimaryFixedVariant),
+ ('secondary', scheme.secondary),
+ ('onSecondary', scheme.onSecondary),
+ ('secondaryContainer', scheme.secondaryContainer),
+ ('onSecondaryContainer', scheme.onSecondaryContainer),
+ ('secondaryFixed', scheme.secondaryFixed),
+ ('secondaryFixedDim', scheme.secondaryFixedDim),
+ ('onSecondaryFixed', scheme.onSecondaryFixed),
+ ('onSecondaryFixedVariant', scheme.onSecondaryFixedVariant),
+ ('tertiary', scheme.tertiary),
+ ('onTertiary', scheme.onTertiary),
+ ('tertiaryContainer', scheme.tertiaryContainer),
+ ('onTertiaryContainer', scheme.onTertiaryContainer),
+ ('tertiaryFixed', scheme.tertiaryFixed),
+ ('tertiaryFixedDim', scheme.tertiaryFixedDim),
+ ('onTertiaryFixed', scheme.onTertiaryFixed),
+ ('onTertiaryFixedVariant', scheme.onTertiaryFixedVariant),
+ ('error', scheme.error),
+ ('onError', scheme.onError),
+ ('errorContainer', scheme.errorContainer),
+ ('onErrorContainer', scheme.onErrorContainer),
+ ('surface', scheme.surface),
+ ('onSurface', scheme.onSurface),
+ ('surfaceDim', scheme.surfaceDim),
+ ('surfaceBright', scheme.surfaceBright),
+ ('surfaceContainerLowest', scheme.surfaceContainerLowest),
+ ('surfaceContainerLow', scheme.surfaceContainerLow),
+ ('surfaceContainer', scheme.surfaceContainer),
+ ('surfaceContainerHigh', scheme.surfaceContainerHigh),
+ ('surfaceContainerHighest', scheme.surfaceContainerHighest),
+ ('onSurfaceVariant', scheme.onSurfaceVariant),
+ ('outline', scheme.outline),
+ ('outlineVariant', scheme.outlineVariant),
+ ('shadow', scheme.shadow),
+ ('scrim', scheme.scrim),
+ ('inverseSurface', scheme.inverseSurface),
+ ('onInverseSurface', scheme.onInverseSurface),
+ ('inversePrimary', scheme.inversePrimary),
+ ('surfaceTint', scheme.surfaceTint),
+ ];
+ return AvesExpansionTile(
+ title: 'Colors',
+ children: [
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 8),
+ child: Column(
+ children: colors.map((kv) {
+ final (text, color) = kv;
+ return Row(
+ children: [
+ Text(text),
+ const Spacer(),
+ Text(
+ color.hex,
+ style: const TextStyle(fontFamily: 'monospace'),
+ ),
+ const SizedBox(width: 4),
+ Container(
+ width: 20,
+ height: 20,
+ color: color,
+ ),
+ ],
+ );
+ }).toList(),
+ ),
+ ),
+ ],
+ );
+ }
+
+ @override
+ bool get wantKeepAlive => true;
+}
diff --git a/lib/widgets/debug/database.dart b/lib/widgets/debug/database.dart
new file mode 100644
index 0000000..42bdb60
--- /dev/null
+++ b/lib/widgets/debug/database.dart
@@ -0,0 +1,343 @@
+import 'package:aves/model/covers.dart';
+import 'package:aves/model/dynamic_albums.dart';
+import 'package:aves/model/entry/entry.dart';
+import 'package:aves/model/favourites.dart';
+import 'package:aves/model/metadata/address.dart';
+import 'package:aves/model/metadata/catalog.dart';
+import 'package:aves/model/metadata/trash.dart';
+import 'package:aves/model/vaults/details.dart';
+import 'package:aves/model/vaults/vaults.dart';
+import 'package:aves/model/viewer/video_playback.dart';
+import 'package:aves/ref/locales.dart';
+import 'package:aves/services/common/services.dart';
+import 'package:aves/utils/file_utils.dart';
+import 'package:aves/widgets/common/identity/aves_expansion_tile.dart';
+import 'package:collection/collection.dart';
+import 'package:flutter/material.dart';
+
+class DebugAppDatabaseSection extends StatefulWidget {
+ const DebugAppDatabaseSection({super.key});
+
+ @override
+ State<DebugAppDatabaseSection> createState() => _DebugAppDatabaseSectionState();
+}
+
+class _DebugAppDatabaseSectionState extends State<DebugAppDatabaseSection> with AutomaticKeepAliveClientMixin {
+ late Future<int> _dbFileSizeLoader;
+ late Future<Set<AvesEntry>> _dbEntryLoader;
+ late Future<Map<int?, int?>> _dbDateLoader;
+ late Future<Set<CatalogMetadata>> _dbMetadataLoader;
+ late Future<Set<AddressDetails>> _dbAddressLoader;
+ late Future<Set<TrashDetails>> _dbTrashLoader;
+ late Future<Set<VaultDetails>> _dbVaultsLoader;
+ late Future<Set<FavouriteRow>> _dbFavouritesLoader;
+ late Future<Set<CoverRow>> _dbCoversLoader;
+ late Future<Set<DynamicAlbumRow>> _dbDynamicAlbumsLoader;
+ late Future<Set<VideoPlaybackRow>> _dbVideoPlaybackLoader;
+
+ @override
+ void initState() {
+ super.initState();
+ _startDbReport();
+ }
+
+ @override
+ void dispose() {
+ _disposeLoadedContent();
+ super.dispose();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ super.build(context);
+
+ return AvesExpansionTile(
+ title: 'Database',
+ children: [
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 8),
+ child: Column(
+ children: [
+ FutureBuilder<int>(
+ future: _dbFileSizeLoader,
+ builder: (context, snapshot) {
+ if (snapshot.hasError) return Text(snapshot.error.toString());
+
+ if (snapshot.connectionState != ConnectionState.done) return const SizedBox();
+
+ return Row(
+ children: [
+ Expanded(
+ child: Text('DB file size: ${formatFileSize(asciiLocale, snapshot.data!)}'),
+ ),
+ const SizedBox(width: 8),
+ ElevatedButton(
+ onPressed: () => localMediaDb.reset().then((_) => _reload()),
+ child: const Text('Reset'),
+ ),
+ ],
+ );
+ },
+ ),
+ FutureBuilder<Set<AvesEntry>>(
+ future: _dbEntryLoader,
+ builder: (context, snapshot) {
+ if (snapshot.hasError) return Text(snapshot.error.toString());
+
+ if (snapshot.connectionState != ConnectionState.done) return const SizedBox();
+
+ final entries = snapshot.data!;
+ final byOrigin = groupBy<AvesEntry, int>(entries, (entry) => entry.origin);
+ return Row(
+ children: [
+ Expanded(
+ child: Text('entry rows: ${entries.length} (${byOrigin.entries.map((kv) => '${kv.key}: ${kv.value.length}').join(', ')})'),
+ ),
+ const SizedBox(width: 8),
+ ElevatedButton(
+ onPressed: () => localMediaDb.clearEntries().then((_) => _reload()),
+ child: const Text('Clear'),
+ ),
+ ],
+ );
+ },
+ ),
+ FutureBuilder<Map<int?, int?>>(
+ future: _dbDateLoader,
+ builder: (context, snapshot) {
+ if (snapshot.hasError) return Text(snapshot.error.toString());
+
+ if (snapshot.connectionState != ConnectionState.done) return const SizedBox();
+
+ return Row(
+ children: [
+ Expanded(
+ child: Text('date rows: ${snapshot.data!.length}'),
+ ),
+ const SizedBox(width: 8),
+ ElevatedButton(
+ onPressed: () => localMediaDb.clearDates().then((_) => _reload()),
+ child: const Text('Clear'),
+ ),
+ ],
+ );
+ },
+ ),
+ FutureBuilder<Set>(
+ future: _dbMetadataLoader,
+ builder: (context, snapshot) {
+ if (snapshot.hasError) return Text(snapshot.error.toString());
+
+ if (snapshot.connectionState != ConnectionState.done) return const SizedBox();
+
+ return Row(
+ children: [
+ Expanded(
+ child: Text('metadata rows: ${snapshot.data!.length}'),
+ ),
+ const SizedBox(width: 8),
+ ElevatedButton(
+ onPressed: () => localMediaDb.clearCatalogMetadata().then((_) => _reload()),
+ child: const Text('Clear'),
+ ),
+ ],
+ );
+ },
+ ),
+ FutureBuilder<Set>(
+ future: _dbAddressLoader,
+ builder: (context, snapshot) {
+ if (snapshot.hasError) return Text(snapshot.error.toString());
+
+ if (snapshot.connectionState != ConnectionState.done) return const SizedBox();
+
+ return Row(
+ children: [
+ Expanded(
+ child: Text('address rows: ${snapshot.data!.length}'),
+ ),
+ const SizedBox(width: 8),
+ ElevatedButton(
+ onPressed: () => localMediaDb.clearAddresses().then((_) => _reload()),
+ child: const Text('Clear'),
+ ),
+ ],
+ );
+ },
+ ),
+ FutureBuilder<Set>(
+ future: _dbTrashLoader,
+ builder: (context, snapshot) {
+ if (snapshot.hasError) return Text(snapshot.error.toString());
+
+ if (snapshot.connectionState != ConnectionState.done) return const SizedBox();
+
+ return Row(
+ children: [
+ Expanded(
+ child: Text('trash rows: ${snapshot.data!.length}'),
+ ),
+ const SizedBox(width: 8),
+ ElevatedButton(
+ onPressed: () => localMediaDb.clearTrashDetails().then((_) => _reload()),
+ child: const Text('Clear'),
+ ),
+ ],
+ );
+ },
+ ),
+ FutureBuilder<Set>(
+ future: _dbVaultsLoader,
+ builder: (context, snapshot) {
+ if (snapshot.hasError) return Text(snapshot.error.toString());
+
+ if (snapshot.connectionState != ConnectionState.done) return const SizedBox();
+
+ return Row(
+ children: [
+ Expanded(
+ child: Text('vault rows: ${snapshot.data!.length} (${vaults.all.length} in memory)'),
+ ),
+ const SizedBox(width: 8),
+ ElevatedButton(
+ onPressed: () => vaults.clear().then((_) => _reload()),
+ child: const Text('Clear'),
+ ),
+ ],
+ );
+ },
+ ),
+ FutureBuilder<Set>(
+ future: _dbFavouritesLoader,
+ builder: (context, snapshot) {
+ if (snapshot.hasError) return Text(snapshot.error.toString());
+
+ if (snapshot.connectionState != ConnectionState.done) return const SizedBox();
+
+ return Row(
+ children: [
+ Expanded(
+ child: Text('favourite rows: ${snapshot.data!.length} (${favourites.count} in memory)'),
+ ),
+ const SizedBox(width: 8),
+ ElevatedButton(
+ onPressed: () => favourites.clear().then((_) => _reload()),
+ child: const Text('Clear'),
+ ),
+ ],
+ );
+ },
+ ),
+ FutureBuilder<Set>(
+ future: _dbCoversLoader,
+ builder: (context, snapshot) {
+ if (snapshot.hasError) return Text(snapshot.error.toString());
+
+ if (snapshot.connectionState != ConnectionState.done) return const SizedBox();
+
+ return Row(
+ children: [
+ Expanded(
+ child: Text('covers: ${snapshot.data!.length} rows\n(${covers.count} in memory)'),
+ ),
+ const SizedBox(width: 8),
+ ElevatedButton(
+ onPressed: () => localMediaDb.loadAllCovers().then((list) {
+ debugPrint('covers dump start');
+ list.forEach((v) => debugPrint(' $v'));
+ debugPrint('covers albums dump end');
+ }),
+ child: const Text('Dump'),
+ ),
+ ElevatedButton(
+ onPressed: () => covers.clear().then((_) => _reload()),
+ child: const Text('Clear'),
+ ),
+ ],
+ );
+ },
+ ),
+ FutureBuilder<Set>(
+ future: _dbDynamicAlbumsLoader,
+ builder: (context, snapshot) {
+ if (snapshot.hasError) return Text(snapshot.error.toString());
+
+ if (snapshot.connectionState != ConnectionState.done) return const SizedBox();
+
+ return Row(
+ children: [
+ Expanded(
+ child: Text('dynamic albums: ${snapshot.data!.length} rows\n(${dynamicAlbums.count} in memory)'),
+ ),
+ const SizedBox(width: 8),
+ ElevatedButton(
+ onPressed: () => localMediaDb.loadAllDynamicAlbums().then((list) {
+ debugPrint('dynamic albums dump start');
+ list.forEach((v) => debugPrint(' $v'));
+ debugPrint('dynamic albums dump end');
+ }),
+ child: const Text('Dump'),
+ ),
+ ElevatedButton(
+ onPressed: () => dynamicAlbums.clear().then((_) => _reload()),
+ child: const Text('Clear'),
+ ),
+ ],
+ );
+ },
+ ),
+ FutureBuilder<Set>(
+ future: _dbVideoPlaybackLoader,
+ builder: (context, snapshot) {
+ if (snapshot.hasError) return Text(snapshot.error.toString());
+
+ if (snapshot.connectionState != ConnectionState.done) return const SizedBox();
+
+ return Row(
+ children: [
+ Expanded(
+ child: Text('video playback rows: ${snapshot.data!.length}'),
+ ),
+ const SizedBox(width: 8),
+ ElevatedButton(
+ onPressed: () => localMediaDb.clearVideoPlayback().then((_) => _reload()),
+ child: const Text('Clear'),
+ ),
+ ],
+ );
+ },
+ ),
+ ],
+ ),
+ ),
+ ],
+ );
+ }
+
+ Future<void> _reload() async {
+ await _disposeLoadedContent();
+ _startDbReport();
+ }
+
+ void _startDbReport() {
+ _dbFileSizeLoader = localMediaDb.dbFileSize();
+ _dbEntryLoader = localMediaDb.loadEntries();
+ _dbDateLoader = localMediaDb.loadDates();
+ _dbMetadataLoader = localMediaDb.loadCatalogMetadata();
+ _dbAddressLoader = localMediaDb.loadAddresses();
+ _dbTrashLoader = localMediaDb.loadAllTrashDetails();
+ _dbVaultsLoader = localMediaDb.loadAllVaults();
+ _dbFavouritesLoader = localMediaDb.loadAllFavourites();
+ _dbCoversLoader = localMediaDb.loadAllCovers();
+ _dbDynamicAlbumsLoader = localMediaDb.loadAllDynamicAlbums();
+ _dbVideoPlaybackLoader = localMediaDb.loadAllVideoPlayback();
+ setState(() {});
+ }
+
+ Future<void> _disposeLoadedContent() async {
+ (await _dbEntryLoader).forEach((v) => v.dispose());
+ }
+
+ @override
+ bool get wantKeepAlive => true;
+}
diff --git a/lib/widgets/debug/general.dart b/lib/widgets/debug/general.dart
new file mode 100644
index 0000000..458c9fc
--- /dev/null
+++ b/lib/widgets/debug/general.dart
@@ -0,0 +1,136 @@
+import 'package:aves/model/settings/settings.dart';
+import 'package:aves/model/source/collection_source.dart';
+import 'package:aves/services/analysis_service.dart';
+import 'package:aves/services/common/service_policy.dart';
+import 'package:aves/widgets/common/identity/aves_expansion_tile.dart';
+import 'package:aves/widgets/settings/common/tiles.dart';
+import 'package:aves/widgets/viewer/info/common.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter/scheduler.dart';
+import 'package:provider/provider.dart';
+
+class DebugGeneralSection extends StatefulWidget {
+ const DebugGeneralSection({super.key});
+
+ @override
+ State<DebugGeneralSection> createState() => _DebugGeneralSectionState();
+}
+
+class _DebugGeneralSectionState extends State<DebugGeneralSection> with AutomaticKeepAliveClientMixin {
+ static OverlayEntry? _taskQueueOverlayEntry;
+
+ @override
+ Widget build(BuildContext context) {
+ super.build(context);
+
+ final source = context.read<CollectionSource>();
+ final visibleEntries = source.visibleEntries;
+ final catalogued = visibleEntries.where((entry) => entry.isCatalogued);
+ final withGps = catalogued.where((entry) => entry.hasGps);
+ final withAddress = withGps.where((entry) => entry.hasAddress);
+ final withFineAddress = withGps.where((entry) => entry.hasFineAddress);
+
+ return AvesExpansionTile(
+ title: 'General',
+ children: [
+ const Padding(
+ padding: EdgeInsets.all(8),
+ child: Text('Time dilation'),
+ ),
+ Slider(
+ value: timeDilation,
+ onChanged: (v) => setState(() => timeDilation = v),
+ min: 1.0,
+ max: 10.0,
+ divisions: 9,
+ label: '$timeDilation',
+ ),
+ SwitchListTile(
+ value: _taskQueueOverlayEntry != null,
+ onChanged: (v) {
+ _taskQueueOverlayEntry
+ ?..remove()
+ ..dispose();
+ _taskQueueOverlayEntry = null;
+ if (v) {
+ _taskQueueOverlayEntry = OverlayEntry(
+ builder: (context) => const _TaskQueueOverlay(),
+ );
+ Overlay.of(context).insert(_taskQueueOverlayEntry!);
+ }
+ setState(() {});
+ },
+ title: const Text('Show tasks overlay'),
+ ),
+ SettingsSwitchListTile(
+ selector: (context, s) => s.debugShowViewerTiles,
+ onChanged: (v) => settings.debugShowViewerTiles = v,
+ title: 'Show viewer tiles',
+ ),
+ ElevatedButton(
+ onPressed: () => AnalysisService.startService(force: false),
+ child: const Text('Start analysis service'),
+ ),
+ const Divider(),
+ Padding(
+ padding: const EdgeInsets.only(left: 8, right: 8, bottom: 8),
+ child: InfoRowGroup(
+ info: {
+ 'All entries': '${source.allEntries.length}',
+ 'Visible entries': '${visibleEntries.length}',
+ 'Catalogued': '${catalogued.length}',
+ 'With GPS': '${withGps.length}',
+ 'With address': '${withAddress.length}',
+ 'With fine address': '${withFineAddress.length}',
+ },
+ ),
+ ),
+ ],
+ );
+ }
+
+ @override
+ bool get wantKeepAlive => true;
+}
+
+class _TaskQueueOverlay extends StatelessWidget {
+ const _TaskQueueOverlay();
+
+ @override
+ Widget build(BuildContext context) {
+ return IgnorePointer(
+ child: DefaultTextStyle(
+ style: const TextStyle(),
+ child: Align(
+ alignment: AlignmentDirectional.bottomStart,
+ child: SafeArea(
+ child: Container(
+ color: Colors.indigo.shade900.withAlpha(0xCC),
+ padding: const EdgeInsets.all(8),
+ child: StreamBuilder<QueueState>(
+ stream: servicePolicy.queueStream,
+ builder: (context, snapshot) {
+ if (snapshot.hasError) return const SizedBox();
+ final queuedEntries = <MapEntry<dynamic, int>>[];
+ if (snapshot.hasData) {
+ final state = snapshot.data!;
+ queuedEntries.add(MapEntry('run', state.runningCount));
+ queuedEntries.add(MapEntry('paused', state.pausedCount));
+ queuedEntries.addAll(state.queueByPriority.entries.map((kv) => MapEntry(kv.key.toString(), kv.value)));
+ }
+ queuedEntries.sort((a, b) => a.key.compareTo(b.key));
+ return Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ Text(queuedEntries.map((kv) => '${kv.key}: ${kv.value}').join(', ')),
+ ],
+ );
+ }),
+ ),
+ ),
+ ),
+ ),
+ );
+ }
+}
diff --git a/lib/widgets/debug/leaking.dart b/lib/widgets/debug/leaking.dart
new file mode 100644
index 0000000..7a97808
--- /dev/null
+++ b/lib/widgets/debug/leaking.dart
@@ -0,0 +1,180 @@
+import 'dart:io';
+
+import 'package:aves/ref/locales.dart';
+import 'package:aves/utils/file_utils.dart';
+import 'package:aves/widgets/common/identity/aves_expansion_tile.dart';
+import 'package:collection/collection.dart';
+import 'package:flutter/material.dart';
+import 'package:leak_tracker/leak_tracker.dart';
+
+class DebugLeakingSection extends StatefulWidget {
+ const DebugLeakingSection({super.key});
+
+ @override
+ State<DebugLeakingSection> createState() => _DebugLeakingSectionState();
+}
+
+class _DebugLeakingSectionState extends State<DebugLeakingSection> with AutomaticKeepAliveClientMixin {
+ static OverlayEntry? _collectorOverlayEntry;
+
+ static const _leakIgnoreConfig = IgnoredLeaks(
+ experimentalNotGCed: IgnoredLeaksSet(),
+ notDisposed: IgnoredLeaksSet(),
+ );
+
+ @override
+ Widget build(BuildContext context) {
+ super.build(context);
+
+ return AvesExpansionTile(
+ title: 'Leaking',
+ children: [
+ SwitchListTile(
+ value: _collectorOverlayEntry != null,
+ onChanged: (v) {
+ _collectorOverlayEntry
+ ?..remove()
+ ..dispose();
+ _collectorOverlayEntry = null;
+ if (v) {
+ _collectorOverlayEntry = OverlayEntry(
+ builder: (context) => const _CollectorOverlay(),
+ );
+ Overlay.of(context).insert(_collectorOverlayEntry!);
+ }
+ setState(() {});
+ },
+ title: const Text('Show leak report overlay'),
+ ),
+ ElevatedButton(
+ onPressed: () => LeakTracking.collectLeaks().then((leaks) {
+ LeakTracking.phase = const PhaseSettings(
+ ignoredLeaks: _leakIgnoreConfig,
+ leakDiagnosticConfig: LeakDiagnosticConfig(
+ collectRetainingPathForNotGCed: true,
+ collectStackTraceOnStart: true,
+ collectStackTraceOnDisposal: true,
+ ),
+ );
+ }),
+ child: const Text('Track leaks with stacks'),
+ ),
+ ElevatedButton(
+ onPressed: () => LeakTracking.collectLeaks().then((leaks) {
+ LeakTracking.phase = const PhaseSettings(
+ ignoredLeaks: _leakIgnoreConfig,
+ leakDiagnosticConfig: LeakDiagnosticConfig(
+ collectRetainingPathForNotGCed: true,
+ collectStackTraceOnStart: false,
+ collectStackTraceOnDisposal: false,
+ ),
+ );
+ }),
+ child: const Text('Track leaks without stacks'),
+ ),
+ ],
+ );
+ }
+
+ @override
+ bool get wantKeepAlive => true;
+}
+
+class _CollectorOverlay extends StatefulWidget {
+ const _CollectorOverlay();
+
+ @override
+ State<_CollectorOverlay> createState() => _CollectorOverlayState();
+}
+
+class _CollectorOverlayState extends State<_CollectorOverlay> {
+ AlignmentGeometry _alignment = AlignmentDirectional.bottomStart;
+
+ @override
+ Widget build(BuildContext context) {
+ return DefaultTextStyle(
+ style: const TextStyle(),
+ child: Align(
+ alignment: _alignment,
+ child: SafeArea(
+ child: Container(
+ color: Colors.indigo.shade900.withAlpha(0xCC),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Wrap(
+ crossAxisAlignment: WrapCrossAlignment.center,
+ children: [
+ IconButton(
+ onPressed: () => setState(() => _alignment = _alignment == AlignmentDirectional.bottomStart ? AlignmentDirectional.topStart : AlignmentDirectional.bottomStart),
+ icon: Icon(_alignment == AlignmentDirectional.bottomStart ? Icons.vertical_align_top_outlined : Icons.vertical_align_bottom_outlined),
+ ),
+ ...LeakType.values.map((type) {
+ return OutlinedButton(
+ style: ButtonStyle(
+ padding: WidgetStateProperty.all(const EdgeInsets.all(6)),
+ minimumSize: WidgetStateProperty.all(Size.zero),
+ ),
+ onPressed: () => LeakTracking.collectLeaks().then((leaks) {
+ final reports = leaks.byType[type] ?? [];
+ _printLeaks(type, reports);
+ }),
+ child: Text(type.name),
+ );
+ }),
+ ],
+ ),
+ Wrap(
+ crossAxisAlignment: WrapCrossAlignment.center,
+ children: [
+ StreamBuilder(
+ stream: Stream.periodic(const Duration(seconds: 1)),
+ builder: (context, snapshot) {
+ final currentRss = formatFileSize(asciiLocale, ProcessInfo.currentRss);
+ final maxRss = formatFileSize(asciiLocale, ProcessInfo.maxRss);
+ return Text('RSS: $currentRss / $maxRss');
+ },
+ ),
+ ],
+ ),
+ Wrap(
+ crossAxisAlignment: WrapCrossAlignment.center,
+ children: [
+ StreamBuilder(
+ stream: Stream.periodic(const Duration(seconds: 1)),
+ builder: (context, snapshot) {
+ final currentImageCache = formatFileSize(asciiLocale, imageCache.currentSizeBytes);
+ final maxImageCache = formatFileSize(asciiLocale, imageCache.maximumSizeBytes);
+ return Text('imageCache: $currentImageCache / $maxImageCache');
+ },
+ ),
+ ],
+ ),
+ ],
+ ),
+ ),
+ ),
+ ),
+ );
+ }
+
+ void _printLeaks(LeakType type, List<LeakReport> reports) {
+ debugPrint('* leak type=$type, ${reports.length} reports');
+ groupBy(reports, (report) => report.type).forEach((reportType, typedReports) {
+ debugPrint(' * report type=$reportType');
+ groupBy(typedReports, (report) => report.trackedClass).forEach((trackedClass, classedReports) {
+ debugPrint(' trackedClass=$trackedClass reports=${classedReports.length}');
+ classedReports.forEach((report) {
+ final phase = report.phase;
+ final retainingPath = report.retainingPath;
+ final detailedPath = report.detailedPath;
+ final context = report.context;
+ if (phase != null || retainingPath != null || detailedPath != null || context != null) {
+ debugPrint(' phase=$phase retainingPath=$retainingPath detailedPath=$detailedPath context=$context');
+ }
+ });
+ });
+ });
+ }
+}
diff --git a/lib/widgets/debug/media_store_scan_dialog.dart b/lib/widgets/debug/media_store_scan_dialog.dart
new file mode 100644
index 0000000..e759c29
--- /dev/null
+++ b/lib/widgets/debug/media_store_scan_dialog.dart
@@ -0,0 +1,51 @@
+import 'dart:io';
+
+import 'package:aves/ref/mime_types.dart';
+import 'package:aves/services/common/services.dart';
+import 'package:aves/widgets/dialogs/aves_dialog.dart';
+import 'package:flutter/material.dart';
+
+class MediaStoreScanDirDialog extends StatefulWidget {
+ const MediaStoreScanDirDialog({super.key});
+
+ @override
+ State<MediaStoreScanDirDialog> createState() => _MediaStoreScanDirDialogState();
+}
+
+class _MediaStoreScanDirDialogState extends State<MediaStoreScanDirDialog> {
+ final TextEditingController _pathController = TextEditingController();
+ bool _processing = false;
+
+ @override
+ void dispose() {
+ _pathController.dispose();
+ super.dispose();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ return AvesDialog(
+ content: _processing ? const CircularProgressIndicator() : TextField(controller: _pathController),
+ actions: [
+ TextButton(
+ onPressed: _processing
+ ? null
+ : () async {
+ final dir = _pathController.text;
+ if (dir.isNotEmpty) {
+ setState(() => _processing = true);
+ await Future.forEach<FileSystemEntity>(Directory(dir).listSync(recursive: true), (file) async {
+ if (file is File) {
+ final mimeType = MimeTypes.forExtension(pContext.extension(file.path));
+ await mediaStoreService.scanFile(file.path, mimeType!);
+ }
+ });
+ }
+ Navigator.maybeOf(context)?.pop();
+ },
+ child: const Text('Scan'),
+ )
+ ],
+ );
+ }
+}
diff --git a/lib/widgets/debug/os_apps.dart b/lib/widgets/debug/os_apps.dart
new file mode 100644
index 0000000..d8250a4
--- /dev/null
+++ b/lib/widgets/debug/os_apps.dart
@@ -0,0 +1,122 @@
+import 'package:aves/image_providers/app_icon_image_provider.dart';
+import 'package:aves/model/app_inventory.dart';
+import 'package:aves/services/common/services.dart';
+import 'package:aves/widgets/common/basic/query_bar.dart';
+import 'package:aves/widgets/common/identity/aves_expansion_tile.dart';
+import 'package:aves/widgets/viewer/info/common.dart';
+import 'package:collection/collection.dart';
+import 'package:flutter/material.dart';
+
+class DebugOSAppSection extends StatefulWidget {
+ const DebugOSAppSection({super.key});
+
+ @override
+ State<DebugOSAppSection> createState() => _DebugOSAppSectionState();
+}
+
+class _DebugOSAppSectionState extends State<DebugOSAppSection> with AutomaticKeepAliveClientMixin {
+ late Future<Set<Package>> _loader;
+ final ValueNotifier<String> _queryNotifier = ValueNotifier('');
+
+ static const iconSize = 20.0;
+
+ @override
+ void initState() {
+ super.initState();
+ _loader = appService.getPackages();
+ }
+
+ @override
+ void dispose() {
+ _queryNotifier.dispose();
+ super.dispose();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ super.build(context);
+
+ return AvesExpansionTile(
+ title: 'OS Apps',
+ children: [
+ Padding(
+ padding: const EdgeInsets.only(left: 8, right: 8, bottom: 8),
+ child: FutureBuilder<Set<Package>>(
+ future: _loader,
+ builder: (context, snapshot) {
+ if (snapshot.hasError) return Text(snapshot.error.toString());
+ if (snapshot.connectionState != ConnectionState.done) return const SizedBox();
+ final packages = snapshot.data!.toList()..sort((a, b) => compareAsciiUpperCase(a.packageName, b.packageName));
+ final enabledTheme = IconTheme.of(context);
+ final disabledTheme = enabledTheme.merge(const IconThemeData(opacity: .2));
+ return Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ QueryBar(queryNotifier: _queryNotifier),
+ ...packages.map((package) {
+ return ValueListenableBuilder<String>(
+ valueListenable: _queryNotifier,
+ builder: (context, query, child) {
+ if ({package.packageName, ...package.potentialDirs}.none((v) => v.toLowerCase().contains(query.toLowerCase()))) {
+ return const SizedBox();
+ }
+ return Text.rich(
+ TextSpan(
+ children: [
+ WidgetSpan(
+ alignment: PlaceholderAlignment.middle,
+ child: Image(
+ image: AppIconImage(
+ packageName: package.packageName,
+ size: iconSize,
+ ),
+ width: iconSize,
+ height: iconSize,
+ ),
+ ),
+ TextSpan(
+ text: ' ${package.packageName}\n',
+ style: InfoRowGroup.keyStyle(context),
+ ),
+ WidgetSpan(
+ alignment: PlaceholderAlignment.middle,
+ child: IconTheme(
+ data: package.categoryLauncher ? enabledTheme : disabledTheme,
+ child: const Icon(
+ Icons.launch_outlined,
+ size: iconSize,
+ ),
+ ),
+ ),
+ WidgetSpan(
+ alignment: PlaceholderAlignment.middle,
+ child: IconTheme(
+ data: package.isSystem ? enabledTheme : disabledTheme,
+ child: const Icon(
+ Icons.android,
+ size: iconSize,
+ ),
+ ),
+ ),
+ TextSpan(
+ text: ' ${package.potentialDirs.join(', ')}\n',
+ style: InfoRowGroup.valueStyle,
+ ),
+ ],
+ ),
+ );
+ },
+ );
+ })
+ ],
+ );
+ },
+ ),
+ ),
+ ],
+ );
+ }
+
+ @override
+ bool get wantKeepAlive => true;
+}
diff --git a/lib/widgets/debug/os_codecs.dart b/lib/widgets/debug/os_codecs.dart
new file mode 100644
index 0000000..e1a4cf9
--- /dev/null
+++ b/lib/widgets/debug/os_codecs.dart
@@ -0,0 +1,87 @@
+import 'package:aves/services/android_debug_service.dart';
+import 'package:aves/widgets/common/basic/query_bar.dart';
+import 'package:aves/widgets/common/identity/aves_expansion_tile.dart';
+import 'package:aves/widgets/common/identity/highlight_title.dart';
+import 'package:aves/widgets/viewer/info/common.dart';
+import 'package:collection/collection.dart';
+import 'package:flutter/material.dart';
+
+class DebugOSCodecSection extends StatefulWidget {
+ const DebugOSCodecSection({super.key});
+
+ @override
+ State<DebugOSCodecSection> createState() => _DebugOSCodecSectionState();
+}
+
+class _DebugOSCodecSectionState extends State<DebugOSCodecSection> with AutomaticKeepAliveClientMixin {
+ late Future<List<Map>> _loader;
+ final ValueNotifier<String> _queryNotifier = ValueNotifier('');
+
+ @override
+ void initState() {
+ super.initState();
+ _loader = AndroidDebugService.getCodecs();
+ }
+
+ @override
+ void dispose() {
+ _queryNotifier.dispose();
+ super.dispose();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ super.build(context);
+
+ return AvesExpansionTile(
+ title: 'OS Codecs',
+ children: [
+ Padding(
+ padding: const EdgeInsets.only(left: 8, right: 8, bottom: 8),
+ child: FutureBuilder<List<Map>>(
+ future: _loader,
+ builder: (context, snapshot) {
+ if (snapshot.hasError) return Text(snapshot.error.toString());
+ if (snapshot.connectionState != ConnectionState.done) return const SizedBox();
+ final codecs = snapshot.data!.map((codec) {
+ return codec.map((k, v) => MapEntry(k.toString(), v.toString()));
+ }).toList()
+ ..sort((a, b) => compareAsciiUpperCase(a['supportedTypes'] ?? '', b['supportedTypes'] ?? ''));
+ final byEncoder = groupBy<Map<String, String>, bool>(codecs, (v) => v['isEncoder'] == 'true');
+ final decoders = byEncoder[false] ?? [];
+ final encoders = byEncoder[true] ?? [];
+ Widget _toCodecColumn(List<Map<String, String>> codecs) => ValueListenableBuilder<String>(
+ valueListenable: _queryNotifier,
+ builder: (context, query, child) => Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: codecs.expand((v) {
+ final types = v['supportedTypes'];
+ return (query.isEmpty || types == null || types.contains(query))
+ ? [
+ InfoRowGroup(info: Map.fromEntries(v.entries.where((kv) => kv.key != 'isEncoder'))),
+ const Divider(),
+ ]
+ : <Widget>[];
+ }).toList(),
+ ),
+ );
+ return Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ QueryBar(queryNotifier: _queryNotifier),
+ const HighlightTitle(title: 'Decoders'),
+ _toCodecColumn(decoders),
+ const HighlightTitle(title: 'Encoders'),
+ _toCodecColumn(encoders),
+ ],
+ );
+ },
+ ),
+ ),
+ ],
+ );
+ }
+
+ @override
+ bool get wantKeepAlive => true;
+}
diff --git a/lib/widgets/debug/os_paths.dart b/lib/widgets/debug/os_paths.dart
new file mode 100644
index 0000000..1b1734a
--- /dev/null
+++ b/lib/widgets/debug/os_paths.dart
@@ -0,0 +1,49 @@
+import 'dart:collection';
+
+import 'package:aves/services/android_debug_service.dart';
+import 'package:aves/widgets/common/identity/aves_expansion_tile.dart';
+import 'package:aves/widgets/viewer/info/common.dart';
+import 'package:flutter/material.dart';
+
+class DebugOSPathSection extends StatefulWidget {
+ const DebugOSPathSection({super.key});
+
+ @override
+ State<DebugOSPathSection> createState() => _DebugOSPathSectionState();
+}
+
+class _DebugOSPathSectionState extends State<DebugOSPathSection> with AutomaticKeepAliveClientMixin {
+ late Future<Map> _loader;
+
+ @override
+ void initState() {
+ super.initState();
+ _loader = AndroidDebugService.getContextDirs();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ super.build(context);
+
+ return AvesExpansionTile(
+ title: 'OS Paths',
+ children: [
+ Padding(
+ padding: const EdgeInsets.only(left: 8, right: 8, bottom: 8),
+ child: FutureBuilder<Map>(
+ future: _loader,
+ builder: (context, snapshot) {
+ if (snapshot.hasError) return Text(snapshot.error.toString());
+ if (snapshot.connectionState != ConnectionState.done) return const SizedBox();
+ final data = SplayTreeMap.of(snapshot.data!.map((k, v) => MapEntry(k.toString(), v?.toString() ?? 'null')));
+ return InfoRowGroup(info: data);
+ },
+ ),
+ ),
+ ],
+ );
+ }
+
+ @override
+ bool get wantKeepAlive => true;
+}
diff --git a/lib/widgets/debug/os_storage.dart b/lib/widgets/debug/os_storage.dart
new file mode 100644
index 0000000..5765e51
--- /dev/null
+++ b/lib/widgets/debug/os_storage.dart
@@ -0,0 +1,64 @@
+import 'package:aves/ref/locales.dart';
+import 'package:aves/services/common/services.dart';
+import 'package:aves/utils/android_file_utils.dart';
+import 'package:aves/utils/file_utils.dart';
+import 'package:aves/view/view.dart';
+import 'package:aves/widgets/common/identity/aves_expansion_tile.dart';
+import 'package:aves/widgets/viewer/info/common.dart';
+import 'package:flutter/material.dart';
+
+class DebugOSStorageSection extends StatefulWidget {
+ const DebugOSStorageSection({super.key});
+
+ @override
+ State<DebugOSStorageSection> createState() => _DebugOSStorageSectionState();
+}
+
+class _DebugOSStorageSectionState extends State<DebugOSStorageSection> with AutomaticKeepAliveClientMixin {
+ final Map<String, int?> _freeSpaceByVolume = {};
+
+ @override
+ void initState() {
+ super.initState();
+ androidFileUtils.storageVolumes.forEach((volume) async {
+ final byteCount = await storageService.getFreeSpace(volume);
+ setState(() => _freeSpaceByVolume[volume.path] = byteCount);
+ });
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ super.build(context);
+
+ return AvesExpansionTile(
+ title: 'OS Storage',
+ children: [
+ ...androidFileUtils.storageVolumes.expand((v) {
+ final freeSpace = _freeSpaceByVolume[v.path];
+ return [
+ Padding(
+ padding: const EdgeInsets.all(8),
+ child: Text(v.path),
+ ),
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 8),
+ child: InfoRowGroup(
+ info: {
+ 'description': v.getDescription(context),
+ 'isPrimary': '${v.isPrimary}',
+ 'isRemovable': '${v.isRemovable}',
+ 'state': v.state,
+ if (freeSpace != null) 'freeSpace': formatFileSize(asciiLocale, freeSpace),
+ },
+ ),
+ ),
+ const Divider(),
+ ];
+ })
+ ],
+ );
+ }
+
+ @override
+ bool get wantKeepAlive => true;
+}
diff --git a/lib/widgets/debug/report.dart b/lib/widgets/debug/report.dart
new file mode 100644
index 0000000..4a7e72d
--- /dev/null
+++ b/lib/widgets/debug/report.dart
@@ -0,0 +1,69 @@
+import 'package:aves/services/android_debug_service.dart';
+import 'package:aves/services/common/services.dart';
+import 'package:aves/widgets/common/identity/aves_expansion_tile.dart';
+import 'package:aves/widgets/viewer/info/common.dart';
+import 'package:flutter/material.dart';
+
+class DebugErrorReportingSection extends StatefulWidget {
+ const DebugErrorReportingSection({super.key});
+
+ @override
+ State<DebugErrorReportingSection> createState() => _DebugErrorReportingSectionState();
+}
+
+class _DebugErrorReportingSectionState extends State<DebugErrorReportingSection> with AutomaticKeepAliveClientMixin {
+ @override
+ Widget build(BuildContext context) {
+ super.build(context);
+
+ return AvesExpansionTile(
+ title: 'Reporting',
+ children: [
+ const Padding(
+ padding: EdgeInsets.symmetric(horizontal: 8),
+ child: ElevatedButton(
+ onPressed: AndroidDebugService.crash,
+ child: Text('Crash'),
+ ),
+ ),
+ const Padding(
+ padding: EdgeInsets.symmetric(horizontal: 8),
+ child: ElevatedButton(
+ onPressed: AndroidDebugService.exception,
+ child: Text('Throw exception'),
+ ),
+ ),
+ const Padding(
+ padding: EdgeInsets.symmetric(horizontal: 8),
+ child: ElevatedButton(
+ onPressed: AndroidDebugService.safeException,
+ child: Text('Throw exception (safe)'),
+ ),
+ ),
+ const Padding(
+ padding: EdgeInsets.symmetric(horizontal: 8),
+ child: ElevatedButton(
+ onPressed: AndroidDebugService.exceptionInCoroutine,
+ child: Text('Throw exception in coroutine'),
+ ),
+ ),
+ const Padding(
+ padding: EdgeInsets.symmetric(horizontal: 8),
+ child: ElevatedButton(
+ onPressed: AndroidDebugService.safeExceptionInCoroutine,
+ child: Text('Throw exception in coroutine (safe)'),
+ ),
+ ),
+ Padding(
+ padding: const EdgeInsets.only(left: 8, right: 8, bottom: 8),
+ child: InfoRowGroup(
+ info: reportService.state,
+ ),
+ )
+ ],
+ );
+ }
+
+ @override
+ bool get wantKeepAlive => true;
+}
diff --git a/lib/widgets/debug/settings.dart b/lib/widgets/debug/settings.dart
new file mode 100644
index 0000000..beb0177
--- /dev/null
+++ b/lib/widgets/debug/settings.dart
@@ -0,0 +1,95 @@
+import 'package:aves/model/settings/settings.dart';
+import 'package:aves/widgets/collection/collection_page.dart';
+import 'package:aves/widgets/common/identity/aves_expansion_tile.dart';
+import 'package:aves/widgets/filter_grids/albums_page.dart';
+import 'package:aves/widgets/filter_grids/countries_page.dart';
+import 'package:aves/widgets/filter_grids/places_page.dart';
+import 'package:aves/widgets/filter_grids/tags_page.dart';
+import 'package:aves/widgets/viewer/info/common.dart';
+import 'package:flutter/material.dart';
+import 'package:provider/provider.dart';
+
+class DebugSettingsSection extends StatefulWidget {
+ const DebugSettingsSection({super.key});
+
+ @override
+ State<DebugSettingsSection> createState() => _DebugSettingsSectionState();
+}
+
+class _DebugSettingsSectionState extends State<DebugSettingsSection> with AutomaticKeepAliveClientMixin {
+ @override
+ Widget build(BuildContext context) {
+ super.build(context);
+
+ return Consumer<Settings>(
+ builder: (context, settings, child) {
+ String toMultiline(Iterable? l) => l != null && l.isNotEmpty ? '\n${l.join('\n')}' : '$l';
+ return AvesExpansionTile(
+ title: 'Settings',
+ children: [
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 8),
+ child: ElevatedButton(
+ onPressed: () => settings.reset(includeInternalKeys: true),
+ child: const Text('Reset (all store)'),
+ ),
+ ),
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 8),
+ child: ElevatedButton(
+ onPressed: () => settings.reset(includeInternalKeys: false),
+ child: const Text('Reset (user preferences)'),
+ ),
+ ),
+ SwitchListTile(
+ value: settings.hasAcceptedTerms,
+ onChanged: (v) => settings.hasAcceptedTerms = v,
+ title: const Text('hasAcceptedTerms'),
+ ),
+ SwitchListTile(
+ value: settings.canUseAnalysisService,
+ onChanged: (v) => settings.canUseAnalysisService = v,
+ title: const Text('canUseAnalysisService'),
+ ),
+ Padding(
+ padding: const EdgeInsets.only(left: 8, right: 8, bottom: 8),
+ child: InfoRowGroup(
+ info: {
+ 'catalogTimeZoneRawOffsetMillis': '${settings.catalogTimeZoneOffsetMillis}',
+ 'tileExtent - Collection': '${settings.getTileExtent(CollectionPage.routeName)}',
+ 'tileExtent - Albums': '${settings.getTileExtent(AlbumListPage.routeName)}',
+ 'tileExtent - Countries': '${settings.getTileExtent(CountryListPage.routeName)}',
+ 'tileExtent - Places': '${settings.getTileExtent(PlaceListPage.routeName)}',
+ 'tileExtent - Tags': '${settings.getTileExtent(TagListPage.routeName)}',
+ 'mapStyle': '${settings.mapStyle}',
+ 'infoMapZoom': '${settings.infoMapZoom}',
+ 'customMapStyles': toMultiline(settings.customMapStyles),
+ 'collectionSelectionQuickActions': '${settings.collectionSelectionQuickActions}',
+ 'viewerQuickActions': '${settings.viewerQuickActions}',
+ 'drawerTypeBookmarks': toMultiline(settings.drawerTypeBookmarks),
+ 'drawerAlbumBookmarks': toMultiline(settings.drawerAlbumBookmarks),
+ 'drawerPageBookmarks': toMultiline(settings.drawerPageBookmarks),
+ 'pinnedFilters': toMultiline(settings.pinnedFilters),
+ 'hiddenFilters': toMultiline(settings.hiddenFilters),
+ 'deactivatedHiddenFilters': toMultiline(settings.deactivatedHiddenFilters),
+ 'searchHistory': toMultiline(settings.searchHistory),
+ 'recentDestinationAlbums': toMultiline(settings.recentDestinationAlbums),
+ 'recentTags': toMultiline(settings.recentTags),
+ 'locale': '${settings.locale}',
+ 'systemLocales': '${WidgetsBinding.instance.platformDispatcher.locales}',
+ 'topEntryIds': '${settings.topEntryIds}',
+ 'longPressTimeout': '${settings.longPressTimeout}',
+ 'albumGroups': toMultiline(settings.albumGroups.entries),
+ 'tagGroups': toMultiline(settings.tagGroups.entries),
+ },
+ ),
+ ),
+ ],
+ );
+ },
+ );
+ }
+
+ @override
+ bool get wantKeepAlive => true;
+}