From 0f62b3044c501dc5679583e06447285ebeb31118 Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Sun, 12 Feb 2023 23:20:11 +0100 Subject: [PATCH] Option to switch to the previous input method A new option changes the "change_method" into the new "change_method_prev". It switch to the previously used input method. A long press on "change_method_prev" sends "change_method". A new section is added in the settings and existing options are moved. --- res/values-cs/strings.xml | 11 +++++++---- res/values-de/strings.xml | 11 +++++++---- res/values-es/strings.xml | 11 +++++++---- res/values-fr/strings.xml | 11 +++++++---- res/values-it/strings.xml | 11 +++++++---- res/values-ko/strings.xml | 11 +++++++---- res/values-lv/strings.xml | 11 +++++++---- res/values-pl/strings.xml | 11 +++++++---- res/values-pt/strings.xml | 11 +++++++---- res/values-ru/strings.xml | 11 +++++++---- res/values-tr/strings.xml | 11 +++++++---- res/values-vi/strings.xml | 11 +++++++---- res/values-zh-rCN/strings.xml | 11 +++++++---- res/values/strings.xml | 11 +++++++---- res/xml/settings.xml | 5 ++++- srcs/juloo.keyboard2/Config.java | 8 +++++++- srcs/juloo.keyboard2/KeyEventHandler.java | 6 ++++-- srcs/juloo.keyboard2/KeyModifier.java | 10 ++++++++++ srcs/juloo.keyboard2/KeyValue.java | 2 ++ srcs/juloo.keyboard2/Keyboard2.java | 16 +++++++++++++--- 20 files changed, 138 insertions(+), 63 deletions(-) diff --git a/res/values-cs/strings.xml b/res/values-cs/strings.xml index 72bbed6..8b9b874 100644 --- a/res/values-cs/strings.xml +++ b/res/values-cs/strings.xml @@ -26,8 +26,6 @@ - Automatická kapitalizace - Stiskne Shift na začátku věty Žádné @@ -36,10 +34,15 @@ Jak daleko je třeba posunout prst pro napsaní znaku/diakritiky v rozích klávey (%s) Časová prodleva opakování znaků Interval opakování znaků - Vibrace - Zapnout/Vypnout vibrace při stisku klávesy Dvojklik pro aktivaci caps lock(u) Dvojklik namísto držení modifikačních kláves po nějakou dobu + + Automatická kapitalizace + Stiskne Shift na začátku věty + + + Vibrace + Zapnout/Vypnout vibrace při stisku klávesy Styl Spodní odsazení Výška klávesnice diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml index 037de27..0314be1 100644 --- a/res/values-de/strings.xml +++ b/res/values-de/strings.xml @@ -26,8 +26,6 @@ - Automatische Großschreibung - Shift-Taste am Satzanfang aktivieren Zusätzliche Zeichen zur Tastatur hinzufügen Keines @@ -36,10 +34,15 @@ Abstand der Zeichen in den Ecken der Tasten (%s) Zeitüberschreitung bei Tastenwiederholung Intervall der Tastenwiederholung - Vibration - Vibration bei Tastendruck ein-/ausschalten Umschalttaste mit Doppeltippen einrasten Anstatt Taste längere Zeit gedrückt zu halten + + Automatische Großschreibung + Shift-Taste am Satzanfang aktivieren + + + Vibration + Vibration bei Tastendruck ein-/ausschalten Design Unterer Abstand Höhe der Tastatur diff --git a/res/values-es/strings.xml b/res/values-es/strings.xml index 92995b2..360f3d9 100644 --- a/res/values-es/strings.xml +++ b/res/values-es/strings.xml @@ -26,8 +26,6 @@ - - @@ -36,10 +34,15 @@ Distancia de caracteres en las esquinas de las letras (%s) Tiempo de espera de repetición de tecla Intervalo de repetición de tecla - Vibración - Habilitar/deshabilitar vibración al presionar una tecla + + + + + + Vibración + Habilitar/deshabilitar vibración al presionar una tecla Estilo Margen del pie Altura del teclado diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml index 6bb37ff..f25c1dc 100644 --- a/res/values-fr/strings.xml +++ b/res/values-fr/strings.xml @@ -26,8 +26,6 @@ Disposition du pavé numérique Du plus haut au plus bas Du plus bas au plus haut - Majuscule automatique - Activer Shift au début des phrases Ajouter des touches au clavier Disposition secondaire Aucune @@ -36,10 +34,15 @@ La distance des caractères dans les coins (%s) Délai avant répétition Écart entre les répétitions - Vibreur - Vibration a chaque touche Appuyer deux fois pour bloquer la majuscule Un appui long bloque la majuscule + Comportement + Majuscule automatique + Activer Shift au début des phrases + Changer vers le clavier utilisé en dernier + Comportement de la touche de changement de clavier + Vibreur + Vibration a chaque touche Style Marge du bas Hauteur du clavier diff --git a/res/values-it/strings.xml b/res/values-it/strings.xml index c76fa7f..cd49538 100644 --- a/res/values-it/strings.xml +++ b/res/values-it/strings.xml @@ -26,8 +26,6 @@ - Maiuscole Automatiche - Premi Shift all\'inizio di una frase Nessuno @@ -36,10 +34,15 @@ Distanza dei caratteri negli angoli dei tasti (%s) Timeout ripetizione tasto Intervallo ripetizione tasto - Vibrazione - Abilita/Disabilita Vibrazione alla pressione dei tasti Doppio tocco su Shift per attivare CapsLock Invece di premere i modificatori a lungo + + Maiuscole Automatiche + Premi Shift all\'inizio di una frase + + + Vibrazione + Abilita/Disabilita Vibrazione alla pressione dei tasti Stile Margine inferiore Altezza tastiera diff --git a/res/values-ko/strings.xml b/res/values-ko/strings.xml index 642da42..164e9ba 100644 --- a/res/values-ko/strings.xml +++ b/res/values-ko/strings.xml @@ -26,8 +26,6 @@ - - @@ -36,10 +34,15 @@ 키 모서리 문자의 입력 범위 (%s) 키 길게 누르기 지연 키 반복 간격 - 진동 - 키 누를 때 진동 키거/끄기 + + + + + + 진동 + 키 누를 때 진동 키거/끄기 스타일 아래 넓이 키보드 높이 diff --git a/res/values-lv/strings.xml b/res/values-lv/strings.xml index 996de31..d606c95 100644 --- a/res/values-lv/strings.xml +++ b/res/values-lv/strings.xml @@ -26,8 +26,6 @@ - Automātiski lielie burti - Piespiest Shift teikuma sākumā Pievienot tastatūrai taustiņus Neviens @@ -36,10 +34,15 @@ Taustiņu stūros esošo rakstzīmju attālums (%s) Taustiņa atkārtošanās ātrums Taustiņa atkārtošanās aizture - Trīcēšana - Iespējot/atspējot taustiņa piespiešanas trīcēšanu Divkāršs piesitiens burtslēgam Tā vietā, lai ilstoši piespiestu pārveidotāju + + Automātiski lielie burti + Piespiest Shift teikuma sākumā + + + Trīcēšana + Iespējot/atspējot taustiņa piespiešanas trīcēšanu Izskata pielāgojumi Apakšējā apmale Tastatūras augstums diff --git a/res/values-pl/strings.xml b/res/values-pl/strings.xml index 949c628..a23e37f 100644 --- a/res/values-pl/strings.xml +++ b/res/values-pl/strings.xml @@ -26,8 +26,6 @@ Układ klawiatury numerycznej Od największej cyfry Od najmniejszej cyfry - Automatyczne wielkie litery - Naciśnij Shift na początku zdania Dodaj klawisze do klawiatury Drugi układ Żaden @@ -36,10 +34,15 @@ Odległość znaków od rogów klawiszy (%s) Opóźnienie powtarzania naciśnięć klawisza Czas pomiędzy powtórzeniami - Wibracja - Wł./wył. wibrację przy naciśnięciu klawisza Naciśnij Shift podwójnie, aby włączyć caps lock Możesz zablokować modyfikator poprzez jego długie naciśnięcie + + Automatyczne wielkie litery + Naciśnij Shift na początku zdania + + + Wibracja + Wł./wył. wibrację przy naciśnięciu klawisza Styl Margines dolny Wysokość klawiatury diff --git a/res/values-pt/strings.xml b/res/values-pt/strings.xml index 908cae5..387dac4 100644 --- a/res/values-pt/strings.xml +++ b/res/values-pt/strings.xml @@ -26,8 +26,6 @@ - Maiusculização automática - Aciona o shift no início de cada frase Nenhum @@ -36,10 +34,15 @@ Distância até acionar os cantos das teclas (%s) Tempo até repetir tecla Intervalo de repetição de tecla - Vibração - Ativar/desativar vibração ao digitar Tecle duas vezes no shift para caixa alta Ao invés de apertar e segurar por um tempo + + Maiusculização automática + Aciona o shift no início de cada frase + + + Vibração + Ativar/desativar vibração ao digitar Estilo Margem inferior Altura do teclado diff --git a/res/values-ru/strings.xml b/res/values-ru/strings.xml index af8670f..0ffe0c3 100644 --- a/res/values-ru/strings.xml +++ b/res/values-ru/strings.xml @@ -26,8 +26,6 @@ NumPad раскладка Старшие цифры сверху Младшие цифры сверху - Автоматическая смена регистра - Автонажатие Shift в начале каждого предложения Добавить клавиши на клавиатуру Дополнительная раскладка Нет @@ -36,10 +34,15 @@ Расстояние между символами в углах клавиш (%s) Тайм-аут повтора клавиш Интервал повтора клавиш - Вибрация - Включение/выключение вибрации при нажатии клавиши Двойное нажатие на Shift активирует Caps lock Вы можете активировать модификатор, удерживая клавишу + + Автоматическая смена регистра + Автонажатие Shift в начале каждого предложения + + + Вибрация + Включение/выключение вибрации при нажатии клавиши Стиль Нижняя граница поля Высота клавиатуры diff --git a/res/values-tr/strings.xml b/res/values-tr/strings.xml index dddcf8b..be75893 100644 --- a/res/values-tr/strings.xml +++ b/res/values-tr/strings.xml @@ -26,8 +26,6 @@ - - Hiçbiri @@ -36,10 +34,15 @@ Tuşların köşelerindeki karakterlerin uzaklıkları (%s) Tuş tekrarlama beklemesi Tuş tekrarlama aralığı - Titreşim - Tuşa basıldığında titreşimi etkinleştir + + + + + + Titreşim + Tuşa basıldığında titreşimi etkinleştir Stil Alt boşluk Klavye yüksekliği diff --git a/res/values-vi/strings.xml b/res/values-vi/strings.xml index 8001e51..d3ab763 100644 --- a/res/values-vi/strings.xml +++ b/res/values-vi/strings.xml @@ -28,8 +28,6 @@ Bố cục NumPad Số lớn nhất trước Số nhỏ nhất trước - Tự động viết hoa - Nhấn Shift ở đầu câu Thêm phím vào bàn phím Bố cục phụ Không @@ -38,10 +36,15 @@ Khoảng cách giữa các ký tự ở góc phím (%s) Thời hạn lặp phím Khoảng thời gian lặp phím - Sự rung - Bật/tắt rung khi nhấn Nhấn hai lần Shift để bật Caps Lock Bạn có thể khóa phím hỗ trợ bằng cách giữ vào nó + + Tự động viết hoa + Nhấn Shift ở đầu câu + + + Sự rung + Bật/tắt rung khi nhấn Kiểu cách Căn lề dưới Chiều cao bàn phím diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml index 414ed95..b47f423 100644 --- a/res/values-zh-rCN/strings.xml +++ b/res/values-zh-rCN/strings.xml @@ -26,8 +26,6 @@ - 句首自动大写 - 在句子的开头自动按下Shift 选择要显示的按键 第二键盘布局 @@ -36,10 +34,15 @@ 输入按键四角的符号需要滑动的距离 (%s) 长按到开始重复输入的时间 长按后每次重复输入的时间间隔 - 振动 - 启用或者禁用按下按键时振动 双击Shift键锁定大写 任何时候都可以长按修改键以锁定 + + 句首自动大写 + 在句子的开头自动按下Shift + + + 振动 + 启用或者禁用按下按键时振动 样式 键盘下边距 键盘高度 diff --git a/res/values/strings.xml b/res/values/strings.xml index cae1a9a..3029b21 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -26,8 +26,6 @@ NumPad layout High digits first Low digits first - Automatic capitalisation - Press Shift at the beginning of a sentence Add keys to the keyboard Secondary layout None @@ -36,10 +34,15 @@ Distance of characters in the corners of the keys (%s) Key repeat timeout Key repeat interval - Vibration - Enable/disable vibration on keypress Double tap on shift for caps lock You can lock any modifier by holding it + Behavior + Automatic capitalisation + Press Shift at the beginning of a sentence + Switch to the last used keyboard + Behavior of the keyboard-switching key + Vibration + Enable/disable vibration on keypress Style Margin bottom Keyboard height diff --git a/res/xml/settings.xml b/res/xml/settings.xml index 1fdb5e6..b1771e3 100644 --- a/res/xml/settings.xml +++ b/res/xml/settings.xml @@ -47,11 +47,14 @@ - + + + + diff --git a/srcs/juloo.keyboard2/Config.java b/srcs/juloo.keyboard2/Config.java index eda2740..586db4e 100644 --- a/srcs/juloo.keyboard2/Config.java +++ b/srcs/juloo.keyboard2/Config.java @@ -48,6 +48,7 @@ final class Config public int accents; // Values are R.values.pref_accents_v_* public int theme; // Values are R.style.* public boolean autocapitalisation; + public boolean switch_input_immediate; // Dynamically set public boolean shouldOfferSwitchingToNextInputMethod; @@ -152,6 +153,7 @@ final class Config accents = Integer.valueOf(_prefs.getString("accents", "1")); theme = getThemeId(res, _prefs.getString("theme", "")); autocapitalisation = _prefs.getBoolean("autocapitalisation", true); + switch_input_immediate = _prefs.getBoolean("switch_input_immediate", false); extra_keys_param = ExtraKeyCheckBoxPreference.get_extra_keys(_prefs); } @@ -200,7 +202,11 @@ final class Config switch (key.getEvent()) { case CHANGE_METHOD: - return shouldOfferSwitchingToNextInputMethod ? key : null; + if (!shouldOfferSwitchingToNextInputMethod) + return null; + if (switch_input_immediate) + return KeyValue.getKeyByName("change_method_prev"); + return key; case ACTION: return (swapEnterActionKey && action_key != null) ? KeyValue.getKeyByName("enter") : action_key; diff --git a/srcs/juloo.keyboard2/KeyEventHandler.java b/srcs/juloo.keyboard2/KeyEventHandler.java index 5b0762e..1a591c8 100644 --- a/srcs/juloo.keyboard2/KeyEventHandler.java +++ b/srcs/juloo.keyboard2/KeyEventHandler.java @@ -48,7 +48,8 @@ class KeyEventHandler implements Config.IKeyEventHandler case SWITCH_NUMERIC: _recv.set_layout(Layout.Numeric); break; case SWITCH_EMOJI: _recv.setPane_emoji(); break; case SWITCH_BACK_EMOJI: _recv.setPane_normal(); break; - case CHANGE_METHOD: _recv.switchToNextInputMethod(); break; + case CHANGE_METHOD: _recv.switchInputMethod(); break; + case CHANGE_METHOD_PREV: _recv.switchToPrevInputMethod(); break; case ACTION: InputConnection conn = _recv.getCurrentInputConnection(); if (conn != null) @@ -179,7 +180,8 @@ class KeyEventHandler implements Config.IKeyEventHandler public static interface IReceiver { - public void switchToNextInputMethod(); + public void switchInputMethod(); + public void switchToPrevInputMethod(); public void setPane_emoji(); public void setPane_normal(); public void showKeyboardConfig(); diff --git a/srcs/juloo.keyboard2/KeyModifier.java b/srcs/juloo.keyboard2/KeyModifier.java index 1529835..392b740 100644 --- a/srcs/juloo.keyboard2/KeyModifier.java +++ b/srcs/juloo.keyboard2/KeyModifier.java @@ -70,6 +70,16 @@ class KeyModifier /** Modify a key after a long press. */ public static KeyValue modify_long_press(KeyValue k) { + switch (k.getKind()) + { + case Event: + switch (k.getEvent()) + { + case CHANGE_METHOD_PREV: + return KeyValue.getKeyByName("change_method"); + } + break; + } return k; } diff --git a/srcs/juloo.keyboard2/KeyValue.java b/srcs/juloo.keyboard2/KeyValue.java index f45bc7c..c4bd069 100644 --- a/srcs/juloo.keyboard2/KeyValue.java +++ b/srcs/juloo.keyboard2/KeyValue.java @@ -13,6 +13,7 @@ final class KeyValue SWITCH_EMOJI, SWITCH_BACK_EMOJI, CHANGE_METHOD, + CHANGE_METHOD_PREV, ACTION, SWITCH_SECOND, SWITCH_SECOND_BACK, @@ -332,6 +333,7 @@ final class KeyValue case "switch_second_back": return eventKey(0x14, Event.SWITCH_SECOND_BACK, FLAG_SMALLER_FONT); case "switch_greekmath": return eventKey("πλ∇¬", Event.SWITCH_GREEKMATH, FLAG_SMALLER_FONT); case "change_method": return eventKey(0x09, Event.CHANGE_METHOD, FLAG_SMALLER_FONT); + case "change_method_prev": return eventKey(0x09, Event.CHANGE_METHOD_PREV, FLAG_SMALLER_FONT); case "action": return eventKey("Action", Event.ACTION, FLAG_SMALLER_FONT); // Will always be replaced case "capslock": return eventKey(0x12, Event.CAPS_LOCK, 0); diff --git a/srcs/juloo.keyboard2/Keyboard2.java b/srcs/juloo.keyboard2/Keyboard2.java index 0065e0d..54caf3c 100644 --- a/srcs/juloo.keyboard2/Keyboard2.java +++ b/srcs/juloo.keyboard2/Keyboard2.java @@ -329,11 +329,21 @@ public class Keyboard2 extends InputMethodService /** Not static */ public class Receiver implements KeyEventHandler.IReceiver { - public void switchToNextInputMethod() { + public void switchInputMethod() + { InputMethodManager imm = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE); imm.showInputMethodPicker(); - // deprecated in version 28: imm.switchToNextInputMethod(getConnectionToken(), false); - // added in version 28: switchToNextInputMethod(false); + } + + public void switchToPrevInputMethod() + { + if (VERSION.SDK_INT < 28) + { + InputMethodManager imm = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE); + imm.switchToLastInputMethod(getConnectionToken()); + } + else + Keyboard2.this.switchToPreviousInputMethod(); } public void setPane_emoji()