Skip to content

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

Merged
merged 17 commits into from
May 4, 2025
Merged

Conversation

mwcampbell
Copy link
Contributor

@mwcampbell mwcampbell commented Apr 28, 2025

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 using Adapter that I'm happy with
  • InjectingAdapter: 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

/// 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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// The `host` paramter is the Android view for this adapter.
/// The `host` parameter is the Android view for this adapter.

/// 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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// The `host` paramter is the Android view for this adapter.
/// The `host` parameter is the Android view for this adapter.

/// Handle the provided hover event.
///
/// The `action`, `x`, and `y` parameters must be retrieved from
/// the corresopnding properties on an Android motion event. These
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// 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(|| {
Copy link
Member

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.

@DataTriny DataTriny merged commit 7ac5911 into main May 4, 2025
16 checks passed
@DataTriny DataTriny deleted the android-less-java branch May 4, 2025 11:13
@DataTriny DataTriny mentioned this pull request Apr 27, 2025
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.

2 participants