mirror of
https://github.com/revanced/revanced-manager.git
synced 2025-05-02 14:54:25 +02:00
feat(patcher): improve logs (#1299)
Co-authored-by: Ushie <ushiekane@gmail.com> Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
This commit is contained in:
parent
b1c9aedac3
commit
8fd4fe0e55
@ -158,6 +158,9 @@
|
|||||||
"exportApkButtonTooltip": "Export patched APK",
|
"exportApkButtonTooltip": "Export patched APK",
|
||||||
"exportLogButtonTooltip": "Export log",
|
"exportLogButtonTooltip": "Export log",
|
||||||
|
|
||||||
|
"screenshotDetected": "A screenshot has been detected. If you are trying to share the log, please share a text copy instead.\n\nCopy log to clipboard?",
|
||||||
|
"copiedToClipboard": "Copied log to clipboard",
|
||||||
|
|
||||||
"noExit": "Installer is still running, cannot exit..."
|
"noExit": "Installer is still running, cannot exit..."
|
||||||
},
|
},
|
||||||
"settingsView": {
|
"settingsView": {
|
||||||
|
@ -273,7 +273,7 @@ class PatcherAPI {
|
|||||||
.replaceAll(':', '')
|
.replaceAll(':', '')
|
||||||
.replaceAll('T', '')
|
.replaceAll('T', '')
|
||||||
.replaceAll('.', '');
|
.replaceAll('.', '');
|
||||||
final String fileName = 'revanced-manager_patcher_$dateTime.log';
|
final String fileName = 'revanced-manager_patcher_$dateTime.txt';
|
||||||
final File log = File('${logDir.path}/$fileName');
|
final File log = File('${logDir.path}/$fileName');
|
||||||
log.writeAsStringSync(logs);
|
log.writeAsStringSync(logs);
|
||||||
CRFileSaver.saveFileWithDialog(
|
CRFileSaver.saveFileWithDialog(
|
||||||
|
@ -15,6 +15,8 @@ import 'package:revanced_manager/services/root_api.dart';
|
|||||||
import 'package:revanced_manager/services/toast.dart';
|
import 'package:revanced_manager/services/toast.dart';
|
||||||
import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart';
|
import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart';
|
||||||
import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart';
|
import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart';
|
||||||
|
import 'package:revanced_manager/utils/about_info.dart';
|
||||||
|
import 'package:screenshot_callback/screenshot_callback.dart';
|
||||||
import 'package:stacked/stacked.dart';
|
import 'package:stacked/stacked.dart';
|
||||||
import 'package:wakelock/wakelock.dart';
|
import 'package:wakelock/wakelock.dart';
|
||||||
|
|
||||||
@ -29,6 +31,7 @@ class InstallerViewModel extends BaseViewModel {
|
|||||||
'app.revanced.manager.flutter/installer',
|
'app.revanced.manager.flutter/installer',
|
||||||
);
|
);
|
||||||
final ScrollController scrollController = ScrollController();
|
final ScrollController scrollController = ScrollController();
|
||||||
|
final ScreenshotCallback screenshotCallback = ScreenshotCallback();
|
||||||
double? progress = 0.0;
|
double? progress = 0.0;
|
||||||
String logs = '';
|
String logs = '';
|
||||||
String headerLogs = '';
|
String headerLogs = '';
|
||||||
@ -38,6 +41,7 @@ class InstallerViewModel extends BaseViewModel {
|
|||||||
bool hasErrors = false;
|
bool hasErrors = false;
|
||||||
bool isCanceled = false;
|
bool isCanceled = false;
|
||||||
bool cancel = false;
|
bool cancel = false;
|
||||||
|
bool showPopupScreenshotWarning = true;
|
||||||
|
|
||||||
Future<void> initialize(BuildContext context) async {
|
Future<void> initialize(BuildContext context) async {
|
||||||
isRooted = await _rootAPI.isRooted();
|
isRooted = await _rootAPI.isRooted();
|
||||||
@ -64,6 +68,12 @@ class InstallerViewModel extends BaseViewModel {
|
|||||||
} // ignore
|
} // ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
screenshotCallback.addListener(() {
|
||||||
|
if (showPopupScreenshotWarning) {
|
||||||
|
showPopupScreenshotWarning = false;
|
||||||
|
screenshotDetected(context);
|
||||||
|
}
|
||||||
|
});
|
||||||
await Wakelock.enable();
|
await Wakelock.enable();
|
||||||
await handlePlatformChannelMethods();
|
await handlePlatformChannelMethods();
|
||||||
await runPatcher();
|
await runPatcher();
|
||||||
@ -169,6 +179,72 @@ class InstallerViewModel extends BaseViewModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> copyLogs() async {
|
||||||
|
final info = await AboutInfo.getInfo();
|
||||||
|
|
||||||
|
final formattedLogs = [
|
||||||
|
'```',
|
||||||
|
'~ Device Info',
|
||||||
|
'ReVanced Manager: ${info['version']}',
|
||||||
|
'Build: ${info['flavor']}',
|
||||||
|
'Model: ${info['model']}',
|
||||||
|
'Android version: ${info['androidVersion']}',
|
||||||
|
'Supported architectures: ${info['supportedArch'].join(", ")}',
|
||||||
|
|
||||||
|
'\n~ Patch Info',
|
||||||
|
'App: ${_app.packageName} v${_app.version}',
|
||||||
|
'Patches version: ${_managerAPI.patchesVersion}',
|
||||||
|
'Patches: ${_patches.map((p) => p.name).toList().join(", ")}',
|
||||||
|
|
||||||
|
'\n~ Settings',
|
||||||
|
'Enabled changing patches: ${_managerAPI.isPatchesChangeEnabled()}',
|
||||||
|
'Enabled universal patches: ${_managerAPI.areUniversalPatchesEnabled()}',
|
||||||
|
'Enabled experimental patches: ${_managerAPI.areExperimentalPatchesEnabled()}',
|
||||||
|
'Patches source: ${_managerAPI.getPatchesRepo()}',
|
||||||
|
'Integration source: ${_managerAPI.getIntegrationsRepo()}',
|
||||||
|
|
||||||
|
'\n~ Logs',
|
||||||
|
logs,
|
||||||
|
'```',
|
||||||
|
];
|
||||||
|
|
||||||
|
Clipboard.setData(ClipboardData(text: formattedLogs.join('\n')));
|
||||||
|
_toast.showBottom('installerView.copiedToClipboard');
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> screenshotDetected(BuildContext context) async {
|
||||||
|
await showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => AlertDialog(
|
||||||
|
title: I18nText(
|
||||||
|
'warning',
|
||||||
|
),
|
||||||
|
backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
|
||||||
|
icon: const Icon(Icons.warning),
|
||||||
|
content: SingleChildScrollView(
|
||||||
|
child: I18nText('installerView.screenshotDetected'),
|
||||||
|
),
|
||||||
|
actions: <Widget>[
|
||||||
|
CustomMaterialButton(
|
||||||
|
isFilled: false,
|
||||||
|
label: I18nText('noButton'),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
CustomMaterialButton(
|
||||||
|
label: I18nText('yesButton'),
|
||||||
|
onPressed: () {
|
||||||
|
copyLogs();
|
||||||
|
showPopupScreenshotWarning = true;
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> installTypeDialog(BuildContext context) async {
|
Future<void> installTypeDialog(BuildContext context) async {
|
||||||
final ValueNotifier<int> installType = ValueNotifier(0);
|
final ValueNotifier<int> installType = ValueNotifier(0);
|
||||||
if (isRooted) {
|
if (isRooted) {
|
||||||
@ -316,10 +392,6 @@ class InstallerViewModel extends BaseViewModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void exportLog() {
|
|
||||||
_patcherAPI.exportPatcherLog(logs);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> cleanPatcher() async {
|
Future<void> cleanPatcher() async {
|
||||||
try {
|
try {
|
||||||
_patcherAPI.cleanPatcher();
|
_patcherAPI.cleanPatcher();
|
||||||
@ -343,7 +415,7 @@ class InstallerViewModel extends BaseViewModel {
|
|||||||
exportResult();
|
exportResult();
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
exportLog();
|
copyLogs();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -365,6 +437,7 @@ class InstallerViewModel extends BaseViewModel {
|
|||||||
} else {
|
} else {
|
||||||
_patcherAPI.cleanPatcher();
|
_patcherAPI.cleanPatcher();
|
||||||
}
|
}
|
||||||
|
screenshotCallback.dispose();
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -75,6 +75,7 @@ dependencies:
|
|||||||
flutter_markdown: ^0.6.14
|
flutter_markdown: ^0.6.14
|
||||||
dio_cache_interceptor: ^3.4.0
|
dio_cache_interceptor: ^3.4.0
|
||||||
install_plugin: ^2.1.0
|
install_plugin: ^2.1.0
|
||||||
|
screenshot_callback: ^3.0.1
|
||||||
synchronized: ^3.1.0
|
synchronized: ^3.1.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user