mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-17 15:32:48 +00:00
properly remove capitalized suggestions, fixes #170
This commit is contained in:
parent
32fe3a1d90
commit
82d0d46ca3
2 changed files with 29 additions and 20 deletions
|
@ -977,19 +977,31 @@ public class DictionaryFacilitatorImpl implements DictionaryFacilitator {
|
|||
}
|
||||
|
||||
final ExpandableBinaryDictionary contactsDict = group.getSubDict(Dictionary.TYPE_CONTACTS);
|
||||
final boolean isInContacts;
|
||||
if (contactsDict != null) {
|
||||
isInContacts = contactsDict.isInDictionary(word);
|
||||
if (isInContacts)
|
||||
if (contactsDict.isInDictionary(word)) {
|
||||
contactsDict.removeUnigramEntryDynamically(word); // will be gone until next reload of dict
|
||||
} else isInContacts = false;
|
||||
addToBlacklist(word, group);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!group.hasDict(Dictionary.TYPE_MAIN, null))
|
||||
return;
|
||||
if (group.getDict(Dictionary.TYPE_MAIN).isValidWord(word)) {
|
||||
addToBlacklist(word, group);
|
||||
return;
|
||||
}
|
||||
final String lowercase = word.toLowerCase(group.mLocale);
|
||||
if (group.getDict(Dictionary.TYPE_MAIN).isValidWord(lowercase)) {
|
||||
addToBlacklist(lowercase, group);
|
||||
}
|
||||
}
|
||||
|
||||
// add to blacklist if in main or contacts dictionaries
|
||||
if ((isInContacts || (group.hasDict(Dictionary.TYPE_MAIN, null) && group.getDict(Dictionary.TYPE_MAIN).isValidWord(word)))
|
||||
&& group.blacklist.add(word)) {
|
||||
// write to file if word wasn't already in blacklist
|
||||
private void addToBlacklist(final String word, final DictionaryGroup group) {
|
||||
if (!group.blacklist.add(word))
|
||||
return;
|
||||
ExecutorUtils.getBackgroundExecutor(ExecutorUtils.KEYBOARD).execute(() -> {
|
||||
try {
|
||||
Log.i("test1", "adding to blacklist file" + group.blacklistFileName);
|
||||
FileOutputStream fos = new FileOutputStream(group.blacklistFileName, true);
|
||||
fos.write((word + "\n").getBytes(StandardCharsets.UTF_8));
|
||||
fos.close();
|
||||
|
@ -998,7 +1010,6 @@ public class DictionaryFacilitatorImpl implements DictionaryFacilitator {
|
|||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private ArrayList<String> readBlacklistFile(final String filename) {
|
||||
final ArrayList<String> blacklist = new ArrayList<>();
|
||||
|
|
|
@ -839,7 +839,6 @@ public final class InputLogic {
|
|||
)
|
||||
)
|
||||
) {
|
||||
Log.i("test1", "separator");
|
||||
handleSeparatorEvent(event, inputTransaction, handler);
|
||||
} else {
|
||||
if (SpaceState.PHANTOM == inputTransaction.getMSpaceState()) {
|
||||
|
@ -854,7 +853,6 @@ public final class InputLogic {
|
|||
commitTyped(sv, LastComposedWord.NOT_A_SEPARATOR);
|
||||
}
|
||||
}
|
||||
Log.i("test1", "nonseparator");
|
||||
handleNonSeparatorEvent(event, sv, inputTransaction);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue