debug: package list
This commit is contained in:
parent
24dcb5b021
commit
8e44d4a9d9
6 changed files with 93 additions and 10 deletions
|
@ -8,7 +8,7 @@ final AndroidFileUtils androidFileUtils = AndroidFileUtils._private();
|
||||||
class AndroidFileUtils {
|
class AndroidFileUtils {
|
||||||
String primaryStorage, dcimPath, downloadPath, moviesPath, picturesPath;
|
String primaryStorage, dcimPath, downloadPath, moviesPath, picturesPath;
|
||||||
Set<StorageVolume> storageVolumes = {};
|
Set<StorageVolume> storageVolumes = {};
|
||||||
Map appNameMap = {};
|
Map _installedAppNameMap = {};
|
||||||
|
|
||||||
AChangeNotifier appNameChangeNotifier = AChangeNotifier();
|
AChangeNotifier appNameChangeNotifier = AChangeNotifier();
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ class AndroidFileUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> initAppNames() async {
|
Future<void> initAppNames() async {
|
||||||
appNameMap = await AndroidAppService.getAppNames()
|
_installedAppNameMap = await AndroidAppService.getAppNames()
|
||||||
..addAll({'KakaoTalkDownload': 'com.kakao.talk'});
|
..addAll({'KakaoTalkDownload': 'com.kakao.talk'});
|
||||||
appNameChangeNotifier.notifyListeners();
|
appNameChangeNotifier.notifyListeners();
|
||||||
}
|
}
|
||||||
|
@ -50,15 +50,16 @@ class AndroidFileUtils {
|
||||||
if (isScreenshotsPath(albumDirectory)) return AlbumType.screenshots;
|
if (isScreenshotsPath(albumDirectory)) return AlbumType.screenshots;
|
||||||
|
|
||||||
final parts = albumDirectory.split(separator);
|
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;
|
return AlbumType.regular;
|
||||||
}
|
}
|
||||||
|
|
||||||
String getAlbumAppPackageName(String albumDirectory) {
|
bool _isInstalledAppName(String name) => _installedAppNameMap.keys.contains(name);
|
||||||
final parts = albumDirectory.split(separator);
|
|
||||||
return appNameMap[parts.last];
|
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 }
|
enum AlbumType { regular, app, camera, download, screenRecordings, screenshots }
|
||||||
|
|
80
lib/widgets/debug/android_apps.dart
Normal file
80
lib/widgets/debug/android_apps.dart
Normal 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;
|
||||||
|
}
|
|
@ -24,7 +24,7 @@ class _DebugAndroidDirSectionState extends State<DebugAndroidDirSection> with Au
|
||||||
super.build(context);
|
super.build(context);
|
||||||
|
|
||||||
return AvesExpansionTile(
|
return AvesExpansionTile(
|
||||||
title: 'Android Dir',
|
title: 'Android Dirs',
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.only(left: 8, right: 8, bottom: 8),
|
padding: EdgeInsets.only(left: 8, right: 8, bottom: 8),
|
||||||
|
|
|
@ -2,6 +2,7 @@ import 'package:aves/model/entry.dart';
|
||||||
import 'package:aves/model/source/collection_source.dart';
|
import 'package:aves/model/source/collection_source.dart';
|
||||||
import 'package:aves/widgets/common/identity/aves_expansion_tile.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/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_dirs.dart';
|
||||||
import 'package:aves/widgets/debug/android_env.dart';
|
import 'package:aves/widgets/debug/android_env.dart';
|
||||||
import 'package:aves/widgets/debug/cache.dart';
|
import 'package:aves/widgets/debug/cache.dart';
|
||||||
|
@ -42,6 +43,7 @@ class _AppDebugPageState extends State<AppDebugPage> {
|
||||||
padding: EdgeInsets.all(8),
|
padding: EdgeInsets.all(8),
|
||||||
children: [
|
children: [
|
||||||
_buildGeneralTabView(),
|
_buildGeneralTabView(),
|
||||||
|
DebugAndroidAppSection(),
|
||||||
DebugAndroidDirSection(),
|
DebugAndroidDirSection(),
|
||||||
DebugAndroidEnvironmentSection(),
|
DebugAndroidEnvironmentSection(),
|
||||||
DebugCacheSection(),
|
DebugCacheSection(),
|
||||||
|
|
|
@ -136,7 +136,7 @@ class _OwnerPropState extends State<OwnerProp> {
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
final packageName = snapshot.data;
|
final packageName = snapshot.data;
|
||||||
if (packageName == null) return SizedBox();
|
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(
|
return Text.rich(
|
||||||
TextSpan(
|
TextSpan(
|
||||||
children: [
|
children: [
|
||||||
|
|
|
@ -64,7 +64,7 @@ class _InfoPageState extends State<InfoPage> {
|
||||||
entry: entry,
|
entry: entry,
|
||||||
visibleNotifier: widget.visibleNotifier,
|
visibleNotifier: widget.visibleNotifier,
|
||||||
scrollController: _scrollController,
|
scrollController: _scrollController,
|
||||||
split: mqWidth > 400,
|
split: mqWidth > 600,
|
||||||
goToViewer: _goToViewer,
|
goToViewer: _goToViewer,
|
||||||
)
|
)
|
||||||
: SizedBox.shrink();
|
: SizedBox.shrink();
|
||||||
|
|
Loading…
Reference in a new issue