1
0
Fork 0

fixed the auto-update confirmation popup not working

This commit is contained in:
sspanak 2024-04-08 21:59:30 +03:00 committed by Dimo Karaivanov
parent ef322ee0f8
commit d5cc6eff65
3 changed files with 16 additions and 13 deletions

View file

@ -109,15 +109,15 @@ public class DictionaryLoader {
} }
public static void autoLoad(InputMethodService context, Language language) { public static boolean autoLoad(InputMethodService context, Language language) {
if (getInstance(context).isRunning()) { if (getInstance(context).isRunning()) {
return; return false;
} }
Long lastUpdateTime = self.lastAutoLoadAttemptTime.get(language.getId()); Long lastUpdateTime = self.lastAutoLoadAttemptTime.get(language.getId());
boolean isItTooSoon = lastUpdateTime != null && System.currentTimeMillis() - lastUpdateTime < SettingsStore.DICTIONARY_AUTO_LOAD_COOLDOWN_TIME; boolean isItTooSoon = lastUpdateTime != null && System.currentTimeMillis() - lastUpdateTime < SettingsStore.DICTIONARY_AUTO_LOAD_COOLDOWN_TIME;
if (isItTooSoon) { if (isItTooSoon) {
return; return false;
} }
WordStoreAsync.getLastLanguageUpdateTime( WordStoreAsync.getLastLanguageUpdateTime(
@ -135,6 +135,8 @@ public class DictionaryLoader {
}, },
language language
); );
return true;
} }

View file

@ -15,6 +15,7 @@ import io.github.sspanak.tt9.R;
import io.github.sspanak.tt9.db.DictionaryLoader; import io.github.sspanak.tt9.db.DictionaryLoader;
import io.github.sspanak.tt9.db.WordStoreAsync; import io.github.sspanak.tt9.db.WordStoreAsync;
import io.github.sspanak.tt9.ime.modes.InputMode; import io.github.sspanak.tt9.ime.modes.InputMode;
import io.github.sspanak.tt9.ime.modes.ModePredictive;
import io.github.sspanak.tt9.preferences.settings.SettingsStore; import io.github.sspanak.tt9.preferences.settings.SettingsStore;
import io.github.sspanak.tt9.ui.UI; import io.github.sspanak.tt9.ui.UI;
import io.github.sspanak.tt9.ui.dialogs.PopupDialog; import io.github.sspanak.tt9.ui.dialogs.PopupDialog;
@ -108,15 +109,6 @@ public class TraditionalT9 extends HotkeyHandler {
} }
@Override
protected void onFinishTyping() {
if (!mInputMode.isPassthrough()) {
DictionaryLoader.autoLoad(this, mLanguage);
}
super.onFinishTyping();
}
@Override @Override
protected void onStop() { protected void onStop() {
onFinishTyping(); onFinishTyping();
@ -136,6 +128,15 @@ public class TraditionalT9 extends HotkeyHandler {
} }
@Override
protected boolean onNumber(int key, boolean hold, int repeat) {
if (mInputMode instanceof ModePredictive && DictionaryLoader.autoLoad(this, mLanguage)) {
return true;
}
return super.onNumber(key, hold, repeat);
}
/** /**
* createMainView * createMainView
* Generates the actual UI of TT9. * Generates the actual UI of TT9.

View file

@ -8,7 +8,7 @@ public class SettingsStore extends SettingsUI {
/************* internal settings *************/ /************* internal settings *************/
public final static int DELETE_WORDS_SEARCH_DELAY = 500; // ms public final static int DELETE_WORDS_SEARCH_DELAY = 500; // ms
public final static int DICTIONARY_AUTO_LOAD_COOLDOWN_TIME = 120000; // ms public final static int DICTIONARY_AUTO_LOAD_COOLDOWN_TIME = 1200000; // 20 minutes in ms
public final static int DICTIONARY_IMPORT_BATCH_SIZE = 5000; // words public final static int DICTIONARY_IMPORT_BATCH_SIZE = 5000; // words
public final static int DICTIONARY_IMPORT_PROGRESS_UPDATE_TIME = 250; // ms public final static int DICTIONARY_IMPORT_PROGRESS_UPDATE_TIME = 250; // ms
public final static byte SLOW_QUERY_TIME = 50; // ms public final static byte SLOW_QUERY_TIME = 50; // ms