chore: Merge dev to main (#1529)

This commit is contained in:
Ushie 2023-11-27 11:06:43 +03:00 committed by GitHub
commit 63c29bdd75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 50 additions and 16 deletions

View File

@ -197,7 +197,7 @@ class AppSelectorViewModel extends BaseViewModel {
Future showSelectFromStorageDialog(BuildContext context) async { Future showSelectFromStorageDialog(BuildContext context) async {
return showDialog( return showDialog(
context: context, context: context,
builder: (context) => SimpleDialog( builder: (innerContext) => SimpleDialog(
alignment: Alignment.center, alignment: Alignment.center,
contentPadding: contentPadding:
const EdgeInsets.symmetric(horizontal: 20, vertical: 20), const EdgeInsets.symmetric(horizontal: 20, vertical: 20),
@ -206,7 +206,7 @@ class AppSelectorViewModel extends BaseViewModel {
Icon( Icon(
Icons.block, Icons.block,
size: 28, size: 28,
color: Theme.of(context).colorScheme.primary, color: Theme.of(innerContext).colorScheme.primary,
), ),
const SizedBox(height: 20), const SizedBox(height: 20),
I18nText( I18nText(
@ -234,7 +234,7 @@ class AppSelectorViewModel extends BaseViewModel {
const SizedBox(height: 30), const SizedBox(height: 30),
CustomMaterialButton( CustomMaterialButton(
onPressed: () async { onPressed: () async {
Navigator.pop(context); Navigator.pop(innerContext);
await selectAppFromStorage(context); await selectAppFromStorage(context);
}, },
label: Row( label: Row(
@ -250,7 +250,7 @@ class AppSelectorViewModel extends BaseViewModel {
CustomMaterialButton( CustomMaterialButton(
isFilled: false, isFilled: false,
onPressed: () { onPressed: () {
Navigator.pop(context); Navigator.pop(innerContext);
}, },
label: Row( label: Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,

View File

@ -179,18 +179,48 @@ class InstallerViewModel extends BaseViewModel {
} }
} }
void _trimLogs(List<String> logLines, String keyword, String? newString) {
final lineCount = logLines.where((line) => line.endsWith(keyword)).length;
final index = logLines.indexWhere((line) => line.endsWith(keyword));
if (newString != null && lineCount > 0) {
logLines.insert(index, newString.replaceAll('{lineCount}', lineCount.toString()));
}
logLines.removeWhere((lines) => lines.endsWith(keyword));
}
dynamic _getPatchOptionValue(String patchName, Option option) {
final Option? savedOption = _managerAPI.getPatchOption(_app.packageName, patchName, option.key);
if (savedOption != null) {
return savedOption.value;
} else {
return option.value;
}
}
String _formatPatches(List<Patch> patches) {
if (patches.isEmpty) {
return 'None';
}
return patches.map((p) => p.name + (p.options.isEmpty ? '' : ' [${p.options.map((o) => '${o.title}: ${_getPatchOptionValue(p.name, o)}').join(", ")}]')).toList().join(', ');
}
Future<void> copyLogs() async { Future<void> copyLogs() async {
final info = await AboutInfo.getInfo(); final info = await AboutInfo.getInfo();
dynamic getValue(String patchName, Option option) {
final Option? savedOption =
_managerAPI.getPatchOption(_app.packageName, patchName, option.key);
if (savedOption != null) {
return savedOption.value;
} else {
return option.value;
}
}
// Trim out extra lines
final logsTrimmed = logs.split('\n');
_trimLogs(logsTrimmed, 'succeeded', 'Applied {lineCount} patches');
_trimLogs(logsTrimmed, '.dex', 'Compiled {lineCount} dex files');
// Get patches added / removed
final defaultPatches = _patcherAPI.getFilteredPatches(_app.packageName).where((p) => !p.excluded).toList();
final patchesAdded = _patches.where((p) => !defaultPatches.contains(p)).toList();
final patchesRemoved = defaultPatches.where((p) => !_patches.contains(p)).toList();
// Options changed
final patchesChanged = defaultPatches.where((p) => _patches.contains(p) && p.options.any((o) => _getPatchOptionValue(p.name, o) != o.value)).toList();
// Add Info
final formattedLogs = [ final formattedLogs = [
'- Device Info', '- Device Info',
'ReVanced Manager: ${info['version']}', 'ReVanced Manager: ${info['version']}',
@ -203,7 +233,10 @@ class InstallerViewModel extends BaseViewModel {
'\n- Patch Info', '\n- Patch Info',
'App: ${_app.packageName} v${_app.version}', 'App: ${_app.packageName} v${_app.version}',
'Patches version: ${_managerAPI.patchesVersion}', 'Patches version: ${_managerAPI.patchesVersion}',
'Patches: ${_patches.map((p) => p.name + (p.options.isEmpty ? '' : ' [${p.options.map((o) => '${o.title}: ${getValue(p.name, o)}').join(", ")}]')).toList().join(", ")}', 'Patches added: ${_formatPatches(patchesAdded)}',
'Patches removed: ${_formatPatches(patchesRemoved)}',
'Options changed: ${_formatPatches(patchesChanged)}',
'\n- Settings', '\n- Settings',
'Allow changing patch selection: ${_managerAPI.isPatchesChangeEnabled()}', 'Allow changing patch selection: ${_managerAPI.isPatchesChangeEnabled()}',
'Version compatibility check: ${_managerAPI.isVersionCompatibilityCheckEnabled()}', 'Version compatibility check: ${_managerAPI.isVersionCompatibilityCheckEnabled()}',
@ -212,7 +245,7 @@ class InstallerViewModel extends BaseViewModel {
'Integration source: ${_managerAPI.getIntegrationsRepo()}', 'Integration source: ${_managerAPI.getIntegrationsRepo()}',
'\n- Logs', '\n- Logs',
logs, logsTrimmed.join('\n'),
]; ];
Clipboard.setData(ClipboardData(text: formattedLogs.join('\n'))); Clipboard.setData(ClipboardData(text: formattedLogs.join('\n')));
@ -343,6 +376,7 @@ class InstallerViewModel extends BaseViewModel {
isCanceled = true; isCanceled = true;
update(0.5, 'Canceling...', 'Canceling patching process'); update(0.5, 'Canceling...', 'Canceling patching process');
await _patcherAPI.stopPatcher(); await _patcherAPI.stopPatcher();
await WakelockPlus.disable();
update(-100.0, 'Canceled...', 'Press back to exit'); update(-100.0, 'Canceled...', 'Press back to exit');
} on Exception catch (e) { } on Exception catch (e) {
if (kDebugMode) { if (kDebugMode) {

View File

@ -4,7 +4,7 @@ homepage: https://github.com/revanced/revanced-manager
publish_to: 'none' publish_to: 'none'
version: 1.16.0+101600000 version: 1.17.0+101700000
environment: environment:
sdk: '>=3.0.0 <4.0.0' sdk: '>=3.0.0 <4.0.0'