diff options
| author | mirror <mirror@localhost> | 2026-11-22 08:41:00 +0900 |
|---|---|---|
| committer | mirror <mirror@localhost> | 2026-11-22 08:41:00 +0900 |
| commit | 449d8b74bd6d9dae98a07254cdfad677b920e7b0 (patch) | |
| tree | c131c3528c4d517f56e19b854a7453fedb097d40 /lib/widgets/debug/app_debug_page.dart | |
| download | aves-src-master.tar.gz aves-src-master.zip | |
Diffstat (limited to 'lib/widgets/debug/app_debug_page.dart')
| -rw-r--r-- | lib/widgets/debug/app_debug_page.dart | 136 |
1 files changed, 136 insertions, 0 deletions
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(), + ), + ), + ); + } + } +} |
