feat: 为更多项目优化无障碍描述
This commit is contained in:
parent
c4a7930cfd
commit
a92b5c5ffe
8 changed files with 43 additions and 12 deletions
|
|
@ -34,7 +34,7 @@ android {
|
||||||
applicationId = "cn.super12138.todo"
|
applicationId = "cn.super12138.todo"
|
||||||
minSdk = 24
|
minSdk = 24
|
||||||
targetSdk = 36
|
targetSdk = 36
|
||||||
versionCode = 676
|
versionCode = 678
|
||||||
versionName = "2.1.2"
|
versionName = "2.1.2"
|
||||||
|
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
|
|
||||||
|
|
@ -47,8 +47,11 @@ import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.platform.LocalView
|
import androidx.compose.ui.platform.LocalView
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
|
import androidx.compose.ui.semantics.LiveRegionMode
|
||||||
import androidx.compose.ui.semantics.contentDescription
|
import androidx.compose.ui.semantics.contentDescription
|
||||||
|
import androidx.compose.ui.semantics.liveRegion
|
||||||
import androidx.compose.ui.semantics.semantics
|
import androidx.compose.ui.semantics.semantics
|
||||||
|
import androidx.compose.ui.semantics.stateDescription
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import cn.super12138.todo.R
|
import cn.super12138.todo.R
|
||||||
import cn.super12138.todo.constants.Constants
|
import cn.super12138.todo.constants.Constants
|
||||||
|
|
@ -249,7 +252,12 @@ fun TodoEditorPage(
|
||||||
val interactionSource = remember { MutableInteractionSource() }
|
val interactionSource = remember { MutableInteractionSource() }
|
||||||
Slider(
|
Slider(
|
||||||
modifier = Modifier.semantics {
|
modifier = Modifier.semantics {
|
||||||
contentDescription = context.getString(R.string.label_priority)
|
contentDescription =
|
||||||
|
context.getString(R.string.label_priority) + priorityName[Priority.fromFloat(
|
||||||
|
priorityState
|
||||||
|
).ordinal]
|
||||||
|
stateDescription = priorityName[Priority.fromFloat(priorityState).ordinal]
|
||||||
|
liveRegion = LiveRegionMode.Polite
|
||||||
},
|
},
|
||||||
value = priorityState,
|
value = priorityState,
|
||||||
onValueChange = {
|
onValueChange = {
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
import androidx.compose.ui.unit.dp
|
import cn.super12138.todo.ui.TodoDefaults
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun SettingsCategory(
|
fun SettingsCategory(
|
||||||
|
|
@ -18,7 +18,11 @@ fun SettingsCategory(
|
||||||
Box(
|
Box(
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(top = 12.dp, start = 24.dp, end = 24.dp)
|
.padding(
|
||||||
|
top = TodoDefaults.settingsItemVerticalPadding / 2,
|
||||||
|
start = TodoDefaults.settingsItemHorizontalPadding,
|
||||||
|
end = TodoDefaults.settingsItemHorizontalPadding
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = title,
|
text = title,
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,8 @@ import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
|
import androidx.compose.ui.semantics.clearAndSetSemantics
|
||||||
|
import androidx.compose.ui.semantics.contentDescription
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import cn.super12138.todo.R
|
import cn.super12138.todo.R
|
||||||
import cn.super12138.todo.ui.TodoDefaults
|
import cn.super12138.todo.ui.TodoDefaults
|
||||||
|
|
@ -23,6 +25,7 @@ fun SettingsPlainBox(
|
||||||
text: String,
|
text: String,
|
||||||
modifier: Modifier = Modifier
|
modifier: Modifier = Modifier
|
||||||
) {
|
) {
|
||||||
|
val tipText = stringResource(R.string.tip_tips)
|
||||||
Column(
|
Column(
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
|
|
@ -35,14 +38,16 @@ fun SettingsPlainBox(
|
||||||
) {
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.Outlined.Info,
|
imageVector = Icons.Outlined.Info,
|
||||||
contentDescription = stringResource(R.string.tip_tips)
|
contentDescription = null
|
||||||
)
|
)
|
||||||
Spacer(Modifier.size(20.dp))
|
Spacer(Modifier.size(20.dp))
|
||||||
Text(
|
Text(
|
||||||
text = text,
|
text = text,
|
||||||
style = MaterialTheme.typography.bodyMedium.copy(
|
style = MaterialTheme.typography.bodyMedium.copy(
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
)
|
),
|
||||||
|
modifier = Modifier
|
||||||
|
.clearAndSetSemantics { contentDescription = "$tipText $text" }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -18,8 +18,12 @@ import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.platform.LocalView
|
import androidx.compose.ui.platform.LocalView
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
|
import androidx.compose.ui.semantics.LiveRegionMode
|
||||||
|
import androidx.compose.ui.semantics.clearAndSetSemantics
|
||||||
import androidx.compose.ui.semantics.contentDescription
|
import androidx.compose.ui.semantics.contentDescription
|
||||||
|
import androidx.compose.ui.semantics.liveRegion
|
||||||
import androidx.compose.ui.semantics.semantics
|
import androidx.compose.ui.semantics.semantics
|
||||||
|
import androidx.compose.ui.semantics.stateDescription
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import cn.super12138.todo.R
|
import cn.super12138.todo.R
|
||||||
import cn.super12138.todo.constants.Constants
|
import cn.super12138.todo.constants.Constants
|
||||||
|
|
@ -44,10 +48,17 @@ fun ContrastPicker(
|
||||||
Constants.PREF_CONTRAST_LEVEL,
|
Constants.PREF_CONTRAST_LEVEL,
|
||||||
Constants.PREF_CONTRAST_LEVEL_DEFAULT
|
Constants.PREF_CONTRAST_LEVEL_DEFAULT
|
||||||
)
|
)
|
||||||
|
val contrastLevelName =
|
||||||
|
ContrastLevel.entries.map { it.getDisplayName(context) }
|
||||||
|
|
||||||
Slider(
|
Slider(
|
||||||
modifier = Modifier.semantics {
|
modifier = Modifier.semantics {
|
||||||
contentDescription = context.getString(R.string.tip_change_contrast_level)
|
contentDescription =
|
||||||
|
context.getString(R.string.pref_contrast_level) + contrastLevelName[ContrastLevel.fromFloat(
|
||||||
|
contrastState
|
||||||
|
).ordinal]
|
||||||
|
stateDescription = contrastLevelName[ContrastLevel.fromFloat(contrastState).ordinal]
|
||||||
|
liveRegion = LiveRegionMode.Polite
|
||||||
},
|
},
|
||||||
value = contrastState,
|
value = contrastState,
|
||||||
onValueChange = {
|
onValueChange = {
|
||||||
|
|
@ -63,7 +74,9 @@ fun ContrastPicker(
|
||||||
|
|
||||||
CompositionLocalProvider(LocalTextStyle provides MaterialTheme.typography.bodyMedium) {
|
CompositionLocalProvider(LocalTextStyle provides MaterialTheme.typography.bodyMedium) {
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.clearAndSetSemantics {},
|
||||||
horizontalArrangement = Arrangement.SpaceBetween
|
horizontalArrangement = Arrangement.SpaceBetween
|
||||||
) {
|
) {
|
||||||
Text(stringResource(R.string.contrast_very_low))
|
Text(stringResource(R.string.contrast_very_low))
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
package cn.super12138.todo.ui.theme
|
package cn.super12138.todo.ui.theme
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import cn.super12138.todo.R
|
||||||
|
|
||||||
enum class ContrastLevel(val value: Float) {
|
enum class ContrastLevel(val value: Float) {
|
||||||
VeryLow(-1f),
|
VeryLow(-1f),
|
||||||
Low(-0.5f),
|
Low(-0.5f),
|
||||||
|
|
@ -7,7 +10,7 @@ enum class ContrastLevel(val value: Float) {
|
||||||
Medium(0.5f),
|
Medium(0.5f),
|
||||||
High(1f);
|
High(1f);
|
||||||
|
|
||||||
/*fun getDisplayName(context: Context): String {
|
fun getDisplayName(context: Context): String {
|
||||||
val resId = when (this) {
|
val resId = when (this) {
|
||||||
VeryLow -> R.string.contrast_very_low
|
VeryLow -> R.string.contrast_very_low
|
||||||
Low -> R.string.contrast_low
|
Low -> R.string.contrast_low
|
||||||
|
|
@ -16,7 +19,7 @@ enum class ContrastLevel(val value: Float) {
|
||||||
High -> R.string.contrast_very_high
|
High -> R.string.contrast_very_high
|
||||||
}
|
}
|
||||||
return context.getString(resId)
|
return context.getString(resId)
|
||||||
}*/
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun fromFloat(float: Float) = entries.find { it.value == float } ?: Default
|
fun fromFloat(float: Float) = entries.find { it.value == float } ?: Default
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,6 @@
|
||||||
<string name="contrast_default">默认</string>
|
<string name="contrast_default">默认</string>
|
||||||
<string name="contrast_high">高</string>
|
<string name="contrast_high">高</string>
|
||||||
<string name="contrast_very_high">极高</string>
|
<string name="contrast_very_high">极高</string>
|
||||||
<string name="tip_change_contrast_level">更改颜色对比度</string>
|
|
||||||
<string name="pref_interface_interaction">界面与交互</string>
|
<string name="pref_interface_interaction">界面与交互</string>
|
||||||
<string name="pref_interface_interaction_desc">待办列表、触感反馈</string>
|
<string name="pref_interface_interaction_desc">待办列表、触感反馈</string>
|
||||||
<string name="pref_show_completed">显示已完成待办</string>
|
<string name="pref_show_completed">显示已完成待办</string>
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,6 @@
|
||||||
<string name="contrast_default">Default</string>
|
<string name="contrast_default">Default</string>
|
||||||
<string name="contrast_high">High</string>
|
<string name="contrast_high">High</string>
|
||||||
<string name="contrast_very_high">Very High</string>
|
<string name="contrast_very_high">Very High</string>
|
||||||
<string name="tip_change_contrast_level">Change the contrast level</string>
|
|
||||||
<string name="pref_interface_interaction">Interface & Interaction</string>
|
<string name="pref_interface_interaction">Interface & Interaction</string>
|
||||||
<string name="pref_interface_interaction_desc">To-Do List, Haptic Feedback</string>
|
<string name="pref_interface_interaction_desc">To-Do List, Haptic Feedback</string>
|
||||||
<string name="pref_show_completed">Show Completed Tasks</string>
|
<string name="pref_show_completed">Show Completed Tasks</string>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue