feat: Add export of logcat logs to Settings

This commit is contained in:
Alberto Ponces 2022-09-13 17:46:22 +01:00
parent d613cece15
commit c92b889cd9
4 changed files with 43 additions and 2 deletions

View File

@ -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"
},

View File

@ -124,10 +124,25 @@ class SettingsView extends StatelessWidget {
],
),
const Divider(thickness: 1.0),
const SettingsSection(
SettingsSection(
title: 'settingsView.infoSectionTitle',
children: <Widget>[
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(),
],
),
],

View File

@ -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<void> 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');
}
}

View File

@ -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