diff --git a/README.md b/README.md index d655ce19..e1c2302b 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Does not use internet permission, and thus is 100% offline. * Customize keyboard themes (style, colors and background image) * can follow the system's day/night setting on Android 10+ (and on some versions of Android 9) * can follow dynamic colors for Android 12+ -* Customize keyboard [layouts](layouts.md) +* Customize keyboard [layouts](layouts.md) (only when disabling _use system languages_) * Multilingual typing * Glide typing (_only with closed source library_) * library not included in the app, as there is no compatible open source library available @@ -39,6 +39,7 @@ Does not use internet permission, and thus is 100% offline. ## FAQ / Common Issues * __Add a dictionary__: First download the dictionary file, e.g. from [here](https://codeberg.org/Helium314/aosp-dictionaries#dictionaries). Then go to language settings, click on the language, then on `+` next to _dictionary_ the _add_ and select the file. Alternatively you can open a `.dict` file in a file explorer with HeliBoard and then select the language. Note that the latter method does not work with all file explorers. * __Emoji search__: You can get addon dictionaries for emoji suggestions in the [dictionaries repo](https://codeberg.org/Helium314/aosp-dictionaries). An actual search function does not exist yet. +* __Cannot switch choose layout__: This is only possible when _use system languages_ is disabled. * __No suggestions for some language__: Check [dictionaries repo](https://codeberg.org/Helium314/aosp-dictionaries) whether a dictionary is available. If there is one, download it and add it in the language settings for this language. * __No suggestions in some app / text field__: This app respects the [no suggestions flag](https://developer.android.com/reference/android/text/InputType#TYPE_TEXT_FLAG_NO_SUGGESTIONS) set by some input fields, i.e. the developer does not want you to see suggestions here. Best do in issue report for that app if you think this behavior is wrong. Alternatively you can enable the _always show suggestions_ setting that overrides the _no suggestions_ flag. * __How to enable glide typing__: There is no glide typing built into this app, but you can load compatible libraries: Go to advanced settings -> _load gesture typing library_ and point to a file (setting not available in _nouserlib_ version). You can extract the file from GApps packages ("_swypelibs_"), or download one [here](https://github.com/erkserkserks/openboard/tree/master/app/src/main/jniLibs). Make sure to use the correct version (app will tell you in the dialog to load the library). diff --git a/app/src/main/java/helium314/keyboard/latin/settings/LanguageSettingsDialog.kt b/app/src/main/java/helium314/keyboard/latin/settings/LanguageSettingsDialog.kt index 6f0ff0c5..6bf45af4 100644 --- a/app/src/main/java/helium314/keyboard/latin/settings/LanguageSettingsDialog.kt +++ b/app/src/main/java/helium314/keyboard/latin/settings/LanguageSettingsDialog.kt @@ -39,7 +39,7 @@ class LanguageSettingsDialog( private val onlySystemLocales: Boolean, private val reloadSetting: () -> Unit ) : AlertDialog(context), LanguageSettingsFragment.Listener { - private val prefs = DeviceProtectedUtils.getSharedPreferences(context)!! + private val prefs = DeviceProtectedUtils.getSharedPreferences(context) private val binding = LocaleSettingsDialogBinding.inflate(LayoutInflater.from(context)) private val mainLocale = infos.first().subtype.locale() private var hasInternalDictForLanguage = false @@ -53,6 +53,10 @@ class LanguageSettingsDialog( } if (onlySystemLocales) + // don't allow setting subtypes, because + // a. subtypes are set purely based on system locales (in SubtypeSettings) + // b. extra handling needed if user disables all subtypes for a locale + // todo (later): fix above and allow it binding.subtypes.isGone = true else fillSubtypesView() @@ -147,7 +151,7 @@ class LanguageSettingsDialog( .setTitle(R.string.keyboard_layout_set) .setItems(displayNames.toTypedArray()) { di, i -> di.dismiss() - val fileName = context.assets.list("layouts")!!.firstOrNull { it.startsWith(layouts[i]) } ?: return@setItems + val fileName = context.assets.list("layouts")?.firstOrNull { it.startsWith(layouts[i]) } ?: return@setItems loadCustomLayout(context.assets.open("layouts${File.separator}$fileName").reader().readText(), displayNames[i], mainLocale.toLanguageTag(), context) { addSubtype(it) } } @@ -161,11 +165,11 @@ class LanguageSettingsDialog( private fun addSubtypeToView(subtype: SubtypeInfo) { val row = LayoutInflater.from(context).inflate(R.layout.language_list_item, listView) - val layoutSetName: String? = subtype.subtype.getExtraValueOf(KEYBOARD_LAYOUT_SET) + val layoutSetName = subtype.subtype.getExtraValueOf(KEYBOARD_LAYOUT_SET) ?: "qwerty" row.findViewById(R.id.language_name).text = SubtypeLocaleUtils.getKeyboardLayoutSetDisplayName(subtype.subtype) ?: SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(subtype.subtype) - if (layoutSetName?.startsWith(CUSTOM_LAYOUT_PREFIX) == true) { + if (layoutSetName.startsWith(CUSTOM_LAYOUT_PREFIX)) { row.findViewById(R.id.language_details).setText(R.string.edit_layout) row.findViewById(R.id.language_text).setOnClickListener { editCustomLayout(layoutSetName, context) } } else { @@ -191,18 +195,18 @@ class LanguageSettingsDialog( row.findViewById(R.id.delete_button).apply { isVisible = true setOnClickListener { - val isCustom = layoutSetName?.startsWith(CUSTOM_LAYOUT_PREFIX) == true + val isCustom = layoutSetName.startsWith(CUSTOM_LAYOUT_PREFIX) fun delete() { binding.subtypes.removeView(row) infos.remove(subtype) if (isCustom) - removeCustomLayoutFile(layoutSetName!!, context) + removeCustomLayoutFile(layoutSetName, context) removeAdditionalSubtype(prefs, context.resources, subtype.subtype) removeEnabledSubtype(prefs, subtype.subtype) reloadSetting() } if (isCustom) { - confirmDialog(context, context.getString(R.string.delete_layout, getLayoutDisplayName(layoutSetName!!)), context.getString(R.string.delete)) { delete() } + confirmDialog(context, context.getString(R.string.delete_layout, getLayoutDisplayName(layoutSetName)), context.getString(R.string.delete)) { delete() } } else { delete() }