fixed custom emoji frequencies not being updated; no more error messages when typing factory emojis
This commit is contained in:
parent
8852239a77
commit
8163f8ab20
2 changed files with 18 additions and 5 deletions
|
|
@ -18,6 +18,7 @@ import io.github.sspanak.tt9.preferences.settings.SettingsStore;
|
||||||
import io.github.sspanak.tt9.util.Characters;
|
import io.github.sspanak.tt9.util.Characters;
|
||||||
import io.github.sspanak.tt9.util.Logger;
|
import io.github.sspanak.tt9.util.Logger;
|
||||||
import io.github.sspanak.tt9.util.Text;
|
import io.github.sspanak.tt9.util.Text;
|
||||||
|
import io.github.sspanak.tt9.util.TextTools;
|
||||||
|
|
||||||
public class ModePredictive extends InputMode {
|
public class ModePredictive extends InputMode {
|
||||||
private final String LOG_TAG = getClass().getSimpleName();
|
private final String LOG_TAG = getClass().getSimpleName();
|
||||||
|
|
@ -329,14 +330,19 @@ public class ModePredictive extends InputMode {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Characters.isStaticEmoji(currentWord)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// increment the frequency of the given word
|
// increment the frequency of the given word
|
||||||
try {
|
try {
|
||||||
String sequence = language.getDigitSequenceForWord(currentWord);
|
Language workingLanguage = TextTools.isGraphic(currentWord) ? new EmojiLanguage() : language;
|
||||||
|
String sequence = workingLanguage.getDigitSequenceForWord(currentWord);
|
||||||
|
|
||||||
// emoji and punctuation are not in the database, so there is no point in
|
// punctuation and special chars are not in the database, so there is no point in
|
||||||
// running queries that would update nothing
|
// running queries that would update nothing
|
||||||
if (!sequence.startsWith(NaturalLanguage.PUNCTUATION_KEY) && !sequence.startsWith(NaturalLanguage.SPECIAL_CHARS_KEY)) {
|
if (!sequence.equals(NaturalLanguage.PUNCTUATION_KEY) && !sequence.startsWith(NaturalLanguage.SPECIAL_CHARS_KEY)) {
|
||||||
WordStoreAsync.makeTopWord(language, currentWord, sequence);
|
WordStoreAsync.makeTopWord(workingLanguage, currentWord, sequence);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.e(LOG_TAG, "Failed incrementing priority of word: '" + currentWord + "'. " + e.getMessage());
|
Logger.e(LOG_TAG, "Failed incrementing priority of word: '" + currentWord + "'. " + e.getMessage());
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,14 @@ public class Characters {
|
||||||
))
|
))
|
||||||
));
|
));
|
||||||
|
|
||||||
|
public static boolean isStaticEmoji(String emoji) {
|
||||||
|
for (ArrayList<String> group : Emoji) {
|
||||||
|
if (group.contains(emoji)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isGraphic(char ch) {
|
public static boolean isGraphic(char ch) {
|
||||||
return !(ch < 256 || Character.isLetterOrDigit(ch) || Character.isAlphabetic(ch));
|
return !(ch < 256 || Character.isLetterOrDigit(ch) || Character.isAlphabetic(ch));
|
||||||
|
|
@ -100,7 +108,6 @@ public class Characters {
|
||||||
return Build.VERSION.SDK_INT < Build.VERSION_CODES.M;
|
return Build.VERSION.SDK_INT < Build.VERSION_CODES.M;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static ArrayList<String> getEmoji(int level) {
|
public static ArrayList<String> getEmoji(int level) {
|
||||||
if (noEmojiSupported()) {
|
if (noEmojiSupported()) {
|
||||||
return new ArrayList<>(TextEmoticons);
|
return new ArrayList<>(TextEmoticons);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue