From ebf80415d8034d853bd79ba7cfb578db67862529 Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Thu, 19 Feb 2026 00:35:14 +0100 Subject: Refactor: KeyValue constants (#1180) * Refactor: KeyValue constants Add constants for keys that are accessed from the app's code. This simplifies the fake pointer handling in Keyboard2View. * Refactor: Pre-compute action key replacement The action key and the enter swap are pre-computed in EditorConfig. This simplifies the code.--- srcs/juloo.keyboard2/LayoutModifier.java | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'srcs/juloo.keyboard2/LayoutModifier.java') diff --git a/srcs/juloo.keyboard2/LayoutModifier.java b/srcs/juloo.keyboard2/LayoutModifier.java index 4a79314..163ff4e 100644 --- a/srcs/juloo.keyboard2/LayoutModifier.java +++ b/srcs/juloo.keyboard2/LayoutModifier.java @@ -31,7 +31,7 @@ public final class LayoutModifier final Set remove_keys = new HashSet(); // Make sure the config key is accessible to avoid being locked in a custom // layout. - extra_keys.put(KeyValue.getKeyByName("config"), KeyboardData.PreferredPos.ANYWHERE); + extra_keys.put(KeyValue.CONFIG, KeyboardData.PreferredPos.ANYWHERE); extra_keys.putAll(globalConfig.extra_keys_param); extra_keys.putAll(globalConfig.extra_keys_custom); // Number row and numpads are added after the modification pass to allow @@ -158,12 +158,7 @@ public final class LayoutModifier case CHANGE_METHOD_PICKER: return globalConfig.change_method_key_replacement; case ACTION: - String action_label = ec.actionLabel; - if (action_label == null) - return null; // Remove the action key - if (ec.swapEnterActionKey) - return KeyValue.getKeyByName("enter"); - return KeyValue.makeActionKey(action_label); + return ec.action_key_replacement; case SWITCH_FORWARD: return (globalConfig.layouts.size() > 1) ? orig : null; case SWITCH_BACKWARD: @@ -177,8 +172,8 @@ public final class LayoutModifier switch (orig.getKeyevent()) { case KeyEvent.KEYCODE_ENTER: - if (ec.swapEnterActionKey && ec.actionLabel != null) - return KeyValue.makeActionKey(ec.actionLabel); + if (ec.enter_key_replacement != null) + return ec.enter_key_replacement; break; } break; -- cgit v1.2.3