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 for FV and KMSample2 #12745

Merged
merged 1 commit into from
Dec 3, 2024

Conversation

darcywong00
Copy link
Contributor

Follows #12125 and fixes #12743

The ENTER key was enhanced in the Keyman system keyboard depending on the type of input field.
This ports the functionality to the FirstVoices for Android and KMSample2 apps.

Copying user tests from the original PR:

User Testing

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

  • Google Keep
  • Messaging app like Facebook Messenger
  • X (twitter)

For the corresponding groups, setup a keyboard and enable as the default corresponding keyboard.
On FirstVoices, can do Region --> BC Coast --> SENCOTEN keyboard.

  • GROUP_FV: Use FirstVoices for Android as system keyboard

  • GROUP_SAMPLE2: Use KMSample2 as system keyboard

  • TEST_KEEP - Verifies how ENTER key is handled in Keep app

  1. Launch Keep
  2. With the GROUP_ keyboard 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 GROUP_ keyboard 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 the GROUP_ keyboard as the system keyboard
  • Press the "ENTER" key
  • Verify the search is triggered

@keymanapp-test-bot
Copy link

keymanapp-test-bot bot commented Nov 29, 2024

User Test Results

Test specification and instructions

  • ✅ GROUP_FV: Use FirstVoices for Android as system keyboard

    3 tests PASSED
  • ✅ GROUP_SAMPLE2: Use KMSample2 as system keyboard

    3 tests PASSED

Test Artifacts

@dinakaranr
Copy link

Test Results

I tested this issue with the attached firstvoices-18.0.148.apk file in the Android 14 environment. Here is my observation.

  1. Installed the below application on the Android 14 mobile and signed in with the valid credentials.
  2. Installed the "Google Keep"
  3. Installed the "Messaging app like Facebook Messenger."
  4. Installed the "X (Twitter)"

GROUP_FV: Use FirstVoices for Android as the system keyboard

Setup:

  1. Open the first voice keyboard.
  2. Installed the below keyboard in the "FirstVoice" keyboard.
  3. Region --> BC Coast --> SENCOTEN.
  4. Select the FirstVoices keyboard by clicking the "Enable FirstVoices"  checkbox.
  5. Set the first voice as the system keyboard by clicking the "Choose first voice as current input method"
  • TEST_KEEP (Passed): 
  1. Open the Keep application.
  2. Create a new note by clicking the "+" icon.
  3. The keyboard is set as a system keyboard. Region --> BC Coast --> SENCOTEN.
  4. Add some text and then press the "Enter" key on the keyboard.
  5. Verified a newline added below the text.
  6. Move the cursor between letters and then press the "Enter" key on the keyboard.
  7. Verified a newline added between letters. 
  • TEST_MESSAGING (Passed): 
  1. Open the Facebook Messenger application.
  2. Select a contact to message and start typing a message with the FirstVoice keyboard as the system keyboard.
  3. Press the "Enter" key.
  4. Verified a newline added in the text box.
  5. The message was sent to the user by pressing the "Arrow" key.
  6. Verified the message is sent.
  • TEST_SEARCH (Passed): 
  1. Open the X application.
  2. Click the search icon to start a search.
  3. Start typing in the search box with the FirstVoice keyboard as the system keyboard.
  4. Press the "Enter" key.
  5. Verified the search is triggered and results appeared.

GROUP_SAMPLE2: Use KMSample2 as system keyboard

I tested this issue with the attached app-debug.apk(KMSample2) file in the Android 14 environment. Here is my observation.
Setup:

  1. Open the "KMSample2" application.
  2. Enable the "KMSample2" keyboard by clicking the "Open Input method settings" button.
  3. Select the "KMSample2" keyboard as the system keyboard by clicking the "Open Input method menu" button.
  • TEST_KEEP (Passed):
  1. Open the Keep application.
  2. Create a new note by clicking the "+" icon.
  3. The keyboard is set as a system keyboard. (by clicking the "Open Input method menu" button.)
  4. Add some text and then press the "Enter" key on the keyboard.
  5. Verified a newline added below the text.
  6. Move the cursor between letters and then press the "Enter" key on the keyboard.
  7. Verified a newline added between letters.
  • TEST_MESSAGING (Passed):
  1. Open the Facebook Messenger application.
  2. Select a contact to message and start typing a message with the KMSample2 keyboard as the system keyboard.
  3. Press the "Enter" key.
  4. Verified a newline was added to the text box.
  5. The message was sent to the user by pressing the "Arrow" key.
  6. Verified the message is sent.
  • TEST_SEARCH (Passed):
  1. Open the X application.
  2. Click the search icon to start a search.
  3. Start typing in the search box with the KMSample2 keyboard as the system keyboard.
  4. Press the "Enter" key.
  5. Verified the search is triggered and results appeared.

Note: The error message appeared on the toast message box when opening the KMSample2 the first time after the installation.
Please refer to the screenshot

@keymanapp-test-bot keymanapp-test-bot bot removed the user-test-required User tests have not been completed label Nov 29, 2024
@sgschantz sgschantz self-assigned this Dec 3, 2024
@darcywong00
Copy link
Contributor Author

Additional info for reviewers:

The bulk of functionality was done in the original PR in Keyman Engine for Android (main control unit is KMManager)

KMManager would alter how the ENTER key was handled depending on what type of input field the cursor was at.

The SystemKeyboard.java for the apps using Keyman Engine would call KMManager.setEnterMode() to initialize this handling. I only updated SystemKeyboard for the Keyman for Android in the original PR.

Hence this one makes the corresponding changes to FirstVoices for Android and the KMSample2 app (the sample system keyboard app we include with the Keyman Engine for Android libraries)

Copy link
Contributor

@sgschantz sgschantz 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 -- just one suggestion to improve the code.


// Determine special handling for ENTER key
KMManager.setEnterMode(attribute.imeOptions, inputType);

// User switched to a new input field so we should extract the text from input field
Copy link
Contributor

Choose a reason for hiding this comment

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

Though you are only adding a couple lines to the code here, it would be nice to break up the functionality of onStartInput into several methods. It is about 50 lines long and is checking several conditions with discrete tasks. Rather than having blocks of code with nice comments, it would be better to extract these into small well-named methods. Even if the methods are not used anywhere else, it will be more readable and unit-testable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep - that's a good suggestion (maybe can do some in early 19.0).

A lot of the Android code could use refactoring (SystemKeyboard and the main culprit KMManager).

@darcywong00 darcywong00 merged commit 7794d2d into master Dec 3, 2024
6 checks passed
@darcywong00 darcywong00 deleted the feat/fv/enter-key branch December 3, 2024 06:34
@keyman-server
Copy link
Collaborator

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

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

Successfully merging this pull request may close these issues.

feat(android): Enhance system ENTER key for FirstVoices app
4 participants