Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@dkwingsmt
Copy link
Contributor

@dkwingsmt dkwingsmt commented May 21, 2020

Description

This PR adds system mouse cursor to the Android engine.

This PR adds only a limited pool of system cursors. More will be added when the system is set up.

Related Issues

* This method guarantees to return a non-null object.
*/
private PointerIcon resolveSystemCursor(@NonNull String kind) {
if (MouseCursorPlugin.systemCursorConstants == null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Since resolveSystemCursor is an instance method and cannot be called unless the constructor is called first, we could initialize systemCursorConstants in the constructor and avoid the if null check on every call.

Copy link
Contributor Author

@dkwingsmt dkwingsmt May 26, 2020

Choose a reason for hiding this comment

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

My concern is that this map will be expanded to ~70 cursors in the future, which will not be used by most mobile devices (since they don't set cursors at all). I want to avoid this overhead when unnecessary but this might indeed be a premature optimization. Do you still think it's fine to initialize it in the constructor unconditionally?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ahh, in that case, a comment would be plenty to justify this to future readers :)

@GaryQian
Copy link
Contributor

Implementation roughly looks good, this change is missing tests.

@dkwingsmt dkwingsmt requested a review from GaryQian June 1, 2020 21:23
}
}),
methodResult);
verify(testView, times(1)).getSystemPointerIcon(PointerIcon.TYPE_TEXT);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we also test the other cases here as well? Should be simple to replicate.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That’ll be 70 cases in the future though, and they’re basically the conversion map written a second time. I think the conversion map itself should suffice.

@GaryQian
Copy link
Contributor

GaryQian commented Jun 1, 2020

Minor test nit, otherwise LGTM!

@dkwingsmt dkwingsmt merged commit b3e7732 into flutter:master Jun 2, 2020
@dkwingsmt dkwingsmt deleted the system-mouse-cursor-android branch June 2, 2020 01:08
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 2, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants