-
Notifications
You must be signed in to change notification settings - Fork 65
refactor!: Simplify the core Android adapter API #558
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…lding the inner adapter lock while raising queued events
…ng Adapter are implemented on the native side
…in the translation to Rust
…election key; it'll be false by default anyway
platforms/android/src/adapter.rs
Outdated
/// AccessKit node identified by the given virtual view ID. | ||
/// Create an `AccessibilityNodeInfo` for the AccessKit node | ||
/// corresponding to the given virtual view ID. Returns null if | ||
/// there is no such node. | ||
/// | ||
/// The `host` paramter is the Android view for this adapter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// The `host` paramter is the Android view for this adapter. | |
/// The `host` parameter is the Android view for this adapter. |
platforms/android/src/adapter.rs
Outdated
/// Create an `AccessibilityNodeInfo` for the AccessKit node | ||
/// with the given focus type. Returns null if there is no such node. | ||
/// | ||
/// The `host` paramter is the Android view for this adapter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// The `host` paramter is the Android view for this adapter. | |
/// The `host` parameter is the Android view for this adapter. |
platforms/android/src/adapter.rs
Outdated
/// Handle the provided hover event. | ||
/// | ||
/// The `action`, `x`, and `y` parameters must be retrieved from | ||
/// the corresopnding properties on an Android motion event. These |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// the corresopnding properties on an Android motion event. These | |
/// the corresponding properties on an Android motion event. These |
static CLASS: OnceCell<GlobalRef> = OnceCell::new(); | ||
let global = CLASS.get_or_try_init(|| { | ||
let global = CLASS.get_or_init(|| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could use a LazyCell
here right? Or maybe even better, use std::sync::OnceLock
until our MSRV permit us to use LazyLock
, which would allow us to drop our dependency on once_cell
.
Now even the
Adapter
API prioritizes a simple interface and ease of integration over ease of internal implementation. And I believe it does so without meaningfully compromising performance. Specifically, this lower-level adapter still avoids the overhead of unnecessarily sending things across threads if the UI toolkit is already running on the Android UI thread.The two adapters can be tested with the demo applications in these two repositories:
Adapter
: android-view; for the first time, this repo demonstrates a direct integration usingAdapter
that I'm happy withInjectingAdapter
: xilem-to-do-mvc-android, an updated version of my test/demo app using GameActivity, winit, and xilem that was the only real test case for the original version of the Android adapter