From ce3566640cb3cc61b7320e4b7e7b1c59d23dd8d5 Mon Sep 17 00:00:00 2001 From: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com> Date: Sun, 15 Jun 2025 22:21:14 +0800 Subject: [PATCH] Add the ability to display more module information, support copying the update configuration address to the clipboard --- .../java/com/sukisu/ultra/ui/screen/Module.kt | 60 ++++++++++++++++--- .../zako/zako/zakoui/screen/MoreSettings.kt | 20 +++++++ .../src/main/res/values-zh-rCN/strings.xml | 8 +++ manager/app/src/main/res/values/strings.xml | 8 +++ 4 files changed, 87 insertions(+), 9 deletions(-) diff --git a/manager/app/src/main/java/com/sukisu/ultra/ui/screen/Module.kt b/manager/app/src/main/java/com/sukisu/ultra/ui/screen/Module.kt index ff1126b2..7dd25922 100644 --- a/manager/app/src/main/java/com/sukisu/ultra/ui/screen/Module.kt +++ b/manager/app/src/main/java/com/sukisu/ultra/ui/screen/Module.kt @@ -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)) diff --git a/manager/app/src/main/java/zako/zako/zako/zakoui/screen/MoreSettings.kt b/manager/app/src/main/java/zako/zako/zako/zakoui/screen/MoreSettings.kt index 1d703267..f1924ea2 100644 --- a/manager/app/src/main/java/zako/zako/zako/zakoui/screen/MoreSettings.kt +++ b/manager/app/src/main/java/zako/zako/zako/zakoui/screen/MoreSettings.kt @@ -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, diff --git a/manager/app/src/main/res/values-zh-rCN/strings.xml b/manager/app/src/main/res/values-zh-rCN/strings.xml index a5034b7b..6728def1 100644 --- a/manager/app/src/main/res/values-zh-rCN/strings.xml +++ b/manager/app/src/main/res/values-zh-rCN/strings.xml @@ -513,4 +513,12 @@ SuSFS 日志配置 启用 SuSFS 日志 关闭 SuSFS 日志 + 更新配置 + 更新配置地址已复制到剪贴板 + 更新配置不可用 + + 显示模块更新配置 + 在模块详情中显示更新配置URL + 显示更多模块信息 + 显示额外的模块信息,如更新配置URL等 \ No newline at end of file diff --git a/manager/app/src/main/res/values/strings.xml b/manager/app/src/main/res/values/strings.xml index 1086d2d8..5cfcbfe5 100644 --- a/manager/app/src/main/res/values/strings.xml +++ b/manager/app/src/main/res/values/strings.xml @@ -515,4 +515,12 @@ SuSFS Logging Configuration Enabling SuSFS Logging Turn off SuSFS logging + Update JSON + Update JSON URL copied to clipboard + Update JSON not available + + Show Module Update JSON + Display update JSON URL in module details + Show More Module Info + Display additional module information like update JSON URLs \ No newline at end of file