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: merge legacy and revamped module card ui, also tapping the card open webui when available and actions when available but if both are available then prefer webui
This commit is contained in:
@@ -12,7 +12,6 @@ import androidx.activity.result.contract.ActivityResultContracts
|
|||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.Image
|
import androidx.compose.foundation.Image
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.LocalIndication
|
|
||||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
@@ -73,6 +72,7 @@ import androidx.compose.runtime.remember
|
|||||||
import androidx.compose.runtime.rememberCoroutineScope
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
import androidx.compose.runtime.saveable.rememberSaveable
|
import androidx.compose.runtime.saveable.rememberSaveable
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
|
import androidx.compose.ui.draw.clip
|
||||||
import androidx.compose.ui.graphics.Brush
|
import androidx.compose.ui.graphics.Brush
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.layout.ContentScale
|
import androidx.compose.ui.layout.ContentScale
|
||||||
@@ -692,8 +692,23 @@ fun ModuleItem(
|
|||||||
onUpdate: (ModuleViewModel.ModuleInfo) -> Unit,
|
onUpdate: (ModuleViewModel.ModuleInfo) -> Unit,
|
||||||
onClick: (ModuleViewModel.ModuleInfo) -> Unit,
|
onClick: (ModuleViewModel.ModuleInfo) -> Unit,
|
||||||
) {
|
) {
|
||||||
|
val viewModel = viewModel<ModuleViewModel>()
|
||||||
|
|
||||||
ElevatedCard(
|
ElevatedCard(
|
||||||
modifier = Modifier.fillMaxWidth()
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.clip(MaterialTheme.shapes.medium)
|
||||||
|
.clickable(
|
||||||
|
enabled = (module.enabled && !module.remove && (module.hasWebUi || module.hasActionScript)),
|
||||||
|
onClick = {
|
||||||
|
if (module.hasWebUi) {
|
||||||
|
onClick(module)
|
||||||
|
} else if (module.hasActionScript) {
|
||||||
|
navigator.navigate(ExecuteModuleActionScreenDestination(module.dirId))
|
||||||
|
viewModel.markNeedRefresh()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
@@ -705,7 +720,7 @@ fun ModuleItem(
|
|||||||
|
|
||||||
val useBanner = prefs.getBoolean("use_banner", true)
|
val useBanner = prefs.getBoolean("use_banner", true)
|
||||||
|
|
||||||
if (useBanner && !useLagacyUI && module.banner.isNotEmpty()) {
|
if (useBanner && module.banner.isNotEmpty()) {
|
||||||
val isDark = isSystemInDarkTheme()
|
val isDark = isSystemInDarkTheme()
|
||||||
val colorScheme = MaterialTheme.colorScheme
|
val colorScheme = MaterialTheme.colorScheme
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
@@ -778,8 +793,6 @@ fun ModuleItem(
|
|||||||
Column {
|
Column {
|
||||||
val textDecoration = if (!module.remove) null else TextDecoration.LineThrough
|
val textDecoration = if (!module.remove) null else TextDecoration.LineThrough
|
||||||
val interactionSource = remember { MutableInteractionSource() }
|
val interactionSource = remember { MutableInteractionSource() }
|
||||||
val indication = LocalIndication.current
|
|
||||||
val viewModel = viewModel<ModuleViewModel>()
|
|
||||||
|
|
||||||
var developerOptionsEnabled by rememberSaveable {
|
var developerOptionsEnabled by rememberSaveable {
|
||||||
mutableStateOf(
|
mutableStateOf(
|
||||||
@@ -791,487 +804,271 @@ fun ModuleItem(
|
|||||||
developerOptionsEnabled = prefs.getBoolean("enable_developer_options", false)
|
developerOptionsEnabled = prefs.getBoolean("enable_developer_options", false)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (useLagacyUI) {
|
Column(
|
||||||
Column(
|
modifier = Modifier
|
||||||
modifier = Modifier
|
.padding(22.dp, 18.dp, 22.dp, 12.dp)
|
||||||
.padding(22.dp, 18.dp, 22.dp, 12.dp)
|
) {
|
||||||
|
Row(
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
horizontalArrangement = Arrangement.SpaceBetween,
|
||||||
) {
|
) {
|
||||||
Row(
|
val moduleVersion = stringResource(id = R.string.module_version)
|
||||||
modifier = Modifier.fillMaxWidth(),
|
val moduleAuthor = stringResource(id = R.string.module_author)
|
||||||
horizontalArrangement = Arrangement.SpaceBetween,
|
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)
|
||||||
) {
|
) {
|
||||||
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)
|
|
||||||
|
|
||||||
Column(
|
|
||||||
modifier = Modifier.fillMaxWidth(0.8f)
|
|
||||||
) {
|
|
||||||
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
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Spacer(modifier = Modifier.weight(1f))
|
|
||||||
|
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier.fillMaxWidth(),
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
horizontalArrangement = Arrangement.End,
|
horizontalArrangement = Arrangement.spacedBy(6.dp)
|
||||||
) {
|
) {
|
||||||
Switch(
|
LabelItem(
|
||||||
enabled = !module.update,
|
text = formatSize(module.size),
|
||||||
checked = module.enabled,
|
style = com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy(
|
||||||
onCheckedChange = onCheckChanged,
|
containerColor = MaterialTheme.colorScheme.secondaryContainer,
|
||||||
interactionSource = if (!module.hasWebUi) interactionSource else null
|
contentColor = MaterialTheme.colorScheme.onSecondaryContainer
|
||||||
|
)
|
||||||
)
|
)
|
||||||
}
|
LabelItem(
|
||||||
}
|
text = if (module.enabled) stringResource(R.string.enabled) else stringResource(R.string.disabled),
|
||||||
|
style = if (module.enabled)
|
||||||
Spacer(modifier = Modifier.height(12.dp))
|
com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy()
|
||||||
|
else
|
||||||
Text(
|
com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy(
|
||||||
text = module.description,
|
containerColor = MaterialTheme.colorScheme.errorContainer,
|
||||||
fontSize = MaterialTheme.typography.bodySmall.fontSize,
|
contentColor = MaterialTheme.colorScheme.onErrorContainer
|
||||||
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(
|
|
||||||
horizontalArrangement = Arrangement.SpaceBetween,
|
|
||||||
verticalAlignment = Alignment.CenterVertically
|
|
||||||
) {
|
|
||||||
if (module.hasActionScript) {
|
|
||||||
FilledTonalButton(
|
|
||||||
modifier = Modifier.defaultMinSize(52.dp, 32.dp),
|
|
||||||
enabled = !module.remove && module.enabled,
|
|
||||||
onClick = {
|
|
||||||
navigator.navigate(ExecuteModuleActionScreenDestination(module.dirId))
|
|
||||||
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) {
|
||||||
|
|
||||||
Spacer(modifier = Modifier.weight(0.1f, true))
|
|
||||||
}
|
|
||||||
|
|
||||||
if (module.hasWebUi) {
|
|
||||||
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
|
|
||||||
)
|
|
||||||
if (!module.hasActionScript && updateUrl.isEmpty()) {
|
|
||||||
Text(
|
|
||||||
modifier = Modifier.padding(start = 7.dp),
|
|
||||||
fontFamily = MaterialTheme.typography.labelMedium.fontFamily,
|
|
||||||
fontSize = MaterialTheme.typography.labelMedium.fontSize,
|
|
||||||
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)
|
|
||||||
|
|
||||||
Column(
|
|
||||||
modifier = Modifier.fillMaxWidth(0.8f)
|
|
||||||
) {
|
|
||||||
Row(
|
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
|
||||||
horizontalArrangement = Arrangement.spacedBy(6.dp)
|
|
||||||
) {
|
|
||||||
LabelItem(
|
LabelItem(
|
||||||
text = formatSize(module.size),
|
text = stringResource(R.string.uninstalled),
|
||||||
style = com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy(
|
style = com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy(
|
||||||
containerColor = MaterialTheme.colorScheme.secondaryContainer,
|
containerColor = MaterialTheme.colorScheme.errorContainer,
|
||||||
contentColor = MaterialTheme.colorScheme.onSecondaryContainer
|
contentColor = MaterialTheme.colorScheme.onErrorContainer
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
if (updateUrl.isNotEmpty() && !module.remove && !module.update) {
|
||||||
LabelItem(
|
LabelItem(
|
||||||
text = if (module.enabled) stringResource(R.string.enabled) else stringResource(R.string.disabled),
|
text = stringResource(R.string.module_update),
|
||||||
style = if (module.enabled)
|
style = com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy(
|
||||||
com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy()
|
containerColor = MaterialTheme.colorScheme.onTertiary,
|
||||||
else
|
contentColor = MaterialTheme.colorScheme.onTertiaryContainer
|
||||||
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) {
|
}
|
||||||
|
if (!module.remove) {
|
||||||
|
if (module.update) {
|
||||||
LabelItem(
|
LabelItem(
|
||||||
text = stringResource(R.string.module_update),
|
text = stringResource(R.string.module_updated),
|
||||||
style = com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy(
|
style = com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy(
|
||||||
containerColor = MaterialTheme.colorScheme.onTertiary,
|
containerColor = MaterialTheme.colorScheme.tertiaryContainer,
|
||||||
contentColor = MaterialTheme.colorScheme.onTertiaryContainer
|
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.remove) {
|
|
||||||
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
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (module.enabled && !module.remove) {
|
||||||
Spacer(modifier = Modifier.height(8.dp))
|
if (module.hasWebUi) {
|
||||||
|
LabelItem(
|
||||||
Text(
|
text = stringResource(R.string.webui),
|
||||||
text = module.name,
|
style = com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy(
|
||||||
fontSize = MaterialTheme.typography.titleMedium.fontSize,
|
containerColor = MaterialTheme.colorScheme.primaryContainer,
|
||||||
fontWeight = FontWeight.SemiBold,
|
contentColor = MaterialTheme.colorScheme.onPrimaryContainer
|
||||||
lineHeight = MaterialTheme.typography.bodySmall.lineHeight,
|
)
|
||||||
fontFamily = MaterialTheme.typography.titleMedium.fontFamily,
|
)
|
||||||
textDecoration = textDecoration,
|
}
|
||||||
)
|
if (module.hasActionScript) {
|
||||||
|
LabelItem(
|
||||||
Text(
|
text = stringResource(R.string.action),
|
||||||
text = "$moduleVersion: ${module.version}",
|
style = com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy(
|
||||||
fontSize = MaterialTheme.typography.bodySmall.fontSize,
|
containerColor = MaterialTheme.colorScheme.secondaryContainer,
|
||||||
lineHeight = MaterialTheme.typography.bodySmall.lineHeight,
|
contentColor = MaterialTheme.colorScheme.onSecondaryContainer
|
||||||
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(
|
Spacer(modifier = Modifier.height(8.dp))
|
||||||
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.remove) {
|
|
||||||
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 ) {
|
Text(
|
||||||
HorizontalDivider()
|
text = module.name,
|
||||||
}
|
fontSize = MaterialTheme.typography.titleMedium.fontSize,
|
||||||
}
|
fontWeight = FontWeight.SemiBold,
|
||||||
|
lineHeight = MaterialTheme.typography.bodySmall.lineHeight,
|
||||||
|
fontFamily = MaterialTheme.typography.titleMedium.fontFamily,
|
||||||
|
textDecoration = textDecoration,
|
||||||
|
)
|
||||||
|
|
||||||
if (!module.remove) {
|
Text(
|
||||||
DropdownMenuItem(
|
text = "$moduleVersion: ${module.version}",
|
||||||
text = {
|
fontSize = MaterialTheme.typography.bodySmall.fontSize,
|
||||||
Text(
|
lineHeight = MaterialTheme.typography.bodySmall.lineHeight,
|
||||||
if (module.enabled) stringResource(R.string.disable)
|
fontFamily = MaterialTheme.typography.bodySmall.fontFamily,
|
||||||
else stringResource(R.string.enable)
|
textDecoration = textDecoration
|
||||||
)
|
)
|
||||||
},
|
|
||||||
onClick = {
|
Text(
|
||||||
expanded = false
|
text = "$moduleAuthor: ${module.author}",
|
||||||
onCheckChanged(!module.enabled)
|
fontSize = MaterialTheme.typography.bodySmall.fontSize,
|
||||||
}
|
lineHeight = MaterialTheme.typography.bodySmall.lineHeight,
|
||||||
)
|
fontFamily = MaterialTheme.typography.bodySmall.fontFamily,
|
||||||
}
|
textDecoration = textDecoration
|
||||||
if (module.remove) {
|
)
|
||||||
DropdownMenuItem(
|
|
||||||
text = { Text(stringResource(R.string.restore)) },
|
if (developerOptionsEnabled) {
|
||||||
onClick = {
|
|
||||||
expanded = false
|
Text(
|
||||||
onRestore(module)
|
text = "$moduleId: ${module.id}",
|
||||||
}
|
fontSize = MaterialTheme.typography.bodySmall.fontSize,
|
||||||
)
|
lineHeight = MaterialTheme.typography.bodySmall.lineHeight,
|
||||||
} else {
|
fontFamily = MaterialTheme.typography.bodySmall.fontFamily,
|
||||||
DropdownMenuItem(
|
textDecoration = textDecoration
|
||||||
text = { Text(stringResource(R.string.uninstall)) },
|
)
|
||||||
onClick = {
|
|
||||||
expanded = false
|
Text(
|
||||||
onUninstall(module)
|
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))
|
Spacer(modifier = Modifier.weight(1f))
|
||||||
|
|
||||||
Text(
|
Row(
|
||||||
text = module.description,
|
modifier = Modifier.fillMaxWidth(),
|
||||||
fontSize = MaterialTheme.typography.bodySmall.fontSize,
|
horizontalArrangement = Arrangement.End,
|
||||||
fontFamily = MaterialTheme.typography.bodySmall.fontFamily,
|
) {
|
||||||
lineHeight = MaterialTheme.typography.bodySmall.lineHeight,
|
Switch(
|
||||||
fontWeight = MaterialTheme.typography.bodySmall.fontWeight,
|
enabled = !module.update,
|
||||||
overflow = TextOverflow.Ellipsis,
|
checked = module.enabled,
|
||||||
maxLines = 4,
|
onCheckedChange = onCheckChanged,
|
||||||
textDecoration = textDecoration
|
interactionSource = if (!module.hasWebUi) interactionSource else null
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(6.dp))
|
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(12.dp))
|
||||||
|
|
||||||
|
Row(
|
||||||
|
horizontalArrangement = Arrangement.SpaceBetween,
|
||||||
|
verticalAlignment = Alignment.CenterVertically
|
||||||
|
) {
|
||||||
|
if (module.hasActionScript) {
|
||||||
|
FilledTonalButton(
|
||||||
|
modifier = Modifier.defaultMinSize(52.dp, 32.dp),
|
||||||
|
enabled = !module.remove && module.enabled,
|
||||||
|
onClick = {
|
||||||
|
navigator.navigate(ExecuteModuleActionScreenDestination(module.dirId))
|
||||||
|
viewModel.markNeedRefresh()
|
||||||
|
},
|
||||||
|
contentPadding = ButtonDefaults.TextButtonContentPadding
|
||||||
|
) {
|
||||||
|
Icon(
|
||||||
|
modifier = Modifier.size(20.dp),
|
||||||
|
imageVector = Icons.Outlined.PlayArrow,
|
||||||
|
contentDescription = null
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
Spacer(modifier = Modifier.weight(0.1f, true))
|
||||||
|
}
|
||||||
|
|
||||||
|
if (module.hasWebUi) {
|
||||||
|
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
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} 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
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user