From 4ee33fb3654a905bfb27a7c275ad8063ee831c0b Mon Sep 17 00:00:00 2001 From: Aleksandras Kostarevas Date: Tue, 23 Jul 2024 11:55:00 +0300 Subject: [PATCH] Fix action key not being set by default --- .../futo/inputmethod/latin/settings/SettingsValues.java | 7 ++++++- .../src/org/futo/inputmethod/latin/uix/actions/Registry.kt | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/java/src/org/futo/inputmethod/latin/settings/SettingsValues.java b/java/src/org/futo/inputmethod/latin/settings/SettingsValues.java index 8ffed5d84..c98150ccf 100644 --- a/java/src/org/futo/inputmethod/latin/settings/SettingsValues.java +++ b/java/src/org/futo/inputmethod/latin/settings/SettingsValues.java @@ -29,6 +29,7 @@ import org.futo.inputmethod.compat.AppWorkaroundsUtils; import org.futo.inputmethod.latin.InputAttributes; import org.futo.inputmethod.latin.R; import org.futo.inputmethod.latin.uix.actions.ActionRegistry; +import org.futo.inputmethod.latin.uix.actions.RegistryKt; import org.futo.inputmethod.latin.utils.AsyncResultHolder; import org.futo.inputmethod.latin.utils.ResourceUtils; import org.futo.inputmethod.latin.utils.TargetPackageInfoGetterTask; @@ -147,7 +148,11 @@ public class SettingsValues { mIncludesOtherImesInLanguageSwitchList = Settings.ENABLE_SHOW_LANGUAGE_SWITCH_KEY_SETTINGS ? prefs.getBoolean(Settings.PREF_INCLUDE_OTHER_IMES_IN_LANGUAGE_SWITCH_LIST, false) : true /* forcibly */; - mActionKeyId = ActionRegistry.INSTANCE.actionStringIdToIdx(prefs.getString(Settings.PREF_ACTION_KEY_ID, "")); + mActionKeyId = ActionRegistry.INSTANCE.actionStringIdToIdx( + prefs.getString( + Settings.PREF_ACTION_KEY_ID, + RegistryKt.getDefaultActionKey() + )); mShowsActionKey = mActionKeyId != -1; mIsNumberRowEnabled = prefs.getBoolean(Settings.PREF_ENABLE_NUMBER_ROW, false); mUseContactsDict = prefs.getBoolean(Settings.PREF_KEY_USE_CONTACTS_DICT, true); diff --git a/java/src/org/futo/inputmethod/latin/uix/actions/Registry.kt b/java/src/org/futo/inputmethod/latin/uix/actions/Registry.kt index 8689d1272..52967675f 100644 --- a/java/src/org/futo/inputmethod/latin/uix/actions/Registry.kt +++ b/java/src/org/futo/inputmethod/latin/uix/actions/Registry.kt @@ -235,6 +235,10 @@ val DefaultActionSettings = mapOf( ActionCategory.Disabled to listOf(MemoryDebugAction, SystemVoiceInputAction) ) +val DefaultActionKey = DefaultActionSettings[ActionCategory.ActionKey]!!.firstOrNull()?.let { + ActionRegistry.actionToStringId(it) +} ?: "" + val ActionsSettings = SettingsKey( stringPreferencesKey("actions_settings_map"), DefaultActionSettings.flattenToActionEditorItems().ensureWellFormed().serializeActionEditorItemListToString()