Skip to content

Commit

Permalink
#201 add UILexicon access for contacts in autosuggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtavis committed Oct 28, 2022
1 parent 39d8f25 commit 06eaf3b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Emojis for the following are chosen based on [gitmoji](https://gitmoji.dev/).
- Autosuggestions for pronouns have been improved for some languages.
- The keyboards shift state is disabled by pressing an autocompletion or autosuggestion.
- Autocomplete now functions after quotes, slashes and hashtags.
- Scribe can now access unordered names in the user's contacts to present them as autocompletions.

### 🎨 Design Changes

Expand Down
14 changes: 11 additions & 3 deletions Keyboards/KeyboardsBase/KeyboardViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1089,14 +1089,13 @@ class KeyboardViewController: UIInputViewController {
commandBar.textColor = keyCharColor
commandBar.conditionallyAddPlaceholder() // in case of color mode change during commands
keyboardView.backgroundColor? = keyboardBgColor
allNonSpecialKeys = allKeys.filter { !specialKeys.contains($0) }

// Set height for Scribe command functionality and annotation elements.
scribeKeyHeight = scribeKey.frame.size.height

linkShadowBlendElements()
setAutoActionPartitions()

allNonSpecialKeys = allKeys.filter { !specialKeys.contains($0) }

// Show the name of the keyboard to the user.
showKeyboardLanguage = true
Expand All @@ -1107,6 +1106,14 @@ class KeyboardViewController: UIInputViewController {
"form": ""
]

// Access UILexicon words.
var lexiconWords: [String] = [String]()
self.requestSupplementaryLexicon { (userLexicon: UILexicon!) -> Void in
for item in userLexicon.entries {
lexiconWords.append(item.documentText)
}
}

var uniqueAutosuggestKeys: [String] = [String]()
for elem in autosuggestions.dictionaryValue.keys {
if elem.count > 2 && !nouns[elem].exists() {
Expand All @@ -1122,7 +1129,8 @@ class KeyboardViewController: UIInputViewController {
}
}
}
autocompleteWords = Array(nouns.dictionaryValue.keys) + uniqueAutosuggestKeys

autocompleteWords = Array(nouns.dictionaryValue.keys) + uniqueAutosuggestKeys + lexiconWords
autocompleteWords = autocompleteWords.filter(
{ $0.rangeOfCharacter(from: CharacterSet(charactersIn: "1234567890-")) == nil }
).sorted{$0.caseInsensitiveCompare($1) == .orderedAscending}
Expand Down

0 comments on commit 06eaf3b

Please sign in to comment.