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 | |
| 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.
| -rw-r--r-- | res/values/arrays.xml | 34 | ||||
| -rw-r--r-- | res/values/strings.xml | 6 | ||||
| -rw-r--r-- | res/xml/settings.xml | 6 | ||||
| -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 |
8 files changed, 62 insertions, 27 deletions
diff --git a/res/values/arrays.xml b/res/values/arrays.xml index 8983820..70143bb 100644 --- a/res/values/arrays.xml +++ b/res/values/arrays.xml @@ -112,16 +112,26 @@ <item>30</item> <item>15</item> </string-array> - <string-array name="pref_clipboard_duration_entries"> - <item>@string/pref_clipboard_history_duration_1</item> - <item>@string/pref_clipboard_history_duration_5</item> - <item>@string/pref_clipboard_history_duration_30</item> - <item>@string/pref_clipboard_history_duration_stop</item> - </string-array> - <string-array name="pref_clipboard_duration_values"> - <item>1</item> - <item>5</item> - <item>30</item> - <item>-1</item> - </string-array> + <string-array name="pref_clipboard_duration_entries"> + <item>@string/pref_clipboard_history_duration_1</item> + <item>@string/pref_clipboard_history_duration_5</item> + <item>@string/pref_clipboard_history_duration_30</item> + <item>@string/pref_clipboard_history_duration_stop</item> + </string-array> + <string-array name="pref_clipboard_duration_values"> + <item>1</item> + <item>5</item> + <item>30</item> + <item>-1</item> + </string-array> + <string-array name="pref_change_method_key_replacement_entries"> + <item>@string/pref_change_method_key_replacement_e_picker</item> + <item>@string/pref_change_method_key_replacement_e_prev</item> + <item>@string/pref_change_method_key_replacement_e_next</item> + </string-array> + <string-array name="pref_change_method_key_replacement_values"> + <item>picker</item> + <item>prev</item> + <item>next</item> + </string-array> </resources> diff --git a/res/values/strings.xml b/res/values/strings.xml index 0a7faf4..6b1c329 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -44,8 +44,10 @@ <string name="pref_category_behavior">Behavior</string> <string name="pref_autocapitalisation_title">Automatic capitalisation</string> <string name="pref_autocapitalisation_summary">Press Shift at the beginning of a sentence</string> - <string name="pref_switch_input_immediate_title">Switch to the last used keyboard</string> - <string name="pref_switch_input_immediate_summary">Behavior of the keyboard-switching key</string> + <string name="pref_change_method_key_replacement_title">Switching between input methods</string> + <string name="pref_change_method_key_replacement_e_picker">Show the input method picker (long press)</string> + <string name="pref_change_method_key_replacement_e_prev">Switch to last used</string> + <string name="pref_change_method_key_replacement_e_next">Switch to the next in the list</string> <string name="pref_vibrate_custom">Custom vibration</string> <string name="pref_vibrate_duration_title">Vibration intensity</string> <string name="pref_number_entry_title">Layout when typing numbers, dates, and phone numbers</string> diff --git a/res/xml/settings.xml b/res/xml/settings.xml index c96f546..175617a 100644 --- a/res/xml/settings.xml +++ b/res/xml/settings.xml @@ -23,7 +23,7 @@ </PreferenceCategory> <PreferenceCategory android:title="@string/pref_category_behavior"> <CheckBoxPreference android:key="autocapitalisation" android:title="@string/pref_autocapitalisation_title" android:summary="@string/pref_autocapitalisation_summary" android:defaultValue="true"/> - <CheckBoxPreference android:key="switch_input_immediate" android:title="@string/pref_switch_input_immediate_title" android:summary="@string/pref_switch_input_immediate_summary" android:defaultValue="false"/> + <ListPreference android:key="change_method_key_replacement" android:title="@string/pref_change_method_key_replacement_title" android:summary="%s" android:entries="@array/pref_change_method_key_replacement_entries" android:entryValues="@array/pref_change_method_key_replacement_values" android:defaultValue="prev"/> <CheckBoxPreference android:key="vibrate_custom" android:title="@string/pref_vibrate_custom" android:defaultValue="false"/> <juloo.keyboard2.prefs.IntSlideBarPreference android:dependency="vibrate_custom" android:key="vibrate_duration" android:title="@string/pref_vibrate_duration_title" android:summary="%sms" android:defaultValue="20" min="0" max="100"/> <ListPreference android:key="number_entry_layout" android:title="@string/pref_number_entry_title" android:summary="%s" android:defaultValue="pin" android:entries="@array/pref_number_entry_entries" android:entryValues="@array/pref_number_entry_values"/> @@ -60,6 +60,6 @@ <juloo.keyboard2.prefs.SlideBarPreference android:key="custom_border_line_width" android:title="@string/pref_border_width_title" android:summary="%sdp" android:defaultValue="0" min="0" max="5" android:dependency="border_config"/> </PreferenceCategory> <PreferenceCategory android:title="@string/pref_category_clipboard"> - <ListPreference android:key="clipboard_history_duration" android:title="@string/pref_clipboard_history_duration" android:summary="%s" android:defaultValue="5" android:entries="@array/pref_clipboard_duration_entries" android:entryValues="@array/pref_clipboard_duration_values" /> - </PreferenceCategory> + <ListPreference android:key="clipboard_history_duration" android:title="@string/pref_clipboard_history_duration" android:summary="%s" android:defaultValue="5" android:entries="@array/pref_clipboard_duration_entries" android:entryValues="@array/pref_clipboard_duration_values"/> + </PreferenceCategory> </PreferenceScreen> 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) |
