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,27 +977,38 @@ public class DictionaryFacilitatorImpl implements DictionaryFacilitator {
|
||||||
}
|
}
|
||||||
|
|
||||||
final ExpandableBinaryDictionary contactsDict = group.getSubDict(Dictionary.TYPE_CONTACTS);
|
final ExpandableBinaryDictionary contactsDict = group.getSubDict(Dictionary.TYPE_CONTACTS);
|
||||||
final boolean isInContacts;
|
|
||||||
if (contactsDict != null) {
|
if (contactsDict != null) {
|
||||||
isInContacts = contactsDict.isInDictionary(word);
|
if (contactsDict.isInDictionary(word)) {
|
||||||
if (isInContacts)
|
|
||||||
contactsDict.removeUnigramEntryDynamically(word); // will be gone until next reload of dict
|
contactsDict.removeUnigramEntryDynamically(word); // will be gone until next reload of dict
|
||||||
} else isInContacts = false;
|
addToBlacklist(word, group);
|
||||||
|
return;
|
||||||
// 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
|
|
||||||
ExecutorUtils.getBackgroundExecutor(ExecutorUtils.KEYBOARD).execute(() -> {
|
|
||||||
try {
|
|
||||||
FileOutputStream fos = new FileOutputStream(group.blacklistFileName, true);
|
|
||||||
fos.write((word + "\n").getBytes(StandardCharsets.UTF_8));
|
|
||||||
fos.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.e(TAG, "Exception while trying to write blacklist", e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
} catch (IOException e) {
|
||||||
|
Log.e(TAG, "Exception while trying to write blacklist", e);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private ArrayList<String> readBlacklistFile(final String filename) {
|
private ArrayList<String> readBlacklistFile(final String filename) {
|
||||||
|
|
|
@ -839,7 +839,6 @@ public final class InputLogic {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
Log.i("test1", "separator");
|
|
||||||
handleSeparatorEvent(event, inputTransaction, handler);
|
handleSeparatorEvent(event, inputTransaction, handler);
|
||||||
} else {
|
} else {
|
||||||
if (SpaceState.PHANTOM == inputTransaction.getMSpaceState()) {
|
if (SpaceState.PHANTOM == inputTransaction.getMSpaceState()) {
|
||||||
|
@ -854,7 +853,6 @@ public final class InputLogic {
|
||||||
commitTyped(sv, LastComposedWord.NOT_A_SEPARATOR);
|
commitTyped(sv, LastComposedWord.NOT_A_SEPARATOR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Log.i("test1", "nonseparator");
|
|
||||||
handleNonSeparatorEvent(event, sv, inputTransaction);
|
handleNonSeparatorEvent(event, sv, inputTransaction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue