mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-06-09 08:07:42 +00:00
some additional safety, so we show at least a working keyboard in case dictionary or native library loading fails
This commit is contained in:
parent
07ea14ea16
commit
f81f6a7f7d
3 changed files with 30 additions and 19 deletions
|
@ -70,7 +70,12 @@ public class ProximityInfo {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
computeNearestNeighbors();
|
computeNearestNeighbors();
|
||||||
|
try {
|
||||||
mNativeProximityInfo = createNativeProximityInfo(touchPositionCorrection);
|
mNativeProximityInfo = createNativeProximityInfo(touchPositionCorrection);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
Log.e(TAG, "could not create proximity info", e);
|
||||||
|
mNativeProximityInfo = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private long mNativeProximityInfo;
|
private long mNativeProximityInfo;
|
||||||
|
|
|
@ -31,10 +31,7 @@ import helium314.keyboard.latin.utils.locale
|
||||||
import helium314.keyboard.latin.utils.prefs
|
import helium314.keyboard.latin.utils.prefs
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.async
|
|
||||||
import kotlinx.coroutines.awaitAll
|
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.runBlocking
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
@ -231,6 +228,7 @@ class DictionaryFacilitatorImpl : DictionaryFacilitator {
|
||||||
val latchForWaitingLoadingMainDictionary = CountDownLatch(1)
|
val latchForWaitingLoadingMainDictionary = CountDownLatch(1)
|
||||||
mLatchForWaitingLoadingMainDictionaries = latchForWaitingLoadingMainDictionary
|
mLatchForWaitingLoadingMainDictionaries = latchForWaitingLoadingMainDictionary
|
||||||
scope.launch {
|
scope.launch {
|
||||||
|
try {
|
||||||
val dictGroupsWithNewMainDict = locales.mapNotNull {
|
val dictGroupsWithNewMainDict = locales.mapNotNull {
|
||||||
val dictionaryGroup = findDictionaryGroupWithLocale(dictionaryGroups, it)
|
val dictionaryGroup = findDictionaryGroupWithLocale(dictionaryGroups, it)
|
||||||
if (dictionaryGroup == null) {
|
if (dictionaryGroup == null) {
|
||||||
|
@ -248,6 +246,9 @@ class DictionaryFacilitatorImpl : DictionaryFacilitator {
|
||||||
|
|
||||||
listener?.onUpdateMainDictionaryAvailability(hasAtLeastOneInitializedMainDictionary())
|
listener?.onUpdateMainDictionaryAvailability(hasAtLeastOneInitializedMainDictionary())
|
||||||
latchForWaitingLoadingMainDictionary.countDown()
|
latchForWaitingLoadingMainDictionary.countDown()
|
||||||
|
} catch (e: Throwable) {
|
||||||
|
Log.e(TAG, "could not initialize main dictionaries for $locales", e)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -755,9 +755,14 @@ public class LatinIME extends InputMethodService implements
|
||||||
// TODO: make sure the current settings always have the right locales, and read from them.
|
// TODO: make sure the current settings always have the right locales, and read from them.
|
||||||
private void resetDictionaryFacilitator(@NonNull final Locale locale) {
|
private void resetDictionaryFacilitator(@NonNull final Locale locale) {
|
||||||
final SettingsValues settingsValues = mSettings.getCurrent();
|
final SettingsValues settingsValues = mSettings.getCurrent();
|
||||||
|
try {
|
||||||
mDictionaryFacilitator.resetDictionaries(this, locale,
|
mDictionaryFacilitator.resetDictionaries(this, locale,
|
||||||
settingsValues.mUseContactsDictionary, settingsValues.mUseAppsDictionary,
|
settingsValues.mUseContactsDictionary, settingsValues.mUseAppsDictionary,
|
||||||
settingsValues.mUsePersonalizedDicts, false, "", this);
|
settingsValues.mUsePersonalizedDicts, false, "", this);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
// this should not happen, but in case it does we at least want to show a keyboard
|
||||||
|
Log.e(TAG, "Could not reset dictionary facilitator, please fix ASAP", e);
|
||||||
|
}
|
||||||
mInputLogic.mSuggest.setAutoCorrectionThreshold(settingsValues.mAutoCorrectionThreshold);
|
mInputLogic.mSuggest.setAutoCorrectionThreshold(settingsValues.mAutoCorrectionThreshold);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue