feat: Reorder Import & Export settings (#2403)

This commit is contained in:
Ushie 2025-02-01 04:05:28 +03:00 committed by GitHub
parent 1092188ab0
commit ede1ab5ed4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 43 additions and 40 deletions

View File

@ -124,7 +124,30 @@ fun ImportExportSettingsScreen(
.fillMaxSize() .fillMaxSize()
.padding(paddingValues) .padding(paddingValues)
) { ) {
GroupHeader(stringResource(R.string.signing)) var showPackageSelector by rememberSaveable {
mutableStateOf(false)
}
var showBundleSelector by rememberSaveable {
mutableStateOf(false)
}
if (showPackageSelector) {
PackageSelector(packages = packagesWithOptions) { selected ->
selected?.let(vm::resetOptionsForPackage)
showPackageSelector = false
}
}
if (showBundleSelector) {
BundleSelector(bundles = patchBundles) { bundle ->
bundle?.let(vm::clearOptionsForBundle)
showBundleSelector = false
}
}
GroupHeader(stringResource(R.string.import_))
GroupItem( GroupItem(
onClick = { onClick = {
importKeystoreLauncher.launch("*/*") importKeystoreLauncher.launch("*/*")
@ -132,6 +155,13 @@ fun ImportExportSettingsScreen(
headline = R.string.import_keystore, headline = R.string.import_keystore,
description = R.string.import_keystore_description description = R.string.import_keystore_description
) )
GroupItem(
onClick = vm::importSelection,
headline = R.string.import_patch_selection,
description = R.string.import_patch_selection_description
)
GroupHeader(stringResource(R.string.export))
GroupItem( GroupItem(
onClick = { onClick = {
if (!vm.canExport()) { if (!vm.canExport()) {
@ -143,54 +173,25 @@ fun ImportExportSettingsScreen(
headline = R.string.export_keystore, headline = R.string.export_keystore,
description = R.string.export_keystore_description description = R.string.export_keystore_description
) )
GroupItem(
onClick = vm::regenerateKeystore,
headline = R.string.regenerate_keystore,
description = R.string.regenerate_keystore_description
)
GroupHeader(stringResource(R.string.patches))
GroupItem(
onClick = vm::importSelection,
headline = R.string.import_patch_selection,
description = R.string.import_patch_selection_description
)
GroupItem( GroupItem(
onClick = vm::exportSelection, onClick = vm::exportSelection,
headline = R.string.export_patch_selection, headline = R.string.export_patch_selection,
description = R.string.export_patch_selection_description description = R.string.export_patch_selection_description
) )
// TODO: allow resetting selection for specific bundle or package name.
GroupHeader(stringResource(R.string.reset))
GroupItem( GroupItem(
onClick = vm::resetSelection, onClick = vm::regenerateKeystore,
headline = R.string.regenerate_keystore,
description = R.string.regenerate_keystore_description
)
GroupItem(
onClick = vm::resetSelection, // TODO: allow resetting selection for specific bundle or package name.
headline = R.string.reset_patch_selection, headline = R.string.reset_patch_selection,
description = R.string.reset_patch_selection_description description = R.string.reset_patch_selection_description
) )
var showPackageSelector by rememberSaveable {
mutableStateOf(false)
}
var showBundleSelector by rememberSaveable {
mutableStateOf(false)
}
if (showPackageSelector)
PackageSelector(packages = packagesWithOptions) { selected ->
selected?.let(vm::resetOptionsForPackage)
showPackageSelector = false
}
if (showBundleSelector)
BundleSelector(bundles = patchBundles) { bundle ->
bundle?.let(vm::clearOptionsForBundle)
showBundleSelector = false
}
// TODO: patch options import/export.
GroupItem( GroupItem(
onClick = vm::resetOptions, onClick = vm::resetOptions, // TODO: patch options import/export.
headline = R.string.patch_options_reset_all, headline = R.string.patch_options_reset_all,
description = R.string.patch_options_reset_all_description, description = R.string.patch_options_reset_all_description,
) )
@ -199,7 +200,7 @@ fun ImportExportSettingsScreen(
headline = R.string.patch_options_reset_package, headline = R.string.patch_options_reset_package,
description = R.string.patch_options_reset_package_description description = R.string.patch_options_reset_package_description
) )
if (patchBundles.size > 1) if (patchBundles.size > 1) {
GroupItem( GroupItem(
onClick = { showBundleSelector = true }, onClick = { showBundleSelector = true },
headline = R.string.patch_options_reset_bundle, headline = R.string.patch_options_reset_bundle,
@ -208,6 +209,7 @@ fun ImportExportSettingsScreen(
} }
} }
} }
}
@OptIn(ExperimentalMaterial3Api::class) @OptIn(ExperimentalMaterial3Api::class)
@Composable @Composable

View File

@ -420,4 +420,5 @@
<string name="show_manager_update_dialog_on_launch">Show update message on launch</string> <string name="show_manager_update_dialog_on_launch">Show update message on launch</string>
<string name="show_manager_update_dialog_on_launch_description">Shows a popup notification whenever there is a new update available on launch.</string> <string name="show_manager_update_dialog_on_launch_description">Shows a popup notification whenever there is a new update available on launch.</string>
<string name="failed_to_import_keystore">Failed to import keystore</string> <string name="failed_to_import_keystore">Failed to import keystore</string>
<string name="export">Export</string>
</resources> </resources>