-
-
Notifications
You must be signed in to change notification settings - Fork 112
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
Conversation
User Test Results |
There was a problem hiding this 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:
- try and avoid using magic numbers and use the enum values everywhere possible
- remove the mayPredict option from the javascript interface as it is redundant
Thanks!
// 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(); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
?
* @param suggestType Radio button index 0 to 3 | ||
*/ | ||
public static void setMaySuggest(String languageID, int suggestType) { | ||
if (suggestType < 0 || suggestType > 3) { |
There was a problem hiding this comment.
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?
Co-authored-by: Marc Durdin <marc@durdin.net>
…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()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
KMManager.setBannerOptions(maySuggest > SuggestionType.SUGGESTIONS_DISABLED.toInt()); | |
KMManager.setBannerOptions(maySuggest <> SuggestionType.SUGGESTIONS_DISABLED.toInt()); |
Yeah same same but removes knowledge of actual values :)
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
> SuggestionType.SUGGESTIONS_DISABLED.toInt(); | |
<> SuggestionType.SUGGESTIONS_DISABLED.toInt(); |
int modes[] = { 0, 1, 2, 3 }; | ||
return modes[this.ordinal()]; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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
Changes in this pull request will be available for download in Keyman version 18.0.124-alpha |
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:
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