mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-03 13:14:46 +00:00
use existing constants for NO_LANGUAGE and QWERTY
This commit is contained in:
parent
8d094e268a
commit
0899245ae7
7 changed files with 12 additions and 9 deletions
|
@ -49,6 +49,7 @@ import helium314.keyboard.latin.utils.Log;
|
|||
import helium314.keyboard.latin.utils.RecapitalizeStatus;
|
||||
import helium314.keyboard.latin.utils.ResourceUtils;
|
||||
import helium314.keyboard.latin.utils.ScriptUtils;
|
||||
import helium314.keyboard.latin.utils.SubtypeLocaleUtils;
|
||||
import helium314.keyboard.latin.utils.SubtypeUtilsAdditional;
|
||||
|
||||
public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||
|
@ -160,7 +161,7 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
|||
Log.e(TAG, "loading keyboard failed: " + e.mKeyboardId, e.getCause());
|
||||
try {
|
||||
final InputMethodSubtype qwerty = SubtypeUtilsAdditional.INSTANCE
|
||||
.createEmojiCapableAdditionalSubtype(mRichImm.getCurrentSubtypeLocale(), "qwerty", true);
|
||||
.createEmojiCapableAdditionalSubtype(mRichImm.getCurrentSubtypeLocale(), SubtypeLocaleUtils.QWERTY, true);
|
||||
mKeyboardLayoutSet = builder.setKeyboardGeometry(keyboardWidth, keyboardHeight)
|
||||
.setSubtype(RichInputMethodSubtype.Companion.get(qwerty))
|
||||
.setVoiceInputKeyEnabled(settingsValues.mShowsVoiceInputKey)
|
||||
|
|
|
@ -229,7 +229,7 @@ private fun getStreamForLocale(locale: Locale, context: Context) =
|
|||
private fun getLocaleTlds(locale: Locale): LinkedHashSet<String> {
|
||||
val ccLower = locale.country.lowercase()
|
||||
val tlds = LinkedHashSet<String>()
|
||||
if (ccLower.isEmpty() || ccLower == "zz")
|
||||
if (ccLower.isEmpty() || locale.language == SubtypeLocaleUtils.NO_LANGUAGE)
|
||||
return tlds
|
||||
specialCountryTlds.forEach {
|
||||
if (ccLower != it.first) return@forEach
|
||||
|
|
|
@ -158,7 +158,7 @@ object LocaleUtils {
|
|||
} else if (elements.size == 2) {
|
||||
if (region == "ZZ") Locale.forLanguageTag(elements[0] + "-Latn")
|
||||
else Locale(language, region!!)
|
||||
} else if (language == "zz") { // localeParams.length == 3
|
||||
} else if (language == SubtypeLocaleUtils.NO_LANGUAGE) { // localeParams.length == 3
|
||||
Locale.Builder().setLanguage(language).setVariant(elements[2]).setScript("Latn").build()
|
||||
} else if (elements[2].startsWith("#")) {
|
||||
// best guess: elements[2] is a script, e.g. sr-Latn locale to string is sr__#Latn
|
||||
|
|
|
@ -41,7 +41,8 @@ fun getDictionaryLocales(context: Context): MutableSet<Locale> {
|
|||
|
||||
fun showMissingDictionaryDialog(context: Context, locale: Locale) {
|
||||
val prefs = context.prefs()
|
||||
if (prefs.getBoolean(Settings.PREF_DONT_SHOW_MISSING_DICTIONARY_DIALOG, Defaults.PREF_DONT_SHOW_MISSING_DICTIONARY_DIALOG) || locale.toString() == "zz")
|
||||
if (prefs.getBoolean(Settings.PREF_DONT_SHOW_MISSING_DICTIONARY_DIALOG, Defaults.PREF_DONT_SHOW_MISSING_DICTIONARY_DIALOG)
|
||||
|| locale.toString() == SubtypeLocaleUtils.NO_LANGUAGE)
|
||||
return
|
||||
val repositoryLink = "<a href='$DICTIONARY_URL'>" + context.getString(R.string.dictionary_link_text) + "</a>"
|
||||
val dictionaryLink = "<a href='$DICTIONARY_URL/src/branch/main/dictionaries/main_$locale.dict'>" + context.getString(
|
||||
|
|
|
@ -199,7 +199,7 @@ object SubtypeSettings {
|
|||
val customLayoutFiles by lazy { LayoutUtilsCustom.getLayoutFiles(LayoutType.MAIN, context).map { it.name } }
|
||||
val subtypesToRemove = mutableListOf<String>()
|
||||
additionalSubtypes.forEach {
|
||||
val name = it.toSettingsSubtype().mainLayoutName() ?: "qwerty"
|
||||
val name = it.toSettingsSubtype().mainLayoutName() ?: SubtypeLocaleUtils.QWERTY
|
||||
if (!LayoutUtilsCustom.isCustomLayout(name)) return@forEach
|
||||
if (name !in customLayoutFiles)
|
||||
subtypesToRemove.add(it)
|
||||
|
@ -240,7 +240,7 @@ object SubtypeSettings {
|
|||
continue
|
||||
}
|
||||
|
||||
val subtype = subtypesForLocale.firstOrNull { SubtypeLocaleUtils.getMainLayoutName(it) == (settingsSubtype.mainLayoutName() ?: "qwerty") }
|
||||
val subtype = subtypesForLocale.firstOrNull { SubtypeLocaleUtils.getMainLayoutName(it) == (settingsSubtype.mainLayoutName() ?: SubtypeLocaleUtils.QWERTY) }
|
||||
if (subtype == null) {
|
||||
val message = "subtype $settingsSubtype could not be loaded"
|
||||
Log.w(TAG, message)
|
||||
|
|
|
@ -110,7 +110,7 @@ data class SettingsSubtype(val locale: Locale, val extraValues: String) {
|
|||
fun toAdditionalSubtype(): InputMethodSubtype? {
|
||||
val asciiCapable = locale.script() == ScriptUtils.SCRIPT_LATIN
|
||||
val subtype = SubtypeUtilsAdditional.createAdditionalSubtype(locale, extraValues, asciiCapable, true)
|
||||
if (subtype.nameResId == SubtypeLocaleUtils.UNKNOWN_KEYBOARD_LAYOUT && !LayoutUtilsCustom.isCustomLayout(mainLayoutName() ?: "qwerty")) {
|
||||
if (subtype.nameResId == SubtypeLocaleUtils.UNKNOWN_KEYBOARD_LAYOUT && !LayoutUtilsCustom.isCustomLayout(mainLayoutName() ?: SubtypeLocaleUtils.QWERTY)) {
|
||||
// Skip unknown keyboard layout subtype. This may happen when predefined keyboard
|
||||
// layout has been removed.
|
||||
Log.w(SettingsSubtype::class.simpleName, "unknown additional subtype $this")
|
||||
|
|
|
@ -33,6 +33,7 @@ import helium314.keyboard.latin.settings.USER_DICTIONARY_SUFFIX
|
|||
import helium314.keyboard.latin.utils.DictionaryInfoUtils
|
||||
import helium314.keyboard.latin.utils.Log
|
||||
import helium314.keyboard.latin.utils.SettingsSubtype.Companion.toSettingsSubtype
|
||||
import helium314.keyboard.latin.utils.SubtypeLocaleUtils
|
||||
import helium314.keyboard.latin.utils.SubtypeSettings
|
||||
import helium314.keyboard.latin.utils.SubtypeUtilsAdditional
|
||||
import helium314.keyboard.latin.utils.displayName
|
||||
|
@ -141,8 +142,8 @@ private fun getSortedSubtypes(context: Context): List<InputMethodSubtype> {
|
|||
{ !(SubtypeSettings.isAdditionalSubtype(it) && !isDefaultSubtype(it) ) },
|
||||
{
|
||||
@Suppress("DEPRECATION")
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) it.languageTag == "zz"
|
||||
else it.locale == "zz"
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) it.languageTag == SubtypeLocaleUtils.NO_LANGUAGE
|
||||
else it.locale == SubtypeLocaleUtils.NO_LANGUAGE
|
||||
},
|
||||
{ it.displayName(context) }
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue