Adjust the prompt for file selection and add instructions for mirror repair.

- Modify the maximum height of the progress bar to improve user experience
- Add localized strings for error messages and installation methods.
-Optimize the installation interface

Signed-off-by: ShirkNeko 109797057+ShirkNeko@users.noreply.github.com
This commit is contained in:
ShirkNeko
2025-04-28 14:39:09 +08:00
parent 56b4664ec7
commit a297e07055
4 changed files with 139 additions and 50 deletions

View File

@@ -354,7 +354,7 @@ fun HorizonKernelFlashProgress(state: FlashState) {
Surface( Surface(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.heightIn(max = 150.dp) .heightIn(max = 230.dp)
.padding(vertical = 4.dp), .padding(vertical = 4.dp),
color = MaterialTheme.colorScheme.surface, color = MaterialTheme.colorScheme.surface,
tonalElevation = 1.dp, tonalElevation = 1.dp,

View File

@@ -21,6 +21,7 @@ import androidx.compose.foundation.selection.toggleable
import androidx.compose.foundation.verticalScroll import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material.icons.filled.AutoFixHigh
import androidx.compose.material.icons.filled.FileUpload import androidx.compose.material.icons.filled.FileUpload
import androidx.compose.material3.* import androidx.compose.material3.*
import androidx.compose.runtime.* import androidx.compose.runtime.*
@@ -335,8 +336,16 @@ private fun SelectInstallMethod(onSelected: (InstallMethod) -> Unit = {}) {
if (it.resultCode == Activity.RESULT_OK) { if (it.resultCode == Activity.RESULT_OK) {
it.data?.data?.let { uri -> it.data?.data?.let { uri ->
val option = when (currentSelectingMethod) { val option = when (currentSelectingMethod) {
is InstallMethod.SelectFile -> InstallMethod.SelectFile(uri, summary = selectFileTip) is InstallMethod.SelectFile -> InstallMethod.SelectFile(
is InstallMethod.HorizonKernel -> InstallMethod.HorizonKernel(uri, summary = horizonKernelSummary) uri,
summary = selectFileTip
)
is InstallMethod.HorizonKernel -> InstallMethod.HorizonKernel(
uri,
summary = horizonKernelSummary
)
else -> null else -> null
} }
option?.let { option?.let {
@@ -364,57 +373,136 @@ private fun SelectInstallMethod(onSelected: (InstallMethod) -> Unit = {}) {
is InstallMethod.SelectFile, is InstallMethod.HorizonKernel -> { is InstallMethod.SelectFile, is InstallMethod.HorizonKernel -> {
selectImageLauncher.launch(Intent(Intent.ACTION_GET_CONTENT).apply { selectImageLauncher.launch(Intent(Intent.ACTION_GET_CONTENT).apply {
type = "application/*" type = "application/*"
putExtra(Intent.EXTRA_MIME_TYPES, arrayOf("application/octet-stream", "application/zip")) putExtra(
Intent.EXTRA_MIME_TYPES,
arrayOf("application/octet-stream", "application/zip")
)
}) })
} }
is InstallMethod.DirectInstall -> { is InstallMethod.DirectInstall -> {
selectedOption = option selectedOption = option
onSelected(option) onSelected(option)
} }
is InstallMethod.DirectInstallToInactiveSlot -> { is InstallMethod.DirectInstallToInactiveSlot -> {
confirmDialog.showConfirm(dialogTitle, dialogContent) confirmDialog.showConfirm(dialogTitle, dialogContent)
} }
} }
} }
var LKMExpanded by remember { mutableStateOf(false) }
var GKIExpanded by remember { mutableStateOf(false) }
Column { Column {
radioOptions.forEach { option -> ListItem(
val interactionSource = remember { MutableInteractionSource() } leadingContent = { Icon(Icons.Filled.AutoFixHigh, null) },
Row( headlineContent = { Text(stringResource(R.string.Lkm_install_methods)) },
verticalAlignment = Alignment.CenterVertically, modifier = Modifier.clickable {
modifier = Modifier LKMExpanded = !LKMExpanded
.fillMaxWidth() }
.toggleable( )
value = option.javaClass == selectedOption?.javaClass, radioOptions.take(3).forEach { option ->
onValueChange = { onClick(option) }, AnimatedVisibility(
role = Role.RadioButton, visible = LKMExpanded,
indication = LocalIndication.current, modifier = Modifier.fillMaxWidth().padding(horizontal = 24.dp)
interactionSource = interactionSource
)
) { ) {
RadioButton( Column {
selected = option.javaClass == selectedOption?.javaClass, val interactionSource = remember { MutableInteractionSource() }
onClick = { onClick(option) }, Row(
interactionSource = interactionSource verticalAlignment = Alignment.CenterVertically,
) modifier = Modifier
Column( .fillMaxWidth()
modifier = Modifier.padding(vertical = 12.dp) .toggleable(
) { value = option.javaClass == selectedOption?.javaClass,
Text( onValueChange = { onClick(option) },
text = stringResource(id = option.label), role = Role.RadioButton,
fontSize = MaterialTheme.typography.titleMedium.fontSize, indication = LocalIndication.current,
fontFamily = MaterialTheme.typography.titleMedium.fontFamily, interactionSource = interactionSource
fontStyle = MaterialTheme.typography.titleMedium.fontStyle )
) ) {
option.summary?.let { RadioButton(
Text( selected = option.javaClass == selectedOption?.javaClass,
text = it, onClick = { onClick(option) },
fontSize = MaterialTheme.typography.bodySmall.fontSize, interactionSource = interactionSource
fontFamily = MaterialTheme.typography.bodySmall.fontFamily,
fontStyle = MaterialTheme.typography.bodySmall.fontStyle
) )
Column(
modifier = Modifier.padding(vertical = 12.dp)
) {
Text(
text = stringResource(id = option.label),
fontSize = MaterialTheme.typography.titleMedium.fontSize,
fontFamily = MaterialTheme.typography.titleMedium.fontFamily,
fontStyle = MaterialTheme.typography.titleMedium.fontStyle
)
option.summary?.let {
Text(
text = it,
fontSize = MaterialTheme.typography.bodySmall.fontSize,
fontFamily = MaterialTheme.typography.bodySmall.fontFamily,
fontStyle = MaterialTheme.typography.bodySmall.fontStyle
)
}
}
} }
} }
Spacer(modifier = Modifier.height(8.dp))
}
}
}
Column {
ListItem(
leadingContent = { Icon(Icons.Filled.FileUpload, null) },
headlineContent = { Text(stringResource(R.string.GKI_install_methods)) },
modifier = Modifier.clickable {
GKIExpanded = !GKIExpanded
}
)
AnimatedVisibility(
visible = GKIExpanded,
modifier = Modifier.fillMaxWidth().padding(horizontal = 24.dp)
) {
Column {
radioOptions.drop(3).forEach { option ->
val interactionSource = remember { MutableInteractionSource() }
Row(
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
.fillMaxWidth()
.toggleable(
value = option.javaClass == selectedOption?.javaClass,
onValueChange = { onClick(option) },
role = Role.RadioButton,
indication = LocalIndication.current,
interactionSource = interactionSource
)
) {
RadioButton(
selected = option.javaClass == selectedOption?.javaClass,
onClick = { onClick(option) },
interactionSource = interactionSource
)
Column(
modifier = Modifier.padding(vertical = 12.dp)
) {
Text(
text = stringResource(id = option.label),
fontSize = MaterialTheme.typography.titleMedium.fontSize,
fontFamily = MaterialTheme.typography.titleMedium.fontFamily,
fontStyle = MaterialTheme.typography.titleMedium.fontStyle
)
option.summary?.let {
Text(
text = it,
fontSize = MaterialTheme.typography.bodySmall.fontSize,
fontFamily = MaterialTheme.typography.bodySmall.fontFamily,
fontStyle = MaterialTheme.typography.bodySmall.fontStyle
)
}
}
}
Spacer(modifier = Modifier.height(8.dp))
}
} }
} }
} }
@@ -522,11 +610,6 @@ private fun TopBar(
Icon(Icons.AutoMirrored.Filled.ArrowBack, contentDescription = null) Icon(Icons.AutoMirrored.Filled.ArrowBack, contentDescription = null)
} }
}, },
actions = {
IconButton(onClick = onLkmUpload) {
Icon(Icons.Filled.FileUpload, contentDescription = null)
}
},
windowInsets = WindowInsets.safeDrawing.only( windowInsets = WindowInsets.safeDrawing.only(
WindowInsetsSides.Top + WindowInsetsSides.Horizontal WindowInsetsSides.Top + WindowInsetsSides.Horizontal
), ),

View File

@@ -117,7 +117,7 @@
<string name="enable_web_debugging">启用 WebView 调试</string> <string name="enable_web_debugging">启用 WebView 调试</string>
<string name="enable_web_debugging_summary">可用于调试 WebUI 。请仅在需要时启用。</string> <string name="enable_web_debugging_summary">可用于调试 WebUI 。请仅在需要时启用。</string>
<string name="direct_install">直接安装(推荐)</string> <string name="direct_install">直接安装(推荐)</string>
<string name="select_file">选择一个文件</string> <string name="select_file">选择一个需要修补的镜像</string>
<string name="install_inactive_slot">安装到未使用的槽位OTA 后)</string> <string name="install_inactive_slot">安装到未使用的槽位OTA 后)</string>
<string name="install_inactive_slot_warning">将在重启后强制切换到另一个槽位!\n注意只能在 OTA 更新完成后的重启之前使用。\n确认</string> <string name="install_inactive_slot_warning">将在重启后强制切换到另一个槽位!\n注意只能在 OTA 更新完成后的重启之前使用。\n确认</string>
<string name="install_next">下一步</string> <string name="install_next">下一步</string>
@@ -284,12 +284,15 @@
<string name="slot_a">A槽位</string> <string name="slot_a">A槽位</string>
<string name="slot_b">B槽位</string> <string name="slot_b">B槽位</string>
<string name="selected_slot">已选择槽位: %1$s</string> <string name="selected_slot">已选择槽位: %1$s</string>
<!-- 错误信息 -->
<string name="horizon_copy_failed">复制失败</string>
<string name="horizon_unknown_error">未知错误</string>
<string name="horizon_getting_original_slot">获取原有槽位</string> <string name="horizon_getting_original_slot">获取原有槽位</string>
<string name="horizon_setting_target_slot">设置指定槽位</string> <string name="horizon_setting_target_slot">设置指定槽位</string>
<string name="horizon_restoring_original_slot">恢复默认槽位</string> <string name="horizon_restoring_original_slot">恢复默认槽位</string>
<string name="current_slot">当前槽位:%1$s </string> <string name="current_slot">当前槽位:%1$s </string>
<!-- 错误信息 -->
<string name="horizon_copy_failed">复制失败</string>
<string name="horizon_unknown_error">未知错误</string>
<string name="flash_failed_message">刷写失败</string> <string name="flash_failed_message">刷写失败</string>
<!-- lkm/gki install -->
<string name="Lkm_install_methods">LKM修补/安装</string>
<string name="GKI_install_methods">GKI安装</string>
</resources> </resources>

View File

@@ -118,7 +118,7 @@
<string name="enable_web_debugging">Enable WebView debugging</string> <string name="enable_web_debugging">Enable WebView debugging</string>
<string name="enable_web_debugging_summary">Can be used to debug WebUI. Please enable only when needed.</string> <string name="enable_web_debugging_summary">Can be used to debug WebUI. Please enable only when needed.</string>
<string name="direct_install">Direct install (Recommended)</string> <string name="direct_install">Direct install (Recommended)</string>
<string name="select_file">Select a file</string> <string name="select_file">Select a mirror that needs to be patched</string>
<string name="install_inactive_slot">Install to inactive slot (After OTA)</string> <string name="install_inactive_slot">Install to inactive slot (After OTA)</string>
<string name="install_inactive_slot_warning">Your device will be **FORCED** to boot to the current inactive slot after a reboot!\nOnly use this option after OTA is done.\nContinue?</string> <string name="install_inactive_slot_warning">Your device will be **FORCED** to boot to the current inactive slot after a reboot!\nOnly use this option after OTA is done.\nContinue?</string>
<string name="install_next">Next</string> <string name="install_next">Next</string>
@@ -288,12 +288,15 @@
<string name="slot_a">Slot A</string> <string name="slot_a">Slot A</string>
<string name="slot_b">Slot B</string> <string name="slot_b">Slot B</string>
<string name="selected_slot">Selected slot: %1$s</string> <string name="selected_slot">Selected slot: %1$s</string>
<!-- Error Messages -->
<string name="horizon_copy_failed">Copy failed</string>
<string name="horizon_unknown_error">Unknown error</string>
<string name="horizon_getting_original_slot">Getting the original slot</string> <string name="horizon_getting_original_slot">Getting the original slot</string>
<string name="horizon_setting_target_slot">Setting the specified slot</string> <string name="horizon_setting_target_slot">Setting the specified slot</string>
<string name="horizon_restoring_original_slot">Restore Default Slot</string> <string name="horizon_restoring_original_slot">Restore Default Slot</string>
<string name="current_slot">Current Slot%1$s </string> <string name="current_slot">Current Slot%1$s </string>
<!-- Error Messages -->
<string name="horizon_copy_failed">Copy failed</string>
<string name="horizon_unknown_error">Unknown error</string>
<string name="flash_failed_message">Flash failed</string> <string name="flash_failed_message">Flash failed</string>
<!-- lkm/gki install -->
<string name="Lkm_install_methods">LKM repair/installation</string>
<string name="GKI_install_methods">GKI installation</string>
</resources> </resources>