fix: exported logs patch selection (#1535)

Co-authored-by: validcube <pun.butrach@gmail.com>
This commit is contained in:
Benjamin 2023-12-22 20:29:36 -08:00 committed by GitHub
parent a0b673c138
commit 2ae8d49526
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -200,20 +200,18 @@ class InstallerViewModel extends BaseViewModel {
} }
} }
String _formatPatches(List<Patch> patches) { String _formatPatches(List<Patch> patches, String noneString) {
if (patches.isEmpty) { return patches.isEmpty
return 'None'; ? noneString
} : patches.map((p) {
return patches final optionsChanged = p.options
.map( .where((o) => _getPatchOptionValue(p.name, o) != o.value)
(p) => .toList();
p.name + return p.name +
(p.options.isEmpty (optionsChanged.isEmpty
? '' ? ''
: ' [${p.options.map((o) => '${o.title}: ${_getPatchOptionValue(p.name, o)}').join(", ")}]'), : ' [${optionsChanged.map((o) => '${o.title}: ${_getPatchOptionValue(p.name, o)}').join(", ")}]');
) }).join(', ');
.toList()
.join(', ');
} }
String _getSuggestedVersion(String packageName) { String _getSuggestedVersion(String packageName) {
@ -239,16 +237,17 @@ class InstallerViewModel extends BaseViewModel {
.getFilteredPatches(_app.packageName) .getFilteredPatches(_app.packageName)
.where((p) => !p.excluded) .where((p) => !p.excluded)
.toList(); .toList();
final patchesAdded = final appliedPatchesNames = _patches.map((p) => p.name).toList();
_patches.where((p) => !defaultPatches.contains(p)).toList();
final patchesRemoved =
defaultPatches.where((p) => !_patches.contains(p)).toList();
// Options changed final patchesAdded = _patches.where((p) => p.excluded).toList();
final patchesChanged = defaultPatches final patchesRemoved = defaultPatches
.where((p) => !appliedPatchesNames.contains(p.name))
.map((p) => p.name)
.toList();
final patchesOptionsChanged = defaultPatches
.where( .where(
(p) => (p) =>
_patches.contains(p) && appliedPatchesNames.contains(p.name) &&
p.options.any((o) => _getPatchOptionValue(p.name, o) != o.value), p.options.any((o) => _getPatchOptionValue(p.name, o) != o.value),
) )
.toList(); .toList();
@ -257,7 +256,6 @@ class InstallerViewModel extends BaseViewModel {
final formattedLogs = [ final formattedLogs = [
'- Device Info', '- Device Info',
'ReVanced Manager: ${info['version']}', 'ReVanced Manager: ${info['version']}',
'Build: ${info['flavor']}',
'Model: ${info['model']}', 'Model: ${info['model']}',
'Android version: ${info['androidVersion']}', 'Android version: ${info['androidVersion']}',
'Supported architectures: ${info['supportedArch'].join(", ")}', 'Supported architectures: ${info['supportedArch'].join(", ")}',
@ -266,9 +264,9 @@ class InstallerViewModel extends BaseViewModel {
'\n- Patch Info', '\n- Patch Info',
'App: ${_app.packageName} v${_app.version} (Suggested: ${_getSuggestedVersion(_app.packageName)})', 'App: ${_app.packageName} v${_app.version} (Suggested: ${_getSuggestedVersion(_app.packageName)})',
'Patches version: ${_managerAPI.patchesVersion}', 'Patches version: ${_managerAPI.patchesVersion}',
'Patches added: ${_formatPatches(patchesAdded)}', 'Patches added: ${_formatPatches(patchesAdded, 'Default')}',
'Patches removed: ${_formatPatches(patchesRemoved)}', 'Patches removed: ${patchesRemoved.isEmpty ? 'None' : patchesRemoved.join(', ')}',
'Options changed: ${_formatPatches(patchesChanged)}', // 'Default patch options changed: ${_formatPatches(patchesOptionsChanged, 'None')}', //
'\n- Settings', '\n- Settings',
'Allow changing patch selection: ${_managerAPI.isPatchesChangeEnabled()}', 'Allow changing patch selection: ${_managerAPI.isPatchesChangeEnabled()}',