Skip to content

Commit 10f6844

Browse files
committed
added an option to prevent learning word frequecies (#1159)
1 parent 5f6d099 commit 10f6844

19 files changed

Lines changed: 47 additions & 7 deletions

File tree

app/src/main/java/io/github/sspanak/tt9/db/DataStore.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ public static void deleteCustomWord(Runnable notification, Language language, St
9696
}
9797

9898

99-
public static void put(Consumer<AddWordResult> statusHandler, Language language, String word) {
100-
runInThread(() -> statusHandler.accept(words.put(language, word)));
99+
public static void put(Consumer<AddWordResult> statusHandler, Language language, String word, boolean makeTopWord) {
100+
runInThread(() -> statusHandler.accept(words.put(language, word, makeTopWord)));
101101
}
102102

103103

app/src/main/java/io/github/sspanak/tt9/db/words/WordStore.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public void removeCustomWord(Language language, String word) {
152152
}
153153

154154

155-
@NonNull public AddWordResult put(Language language, String word) {
155+
@NonNull public AddWordResult put(Language language, String word, boolean makeTopWord) {
156156
if (word == null || word.isEmpty()) {
157157
return new AddWordResult(AddWordResult.CODE_BLANK_WORD, word);
158158
}
@@ -173,7 +173,9 @@ public void removeCustomWord(Language language, String word) {
173173
}
174174

175175
if (InsertOps.insertCustomWord(sqlite.getDb(), language, sequence, word)) {
176-
makeTopWord(language, word, sequence);
176+
if (makeTopWord) {
177+
makeTopWord(language, word, sequence);
178+
}
177179
} else {
178180
throw new Exception("SQLite INSERT failure.");
179181
}

app/src/main/java/io/github/sspanak/tt9/ime/modes/predictions/WordPredictions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ public void onAccept(String word, String sequence) {
282282
* because it is in a popular word pair.
283283
*/
284284
protected void makeTopWord(String word, String sequence) {
285-
if (!word.equals(lastEnforcedTopWord)) {
285+
if (settings.getPredictTopWords() && !word.equals(lastEnforcedTopWord)) {
286286
DataStore.makeTopWord(language, word, sequence);
287287
}
288288
}

app/src/main/java/io/github/sspanak/tt9/preferences/settings/SettingsTyping.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,12 @@ public boolean getPredictiveMode() {
9191
return prefs.getBoolean("pref_predictive_mode", true);
9292
}
9393

94+
public boolean getPredictTopWords() {
95+
return prefs.getBoolean("pref_predict_top_words", true);
96+
}
97+
9498
public boolean getPredictWordPairs() {
95-
return prefs.getBoolean("pref_predict_word_pairs", true);
99+
return getPredictTopWords() && prefs.getBoolean("pref_predict_word_pairs", true);
96100
}
97101

98102
public boolean getShowSuggestions() {

app/src/main/java/io/github/sspanak/tt9/ui/dialogs/AddWordDialog.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ private void onOK() {
3333
DataStore.put(
3434
(result) -> UI.toastLongFromAsync(context, result.toHumanFriendlyString(context)),
3535
language,
36-
word
36+
word,
37+
settings.getPredictTopWords()
3738
);
3839
}
3940

app/src/main/res/values-bg/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
<string name="pref_numpad_shape_long_space">Дълъг интервал</string>
3838
<string name="pref_numpad_width">Ширина</string>
3939
<string name="pref_one_key_emoji_simple">Кратък списък</string>
40+
<string name="pref_predict_top_words_summary">Запомня често използваните думи, за да подобри точността на предложенията.</string>
4041
<string name="pref_predict_word_pairs">Запомняне на двойки думи</string>
4142
<string name="pref_predict_word_pairs_summary">Запомняй често ползвани фрази, за по-точно подсказване на думи.</string>
4243
<string name="pref_predictive_auto_accept">Автоматичен избор на думи</string>
@@ -315,4 +316,5 @@
315316
<string name="pref_pref_auto_mind_reading_in_all_fields">Активиране във всички текстови полета</string>
316317
<string name="pref_category_unfolded_appearance">Изглед при разгънато устройство</string>
317318
<string name="pref_category_unfolded_appearance_summary">Настройки на изгледа при разгънато устройство.</string>
319+
<string name="pref_predict_top_words">Запомняне на често използвани думи</string>
318320
</resources>

app/src/main/res/values-de/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
<string name="pref_numpad_shape_long_space">Lange Leertaste</string>
5959
<string name="pref_numpad_width">Breite</string>
6060
<string name="pref_one_key_emoji_simple">Kurze Liste</string>
61+
<string name="pref_predict_top_words_summary">Speichert häufig verwendete Wörter, um die Genauigkeit der Vorschläge zu verbessern.</string>
6162
<string name="pref_predict_word_pairs">Wortpaare lernen</string>
6263
<string name="pref_predict_word_pairs_summary">Häufig verwendete Phrasen merken, um die Genauigkeit der Vorschläge zu verbessern.</string>
6364
<string name="pref_predictive_auto_accept">Automatische Wortauswahl</string>
@@ -317,4 +318,5 @@
317318
<string name="pref_pref_auto_mind_reading_in_all_fields">In allen Textfeldern aktivieren</string>
318319
<string name="pref_category_unfolded_appearance">Darstellung im aufgeklappten Zustand</string>
319320
<string name="pref_category_unfolded_appearance_summary">Darstellung bei aufgeklapptem Gerät konfigurieren.</string>
321+
<string name="pref_predict_top_words">Häufig verwendete Wörter lernen</string>
320322
</resources>

app/src/main/res/values-es/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
<string name="pref_numpad_shape_long_space">Barra espaciadora larga</string>
7272
<string name="pref_numpad_width">Anchura</string>
7373
<string name="pref_one_key_emoji_simple">Lista breve</string>
74+
<string name="pref_predict_top_words_summary">Recuerda las palabras más usadas para mejorar la precisión de las sugerencias.</string>
7475
<string name="pref_predict_word_pairs">Aprender pares de palabras</string>
7576
<string name="pref_predict_word_pairs_summary">Recordar frases de uso común para mejorar las sugerencias de palabras.</string>
7677
<string name="pref_predictive_auto_accept">Selección automática de palabras</string>
@@ -315,4 +316,5 @@
315316
<string name="pref_pref_auto_mind_reading_in_all_fields">Activar en todos los campos de texto</string>
316317
<string name="pref_category_unfolded_appearance">Apariencia en modo desplegado</string>
317318
<string name="pref_category_unfolded_appearance_summary">Configura la apariencia cuando el dispositivo está desplegado.</string>
319+
<string name="pref_predict_top_words">Aprender palabras frecuentes</string>
318320
</resources>

app/src/main/res/values-fr/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
<string name="pref_numpad_shape_long_space">Grande barre d\'espace</string>
4141
<string name="pref_numpad_width">Largeur</string>
4242
<string name="pref_one_key_emoji_simple">Liste courte</string>
43+
<string name="pref_predict_top_words_summary">Mémorise les mots les plus utilisés pour améliorer la précision des suggestions.</string>
4344
<string name="pref_predict_word_pairs">Mémoriser les paires de mots</string>
4445
<string name="pref_predict_word_pairs_summary">Apprendre des phrases couramment utilisées pour améliorer les suggestions.</string>
4546
<string name="pref_predictive_auto_accept">Sélection automatique des mots</string>
@@ -315,4 +316,5 @@
315316
<string name="pref_pref_auto_mind_reading_in_all_fields">Activer dans tous les champs de texte</string>
316317
<string name="pref_category_unfolded_appearance">Apparence en mode déplié</string>
317318
<string name="pref_category_unfolded_appearance_summary">Configure l\'apparence lorsque l\'appareil est déplié.</string>
319+
<string name="pref_predict_top_words">Mémoriser les mots fréquents</string>
318320
</resources>

app/src/main/res/values-it/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
<string name="pref_numpad_shape_long_space">Barra spaziatrice lunga</string>
6262
<string name="pref_numpad_width">Larghezza</string>
6363
<string name="pref_one_key_emoji_simple">Elenco breve</string>
64+
<string name="pref_predict_top_words_summary">Memorizza le parole usate più spesso per migliorare la precisione dei suggerimenti.</string>
6465
<string name="pref_predict_word_pairs">Memorizzare coppie di parole</string>
6566
<string name="pref_predict_word_pairs_summary">Ricordare frasi comunemente usate per migliorare i suggerimenti di parole.</string>
6667
<string name="pref_predictive_auto_accept">Selezione automatica delle parole</string>
@@ -318,5 +319,6 @@
318319
<string name="pref_pref_auto_mind_reading_in_all_fields">Abilita in tutti i campi di testo</string>
319320
<string name="pref_category_unfolded_appearance">Aspetto in modalità aperta</string>
320321
<string name="pref_category_unfolded_appearance_summary">Configura l\'aspetto quando il dispositivo è aperto.</string>
322+
<string name="pref_predict_top_words">Memorizza le parole più usate</string>
321323
</resources>
322324

0 commit comments

Comments
 (0)