mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-10-20 17:53:46 +02:00
Allow excluding secret values from export file (#2430)
This commit is contained in:
@@ -1037,7 +1037,7 @@ class AppsPageState extends State<AppsPage> {
|
||||
var exportJSON = encoder.convert(
|
||||
appsProvider.generateExportJSON(
|
||||
appIds: selectedApps.map((e) => e.id).toList(),
|
||||
overrideExportSettings: false,
|
||||
overrideExportSettings: 0,
|
||||
),
|
||||
);
|
||||
String fn =
|
||||
|
@@ -412,9 +412,7 @@ class _ImportExportPageState extends State<ImportExportPage> {
|
||||
child: TextButton(
|
||||
style: outlineButtonStyle,
|
||||
onPressed:
|
||||
appsProvider.apps.isEmpty ||
|
||||
importInProgress ||
|
||||
snapshot.data == null
|
||||
importInProgress || snapshot.data == null
|
||||
? null
|
||||
: runObtainiumExport,
|
||||
child: Text(
|
||||
@@ -457,11 +455,17 @@ class _ImportExportPageState extends State<ImportExportPage> {
|
||||
),
|
||||
],
|
||||
[
|
||||
GeneratedFormSwitch(
|
||||
GeneratedFormDropdown(
|
||||
'exportSettings',
|
||||
[
|
||||
MapEntry('0', tr('none')),
|
||||
MapEntry('1', tr('excludeSecrets')),
|
||||
MapEntry('2', tr('all')),
|
||||
],
|
||||
label: tr('includeSettings'),
|
||||
defaultValue:
|
||||
settingsProvider.exportSettings,
|
||||
defaultValue: settingsProvider
|
||||
.exportSettings
|
||||
.toString(),
|
||||
),
|
||||
],
|
||||
],
|
||||
@@ -475,7 +479,7 @@ class _ImportExportPageState extends State<ImportExportPage> {
|
||||
}
|
||||
if (value['exportSettings'] != null) {
|
||||
settingsProvider.exportSettings =
|
||||
value['exportSettings'] == true;
|
||||
int.parse(value['exportSettings']);
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -497,7 +501,7 @@ class _ImportExportPageState extends State<ImportExportPage> {
|
||||
else
|
||||
Column(
|
||||
children: [
|
||||
const Divider(height: 32),
|
||||
SizedBox(height: 32),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
|
@@ -1965,7 +1965,7 @@ class AppsProvider with ChangeNotifier {
|
||||
|
||||
Map<String, dynamic> generateExportJSON({
|
||||
List<String>? appIds,
|
||||
bool? overrideExportSettings,
|
||||
int? overrideExportSettings,
|
||||
}) {
|
||||
Map<String, dynamic> finalExport = {};
|
||||
finalExport['apps'] = apps.values
|
||||
@@ -1978,15 +1978,18 @@ class AppsProvider with ChangeNotifier {
|
||||
})
|
||||
.map((e) => e.app.toJson())
|
||||
.toList();
|
||||
bool shouldExportSettings = settingsProvider.exportSettings;
|
||||
int shouldExportSettings = settingsProvider.exportSettings;
|
||||
if (overrideExportSettings != null) {
|
||||
shouldExportSettings = overrideExportSettings;
|
||||
}
|
||||
if (shouldExportSettings) {
|
||||
if (shouldExportSettings > 0) {
|
||||
var settingsValueKeys = settingsProvider.prefs?.getKeys();
|
||||
if (shouldExportSettings < 2) {
|
||||
settingsValueKeys?.removeWhere((k) => k.endsWith('-creds'));
|
||||
}
|
||||
finalExport['settings'] = Map<String, Object?>.fromEntries(
|
||||
(settingsProvider.prefs
|
||||
?.getKeys()
|
||||
.map((key) => MapEntry(key, settingsProvider.prefs?.get(key)))
|
||||
(settingsValueKeys
|
||||
?.map((key) => MapEntry(key, settingsProvider.prefs?.get(key)))
|
||||
.toList()) ??
|
||||
[],
|
||||
);
|
||||
|
@@ -453,12 +453,19 @@ class SettingsProvider with ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
bool get exportSettings {
|
||||
return prefs?.getBool('exportSettings') ?? false;
|
||||
int get exportSettings {
|
||||
try {
|
||||
return prefs?.getInt('exportSettings') ??
|
||||
1; // 0 for no, 1 for yes but no secrets, 2 for everything
|
||||
} catch (e) {
|
||||
var val = prefs?.getBool('exportSettings') == true ? 1 : 0;
|
||||
prefs?.setInt('exportSettings', val);
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
set exportSettings(bool val) {
|
||||
prefs?.setBool('exportSettings', val);
|
||||
set exportSettings(int val) {
|
||||
prefs?.setInt('exportSettings', val > 2 || val < 0 ? 1 : val);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user