manager: clean lkm remnants

ksud: clean clippy warnings
This commit is contained in:
rifsxd
2025-05-01 16:29:16 +06:00
parent 1336996129
commit 757d20166a
9 changed files with 169 additions and 125 deletions

View File

@@ -378,12 +378,12 @@ fun SettingScreen(navigator: DestinationsNavigator) {
)
}
val lkmMode = Natives.version >= Natives.MINIMAL_SUPPORTED_KERNEL_LKM && Natives.isLkmMode
if (lkmMode) {
UninstallItem(navigator) {
loadingDialog.withLoading(it)
}
}
// val lkmMode = Natives.version >= Natives.MINIMAL_SUPPORTED_KERNEL_LKM && Natives.isLkmMode
// if (lkmMode) {
// UninstallItem(navigator) {
// loadingDialog.withLoading(it)
// }
// } // DISBAND LKM MODE
var showBottomsheet by remember { mutableStateOf(false) }
@@ -511,107 +511,107 @@ fun SettingScreen(navigator: DestinationsNavigator) {
}
}
@Composable
fun UninstallItem(
navigator: DestinationsNavigator,
withLoading: suspend (suspend () -> Unit) -> Unit,
) {
val context = LocalContext.current
val scope = rememberCoroutineScope()
val uninstallConfirmDialog = rememberConfirmDialog()
val showTodo = {
Toast.makeText(context, "TODO", Toast.LENGTH_SHORT).show()
}
val uninstallDialog = rememberUninstallDialog { uninstallType ->
scope.launch {
val result = uninstallConfirmDialog.awaitConfirm(
title = context.getString(uninstallType.title),
content = context.getString(uninstallType.message)
)
if (result == ConfirmResult.Confirmed) {
withLoading {
when (uninstallType) {
UninstallType.TEMPORARY -> showTodo()
UninstallType.PERMANENT -> navigator.navigate(
FlashScreenDestination(FlashIt.FlashUninstall)
)
UninstallType.RESTORE_STOCK_IMAGE -> navigator.navigate(
FlashScreenDestination(FlashIt.FlashRestore)
)
UninstallType.NONE -> Unit
}
}
}
}
}
val uninstall = stringResource(id = R.string.settings_uninstall)
ListItem(
leadingContent = {
Icon(
Icons.Filled.Delete,
uninstall
)
},
headlineContent = { Text(uninstall) },
modifier = Modifier.clickable {
uninstallDialog.show()
}
)
}
// @Composable
// fun UninstallItem(
// navigator: DestinationsNavigator,
// withLoading: suspend (suspend () -> Unit) -> Unit,
// ) {
// val context = LocalContext.current
// val scope = rememberCoroutineScope()
// val uninstallConfirmDialog = rememberConfirmDialog()
// val showTodo = {
// Toast.makeText(context, "TODO", Toast.LENGTH_SHORT).show()
// }
// val uninstallDialog = rememberUninstallDialog { uninstallType ->
// scope.launch {
// val result = uninstallConfirmDialog.awaitConfirm(
// title = context.getString(uninstallType.title),
// content = context.getString(uninstallType.message)
// )
// if (result == ConfirmResult.Confirmed) {
// withLoading {
// when (uninstallType) {
// UninstallType.TEMPORARY -> showTodo()
// UninstallType.PERMANENT -> navigator.navigate(
// FlashScreenDestination(FlashIt.FlashUninstall)
// )
// UninstallType.RESTORE_STOCK_IMAGE -> navigator.navigate(
// FlashScreenDestination(FlashIt.FlashRestore)
// )
// UninstallType.NONE -> Unit
// }
// }
// }
// }
// }
// val uninstall = stringResource(id = R.string.settings_uninstall)
// ListItem(
// leadingContent = {
// Icon(
// Icons.Filled.Delete,
// uninstall
// )
// },
// headlineContent = { Text(uninstall) },
// modifier = Modifier.clickable {
// uninstallDialog.show()
// }
// )
// }
enum class UninstallType(val title: Int, val message: Int, val icon: ImageVector) {
TEMPORARY(
R.string.settings_uninstall_temporary,
R.string.settings_uninstall_temporary_message,
Icons.Filled.Delete
),
PERMANENT(
R.string.settings_uninstall_permanent,
R.string.settings_uninstall_permanent_message,
Icons.Filled.DeleteForever
),
RESTORE_STOCK_IMAGE(
R.string.settings_restore_stock_image,
R.string.settings_restore_stock_image_message,
Icons.AutoMirrored.Filled.Undo
),
NONE(0, 0, Icons.Filled.Delete)
}
// enum class UninstallType(val title: Int, val message: Int, val icon: ImageVector) {
// TEMPORARY(
// R.string.settings_uninstall_temporary,
// R.string.settings_uninstall_temporary_message,
// Icons.Filled.Delete
// ),
// PERMANENT(
// R.string.settings_uninstall_permanent,
// R.string.settings_uninstall_permanent_message,
// Icons.Filled.DeleteForever
// ),
// RESTORE_STOCK_IMAGE(
// R.string.settings_restore_stock_image,
// R.string.settings_restore_stock_image_message,
// Icons.AutoMirrored.Filled.Undo
// ),
// NONE(0, 0, Icons.Filled.Delete)
// }
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun rememberUninstallDialog(onSelected: (UninstallType) -> Unit): DialogHandle {
return rememberCustomDialog { dismiss ->
val options = listOf(
// UninstallType.TEMPORARY,
UninstallType.PERMANENT,
UninstallType.RESTORE_STOCK_IMAGE
)
val listOptions = options.map {
ListOption(
titleText = stringResource(it.title),
subtitleText = if (it.message != 0) stringResource(it.message) else null,
icon = IconSource(it.icon)
)
}
// @OptIn(ExperimentalMaterial3Api::class)
// @Composable
// fun rememberUninstallDialog(onSelected: (UninstallType) -> Unit): DialogHandle {
// return rememberCustomDialog { dismiss ->
// val options = listOf(
// // UninstallType.TEMPORARY,
// UninstallType.PERMANENT,
// UninstallType.RESTORE_STOCK_IMAGE
// )
// val listOptions = options.map {
// ListOption(
// titleText = stringResource(it.title),
// subtitleText = if (it.message != 0) stringResource(it.message) else null,
// icon = IconSource(it.icon)
// )
// }
var selection = UninstallType.NONE
ListDialog(state = rememberUseCaseState(visible = true, onFinishedRequest = {
if (selection != UninstallType.NONE) {
onSelected(selection)
}
}, onCloseRequest = {
dismiss()
}), header = Header.Default(
title = stringResource(R.string.settings_uninstall),
), selection = ListSelection.Single(
showRadioButtons = false,
options = listOptions,
) { index, _ ->
selection = options[index]
})
}
}
// var selection = UninstallType.NONE
// ListDialog(state = rememberUseCaseState(visible = true, onFinishedRequest = {
// if (selection != UninstallType.NONE) {
// onSelected(selection)
// }
// }, onCloseRequest = {
// dismiss()
// }), header = Header.Default(
// title = stringResource(R.string.settings_uninstall),
// ), selection = ListSelection.Single(
// showRadioButtons = false,
// options = listOptions,
// ) { index, _ ->
// selection = options[index]
// })
// }
// } // DISBAND LKM MODE
@OptIn(ExperimentalMaterial3Api::class)
@Composable