Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Marc Durdin <marc@durdin.net>
  • Loading branch information
darcywong00 and mcdurdin authored Sep 27, 2024
1 parent 9096105 commit a6f9082
Showing 1 changed file with 13 additions and 32 deletions.
45 changes: 13 additions & 32 deletions android/KMEA/app/src/main/assets/android-host.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,42 +229,23 @@ function deregisterModel(modelID) {
keyman.removeModel(modelID);
}

function enableSuggestions(model, mayPredict, maySuggest) {
function enableSuggestions(model, suggestionType) {
// Set the options first so that KMW's ModelManager can properly handle model enablement states
// the moment we actually register the new model.
// Use console_debug
console_debug('enableSuggestions(mayPredict='+mayPredict+', maySuggest='+maySuggest+')');
if (!mayPredict) {
keyman.core.languageProcessor.mayPredict = false;
keyman.core.languageProcessor.mayCorrect = false;
// keyman.core.languageProcessor.mayAutoCorrect = false;
} else {
switch(maySuggest) {
case 1 :
// SuggestionType.PREDICTIONS_ONLY
keyman.core.languageProcessor.mayPredict = true;
keyman.core.languageProcessor.mayCorrect = false;
//keyman.core.languageProcessor.mayAutoCorrect = false;
break;
case 2 :
// SuggestionType.PREDICTIONS_WITH_CORRECTIONS
keyman.core.languageProcessor.mayPredict = true;
keyman.core.languageProcessor.mayCorrect = true;
//keyman.core.languageProcessor.mayAutoCorrect = false;
break;
case 3 :
// SuggesionType.PREDICTIONS_WITH_AUTO_CORRECT
keyman.core.languageProcessor.mayPredict = true;
keyman.core.languageProcessor.mayCorrect = true;
//keyman.core.languageProcessor.mayAutoCorrect = true;
break;
case 0 :
default :
// SuggestionType.SUGGESTIONS_DISABLED
keyman.core.languageProcessor.mayPredict = false;
keyman.core.languageProcessor.mayCorrect = false;
//keyman.core.languageProcessor.mayAutoCorrect = false;
break;
const suggestionSettings = [
// mayPredict, mayCorrect, mayAutoCorrect
[false, false, false], // 0 = SuggestionType.SUGGESTIONS_DISABLED
[true, false, false], // 1 = SuggestionType.PREDICTIONS_ONLY
[true, true, false], // 2 = SuggestionType.PREDICTIONS_WITH_CORRECTIONS
[true, true, true], // 3 = SuggestionType.PREDICTIONS_WITH_AUTO_CORRECT
];
const t = suggestionSettings[suggestionType]
? suggestionSettings[suggestionType] : suggestionSettings[0];
keyman.core.languageProcessor.mayPredict = t[0];
keyman.core.languageProcessor.maySuggest = t[1];
// keyman.core.languageProcessor.mayAutoCorrect = t[2];
}
}

Expand Down

0 comments on commit a6f9082

Please sign in to comment.