Add the ability to display more module information, support copying the update configuration address to the clipboard

This commit is contained in:
ShirkNeko
2025-06-15 22:21:14 +08:00
parent a0a9fb01f4
commit ce3566640c
4 changed files with 87 additions and 9 deletions

View File

@@ -2,6 +2,8 @@ package com.sukisu.ultra.ui.screen
import android.annotation.SuppressLint
import android.app.Activity.*
import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
import android.content.Intent
import android.net.Uri
@@ -37,6 +39,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.rotate
import androidx.compose.ui.draw.scale
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.hapticfeedback.HapticFeedbackType
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.platform.*
import androidx.compose.ui.res.painterResource
@@ -898,6 +901,12 @@ fun ModuleItem(
val context = LocalContext.current
val prefs = context.getSharedPreferences("settings", MODE_PRIVATE)
val isHideTagRow = prefs.getBoolean("is_hide_tag_row", false)
// 获取显示更多模块信息的设置
val showMoreModuleInfo = prefs.getBoolean("show_more_module_info", false)
// 剪贴板管理器和触觉反馈
val clipboardManager = context.getSystemService(CLIPBOARD_SERVICE) as ClipboardManager
val hapticFeedback = LocalHapticFeedback.current
ElevatedCard(
colors = getCardColors(MaterialTheme.colorScheme.surfaceContainerHigh),
@@ -966,6 +975,43 @@ fun ModuleItem(
fontFamily = MaterialTheme.typography.bodySmall.fontFamily,
textDecoration = textDecoration,
)
// 显示更多模块信息时添加updateJson
if (showMoreModuleInfo && module.updateJson.isNotEmpty()) {
val updateJsonLabel = stringResource(R.string.module_update_json)
Text(
text = "$updateJsonLabel: ${module.updateJson}",
fontSize = MaterialTheme.typography.bodySmall.fontSize,
lineHeight = MaterialTheme.typography.bodySmall.lineHeight,
fontFamily = MaterialTheme.typography.bodySmall.fontFamily,
textDecoration = textDecoration,
color = MaterialTheme.colorScheme.primary,
maxLines = 5,
overflow = TextOverflow.Ellipsis,
modifier = Modifier
.fillMaxWidth()
.combinedClickable(
onClick = {
},
onLongClick = {
// 长按复制updateJson地址
val clipData = ClipData.newPlainText(
"Update JSON URL",
module.updateJson
)
clipboardManager.setPrimaryClip(clipData)
hapticFeedback.performHapticFeedback(HapticFeedbackType.LongPress)
// 显示复制成功的提示
Toast.makeText(
context,
context.getString(R.string.module_update_json_copied),
Toast.LENGTH_SHORT
).show()
}
),
)
}
}
Spacer(modifier = Modifier.weight(1f))
@@ -995,17 +1041,15 @@ fun ModuleItem(
maxLines = 4,
textDecoration = textDecoration,
)
Spacer(modifier = Modifier.height(12.dp))
// 标签行
if (!isHideTagRow) {
Spacer(modifier = Modifier.height(12.dp))
// 文件夹名称和大小标签
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(8.dp),
modifier = Modifier.fillMaxWidth()
) {
// 文件夹名称标签
Surface(
shape = RoundedCornerShape(4.dp),
color = MaterialTheme.colorScheme.primary,
@@ -1020,8 +1064,6 @@ fun ModuleItem(
overflow = TextOverflow.Ellipsis
)
}
// 大小标签
Surface(
shape = RoundedCornerShape(4.dp),
color = MaterialTheme.colorScheme.secondaryContainer,
@@ -1036,10 +1078,10 @@ fun ModuleItem(
)
}
}
Spacer(modifier = Modifier.height(16.dp))
}
Spacer(modifier = Modifier.height(16.dp))
HorizontalDivider(thickness = Dp.Hairline)
Spacer(modifier = Modifier.height(8.dp))

View File

@@ -238,6 +238,11 @@ fun MoreSettingsScreen(
mutableStateOf(prefs.getBoolean("is_hide_tag_row", false))
}
// 显示更多模块信息开关状态
var showMoreModuleInfo by remember {
mutableStateOf(prefs.getBoolean("show_more_module_info", false))
}
// SELinux状态
var selinuxEnabled by remember {
mutableStateOf(Shell.cmd("getenforce").exec().out.firstOrNull() == "Enforcing")
@@ -326,6 +331,12 @@ fun MoreSettingsScreen(
isHideTagRow = newValue
}
// 显示更多模块信息开关状态
val onShowMoreModuleInfoChange = { newValue: Boolean ->
prefs.edit { putBoolean("show_more_module_info", newValue) }
showMoreModuleInfo = newValue
}
// 备用图标开关状态
val onUseAltIconChange = { newValue: Boolean ->
prefs.edit { putBoolean("use_alt_icon", newValue) }
@@ -1036,6 +1047,15 @@ fun MoreSettingsScreen(
onChange = onUseAltIconChange
)
// 显示更多模块信息开关
SwitchSettingItem(
icon = Icons.Filled.Info,
title = stringResource(R.string.show_more_module_info),
summary = stringResource(R.string.show_more_module_info_summary),
checked = showMoreModuleInfo,
onChange = onShowMoreModuleInfoChange
)
// 添加简洁模式开关
SwitchSettingItem(
icon = Icons.Filled.Brush,

View File

@@ -513,4 +513,12 @@
<string name="susfs_log_config_title">SuSFS 日志配置</string>
<string name="susfs_log_enabled">启用 SuSFS 日志</string>
<string name="susfs_log_disabled">关闭 SuSFS 日志</string>
<string name="module_update_json">更新配置</string>
<string name="module_update_json_copied">更新配置地址已复制到剪贴板</string>
<string name="module_update_json_not_available">更新配置不可用</string>
<!-- 设置相关字符串 -->
<string name="show_module_update_json">显示模块更新配置</string>
<string name="show_module_update_json_summary">在模块详情中显示更新配置URL</string>
<string name="show_more_module_info">显示更多模块信息</string>
<string name="show_more_module_info_summary">显示额外的模块信息如更新配置URL等</string>
</resources>

View File

@@ -515,4 +515,12 @@
<string name="susfs_log_config_title">SuSFS Logging Configuration</string>
<string name="susfs_log_enabled">Enabling SuSFS Logging</string>
<string name="susfs_log_disabled">Turn off SuSFS logging</string>
<string name="module_update_json">Update JSON</string>
<string name="module_update_json_copied">Update JSON URL copied to clipboard</string>
<string name="module_update_json_not_available">Update JSON not available</string>
<!-- Settings related strings -->
<string name="show_module_update_json">Show Module Update JSON</string>
<string name="show_module_update_json_summary">Display update JSON URL in module details</string>
<string name="show_more_module_info">Show More Module Info</string>
<string name="show_more_module_info_summary">Display additional module information like update JSON URLs</string>
</resources>