Skip to content
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

Request and handle cursor changes #613

Merged
merged 8 commits into from
Jan 19, 2024

Conversation

jm355
Copy link
Contributor

@jm355 jm355 commented Jan 10, 2024

Request updates to cursor movement in KeyboardScreen, update IMEService to handle cursor movement, and track whether the cursor moved in a way that should inhibit the next multitap action.

Tested on my phone and it works as expected, resolves #242

…uld inhibit the next multitap action. Request updates to cursor movement in KeyboardScreen.z
@jm355
Copy link
Contributor Author

jm355 commented Jan 10, 2024

Also, shoutout to @patrickgold, florisboard/florisboard@e8ee49a put me on the right track for where to put onUpdateCursorAnchorInfo(), thanks!

@jm355
Copy link
Contributor Author

jm355 commented Jan 10, 2024

Also worth noting that this depends on the text field properly calling onUpdateCursorAnchorInfo(). I don't think the "Test out Thumb-Key" field does, so the bug is still present there. I used note to self on signal to test this out

@KraXen72
Copy link
Contributor

huge

@jm355
Copy link
Contributor Author

jm355 commented Jan 10, 2024

One edge case I just thought of, if you multitap at the right edge of the text box such that the space moves the cursor to the next line, that multitap will be blocked. Maybe only checking the vertical has changed if the horizontal is not zero would work?

edit: then again, if the user moves the cursor to the left edge of the text box, it may incorrectly trigger the bug and be harder to notice since text was changed on the other side of the text box. I think it's better for edge cases to block multitap than trigger it when it shouldn't be triggered, since it's easier to notice that multitap failed than that the bug occurred imo

edit 2: could have it where it allows multitap if the cursor moved down 1 line, the previous horizontal was large, and the new horizontal is 0

@jm355 jm355 changed the title Update IMEService to track whether the cursor moved in a way that ... Request and handle cursor changes Jan 10, 2024
Copy link
Owner

@dessalines dessalines left a comment

Choose a reason for hiding this comment

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

I can't test this cause its crashes thumbkey with a NoSuchMethodError: no interface method requestCursorUpdates

What IDE are you using, because android-studio is picking up a ton of errors and corrections.

@jm355
Copy link
Contributor Author

jm355 commented Jan 10, 2024

I can't test this cause its crashes thumbkey with a NoSuchMethodError: no interface method requestCursorUpdates

What IDE are you using, because android-studio is picking up a ton of errors and corrections.

I'm using android studio. It builds on woodpecker as well.

@dessalines
Copy link
Owner

dessalines commented Jan 10, 2024

I'm guessing its an older android-studio version you're using, I'm at Android Studio Hedgehog | 2023.1.1 Patch 1

I'll let you fix this up tho, and eliminate the crash.

@jm355
Copy link
Contributor Author

jm355 commented Jan 10, 2024

No, I'm using the same version as you. That said this is pushing the limit of my android dev experience, there's a good chance I don't have it set up/configured correctly.

Which crash are you talking about?

@dessalines
Copy link
Owner

Your recent update fixed the crash I was getting (API level 21 version of that requestCursorUpdates).

@dessalines
Copy link
Owner

If you'd like, I can finish up this PR. Usually people don't like that tho, which is why I'm always reticent to do that right away.

@jm355
Copy link
Contributor Author

jm355 commented Jan 10, 2024

You should just wrap it up, that doesn't bother me at all

@@ -302,7 +301,7 @@ fun KeyboardScreen(
}
}
} else {
if (ctx.currentInputConnection.requestCursorUpdates(CURSOR_UPDATE_MONITOR or CURSOR_UPDATE_FILTER_INSERTION_MARKER)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there a reason you disabled the insertion marker filter? According to https://developer.android.com/reference/android/view/inputmethod/InputConnection#CURSOR_UPDATE_IMMEDIATE, "by default all of CURSOR_UPDATE_FILTER_EDITOR_BOUNDS, CURSOR_UPDATE_FILTER_CHARACTER_BOUNDS, CURSOR_UPDATE_FILTER_VISIBLE_LINE_BOUNDS, CURSOR_UPDATE_FILTER_TEXT_APPEARANCE, and CURSOR_UPDATE_FILTER_INSERTION_MARKER, are included but specifying them can filter-out others. It can be CPU intensive to include all, filtering specific info is recommended" (emph. added)

Copy link
Contributor Author

@jm355 jm355 Jan 12, 2024

Choose a reason for hiding this comment

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

Note that CURSOR_UPDATE_MONITOR isn't a filter, they do it weird where they have flags for how to monitor and filter flags in one parameter. The API34 way with separate parameters makes more sense to me, but that's how this one is

Copy link
Owner

Choose a reason for hiding this comment

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

When I had that or CURSOR_UPDATE_FILTER_INSERTION_MARKER, it failed everywhere.

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's weird, even in signal?

Copy link
Owner

Choose a reason for hiding this comment

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

I'd need to test again, but I'm pretty sure.

@jm355
Copy link
Contributor Author

jm355 commented Jan 18, 2024

Can we merge this in to at least fix the bug for some text fields? Or do you want to switch to a check that compares against the previous character?

@dessalines
Copy link
Owner

Can we merge this in to at least fix the bug for some text fields?

I'd rather not have inconsistent behavior, especially since jetpack compose is the standard now for building android apps.

Or do you want to switch to a check that compares against the previous character?

I'd rather not do that, since it has other potential problems.

I didn't get any updates on my stackoverflow thread, so I've just opened up one now on google's issue tracker for this. I'll ping back when that gets any updates from the team. If they find that its a bug, then its on them, and I'll merge this. If they find that its not a bug, hopefully they'll direct me on how to fix.

@dessalines
Copy link
Owner

They got back to me, and said:

InputConnection#requestCursorUpdates is supported by Compose text fields starting in Compose 1.6.

1.6 is still a release candidate, but I'll test out that RC within a few days.

@dessalines
Copy link
Owner

Verified that it works!

@jm355
Copy link
Contributor Author

jm355 commented Jan 19, 2024

Awesome!

Copy link
Owner

@dessalines dessalines left a comment

Choose a reason for hiding this comment

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

Looks good now, thx! This'll be in the next release.

@dessalines dessalines enabled auto-merge (squash) January 19, 2024 19:24
@dessalines dessalines merged commit 3776edd into dessalines:main Jan 19, 2024
1 check passed
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.

moving the cursor does not reset spacebar multi-tap
3 participants