feat: 优化待办进度的无障碍描述
This commit is contained in:
parent
fe0364042a
commit
ddc1771da1
4 changed files with 29 additions and 4 deletions
|
|
@ -34,7 +34,7 @@ android {
|
|||
applicationId = "cn.super12138.todo"
|
||||
minSdk = 24
|
||||
targetSdk = 36
|
||||
versionCode = 675
|
||||
versionCode = 676
|
||||
versionName = "2.1.2"
|
||||
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ import androidx.compose.runtime.Composable
|
|||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.semantics.clearAndSetSemantics
|
||||
import androidx.compose.ui.semantics.stateDescription
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
import cn.super12138.todo.R
|
||||
|
|
@ -30,6 +32,17 @@ fun ProgressFragment(
|
|||
0f
|
||||
}
|
||||
|
||||
val progressDescription = if (totalTasks != 0) {
|
||||
stringResource(
|
||||
R.string.accessibility_progress_tasks,
|
||||
totalTasks,
|
||||
completedTasks,
|
||||
remainTasks
|
||||
)
|
||||
} else {
|
||||
stringResource(R.string.accessibility_progress_no_tasks)
|
||||
}
|
||||
|
||||
Box(
|
||||
modifier = modifier,
|
||||
contentAlignment = Alignment.Center
|
||||
|
|
@ -38,11 +51,18 @@ fun ProgressFragment(
|
|||
progress = progress,
|
||||
strokeWidth = 10.dp,
|
||||
gapSize = 10.dp,
|
||||
modifier = Modifier.size(175.dp)
|
||||
modifier = Modifier
|
||||
.size(175.dp)
|
||||
.clearAndSetSemantics {}
|
||||
)
|
||||
|
||||
Column(horizontalAlignment = Alignment.CenterHorizontally) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = Modifier.clearAndSetSemantics {
|
||||
stateDescription = progressDescription
|
||||
}
|
||||
) {
|
||||
Text(
|
||||
text = completedTasks.toString(),
|
||||
style = MaterialTheme.typography.displaySmall.copy(
|
||||
|
|
@ -65,7 +85,8 @@ fun ProgressFragment(
|
|||
AnimatedVisibility(remainTasks != 0) {
|
||||
Text(
|
||||
text = stringResource(R.string.tip_remain_tasks, remainTasks),
|
||||
style = MaterialTheme.typography.labelMedium
|
||||
style = MaterialTheme.typography.labelMedium,
|
||||
modifier = Modifier.clearAndSetSemantics {}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,4 +110,6 @@
|
|||
<string name="happy_birthday">待办1岁生日快乐</string>
|
||||
<string name="subject_customization">自定义</string>
|
||||
<string name="label_enter_subject_name">输入学科名称</string>
|
||||
<string name="accessibility_progress_tasks">当前共有 %1$d 项任务,其中 %2$d 项已完成,%3$d 项未完成</string>
|
||||
<string name="accessibility_progress_no_tasks">当前没有任务</string>
|
||||
</resources>
|
||||
|
|
@ -111,4 +111,6 @@
|
|||
<string name="happy_birthday">Happy 1st birthday to ToDo</string>
|
||||
<string name="subject_customization">Customization</string>
|
||||
<string name="label_enter_subject_name">Enter subject name</string>
|
||||
<string name="accessibility_progress_tasks">Currently, there are %1$d tasks in total, with %2$d completed and %3$d unfinished.</string>
|
||||
<string name="accessibility_progress_no_tasks">There are no tasks at the moment.</string>
|
||||
</resources>
|
||||
Loading…
Reference in a new issue