Browse Source

Add docs about desktop a11y (#1775)

pull/1814/head
Aleksandr Veselov 3 years ago committed by GitHub
parent
commit
d822283c4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 61
      tutorials/Accessibility/README.md
  2. 18
      tutorials/Accessibility/Windows.md
  3. BIN
      tutorials/Accessibility/images/custom-widget.png
  4. BIN
      tutorials/Accessibility/images/nvda-compat.png

61
tutorials/Accessibility/README.md

@ -0,0 +1,61 @@
# Accessibility support
## Platform Support
| Platform | Status |
|----------|-----------------------------------|
| MacOS | Supported |
| Windows | Supported with Java Access Bridge |
| Linux | Not supported |
## Custom widget with semantic rules
```kotlin
import androidx.compose.foundation.*
import androidx.compose.foundation.layout.*
import androidx.compose.material.Text
import androidx.compose.runtime.*
import androidx.compose.ui.*
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.semantics.*
import androidx.compose.ui.unit.*
import androidx.compose.ui.window.*
fun main() = singleWindowApplication(
title = "Custom Button", state = WindowState(size = DpSize(300.dp, 200.dp))
) {
var count by remember { mutableStateOf(0) }
Box(modifier = Modifier.padding(50.dp)) {
Box(modifier = Modifier
.background(Color.LightGray)
.fillMaxSize()
.clickable { count += 1 }
.semantics(mergeDescendants = true /* Use text from the contents (1) */) {
// This is a button (2)
role = Role.Button
// Add some help text to button (3)
contentDescription = "Click to increment value"
}
) {
val text = when (count) {
0 -> "Click Me!"
1 -> "Clicked"
else -> "Clicked $count times"
}
Text(text, modifier = Modifier.align(Alignment.Center), fontSize = 24.sp)
}
}
}
```
![Custom Widget](./images/custom-widget.png)
# Windows
Accessibility on Windows is provided by Java Access Bridge and is disabled by default. To enable it, run the following command in Command Prompt.
```cmd
%JAVA_HOME%\bin\jabswitch.exe /enable
```
There are some issues with HiDPI display support on windows, see [Desktop Accessibility on Windows](Windows.md) for details.

18
tutorials/Accessibility/Windows.md

@ -0,0 +1,18 @@
# Desktop Accessibility on Windows
## Enabling Java Accessibility on Windows
Java Access Bridge is disabled by default. To enable it, run
```cmd
%JAVA_HOME%\bin\jabswitch.exe /enable
```
## HiDPI issues
### JDK support
HiDPI support in Access Bridge was landed in [JDK-8279227](https://bugs.openjdk.java.net/browse/JDK-8279227). As for Feb/01/2022 this feature is not included in any released JDK, OpenJDK 17.0.4 release with this feature is planned for May 2022.
### NVDA workaround
NVDA 2021.3.1 does not handle widget position properly. Until they fix it we can override DPI awareness in NVDA compatibility settings as shown:
![NVDA compatibility settings](./images/nvda-compat.png)

BIN
tutorials/Accessibility/images/custom-widget.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 332 KiB

BIN
tutorials/Accessibility/images/nvda-compat.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

Loading…
Cancel
Save