Skip to content

Commit

Permalink
fix: exported logs patch selection (ReVanced#1535)
Browse files Browse the repository at this point in the history
Co-authored-by: validcube <[email protected]>
  • Loading branch information
BenjaminHalko and validcube authored Dec 23, 2023
1 parent a0b673c commit 2ae8d49
Showing 1 changed file with 23 additions and 25 deletions.
48 changes: 23 additions & 25 deletions lib/ui/views/installer/installer_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -200,20 +200,18 @@ class InstallerViewModel extends BaseViewModel {
}
}

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(', ');
String _formatPatches(List<Patch> patches, String noneString) {
return patches.isEmpty
? noneString
: patches.map((p) {
final optionsChanged = p.options
.where((o) => _getPatchOptionValue(p.name, o) != o.value)
.toList();
return p.name +
(optionsChanged.isEmpty
? ''
: ' [${optionsChanged.map((o) => '${o.title}: ${_getPatchOptionValue(p.name, o)}').join(", ")}]');
}).join(', ');
}

String _getSuggestedVersion(String packageName) {
Expand All @@ -239,16 +237,17 @@ class InstallerViewModel extends BaseViewModel {
.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();
final appliedPatchesNames = _patches.map((p) => p.name).toList();

// Options changed
final patchesChanged = defaultPatches
final patchesAdded = _patches.where((p) => p.excluded).toList();
final patchesRemoved = defaultPatches
.where((p) => !appliedPatchesNames.contains(p.name))
.map((p) => p.name)
.toList();
final patchesOptionsChanged = defaultPatches
.where(
(p) =>
_patches.contains(p) &&
appliedPatchesNames.contains(p.name) &&
p.options.any((o) => _getPatchOptionValue(p.name, o) != o.value),
)
.toList();
Expand All @@ -257,7 +256,6 @@ class InstallerViewModel extends BaseViewModel {
final formattedLogs = [
'- Device Info',
'ReVanced Manager: ${info['version']}',
'Build: ${info['flavor']}',
'Model: ${info['model']}',
'Android version: ${info['androidVersion']}',
'Supported architectures: ${info['supportedArch'].join(", ")}',
Expand All @@ -266,9 +264,9 @@ class InstallerViewModel extends BaseViewModel {
'\n- Patch Info',
'App: ${_app.packageName} v${_app.version} (Suggested: ${_getSuggestedVersion(_app.packageName)})',
'Patches version: ${_managerAPI.patchesVersion}',
'Patches added: ${_formatPatches(patchesAdded)}',
'Patches removed: ${_formatPatches(patchesRemoved)}',
'Options changed: ${_formatPatches(patchesChanged)}', //
'Patches added: ${_formatPatches(patchesAdded, 'Default')}',
'Patches removed: ${patchesRemoved.isEmpty ? 'None' : patchesRemoved.join(', ')}',
'Default patch options changed: ${_formatPatches(patchesOptionsChanged, 'None')}', //

'\n- Settings',
'Allow changing patch selection: ${_managerAPI.isPatchesChangeEnabled()}',
Expand Down

0 comments on commit 2ae8d49

Please sign in to comment.