debug: package list

This commit is contained in:
Thibault Deckers 2021-01-29 11:23:34 +09:00
parent 24dcb5b021
commit 8e44d4a9d9
6 changed files with 93 additions and 10 deletions

View file

@ -8,7 +8,7 @@ final AndroidFileUtils androidFileUtils = AndroidFileUtils._private();
class AndroidFileUtils {
String primaryStorage, dcimPath, downloadPath, moviesPath, picturesPath;
Set<StorageVolume> storageVolumes = {};
Map appNameMap = {};
Map _installedAppNameMap = {};
AChangeNotifier appNameChangeNotifier = AChangeNotifier();
@ -25,7 +25,7 @@ class AndroidFileUtils {
}
Future<void> initAppNames() async {
appNameMap = await AndroidAppService.getAppNames()
_installedAppNameMap = await AndroidAppService.getAppNames()
..addAll({'KakaoTalkDownload': 'com.kakao.talk'});
appNameChangeNotifier.notifyListeners();
}
@ -50,15 +50,16 @@ class AndroidFileUtils {
if (isScreenshotsPath(albumDirectory)) return AlbumType.screenshots;
final parts = albumDirectory.split(separator);
if (albumDirectory.startsWith(primaryStorage) && appNameMap.keys.contains(parts.last)) return AlbumType.app;
if (albumDirectory.startsWith(primaryStorage) && _isInstalledAppName(parts.last)) return AlbumType.app;
}
return AlbumType.regular;
}
String getAlbumAppPackageName(String albumDirectory) {
final parts = albumDirectory.split(separator);
return appNameMap[parts.last];
}
bool _isInstalledAppName(String name) => _installedAppNameMap.keys.contains(name);
String getAlbumAppPackageName(String albumDirectory) => _installedAppNameMap[albumDirectory.split(separator).last];
String getAppName(String packageName) => _installedAppNameMap.entries.firstWhere((kv) => kv.value == packageName, orElse: () => null)?.key;
}
enum AlbumType { regular, app, camera, download, screenRecordings, screenshots }

View file

@ -0,0 +1,80 @@
import 'package:aves/image_providers/app_icon_image_provider.dart';
import 'package:aves/services/android_app_service.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 DebugAndroidAppSection extends StatefulWidget {
@override
_DebugAndroidAppSectionState createState() => _DebugAndroidAppSectionState();
}
class _DebugAndroidAppSectionState extends State<DebugAndroidAppSection> with AutomaticKeepAliveClientMixin {
Future<Map> _loader;
static const iconSize = 20.0;
@override
void initState() {
super.initState();
_loader = AndroidAppService.getAppNames();
}
@override
Widget build(BuildContext context) {
super.build(context);
return AvesExpansionTile(
title: 'Android Apps',
children: [
Padding(
padding: 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 SizedBox.shrink();
final entries = snapshot.data.entries.toList()..sort((kv1, kv2) => compareAsciiUpperCase(kv1.value, kv2.value));
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: entries.map((kv) {
final appName = kv.key.toString();
final packageName = kv.value.toString();
return Text.rich(
TextSpan(
children: [
WidgetSpan(
alignment: PlaceholderAlignment.middle,
child: Image(
image: AppIconImage(
packageName: packageName,
size: iconSize,
),
width: iconSize,
height: iconSize,
),
),
TextSpan(
text: ' $packageName',
style: InfoRowGroup.keyStyle,
),
TextSpan(
text: ' $appName',
style: InfoRowGroup.baseStyle,
),
],
),
);
}).toList(),
);
},
),
),
],
);
}
@override
bool get wantKeepAlive => true;
}

View file

@ -24,7 +24,7 @@ class _DebugAndroidDirSectionState extends State<DebugAndroidDirSection> with Au
super.build(context);
return AvesExpansionTile(
title: 'Android Dir',
title: 'Android Dirs',
children: [
Padding(
padding: EdgeInsets.only(left: 8, right: 8, bottom: 8),

View file

@ -2,6 +2,7 @@ import 'package:aves/model/entry.dart';
import 'package:aves/model/source/collection_source.dart';
import 'package:aves/widgets/common/identity/aves_expansion_tile.dart';
import 'package:aves/widgets/common/providers/media_query_data_provider.dart';
import 'package:aves/widgets/debug/android_apps.dart';
import 'package:aves/widgets/debug/android_dirs.dart';
import 'package:aves/widgets/debug/android_env.dart';
import 'package:aves/widgets/debug/cache.dart';
@ -42,6 +43,7 @@ class _AppDebugPageState extends State<AppDebugPage> {
padding: EdgeInsets.all(8),
children: [
_buildGeneralTabView(),
DebugAndroidAppSection(),
DebugAndroidDirSection(),
DebugAndroidEnvironmentSection(),
DebugCacheSection(),

View file

@ -136,7 +136,7 @@ class _OwnerPropState extends State<OwnerProp> {
builder: (context, snapshot) {
final packageName = snapshot.data;
if (packageName == null) return SizedBox();
final appName = androidFileUtils.appNameMap.entries.firstWhere((kv) => kv.value == packageName, orElse: () => null)?.key ?? packageName;
final appName = androidFileUtils.getAppName(packageName) ?? packageName;
return Text.rich(
TextSpan(
children: [

View file

@ -64,7 +64,7 @@ class _InfoPageState extends State<InfoPage> {
entry: entry,
visibleNotifier: widget.visibleNotifier,
scrollController: _scrollController,
split: mqWidth > 400,
split: mqWidth > 600,
goToViewer: _goToViewer,
)
: SizedBox.shrink();