diff --git a/assets/i18n/en.json b/assets/i18n/en.json index bf0dde0b..b8e3362c 100644 --- a/assets/i18n/en.json +++ b/assets/i18n/en.json @@ -108,6 +108,8 @@ "sourcesResetDialogText": "Are you sure you want to reset custom sources to their default values?", "contributorsLabel": "Contributors", "contributorsHint": "A list of contributors of ReVanced", + "logsLabel": "Logs", + "logsHint": "Share device debug logs", "aboutLabel": "About", "versionLabel": "Version" }, diff --git a/lib/ui/views/settings/settings_view.dart b/lib/ui/views/settings/settings_view.dart index 213c2b3a..d29fec03 100644 --- a/lib/ui/views/settings/settings_view.dart +++ b/lib/ui/views/settings/settings_view.dart @@ -124,10 +124,25 @@ class SettingsView extends StatelessWidget { ], ), const Divider(thickness: 1.0), - const SettingsSection( + SettingsSection( title: 'settingsView.infoSectionTitle', children: [ - AboutWidget(), + ListTile( + contentPadding: EdgeInsets.zero, + title: I18nText( + 'settingsView.logsLabel', + child: const Text( + '', + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.w500, + ), + ), + ), + subtitle: I18nText('settingsView.logsHint'), + onTap: () => model.exportLogcatLogs(), + ), + const AboutWidget(), ], ), ], diff --git a/lib/ui/views/settings/settings_viewmodel.dart b/lib/ui/views/settings/settings_viewmodel.dart index 5d4e8123..b08e728c 100644 --- a/lib/ui/views/settings/settings_viewmodel.dart +++ b/lib/ui/views/settings/settings_viewmodel.dart @@ -1,13 +1,17 @@ // ignore_for_file: use_build_context_synchronously +import 'dart:io'; import 'package:device_info_plus/device_info_plus.dart'; import 'package:dynamic_themes/dynamic_themes.dart'; import 'package:flutter/material.dart'; import 'package:flutter_i18n/flutter_i18n.dart'; +import 'package:logcat/logcat.dart'; +import 'package:path_provider/path_provider.dart'; import 'package:revanced_manager/app/app.locator.dart'; import 'package:revanced_manager/app/app.router.dart'; import 'package:revanced_manager/services/manager_api.dart'; import 'package:revanced_manager/ui/widgets/installerView/custom_material_button.dart'; import 'package:revanced_manager/ui/widgets/settingsView/custom_text_field.dart'; +import 'package:share_extend/share_extend.dart'; import 'package:stacked/stacked.dart'; import 'package:stacked_services/stacked_services.dart'; import 'package:timeago/timeago.dart'; @@ -220,4 +224,20 @@ class SettingsViewModel extends BaseViewModel { AndroidDeviceInfo info = await DeviceInfoPlugin().androidInfo; return info.version.sdkInt ?? -1; } + + Future exportLogcatLogs() async { + Directory appCache = await getTemporaryDirectory(); + Directory logDir = Directory('${appCache.path}/logs'); + logDir.createSync(); + String dateTime = DateTime.now() + .toIso8601String() + .replaceAll('-', '') + .replaceAll(':', '') + .replaceAll('T', '') + .replaceAll('.', ''); + File logcat = File('${logDir.path}/revanced-manager_$dateTime.log'); + String logs = await Logcat.execute(); + logcat.writeAsStringSync(logs); + ShareExtend.share(logcat.path, 'file'); + } } diff --git a/pubspec.yaml b/pubspec.yaml index 826ebc00..27f8f52a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -43,6 +43,10 @@ dependencies: injectable: ^1.5.3 intl: ^0.17.0 json_annotation: ^4.6.0 + logcat: + git: + url: https://github.com/SuaMusica/logcat + ref: feature/nullSafe package_info_plus: ^1.4.3+1 path_provider: ^2.0.11 pull_to_refresh: ^2.0.0