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): Add controls for auto-correct #12443

Merged
merged 8 commits into from
Oct 9, 2024

Conversation

darcywong00
Copy link
Contributor

@darcywong00 darcywong00 commented Sep 19, 2024

Follows #12442 and addresses much of #12203 for adding "auto-correct" control on the language settings menu.

From the design meeting decisions, we replace the current "Prediction" and "Correction" toggles with a group of 4 radio-buttons. This has options:

suggestion radio options

TODO for follow-on PR: add KeymanWeb API to apply auto-correct control

User Testing

Setup - Install the PR build of Keyman for Android on a device/emulator

  • TEST_SUGGESTIONS_RADIO_BUTTONS
  1. Launch Keyman for Android.
  2. From the "Get Started" menu, set Keyman as the default system keyboard
  3. In the Keyman app, verify the default sil_euro_latin keyboard displays suggestions
  4. Launch Chrome and select a text area to type with Keyman as the default keyboard
  5. Verify the default sil_euro_latin keyboard displays suggestions
  6. Return to the Keyman app --> Keyman settings --> Installed languages --> English to bring up the "English Settings" menu
  7. Verify the default suggestion radio selection (at the bottom) is "Predictions with corrections"
  8. Select "Predictions only"
  9. Verify "Predictions only" is the only selected option
  10. Select "Disable suggestions"
  11. Verify "Disable suggestions" is the only selected option
  12. Exit the menu
  13. In the Keyman app, verify the suggestion banner is now disabled (replaced with Keyman banner)
  14. In Chrome select a text field to type in
  15. Verify the Keyman suggestion banner is disabled (replaced with Keyman banner)

@keymanapp-test-bot keymanapp-test-bot bot added the user-test-missing User tests have not yet been defined for the PR label Sep 19, 2024
@keymanapp-test-bot
Copy link

keymanapp-test-bot bot commented Sep 19, 2024

User Test Results

Test specification and instructions

@keymanapp-test-bot keymanapp-test-bot bot added this to the A18S11 milestone Sep 19, 2024
@keymanapp-test-bot keymanapp-test-bot bot added has-user-test user-test-required User tests have not been completed and removed user-test-missing User tests have not yet been defined for the PR labels Sep 19, 2024
@dinakaranr
Copy link

Test Results

I tested this issue with the attached "Keyman 18.0.115-alpha-test-12443" build on the Android 14 mobile. Here is my observation.

  • TEST_SUGGESTIONS_RADIO_BUTTONS (Passed): 
  1. Installed the "Keyman-18.0.115.apk" file from the PR build. and gave all permissions to the application.
  2. Checked the "Enable Keyman as system-wide keyboard" on the settings page. Checked the "Set Keyman as default keyboard.".
  3. Open the Keyman app. Enter some text in the keyman's notepad.
  4. Verified the default "sil_euro_latin" keyboard displays suggestions.
  5. Launch the Chrome browser. Navigate the "editpad.org" website and enter some text on the page.
  6. Verified the default "sil_euro_latin" keyboard displays suggestions.
  7. Return to the Keyman app --> Keyman settings --> Installed languages --> English to bring up the "English Settings" menu
  8. Verified the "Predictions with corrections" is set as the default suggestion radio selection.
  9. Select "Predictions only"
  10. Verified "Predictions only" is the only selected option
  11. Select "Disable suggestions"
  12. Verified "Disable suggestions" is the only selected option.
  13. Exit the menu and return to Keyman Notepad.
  14. Verified the suggestion banner is now disabled and it is showing the Keyman banner.
  15. Launch the Chrome browser. Navigate the "editpad.org" website and enter some text on the page.
  16. Verified the suggestion banner is now disabled and it is showing the Keyman banner.
  17. It works as per the given steps. Thanks.

I have seen another behavior on Keyman's Notepad and Chrome browser (editpad.org) when using the "Predictions with auto-corrections" option.

  1. Launch the Chrome browser. 
  2. Navigate to the "editpad.org" website.
  3. Enter the wrong words in the text area.
  4. Actual Results: Here, the word does not turn into the correct word if entering the wrong word. Instead of showing the correct word on the banner with highlights (I am expecting the word to auto-correction),
    Please refer to the screenshot below

@keymanapp-test-bot keymanapp-test-bot bot removed the user-test-required User tests have not been completed label Sep 19, 2024
Base automatically changed from fix/android/disable-banner-password to master September 25, 2024 02:40
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.

This functionally looks good. Can you:

  1. try and avoid using magic numbers and use the enum values everywhere possible
  2. remove the mayPredict option from the javascript interface as it is redundant

Thanks!

Comment on lines 110 to 125
// Initialize radio button group
switch(maySuggest) {
case 1:
radioButton = (RadioButton) radioGroup.findViewById(R.id.suggestion_radio_1);
break;
case 2:
radioButton = (RadioButton) radioGroup.findViewById(R.id.suggestion_radio_2);
break;
case 3:
radioButton = (RadioButton) radioGroup.findViewById(R.id.suggestion_radio_3);
break;
case 0:
default:
radioButton = (RadioButton) radioGroup.findViewById(R.id.suggestion_radio_0);
}
radioGroup.clearCheck();
Copy link
Member

Choose a reason for hiding this comment

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

This would be neater with an array but it's not critical.

KMManager.setBannerOptions(mayPredict);
int maySuggest = prefs.getInt(KMManager.getLanguageAutoCorrectionPreferenceKey(langId), KMManager.KMDefault_Suggestion);
// Enable banner if maySuggest is not SuggestionType.SUGGESTIONS_DISABLED (0)
KMManager.setBannerOptions(maySuggest > 0);
Copy link
Member

Choose a reason for hiding this comment

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

Can we avoid using a number 0 here and use SuggestionType.SUGGESTIONS_DISABLED?

android/KMEA/app/src/main/assets/android-host.js Outdated Show resolved Hide resolved
android/KMEA/app/src/main/assets/android-host.js Outdated Show resolved Hide resolved
* @param suggestType Radio button index 0 to 3
*/
public static void setMaySuggest(String languageID, int suggestType) {
if (suggestType < 0 || suggestType > 3) {
Copy link
Member

Choose a reason for hiding this comment

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

Can we use SuggestionType.SUGGESTIONS_DISABLED.toInt() or something like that? Everywhere we have integer values in the java code?

@darcywong00 darcywong00 modified the milestones: A18S11, A18S12 Sep 28, 2024
…t/android/auto-correct-radio-buttons

# Keyman Conventional Commit suggestions:
#
# - Link to a Sentry issue with git trailer:
#     Fixes: _MODULE_-_ID_
# - Give credit to co-authors:
#     Co-authored-by: _Name_ <_email_>
# - Use imperative, present tense ('attach' not 'attaches', 'attached' etc)
# - Don't include a period at the end of the title
# - Always include a blank line before trailers
# - More: https://github.com/keymanapp/keyman/wiki/Pull-Request-and-Commit-workflow-notes
KMManager.setBannerOptions(mayPredict);
int maySuggest = prefs.getInt(KMManager.getLanguageAutoCorrectionPreferenceKey(langId), KMManager.KMDefault_Suggestion);
// Enable banner if maySuggest is not SuggestionType.SUGGESTIONS_DISABLED (0)
KMManager.setBannerOptions(maySuggest > SuggestionType.SUGGESTIONS_DISABLED.toInt());
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
KMManager.setBannerOptions(maySuggest > SuggestionType.SUGGESTIONS_DISABLED.toInt());
KMManager.setBannerOptions(maySuggest <> SuggestionType.SUGGESTIONS_DISABLED.toInt());

Yeah same same but removes knowledge of actual values :)

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. will use !=

modelPredictionPref = prefs.getBoolean(KMManager.getLanguagePredictionPreferenceKey(KMManager.currentLexicalModel.get(KMManager.KMKey_LanguageID)), true);
modelPredictionPref = prefs.getInt(KMManager.getLanguageAutoCorrectionPreferenceKey(
KMManager.currentLexicalModel.get(KMManager.KMKey_LanguageID)), KMManager.KMDefault_Suggestion)
> SuggestionType.SUGGESTIONS_DISABLED.toInt();
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
> SuggestionType.SUGGESTIONS_DISABLED.toInt();
<> SuggestionType.SUGGESTIONS_DISABLED.toInt();

Comment on lines 220 to 221
int modes[] = { 0, 1, 2, 3 };
return modes[this.ordinal()];
Copy link
Member

Choose a reason for hiding this comment

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

Why not just return this.ordinal();?

@@ -315,6 +346,8 @@ public enum EnterModeType {
public static final int KMMinimum_LongpressDelay = 300;
public static final int KMMaximum_LongpressDelay = 1500;

// Default prediction/correction setting - corresponds to SuggestionType.PREDICTIONS_WITH_CORRECTIONS
public static final int KMDefault_Suggestion = 2;
Copy link
Member

Choose a reason for hiding this comment

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

Still got a magic number here

@darcywong00 darcywong00 merged commit 9fa0670 into master Oct 9, 2024
3 checks passed
@darcywong00 darcywong00 deleted the feat/android/auto-correct-radio-buttons branch October 9, 2024 10:25
@keyman-server
Copy link
Collaborator

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

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

Successfully merging this pull request may close these issues.

4 participants