diff options
| author | Jules Aguillon | 2026-01-30 21:18:48 +0100 |
|---|---|---|
| committer | GitHub | 2026-01-30 21:18:48 +0100 |
| commit | 1b8506876a1d8cff876220a7b6610b7bbe9e8841 (patch) | |
| tree | 4881a8e8fd4276a823c57869000308d1bc5ba66f /srcs/juloo.keyboard2 | |
| parent | e05be0821ba507dd5ea661bdde0af8a14e6fcbd6 (diff) | |
| download | unexpected-keyboard-1b8506876a1d8cff876220a7b6610b7bbe9e8841.tar.gz unexpected-keyboard-1b8506876a1d8cff876220a7b6610b7bbe9e8841.zip | |
Option to switch to the previously used keyboard (#1165)
The "Switch to the last used keyboard" is renamed to "Switching between
input methods" and allows to select "Switch to last used", which was the
default in older releases.
Diffstat (limited to 'srcs/juloo.keyboard2')
| -rw-r--r-- | srcs/juloo.keyboard2/Config.java | 21 | ||||
| -rw-r--r-- | srcs/juloo.keyboard2/KeyModifier.java | 3 | ||||
| -rw-r--r-- | srcs/juloo.keyboard2/KeyValue.java | 6 | ||||
| -rw-r--r-- | srcs/juloo.keyboard2/Keyboard2.java | 9 | ||||
| -rw-r--r-- | srcs/juloo.keyboard2/LayoutModifier.java | 4 |
5 files changed, 33 insertions, 10 deletions
diff --git a/srcs/juloo.keyboard2/Config.java b/srcs/juloo.keyboard2/Config.java index 775c206..5719bd9 100644 --- a/srcs/juloo.keyboard2/Config.java +++ b/srcs/juloo.keyboard2/Config.java @@ -65,7 +65,7 @@ public final class Config public float characterSize; // Ratio public int theme; // Values are R.style.* public boolean autocapitalisation; - public boolean switch_input_immediate; + public KeyValue change_method_key_replacement; public NumberLayout selected_number_layout; public boolean borderConfig; public int circle_sensitivity; @@ -173,7 +173,7 @@ public final class Config * characterSizeScale; theme = getThemeId(res, _prefs.getString("theme", "")); autocapitalisation = _prefs.getBoolean("autocapitalisation", true); - switch_input_immediate = _prefs.getBoolean("switch_input_immediate", false); + change_method_key_replacement = get_change_method_key_replacement(_prefs); extra_keys_param = ExtraKeysPreference.get_extra_keys(_prefs); extra_keys_custom = CustomExtraKeysPreference.get(_prefs); selected_number_layout = NumberLayout.of_string(_prefs.getString("number_entry_layout", "pin")); @@ -268,6 +268,17 @@ public final class Config } } + private static KeyValue get_change_method_key_replacement(SharedPreferences prefs) + { + switch (prefs.getString("change_method_key_replacement", "prev")) + { + case "prev": return KeyValue.getKeyByName("change_method_prev"); + case "next": return KeyValue.getKeyByName("change_method_next"); + default: + case "picker": return KeyValue.getKeyByName("change_method"); + } + } + private static Config _globalConfig = null; public static void initGlobalConfig(SharedPreferences prefs, Resources res, @@ -298,7 +309,7 @@ public final class Config /** Config migrations. */ - private static int CONFIG_VERSION = 3; + private static int CONFIG_VERSION = 4; public static void migrate(SharedPreferences prefs) { @@ -335,6 +346,10 @@ public final class Config } // Fallthrough case 3: + e.putString("change_method_key_replacement", + prefs.getBoolean("switch_input_immediate", false) ? "prev" : "picker"); + // Fallthrough + case 4: default: break; } e.apply(); diff --git a/srcs/juloo.keyboard2/KeyModifier.java b/srcs/juloo.keyboard2/KeyModifier.java index 3f5672f..2ef5445 100644 --- a/srcs/juloo.keyboard2/KeyModifier.java +++ b/srcs/juloo.keyboard2/KeyModifier.java @@ -96,7 +96,8 @@ public final class KeyModifier case Event: switch (k.getEvent()) { - case CHANGE_METHOD_AUTO: + case CHANGE_METHOD_PREV: + case CHANGE_METHOD_NEXT: return KeyValue.getKeyByName("change_method"); case SWITCH_VOICE_TYPING: return KeyValue.getKeyByName("voice_typing_chooser"); diff --git a/srcs/juloo.keyboard2/KeyValue.java b/srcs/juloo.keyboard2/KeyValue.java index ed93523..7cb50a4 100644 --- a/srcs/juloo.keyboard2/KeyValue.java +++ b/srcs/juloo.keyboard2/KeyValue.java @@ -15,7 +15,8 @@ public final class KeyValue implements Comparable<KeyValue> SWITCH_CLIPBOARD, SWITCH_BACK_CLIPBOARD, CHANGE_METHOD_PICKER, - CHANGE_METHOD_AUTO, + CHANGE_METHOD_PREV, + CHANGE_METHOD_NEXT, ACTION, SWITCH_FORWARD, SWITCH_BACKWARD, @@ -627,7 +628,8 @@ public final class KeyValue implements Comparable<KeyValue> case "switch_backward": return eventKey(0xE014, Event.SWITCH_BACKWARD, FLAG_SMALLER_FONT); case "switch_greekmath": return eventKey("πλ∇¬", Event.SWITCH_GREEKMATH, FLAG_SMALLER_FONT); case "change_method": return eventKey(0xE009, Event.CHANGE_METHOD_PICKER, FLAG_SMALLER_FONT); - case "change_method_prev": return eventKey(0xE009, Event.CHANGE_METHOD_AUTO, FLAG_SMALLER_FONT); + case "change_method_prev": return eventKey(0xE009, Event.CHANGE_METHOD_PREV, FLAG_SMALLER_FONT); + case "change_method_next": return eventKey(0xE009, Event.CHANGE_METHOD_NEXT, FLAG_SMALLER_FONT); case "action": return eventKey("Action", Event.ACTION, FLAG_SMALLER_FONT); // Will always be replaced case "capslock": return eventKey(0xE012, Event.CAPS_LOCK, 0); case "voice_typing": return eventKey(0xE015, Event.SWITCH_VOICE_TYPING, FLAG_SMALLER_FONT); diff --git a/srcs/juloo.keyboard2/Keyboard2.java b/srcs/juloo.keyboard2/Keyboard2.java index a919405..4d008d9 100644 --- a/srcs/juloo.keyboard2/Keyboard2.java +++ b/srcs/juloo.keyboard2/Keyboard2.java @@ -369,10 +369,17 @@ public class Keyboard2 extends InputMethodService get_imm().showInputMethodPicker(); break; - case CHANGE_METHOD_AUTO: + case CHANGE_METHOD_PREV: if (VERSION.SDK_INT < 28) get_imm().switchToLastInputMethod(getConnectionToken()); else + switchToPreviousInputMethod(); + break; + + case CHANGE_METHOD_NEXT: + if (VERSION.SDK_INT < 28) + get_imm().switchToNextInputMethod(getConnectionToken(), false); + else switchToNextInputMethod(false); break; diff --git a/srcs/juloo.keyboard2/LayoutModifier.java b/srcs/juloo.keyboard2/LayoutModifier.java index fa7be0c..4a79314 100644 --- a/srcs/juloo.keyboard2/LayoutModifier.java +++ b/srcs/juloo.keyboard2/LayoutModifier.java @@ -156,9 +156,7 @@ public final class LayoutModifier switch (orig.getEvent()) { case CHANGE_METHOD_PICKER: - if (globalConfig.switch_input_immediate) - return KeyValue.getKeyByName("change_method_prev"); - break; + return globalConfig.change_method_key_replacement; case ACTION: String action_label = ec.actionLabel; if (action_label == null) |
