Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8f47ec64 authored by Nishith  Khanna's avatar Nishith Khanna
Browse files

Merge remote-tracking branch 'origin/lineage-19.1' into v1-s

parents e795cf1f c4c9fd8f
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -237,16 +237,23 @@ public abstract class AndroidWordLevelSpellCheckerSession extends Session {
            // Handle special patterns like email, URI, telephone number.
            final int checkability = getCheckabilityInScript(text, mScript);
            if (CHECKABILITY_CHECKABLE != checkability) {
                // CHECKABILITY_CONTAINS_PERIOD typo should not be reported when text
                // is a valid word followed by a single period (end of sentence).
                boolean periodOnlyAtLastIndex = text.indexOf(
                        Constants.CODE_PERIOD) == (text.length() - 1);
                if (CHECKABILITY_CONTAINS_PERIOD == checkability) {
                    final String[] splitText = text.split(Constants.REGEXP_PERIOD);
                    boolean allWordsAreValid = true;
                    // Validate all words on both sides of periods,
                    // skip empty tokens due to periods at first/last index
                    for (final String word : splitText) {
                        if (!mService.isValidWord(mLocale, word)) {
                        if (!word.isEmpty() && !mService.isValidWord(mLocale, word) &&
                                !mService.isValidWord(mLocale, word.toLowerCase(mLocale))) {
                            allWordsAreValid = false;
                            break;
                        }
                    }
                    if (allWordsAreValid) {
                    if (allWordsAreValid && !periodOnlyAtLastIndex) {
                        return new SuggestionsInfo(SuggestionsInfo.RESULT_ATTR_LOOKS_LIKE_TYPO
                                | SuggestionsInfo.RESULT_ATTR_HAS_RECOMMENDED_SUGGESTIONS,
                                new String[] {
@@ -256,7 +263,7 @@ public abstract class AndroidWordLevelSpellCheckerSession extends Session {
                return mService.isValidWord(mLocale, text) ?
                        AndroidSpellCheckerService.getInDictEmptySuggestions() :
                        AndroidSpellCheckerService.getNotInDictEmptySuggestions(
                                CHECKABILITY_CONTAINS_PERIOD == checkability /* reportAsTypo */);
                                !periodOnlyAtLastIndex);
            }

            // Handle normal words.