You've already forked KernelSU-Next
mirror of
https://github.com/KernelSU-Next/KernelSU-Next.git
synced 2025-08-27 23:46:34 +00:00
manager: add legacy ui toggle
This commit is contained in:
@@ -633,243 +633,481 @@ fun ModuleItem(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val useLagacyUI = prefs.getBoolean("use_legacyui", false)
|
||||||
|
|
||||||
LaunchedEffect(Unit) {
|
LaunchedEffect(Unit) {
|
||||||
developerOptionsEnabled = prefs.getBoolean("enable_developer_options", false)
|
developerOptionsEnabled = prefs.getBoolean("enable_developer_options", false)
|
||||||
}
|
}
|
||||||
|
|
||||||
Column(
|
if (useLagacyUI) {
|
||||||
modifier = Modifier
|
Column(
|
||||||
.padding(22.dp, 18.dp, 22.dp, 12.dp)
|
modifier = Modifier
|
||||||
) {
|
.padding(22.dp, 18.dp, 22.dp, 12.dp)
|
||||||
Row(
|
|
||||||
modifier = Modifier.fillMaxWidth(),
|
|
||||||
horizontalArrangement = Arrangement.SpaceBetween
|
|
||||||
) {
|
) {
|
||||||
val moduleVersion = stringResource(id = R.string.module_version)
|
Row(
|
||||||
val moduleAuthor = stringResource(id = R.string.module_author)
|
modifier = Modifier.fillMaxWidth(),
|
||||||
val moduleId = stringResource(id = R.string.module_id)
|
horizontalArrangement = Arrangement.SpaceBetween,
|
||||||
val moduleVersionCode = stringResource(id = R.string.module_version_code)
|
|
||||||
val moduleUpdateJson = stringResource(id = R.string.module_update_json)
|
|
||||||
val moduleUpdateJsonEmpty = stringResource(id = R.string.module_update_json_empty)
|
|
||||||
|
|
||||||
Column(
|
|
||||||
modifier = Modifier.fillMaxWidth(0.8f)
|
|
||||||
) {
|
) {
|
||||||
Row(
|
val moduleVersion = stringResource(id = R.string.module_version)
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
val moduleAuthor = stringResource(id = R.string.module_author)
|
||||||
horizontalArrangement = Arrangement.spacedBy(6.dp)
|
val moduleId = stringResource(id = R.string.module_id)
|
||||||
|
val moduleVersionCode = stringResource(id = R.string.module_version_code)
|
||||||
|
val moduleUpdateJson = stringResource(id = R.string.module_update_json)
|
||||||
|
val moduleUpdateJsonEmpty = stringResource(id = R.string.module_update_json_empty)
|
||||||
|
|
||||||
|
Column(
|
||||||
|
modifier = Modifier.fillMaxWidth(0.8f)
|
||||||
) {
|
) {
|
||||||
LabelItem(
|
Text(
|
||||||
text = if (module.enabled) stringResource(R.string.enabled) else stringResource(R.string.disabled),
|
text = module.name,
|
||||||
style = if (module.enabled)
|
fontSize = MaterialTheme.typography.titleMedium.fontSize,
|
||||||
com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy()
|
fontWeight = FontWeight.SemiBold,
|
||||||
else
|
lineHeight = MaterialTheme.typography.bodySmall.lineHeight,
|
||||||
com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy(
|
fontFamily = MaterialTheme.typography.titleMedium.fontFamily,
|
||||||
containerColor = MaterialTheme.colorScheme.errorContainer,
|
textDecoration = textDecoration,
|
||||||
contentColor = MaterialTheme.colorScheme.onErrorContainer
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
if (module.remove) {
|
|
||||||
LabelItem(
|
Text(
|
||||||
text = stringResource(R.string.uninstalled),
|
text = "$moduleVersion: ${module.version}",
|
||||||
style = com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy(
|
fontSize = MaterialTheme.typography.bodySmall.fontSize,
|
||||||
containerColor = MaterialTheme.colorScheme.errorContainer,
|
lineHeight = MaterialTheme.typography.bodySmall.lineHeight,
|
||||||
contentColor = MaterialTheme.colorScheme.onErrorContainer
|
fontFamily = MaterialTheme.typography.bodySmall.fontFamily,
|
||||||
)
|
textDecoration = textDecoration
|
||||||
|
)
|
||||||
|
|
||||||
|
Text(
|
||||||
|
text = "$moduleAuthor: ${module.author}",
|
||||||
|
fontSize = MaterialTheme.typography.bodySmall.fontSize,
|
||||||
|
lineHeight = MaterialTheme.typography.bodySmall.lineHeight,
|
||||||
|
fontFamily = MaterialTheme.typography.bodySmall.fontFamily,
|
||||||
|
textDecoration = textDecoration
|
||||||
|
)
|
||||||
|
|
||||||
|
if (developerOptionsEnabled) {
|
||||||
|
|
||||||
|
Text(
|
||||||
|
text = "$moduleId: ${module.id}",
|
||||||
|
fontSize = MaterialTheme.typography.bodySmall.fontSize,
|
||||||
|
lineHeight = MaterialTheme.typography.bodySmall.lineHeight,
|
||||||
|
fontFamily = MaterialTheme.typography.bodySmall.fontFamily,
|
||||||
|
textDecoration = textDecoration
|
||||||
)
|
)
|
||||||
}
|
|
||||||
if (updateUrl.isNotEmpty() && !module.remove && !module.update) {
|
Text(
|
||||||
LabelItem(
|
text = "$moduleVersionCode: ${module.versionCode}",
|
||||||
text = stringResource(R.string.module_update),
|
fontSize = MaterialTheme.typography.bodySmall.fontSize,
|
||||||
style = com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy(
|
lineHeight = MaterialTheme.typography.bodySmall.lineHeight,
|
||||||
containerColor = MaterialTheme.colorScheme.onTertiary,
|
fontFamily = MaterialTheme.typography.bodySmall.fontFamily,
|
||||||
contentColor = MaterialTheme.colorScheme.onTertiaryContainer
|
textDecoration = textDecoration
|
||||||
)
|
|
||||||
)
|
)
|
||||||
}
|
|
||||||
if (!module.remove) {
|
Text(
|
||||||
if (module.update) {
|
text = if (module.updateJson.isNotEmpty()) "$moduleUpdateJson: ${module.updateJson}" else "$moduleUpdateJson: $moduleUpdateJsonEmpty",
|
||||||
LabelItem(
|
fontSize = MaterialTheme.typography.bodySmall.fontSize,
|
||||||
text = stringResource(R.string.module_updated),
|
lineHeight = MaterialTheme.typography.bodySmall.lineHeight,
|
||||||
style = com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy(
|
fontFamily = MaterialTheme.typography.bodySmall.fontFamily,
|
||||||
containerColor = MaterialTheme.colorScheme.tertiaryContainer,
|
textDecoration = textDecoration
|
||||||
contentColor = MaterialTheme.colorScheme.onTertiaryContainer
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (module.hasWebUi) {
|
|
||||||
LabelItem(
|
|
||||||
text = stringResource(R.string.webui),
|
|
||||||
style = com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy(
|
|
||||||
containerColor = MaterialTheme.colorScheme.primaryContainer,
|
|
||||||
contentColor = MaterialTheme.colorScheme.onPrimaryContainer
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
if (module.hasActionScript) {
|
|
||||||
LabelItem(
|
|
||||||
text = stringResource(R.string.action),
|
|
||||||
style = com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy(
|
|
||||||
containerColor = MaterialTheme.colorScheme.secondaryContainer,
|
|
||||||
contentColor = MaterialTheme.colorScheme.onSecondaryContainer
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(8.dp))
|
Spacer(modifier = Modifier.weight(1f))
|
||||||
|
|
||||||
Text(
|
Row(
|
||||||
text = module.name,
|
modifier = Modifier.fillMaxWidth(),
|
||||||
fontSize = MaterialTheme.typography.titleMedium.fontSize,
|
horizontalArrangement = Arrangement.End,
|
||||||
fontWeight = FontWeight.SemiBold,
|
) {
|
||||||
lineHeight = MaterialTheme.typography.bodySmall.lineHeight,
|
Switch(
|
||||||
fontFamily = MaterialTheme.typography.titleMedium.fontFamily,
|
enabled = !module.update,
|
||||||
textDecoration = textDecoration,
|
checked = module.enabled,
|
||||||
)
|
onCheckedChange = onCheckChanged,
|
||||||
|
interactionSource = if (!module.hasWebUi) interactionSource else null
|
||||||
Text(
|
|
||||||
text = "$moduleVersion: ${module.version}",
|
|
||||||
fontSize = MaterialTheme.typography.bodySmall.fontSize,
|
|
||||||
lineHeight = MaterialTheme.typography.bodySmall.lineHeight,
|
|
||||||
fontFamily = MaterialTheme.typography.bodySmall.fontFamily,
|
|
||||||
textDecoration = textDecoration
|
|
||||||
)
|
|
||||||
|
|
||||||
Text(
|
|
||||||
text = "$moduleAuthor: ${module.author}",
|
|
||||||
fontSize = MaterialTheme.typography.bodySmall.fontSize,
|
|
||||||
lineHeight = MaterialTheme.typography.bodySmall.lineHeight,
|
|
||||||
fontFamily = MaterialTheme.typography.bodySmall.fontFamily,
|
|
||||||
textDecoration = textDecoration
|
|
||||||
)
|
|
||||||
|
|
||||||
if (developerOptionsEnabled) {
|
|
||||||
|
|
||||||
Text(
|
|
||||||
text = "$moduleId: ${module.id}",
|
|
||||||
fontSize = MaterialTheme.typography.bodySmall.fontSize,
|
|
||||||
lineHeight = MaterialTheme.typography.bodySmall.lineHeight,
|
|
||||||
fontFamily = MaterialTheme.typography.bodySmall.fontFamily,
|
|
||||||
textDecoration = textDecoration
|
|
||||||
)
|
|
||||||
|
|
||||||
Text(
|
|
||||||
text = "$moduleVersionCode: ${module.versionCode}",
|
|
||||||
fontSize = MaterialTheme.typography.bodySmall.fontSize,
|
|
||||||
lineHeight = MaterialTheme.typography.bodySmall.lineHeight,
|
|
||||||
fontFamily = MaterialTheme.typography.bodySmall.fontFamily,
|
|
||||||
textDecoration = textDecoration
|
|
||||||
)
|
|
||||||
|
|
||||||
Text(
|
|
||||||
text = if (module.updateJson.isNotEmpty()) "$moduleUpdateJson: ${module.updateJson}" else "$moduleUpdateJson: $moduleUpdateJsonEmpty",
|
|
||||||
fontSize = MaterialTheme.typography.bodySmall.fontSize,
|
|
||||||
lineHeight = MaterialTheme.typography.bodySmall.lineHeight,
|
|
||||||
fontFamily = MaterialTheme.typography.bodySmall.fontFamily,
|
|
||||||
textDecoration = textDecoration
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Spacer(modifier = Modifier.height(12.dp))
|
||||||
|
|
||||||
|
Text(
|
||||||
|
text = module.description,
|
||||||
|
fontSize = MaterialTheme.typography.bodySmall.fontSize,
|
||||||
|
fontFamily = MaterialTheme.typography.bodySmall.fontFamily,
|
||||||
|
lineHeight = MaterialTheme.typography.bodySmall.lineHeight,
|
||||||
|
fontWeight = MaterialTheme.typography.bodySmall.fontWeight,
|
||||||
|
overflow = TextOverflow.Ellipsis,
|
||||||
|
maxLines = 4,
|
||||||
|
textDecoration = textDecoration
|
||||||
|
)
|
||||||
|
|
||||||
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
|
|
||||||
|
HorizontalDivider(thickness = Dp.Hairline)
|
||||||
|
|
||||||
|
Spacer(modifier = Modifier.height(4.dp))
|
||||||
|
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier.fillMaxWidth(),
|
horizontalArrangement = Arrangement.SpaceBetween,
|
||||||
horizontalArrangement = Arrangement.End,
|
verticalAlignment = Alignment.CenterVertically
|
||||||
) {
|
) {
|
||||||
var expanded by remember { mutableStateOf(false) }
|
if (module.hasActionScript) {
|
||||||
IconButton(onClick = { expanded = true }) {
|
FilledTonalButton(
|
||||||
Icon(
|
modifier = Modifier.defaultMinSize(52.dp, 32.dp),
|
||||||
Icons.Filled.MoreVert,
|
enabled = !module.remove && module.enabled,
|
||||||
contentDescription = "Module actions"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
DropdownMenu(
|
|
||||||
expanded = expanded,
|
|
||||||
onDismissRequest = { expanded = false }
|
|
||||||
) {
|
|
||||||
if (updateUrl.isNotEmpty() && !module.remove) {
|
|
||||||
DropdownMenuItem(
|
|
||||||
text = { Text(stringResource(R.string.module_update)) },
|
|
||||||
onClick = {
|
|
||||||
expanded = false
|
|
||||||
onUpdate(module)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
HorizontalDivider()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (module.hasWebUi) {
|
|
||||||
DropdownMenuItem(
|
|
||||||
text = { Text(stringResource(R.string.webui)) },
|
|
||||||
onClick = {
|
|
||||||
expanded = false
|
|
||||||
onClick(module)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
if (module.hasActionScript) {
|
|
||||||
DropdownMenuItem(
|
|
||||||
text = { Text(stringResource(R.string.action)) },
|
|
||||||
onClick = {
|
|
||||||
expanded = false
|
|
||||||
navigator.navigate(ExecuteModuleActionScreenDestination(module.dirId))
|
|
||||||
viewModel.markNeedRefresh()
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (module.hasWebUi || module.hasActionScript ) {
|
|
||||||
HorizontalDivider()
|
|
||||||
}
|
|
||||||
|
|
||||||
DropdownMenuItem(
|
|
||||||
text = {
|
|
||||||
Text(
|
|
||||||
if (module.enabled) stringResource(R.string.disable)
|
|
||||||
else stringResource(R.string.enable)
|
|
||||||
)
|
|
||||||
},
|
|
||||||
onClick = {
|
onClick = {
|
||||||
expanded = false
|
navigator.navigate(ExecuteModuleActionScreenDestination(module.dirId))
|
||||||
onCheckChanged(!module.enabled)
|
viewModel.markNeedRefresh()
|
||||||
|
},
|
||||||
|
contentPadding = ButtonDefaults.TextButtonContentPadding
|
||||||
|
) {
|
||||||
|
Icon(
|
||||||
|
modifier = Modifier.size(20.dp),
|
||||||
|
imageVector = Icons.Outlined.PlayArrow,
|
||||||
|
contentDescription = null
|
||||||
|
)
|
||||||
|
if (!module.hasWebUi && updateUrl.isEmpty()) {
|
||||||
|
Text(
|
||||||
|
modifier = Modifier.padding(start = 7.dp),
|
||||||
|
text = stringResource(R.string.action),
|
||||||
|
fontFamily = MaterialTheme.typography.labelMedium.fontFamily,
|
||||||
|
fontSize = MaterialTheme.typography.labelMedium.fontSize
|
||||||
|
)
|
||||||
}
|
}
|
||||||
)
|
}
|
||||||
if (module.remove) {
|
|
||||||
DropdownMenuItem(
|
Spacer(modifier = Modifier.weight(0.1f, true))
|
||||||
text = { Text(stringResource(R.string.restore)) },
|
}
|
||||||
onClick = {
|
|
||||||
expanded = false
|
if (module.hasWebUi) {
|
||||||
onRestore(module)
|
FilledTonalButton(
|
||||||
}
|
modifier = Modifier.defaultMinSize(52.dp, 32.dp),
|
||||||
|
enabled = !module.remove && module.enabled,
|
||||||
|
onClick = { onClick(module) },
|
||||||
|
interactionSource = interactionSource,
|
||||||
|
contentPadding = ButtonDefaults.TextButtonContentPadding
|
||||||
|
) {
|
||||||
|
Icon(
|
||||||
|
modifier = Modifier.size(20.dp),
|
||||||
|
imageVector = Icons.AutoMirrored.Outlined.Wysiwyg,
|
||||||
|
contentDescription = null
|
||||||
)
|
)
|
||||||
} else {
|
if (!module.hasActionScript && updateUrl.isEmpty()) {
|
||||||
DropdownMenuItem(
|
Text(
|
||||||
text = { Text(stringResource(R.string.uninstall)) },
|
modifier = Modifier.padding(start = 7.dp),
|
||||||
onClick = {
|
fontFamily = MaterialTheme.typography.labelMedium.fontFamily,
|
||||||
expanded = false
|
fontSize = MaterialTheme.typography.labelMedium.fontSize,
|
||||||
onUninstall(module)
|
text = stringResource(R.string.open)
|
||||||
}
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Spacer(modifier = Modifier.weight(1f, true))
|
||||||
|
|
||||||
|
if (updateUrl.isNotEmpty()) {
|
||||||
|
Button(
|
||||||
|
modifier = Modifier.defaultMinSize(52.dp, 32.dp),
|
||||||
|
enabled = !module.remove,
|
||||||
|
onClick = { onUpdate(module) },
|
||||||
|
shape = ButtonDefaults.textShape,
|
||||||
|
contentPadding = ButtonDefaults.TextButtonContentPadding
|
||||||
|
) {
|
||||||
|
Icon(
|
||||||
|
modifier = Modifier.size(20.dp),
|
||||||
|
imageVector = Icons.Outlined.Download,
|
||||||
|
contentDescription = null
|
||||||
)
|
)
|
||||||
|
if (!module.hasActionScript || !module.hasWebUi) {
|
||||||
|
Text(
|
||||||
|
modifier = Modifier.padding(start = 7.dp),
|
||||||
|
fontFamily = MaterialTheme.typography.labelMedium.fontFamily,
|
||||||
|
fontSize = MaterialTheme.typography.labelMedium.fontSize,
|
||||||
|
text = stringResource(R.string.module_update)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Spacer(modifier = Modifier.weight(0.1f, true))
|
||||||
|
}
|
||||||
|
|
||||||
|
if (module.remove) {
|
||||||
|
FilledTonalButton(
|
||||||
|
modifier = Modifier.defaultMinSize(52.dp, 32.dp),
|
||||||
|
onClick = { onRestore(module) },
|
||||||
|
contentPadding = ButtonDefaults.TextButtonContentPadding
|
||||||
|
) {
|
||||||
|
Icon(
|
||||||
|
modifier = Modifier.size(20.dp),
|
||||||
|
imageVector = Icons.Outlined.Restore,
|
||||||
|
contentDescription = null
|
||||||
|
)
|
||||||
|
if (!module.hasActionScript && !module.hasWebUi && updateUrl.isEmpty()) {
|
||||||
|
Text(
|
||||||
|
modifier = Modifier.padding(start = 7.dp),
|
||||||
|
fontFamily = MaterialTheme.typography.labelMedium.fontFamily,
|
||||||
|
fontSize = MaterialTheme.typography.labelMedium.fontSize,
|
||||||
|
text = stringResource(R.string.restore)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
FilledTonalButton(
|
||||||
|
modifier = Modifier.defaultMinSize(52.dp, 32.dp),
|
||||||
|
enabled = true,
|
||||||
|
onClick = { onUninstall(module) },
|
||||||
|
contentPadding = ButtonDefaults.TextButtonContentPadding
|
||||||
|
) {
|
||||||
|
Icon(
|
||||||
|
modifier = Modifier.size(20.dp),
|
||||||
|
imageVector = Icons.Outlined.Delete,
|
||||||
|
contentDescription = null
|
||||||
|
)
|
||||||
|
if (!module.hasActionScript && !module.hasWebUi && updateUrl.isEmpty()) {
|
||||||
|
Text(
|
||||||
|
modifier = Modifier.padding(start = 7.dp),
|
||||||
|
fontFamily = MaterialTheme.typography.labelMedium.fontFamily,
|
||||||
|
fontSize = MaterialTheme.typography.labelMedium.fontSize,
|
||||||
|
text = stringResource(R.string.uninstall)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
Column(
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(22.dp, 18.dp, 22.dp, 12.dp)
|
||||||
|
) {
|
||||||
|
Row(
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
horizontalArrangement = Arrangement.SpaceBetween
|
||||||
|
) {
|
||||||
|
val moduleVersion = stringResource(id = R.string.module_version)
|
||||||
|
val moduleAuthor = stringResource(id = R.string.module_author)
|
||||||
|
val moduleId = stringResource(id = R.string.module_id)
|
||||||
|
val moduleVersionCode = stringResource(id = R.string.module_version_code)
|
||||||
|
val moduleUpdateJson = stringResource(id = R.string.module_update_json)
|
||||||
|
val moduleUpdateJsonEmpty = stringResource(id = R.string.module_update_json_empty)
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(12.dp))
|
Column(
|
||||||
|
modifier = Modifier.fillMaxWidth(0.8f)
|
||||||
|
) {
|
||||||
|
Row(
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
horizontalArrangement = Arrangement.spacedBy(6.dp)
|
||||||
|
) {
|
||||||
|
LabelItem(
|
||||||
|
text = if (module.enabled) stringResource(R.string.enabled) else stringResource(R.string.disabled),
|
||||||
|
style = if (module.enabled)
|
||||||
|
com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy()
|
||||||
|
else
|
||||||
|
com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy(
|
||||||
|
containerColor = MaterialTheme.colorScheme.errorContainer,
|
||||||
|
contentColor = MaterialTheme.colorScheme.onErrorContainer
|
||||||
|
)
|
||||||
|
)
|
||||||
|
if (module.remove) {
|
||||||
|
LabelItem(
|
||||||
|
text = stringResource(R.string.uninstalled),
|
||||||
|
style = com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy(
|
||||||
|
containerColor = MaterialTheme.colorScheme.errorContainer,
|
||||||
|
contentColor = MaterialTheme.colorScheme.onErrorContainer
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (updateUrl.isNotEmpty() && !module.remove && !module.update) {
|
||||||
|
LabelItem(
|
||||||
|
text = stringResource(R.string.module_update),
|
||||||
|
style = com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy(
|
||||||
|
containerColor = MaterialTheme.colorScheme.onTertiary,
|
||||||
|
contentColor = MaterialTheme.colorScheme.onTertiaryContainer
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (!module.remove) {
|
||||||
|
if (module.update) {
|
||||||
|
LabelItem(
|
||||||
|
text = stringResource(R.string.module_updated),
|
||||||
|
style = com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy(
|
||||||
|
containerColor = MaterialTheme.colorScheme.tertiaryContainer,
|
||||||
|
contentColor = MaterialTheme.colorScheme.onTertiaryContainer
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (module.hasWebUi) {
|
||||||
|
LabelItem(
|
||||||
|
text = stringResource(R.string.webui),
|
||||||
|
style = com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy(
|
||||||
|
containerColor = MaterialTheme.colorScheme.primaryContainer,
|
||||||
|
contentColor = MaterialTheme.colorScheme.onPrimaryContainer
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (module.hasActionScript) {
|
||||||
|
LabelItem(
|
||||||
|
text = stringResource(R.string.action),
|
||||||
|
style = com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy(
|
||||||
|
containerColor = MaterialTheme.colorScheme.secondaryContainer,
|
||||||
|
contentColor = MaterialTheme.colorScheme.onSecondaryContainer
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Text(
|
Spacer(modifier = Modifier.height(8.dp))
|
||||||
text = module.description,
|
|
||||||
fontSize = MaterialTheme.typography.bodySmall.fontSize,
|
|
||||||
fontFamily = MaterialTheme.typography.bodySmall.fontFamily,
|
|
||||||
lineHeight = MaterialTheme.typography.bodySmall.lineHeight,
|
|
||||||
fontWeight = MaterialTheme.typography.bodySmall.fontWeight,
|
|
||||||
overflow = TextOverflow.Ellipsis,
|
|
||||||
maxLines = 4,
|
|
||||||
textDecoration = textDecoration
|
|
||||||
)
|
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(6.dp))
|
Text(
|
||||||
|
text = module.name,
|
||||||
|
fontSize = MaterialTheme.typography.titleMedium.fontSize,
|
||||||
|
fontWeight = FontWeight.SemiBold,
|
||||||
|
lineHeight = MaterialTheme.typography.bodySmall.lineHeight,
|
||||||
|
fontFamily = MaterialTheme.typography.titleMedium.fontFamily,
|
||||||
|
textDecoration = textDecoration,
|
||||||
|
)
|
||||||
|
|
||||||
|
Text(
|
||||||
|
text = "$moduleVersion: ${module.version}",
|
||||||
|
fontSize = MaterialTheme.typography.bodySmall.fontSize,
|
||||||
|
lineHeight = MaterialTheme.typography.bodySmall.lineHeight,
|
||||||
|
fontFamily = MaterialTheme.typography.bodySmall.fontFamily,
|
||||||
|
textDecoration = textDecoration
|
||||||
|
)
|
||||||
|
|
||||||
|
Text(
|
||||||
|
text = "$moduleAuthor: ${module.author}",
|
||||||
|
fontSize = MaterialTheme.typography.bodySmall.fontSize,
|
||||||
|
lineHeight = MaterialTheme.typography.bodySmall.lineHeight,
|
||||||
|
fontFamily = MaterialTheme.typography.bodySmall.fontFamily,
|
||||||
|
textDecoration = textDecoration
|
||||||
|
)
|
||||||
|
|
||||||
|
if (developerOptionsEnabled) {
|
||||||
|
|
||||||
|
Text(
|
||||||
|
text = "$moduleId: ${module.id}",
|
||||||
|
fontSize = MaterialTheme.typography.bodySmall.fontSize,
|
||||||
|
lineHeight = MaterialTheme.typography.bodySmall.lineHeight,
|
||||||
|
fontFamily = MaterialTheme.typography.bodySmall.fontFamily,
|
||||||
|
textDecoration = textDecoration
|
||||||
|
)
|
||||||
|
|
||||||
|
Text(
|
||||||
|
text = "$moduleVersionCode: ${module.versionCode}",
|
||||||
|
fontSize = MaterialTheme.typography.bodySmall.fontSize,
|
||||||
|
lineHeight = MaterialTheme.typography.bodySmall.lineHeight,
|
||||||
|
fontFamily = MaterialTheme.typography.bodySmall.fontFamily,
|
||||||
|
textDecoration = textDecoration
|
||||||
|
)
|
||||||
|
|
||||||
|
Text(
|
||||||
|
text = if (module.updateJson.isNotEmpty()) "$moduleUpdateJson: ${module.updateJson}" else "$moduleUpdateJson: $moduleUpdateJsonEmpty",
|
||||||
|
fontSize = MaterialTheme.typography.bodySmall.fontSize,
|
||||||
|
lineHeight = MaterialTheme.typography.bodySmall.lineHeight,
|
||||||
|
fontFamily = MaterialTheme.typography.bodySmall.fontFamily,
|
||||||
|
textDecoration = textDecoration
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Row(
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
horizontalArrangement = Arrangement.End,
|
||||||
|
) {
|
||||||
|
var expanded by remember { mutableStateOf(false) }
|
||||||
|
IconButton(onClick = { expanded = true }) {
|
||||||
|
Icon(
|
||||||
|
Icons.Filled.MoreVert,
|
||||||
|
contentDescription = "Module actions"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
DropdownMenu(
|
||||||
|
expanded = expanded,
|
||||||
|
onDismissRequest = { expanded = false }
|
||||||
|
) {
|
||||||
|
if (updateUrl.isNotEmpty() && !module.remove) {
|
||||||
|
DropdownMenuItem(
|
||||||
|
text = { Text(stringResource(R.string.module_update)) },
|
||||||
|
onClick = {
|
||||||
|
expanded = false
|
||||||
|
onUpdate(module)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
HorizontalDivider()
|
||||||
|
}
|
||||||
|
|
||||||
|
if (module.hasWebUi) {
|
||||||
|
DropdownMenuItem(
|
||||||
|
text = { Text(stringResource(R.string.webui)) },
|
||||||
|
onClick = {
|
||||||
|
expanded = false
|
||||||
|
onClick(module)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (module.hasActionScript) {
|
||||||
|
DropdownMenuItem(
|
||||||
|
text = { Text(stringResource(R.string.action)) },
|
||||||
|
onClick = {
|
||||||
|
expanded = false
|
||||||
|
navigator.navigate(ExecuteModuleActionScreenDestination(module.dirId))
|
||||||
|
viewModel.markNeedRefresh()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (module.hasWebUi || module.hasActionScript ) {
|
||||||
|
HorizontalDivider()
|
||||||
|
}
|
||||||
|
|
||||||
|
DropdownMenuItem(
|
||||||
|
text = {
|
||||||
|
Text(
|
||||||
|
if (module.enabled) stringResource(R.string.disable)
|
||||||
|
else stringResource(R.string.enable)
|
||||||
|
)
|
||||||
|
},
|
||||||
|
onClick = {
|
||||||
|
expanded = false
|
||||||
|
onCheckChanged(!module.enabled)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
if (module.remove) {
|
||||||
|
DropdownMenuItem(
|
||||||
|
text = { Text(stringResource(R.string.restore)) },
|
||||||
|
onClick = {
|
||||||
|
expanded = false
|
||||||
|
onRestore(module)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
DropdownMenuItem(
|
||||||
|
text = { Text(stringResource(R.string.uninstall)) },
|
||||||
|
onClick = {
|
||||||
|
expanded = false
|
||||||
|
onUninstall(module)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Spacer(modifier = Modifier.height(12.dp))
|
||||||
|
|
||||||
|
Text(
|
||||||
|
text = module.description,
|
||||||
|
fontSize = MaterialTheme.typography.bodySmall.fontSize,
|
||||||
|
fontFamily = MaterialTheme.typography.bodySmall.fontFamily,
|
||||||
|
lineHeight = MaterialTheme.typography.bodySmall.lineHeight,
|
||||||
|
fontWeight = MaterialTheme.typography.bodySmall.fontWeight,
|
||||||
|
overflow = TextOverflow.Ellipsis,
|
||||||
|
maxLines = 4,
|
||||||
|
textDecoration = textDecoration
|
||||||
|
)
|
||||||
|
|
||||||
|
Spacer(modifier = Modifier.height(6.dp))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -360,6 +360,21 @@ fun SettingScreen(navigator: DestinationsNavigator) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var useLagacyUI by rememberSaveable {
|
||||||
|
mutableStateOf(
|
||||||
|
prefs.getBoolean("use_legacyui", false)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
SwitchItem(
|
||||||
|
icon = Icons.Filled.ColorLens,
|
||||||
|
title = stringResource(id = R.string.settings_legacyui),
|
||||||
|
summary = stringResource(id = R.string.settings_legacyui_summary),
|
||||||
|
checked = useLagacyUI
|
||||||
|
) {
|
||||||
|
prefs.edit().putBoolean("use_legacyui", it).apply()
|
||||||
|
useLagacyUI = it
|
||||||
|
}
|
||||||
|
|
||||||
var enableAmoled by rememberSaveable {
|
var enableAmoled by rememberSaveable {
|
||||||
mutableStateOf(
|
mutableStateOf(
|
||||||
prefs.getBoolean("enable_amoled", false)
|
prefs.getBoolean("enable_amoled", false)
|
||||||
|
|||||||
@@ -209,6 +209,8 @@
|
|||||||
<string name="settings_disable_su">Disable su compatibility</string>
|
<string name="settings_disable_su">Disable su compatibility</string>
|
||||||
<string name="settings_disable_su_summary">Temporarily disable the ability of any app to gain root privileges via the su command (existing root processes won\'t be affected).</string>
|
<string name="settings_disable_su_summary">Temporarily disable the ability of any app to gain root privileges via the su command (existing root processes won\'t be affected).</string>
|
||||||
<string name="settings_language">Language</string>
|
<string name="settings_language">Language</string>
|
||||||
|
<string name="settings_legacyui">Use Legacy UI</string>
|
||||||
|
<string name="settings_legacyui_summary">Switch to the previous user interface style.</string>
|
||||||
<string name="use_webuix">Use WebUI X</string>
|
<string name="use_webuix">Use WebUI X</string>
|
||||||
<string name="use_webuix_summary">Use WebUI X instead of WebUI, which supports more APIs.</string>
|
<string name="use_webuix_summary">Use WebUI X instead of WebUI, which supports more APIs.</string>
|
||||||
<string name="use_webuix_eruda">Inject Eruda into WebUI X</string>
|
<string name="use_webuix_eruda">Inject Eruda into WebUI X</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user