mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
Add fallback for getting dictionary resid a more normal way
This commit is contained in:
parent
7aea41eede
commit
abc5a74004
@ -65,11 +65,12 @@ android {
|
|||||||
buildTypes {
|
buildTypes {
|
||||||
debug {
|
debug {
|
||||||
minifyEnabled false
|
minifyEnabled false
|
||||||
|
shrinkResources false
|
||||||
signingConfig signingConfigs.debug
|
signingConfig signingConfigs.debug
|
||||||
}
|
}
|
||||||
release {
|
release {
|
||||||
minifyEnabled true
|
minifyEnabled true
|
||||||
shrinkResources true
|
shrinkResources false
|
||||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||||
signingConfig releaseSigning
|
signingConfig releaseSigning
|
||||||
}
|
}
|
||||||
|
37
java/src/org/futo/inputmethod/latin/utils/Dictionaries.kt
Normal file
37
java/src/org/futo/inputmethod/latin/utils/Dictionaries.kt
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
package org.futo.inputmethod.latin.utils
|
||||||
|
|
||||||
|
import androidx.annotation.RawRes
|
||||||
|
import org.futo.inputmethod.latin.R
|
||||||
|
import java.util.Locale
|
||||||
|
|
||||||
|
object Dictionaries {
|
||||||
|
private val dictionaries = mapOf(
|
||||||
|
"" to R.raw.main,
|
||||||
|
"de" to R.raw.main_de,
|
||||||
|
"en" to R.raw.main_en,
|
||||||
|
"es" to R.raw.main_es,
|
||||||
|
"fr" to R.raw.main_fr,
|
||||||
|
"it" to R.raw.main_it,
|
||||||
|
"pt_br" to R.raw.main_pt_br,
|
||||||
|
"ru" to R.raw.main_ru
|
||||||
|
)
|
||||||
|
|
||||||
|
@RawRes
|
||||||
|
public fun getDictionaryId(locale: Locale): Int {
|
||||||
|
var resId = 0
|
||||||
|
|
||||||
|
// Try to find main_language_country dictionary.
|
||||||
|
if (locale.country.isNotEmpty()) {
|
||||||
|
val dictLanguageCountry = locale.toString().lowercase()
|
||||||
|
resId = dictionaries[dictLanguageCountry] ?: 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try to find main_language dictionary.
|
||||||
|
if(resId == 0) {
|
||||||
|
val dictLanguage = locale.language
|
||||||
|
resId = dictionaries[dictLanguage] ?: 0
|
||||||
|
}
|
||||||
|
|
||||||
|
return resId
|
||||||
|
}
|
||||||
|
}
|
@ -368,6 +368,10 @@ public class DictionaryInfoUtils {
|
|||||||
return resId;
|
return resId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((resId = Dictionaries.INSTANCE.getDictionaryId(locale)) != 0) {
|
||||||
|
return resId;
|
||||||
|
}
|
||||||
|
|
||||||
// Not found, return 0
|
// Not found, return 0
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -383,8 +387,14 @@ public class DictionaryInfoUtils {
|
|||||||
if (0 != resourceId) {
|
if (0 != resourceId) {
|
||||||
return resourceId;
|
return resourceId;
|
||||||
}
|
}
|
||||||
return res.getIdentifier(DEFAULT_MAIN_DICT + DecoderSpecificConstants.DECODER_DICT_SUFFIX,
|
resourceId = res.getIdentifier(DEFAULT_MAIN_DICT + DecoderSpecificConstants.DECODER_DICT_SUFFIX,
|
||||||
"raw", RESOURCE_PACKAGE_NAME);
|
"raw", RESOURCE_PACKAGE_NAME);
|
||||||
|
|
||||||
|
if (0 != resourceId) {
|
||||||
|
return resourceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
return R.raw.main;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user