Skip to content

Add support for Android TV#146

Merged
chenxiaolong merged 1 commit into
masterfrom
tv
Jun 4, 2026
Merged

Add support for Android TV#146
chenxiaolong merged 1 commit into
masterfrom
tv

Conversation

@chenxiaolong
Copy link
Copy Markdown
Owner

@chenxiaolong chenxiaolong commented Jun 4, 2026

This required a bit of hackery in webview_bridge.js to make Syncthing's web UI navigable via arrow keys. There are a few main issues:

  • Many web UI elements don't have a visually distinct focused state, so we inject some CSS to add a dotted border around the focused element.
  • The dropdown menus have a keydown handler coming from Bootstrap that hijacks the up/down arrow keys, making it difficult or impossible to leave the dropdown menus using the browser's builtin spatial navigation.
  • The <input type="number"> elements have default browser behavior of incrementing or decrementing the number using the arrow keys. There are no spatial navigation APIs available yet, so we can't just preventDefault() these events. Instead, we have a horrible hack to make the field immutable for 100ms while the default handler runs.

There are also some limitations in functionality due to Android TV:

  • Importing, exporting, and saving logs will never work because DocumentsUI doesn't exist.
  • The persistent notification isn't visible because notifications for third party apps isn't supported at all. However, the permission must still be requested for the foreground service to run reliably.
  • "Battery" optimizations also need to be disabled for the foreground service to run reliably, but there's no UI for it. Users need to grant the permission via adb.

On the BasicSync side, there were a couple things to fix:

  • Snackbars are not focusable. Compose doesn't provide an easy way to fix this, so we just skip the snackbar button and show the error details dialog immediately.
  • The split switch preference's switch element isn't focusable with arrow keys by default (but is focusable with the tab key). This was fixed by manually specifying start/end focus direction targets.

@chenxiaolong chenxiaolong self-assigned this Jun 4, 2026
@chenxiaolong chenxiaolong force-pushed the tv branch 4 times, most recently from cebc54b to 4b37512 Compare June 4, 2026 02:20
This required a bit of hackery in webview_bridge.js to make Syncthing's
web UI navigable via arrow keys. There are a few main issues:

* Many web UI elements don't have a visually distinct focused state, so
  we inject some CSS to add a dotted border around the focused element.
* The dropdown menus have a keydown handler coming from Bootstrap that
  hijacks the up/down arrow keys, making it difficult or impossible to
  leave the dropdown menus using the browser's builtin spatial
  navigation.
* The <input type="number"> elements have default browser behavior of
  incrementing or decrementing the number using the arrow keys. There
  are no spatial navigation APIs available yet, so we can't just
  preventDefault() these events. Instead, we have a horrible hack to
  make the field immutable for 100ms while the default handler runs.

There are also some limitations in functionality due to Android TV:

* Importing, exporting, and saving logs will never work because
  DocumentsUI doesn't exist.
* The persistent notification isn't visible because notifications for
  third party apps isn't supported at all. However, the permission must
  still be requested for the foreground service to run reliably.
* "Battery" optimizations also need to be disabled for the foreground
  service to run reliably, but there's no UI for it. Users need to grant
  the permission via adb.

On the BasicSync side, there were a couple things to fix:

* Snackbars are not focusable. Compose doesn't provide an easy way to
  fix this, so we just skip the snackbar button and show the error
  details dialog immediately.
* The split switch preference's switch element isn't focusable with
  arrow keys by default (but is focusable with the tab key). This was
  fixed by manually specifying start/end focus direction targets.

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
chenxiaolong added a commit that referenced this pull request Jun 4, 2026
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
@chenxiaolong chenxiaolong merged commit 713b655 into master Jun 4, 2026
1 check passed
@chenxiaolong chenxiaolong deleted the tv branch June 4, 2026 03:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant