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

feat(android): Enhance how ENTER key is handled in apps #12125

Merged
merged 6 commits into from
Aug 19, 2024

Conversation

darcywong00
Copy link
Contributor

@darcywong00 darcywong00 commented Aug 8, 2024

Fixes #7796

This PR enhances how the ENTER key is handled as actions in different apps.

In multi-line text (like messaging apps), the enter key inserts a newline (\n).

When the IME action is Go / Search / Done, the ENTER key sends the corresponding action. (DONE dismisses the keyboard).
Note: EditorInfo also has more actions like PREVIOUS and NEXT, but I didn't bother implementing those this time.
(edit)
From standup, I'll add PREVIOUS and NEXT actions.

Also a future PR for KMW is getting the ENTER key label to change depending on the action

API Changes

to add to help.keyman.com

  • KMManager.setEnterMode
  • KMManager.getEnterMode

User Testing

Setup - On an Android device, install the PR build of Keyman for Android. Preferably use a physical device instead of emulator because you'll also need additional Android apps installed:

  • Messaging app like Facebook Messenger
  • X (twitter)

Setup and enable Keyman as a default system keyboard

  • TEST_KEEP - Verifies how ENTER key is handled in Keep app
  1. Launch Keep
  2. With Keyman selected as the system keyboard, type in the Keep app
  3. Press the "ENTER" key
  4. Verify a newline is inserted in the text
  • TEST_MESSAGING - Verifies how ENTER key is handled in a multi-line text field (as requested in the original issue)
  1. Launch messaging app (like Facebook Messenger)
  2. Select a contact to message and start typing a message with Keyman as the system keyboard
  3. Press the "ENTER" key
  4. Verify a newline is inserted in the text
  5. Above the keyboard, the device should have an arrow key to send the message
  6. Press the arrow key
  7. Verify the message is sent
  • TEST_SEARCH - Verifies how ENTER key is handled in a search field (as @dyacob requested in the original issue)
  • Launch X (Twitter app)
  • Click the eyeglass icon to start a search
  • Start typing in the search field with Keyman as the system keyboard
  • Press the "ENTER" key
  • Verify the search is triggered

@darcywong00 darcywong00 requested a review from sgschantz as a code owner August 8, 2024 02:09
@keymanapp-test-bot keymanapp-test-bot bot added has-user-test user-test-required User tests have not been completed labels Aug 8, 2024
@keymanapp-test-bot
Copy link

keymanapp-test-bot bot commented Aug 8, 2024

@darcywong00 darcywong00 marked this pull request as draft August 9, 2024 06:53
@darcywong00 darcywong00 marked this pull request as ready for review August 12, 2024 23:42
@dinakaranr
Copy link

Test Results

I tested this issue with the attached "Keyman 18.0.86-alpha-test-12125" build on the Android 14 physical device. Here is my observation.

  1. Installed the "Keyman-18.0.88.apk" file and gave all permissions to the application.
  2. Checked the "Enable Keyman as system-wide keyboard" and set the keyboard as the default keyboard box on the settings page.
  3. Open the Keyman app. Enable the "Predictions" to install the "Dictionary."
  • TEST_KEEP (Passed):
  1. Launch the Google Keep app.
  2. Open the empty note by clicking the "+" button.
  3. Enter a sentence using the keyman keyboard.
  4. Press the "Enter" key.
  5. I observed that an empty line was inserted under the sentence.
  • TEST_MESSAGING (Failed):
  1. Launch the Facebook messenger app.
  2. Select a person from the contact list.
  3. Enter a sentence using the keyman keyboard.
  4. Press the "Enter" key.
  5. I observed that the empty line was inserted under the sentence.
  6. Click the arrow key.
    Observed that the message was sent to the user. but the blank line was removed in the sent message. (Which is inserted a line.)
    It is a problem. Please refer to the attached video.
    https://github.com/user-attachments/assets/131ee1b7-d6a1-48a9-a955-941a0973f6a2
  • TEST_SEARCH (Passed):
  1. Launch the Twitter app.
  2. Open the search box by clicking the eyeglass icon.
  3. Enter a word in the search field.
  4. Press the "Enter" key.
    Observed that the search result appears after pressing the "Enter" key. It works well. Thank you.

@keymanapp-test-bot keymanapp-test-bot bot added user-test-failed and removed user-test-required User tests have not been completed labels Aug 14, 2024
@darcywong00
Copy link
Contributor Author

@dinakaranr - I've made a code change to advance the cursor on newline.
However, on my default Gboard keyboard, entering multiple blank newlines in the messaging app ends up with the newlines also getting truncated when the text is sent.

@keymanapp-test-bot retest TEST_MESSAGING

@keymanapp-test-bot keymanapp-test-bot bot added user-test-required User tests have not been completed and removed user-test-failed labels Aug 15, 2024
@dinakaranr
Copy link

dinakaranr commented Aug 16, 2024

I tested this issue with the attached "Keyman 18.0.86-alpha-test-12125" build on the Android 14 physical device. Here is my observation.

Test Results

  • TEST_MESSAGING (Passed):
  1. Launch the Facebook messenger app.
  2. Select a person from the contact list.
  3. Enter a sentence using the keyman keyboard.
  4. Press the "Enter" key.
  5. I observed that the empty line was inserted under the sentence.
  6. The mouse cursor moved into a new blank line.
  7. Click the arrow key.
    Observed that the message was sent to the user. but the blank line was removed from the sent message. This works as expected behavior.
    Thank you Darcy for the clarification.

@keymanapp-test-bot keymanapp-test-bot bot removed the user-test-required User tests have not been completed label Aug 16, 2024
@darcywong00 darcywong00 modified the milestones: A18S8, A18S9 Aug 17, 2024
Copy link
Member

@mcdurdin mcdurdin left a comment

Choose a reason for hiding this comment

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

LGTM. We need a new issue to make the Enter mode visible on the Enter key on the touch keyboard.

Can Shift layer change the Enter mode on other keyboard apps?

Comment on lines +200 to +203
} else {
// In-app keyboard uses default ENTER action
keyDownUp(KeyEvent.KEYCODE_ENTER, 0);
}
Copy link
Member

Choose a reason for hiding this comment

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

This seems like it is an opportunity for a future feature?

@darcywong00 darcywong00 merged commit 79ebbfa into master Aug 19, 2024
5 checks passed
@darcywong00 darcywong00 deleted the feat/android/enter-mode branch August 19, 2024 07:31
@keyman-server
Copy link
Collaborator

Changes in this pull request will be available for download in Keyman version 18.0.92-alpha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(android): Allow enter key to send newline instead of submit in messenger apps
4 participants