From 51b330c6168a8b0e0c16482254d4674fbe5476c7 Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Sun, 13 Nov 2022 00:24:23 +0100 Subject: [PATCH] Allow switching quickly between two layouts A new option allow to choose a secondary layout, the switching key is placed on the top edge of the space bar. The "Programming layout" option was basically doing that but it was possible to choose from a few layouts only. It is improved and renamed. The 'LayoutListPreference' allows setting the string for the first entry but otherwise share the rest of the array. Add nice icons from materialdesignicons. --- res/values-cs/strings.xml | 3 +-- res/values-de/strings.xml | 3 +-- res/values-it/strings.xml | 3 +-- res/values-lv/strings.xml | 3 +-- res/values-pt/strings.xml | 3 +-- res/values-ru/strings.xml | 3 +-- res/values-tr/strings.xml | 3 +-- res/values/arrays.xml | 16 ++--------- res/values/attrs.xml | 3 +++ res/values/strings.xml | 4 +-- res/xml/bone.xml | 2 +- res/xml/bottom_row.xml | 2 +- res/xml/neo2.xml | 2 +- res/xml/settings.xml | 4 +-- srcs/juloo.keyboard2/Config.java | 19 +++++++------ srcs/juloo.keyboard2/KeyEventHandler.java | 7 ++--- srcs/juloo.keyboard2/KeyValue.java | 6 +++-- srcs/juloo.keyboard2/Keyboard2.java | 16 +++++------ .../juloo.keyboard2/LayoutListPreference.java | 25 ++++++++++++++++++ srcs/special_font/09.svg | 8 ++---- srcs/special_font/13.svg | 2 ++ srcs/special_font/14.svg | 2 ++ srcs/special_font/result.ttf | Bin 7460 -> 7900 bytes 23 files changed, 75 insertions(+), 64 deletions(-) create mode 100644 srcs/juloo.keyboard2/LayoutListPreference.java create mode 100644 srcs/special_font/13.svg create mode 100644 srcs/special_font/14.svg diff --git a/res/values-cs/strings.xml b/res/values-cs/strings.xml index f6d5d20..e332475 100644 --- a/res/values-cs/strings.xml +++ b/res/values-cs/strings.xml @@ -12,8 +12,7 @@ Skrýt (univerzální) diakritická znaménka Automatická kapitalizace Stiskne Shift na začátku věty - Rozložení klávesnice pro programování - Žádné + Žádné Psaní Vzdálenost posunutí prstem Jak daleko je třeba posunout prst pro napsaní znaku/diakritiky v rozích klávey (%s) diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml index 686766f..9b49e57 100644 --- a/res/values-de/strings.xml +++ b/res/values-de/strings.xml @@ -14,9 +14,8 @@ Nie Nur im Querformat Immer - Tastaturlayout zum Programmieren Zusätzliche Zeichen zur Tastatur hinzufügen - Keines + Keines Tippen Automatische Großschreibung Shift-Taste am Satzanfang aktivieren diff --git a/res/values-it/strings.xml b/res/values-it/strings.xml index 9228673..dd44bd9 100644 --- a/res/values-it/strings.xml +++ b/res/values-it/strings.xml @@ -12,8 +12,7 @@ Nascondi accenti Maiuscole Automatiche Premi Shift all\'inizio di una frase - Layout tastiera per programmare - Nessuno + Nessuno Digitando Distanza swipe Distanza dei caratteri negli angoli dei tasti (%s) diff --git a/res/values-lv/strings.xml b/res/values-lv/strings.xml index 3c9cad1..aa6356c 100644 --- a/res/values-lv/strings.xml +++ b/res/values-lv/strings.xml @@ -17,8 +17,7 @@ Automātiski lielie burti Piespiest Shift teikuma sākumā Pievienot tastatūrai taustiņus - Tastatūras izkārtojums programmēšanai - Neviens + Neviens Rakstīšana Pavilkšanas attālums Taustiņu stūros esošo rakstzīmju attālums (%s) diff --git a/res/values-pt/strings.xml b/res/values-pt/strings.xml index 1d05d07..f008079 100644 --- a/res/values-pt/strings.xml +++ b/res/values-pt/strings.xml @@ -12,8 +12,7 @@ Ocultar acentos Maiusculização automática Aciona o shift no início de cada frase - Layout do teclado para programação - Nenhum + Nenhum Digitação Distância a deslizar Distância até acionar os cantos das teclas (%s) diff --git a/res/values-ru/strings.xml b/res/values-ru/strings.xml index bc6c31d..a7a41f3 100644 --- a/res/values-ru/strings.xml +++ b/res/values-ru/strings.xml @@ -9,8 +9,7 @@ Показывать акценты для всех установленных языков Показывать акценты только для выбранного языка Скрыть акценты - Раскладка клавиатуры для программирования - Нету + Нету Печатание Расстояние пролистывания Расстояние между символами в углах клавиш (%s) diff --git a/res/values-tr/strings.xml b/res/values-tr/strings.xml index 59ca8ae..e858307 100644 --- a/res/values-tr/strings.xml +++ b/res/values-tr/strings.xml @@ -10,8 +10,7 @@ Yüklü tüm dillerin aksanlarını göster Sadece seçili dilin aksanlarını göster Aksanları gizle - Programlama için klavye düzeni - Hiçbiri + Hiçbiri Yazma Kaydırma mesafesi Tuşların köşelerindeki karakterlerin uzaklıkları (%s) diff --git a/res/values/arrays.xml b/res/values/arrays.xml index 50c140e..17c4bd9 100644 --- a/res/values/arrays.xml +++ b/res/values/arrays.xml @@ -1,7 +1,7 @@ - system + none azerty qwerty qwerty_pt @@ -28,7 +28,7 @@ hindi - @string/pref_layout_e_system + None AZERTY QWERTY QWERTY (Brasileiro) @@ -54,18 +54,6 @@ বাংলা हिन्दी - - none - qwerty - dvorak - colemak - - - @string/pref_programming_layout_none - QWERTY - Dvorak - Colemak - @string/pref_accents_e_all_installed @string/pref_accents_e_selected diff --git a/res/values/attrs.xml b/res/values/attrs.xml index b012a7c..693ef89 100644 --- a/res/values/attrs.xml +++ b/res/values/attrs.xml @@ -3,4 +3,7 @@ + + + diff --git a/res/values/strings.xml b/res/values/strings.xml index f7f3a8b..63c55ab 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -18,8 +18,8 @@ Automatic capitalisation Press Shift at the beginning of a sentence Add keys to the keyboard - Keyboard layout for programming - None + Secondary layout + None Typing Swiping distance Distance of characters in the corners of the keys (%s) diff --git a/res/xml/bone.xml b/res/xml/bone.xml index d84622a..b6488ee 100644 --- a/res/xml/bone.xml +++ b/res/xml/bone.xml @@ -38,7 +38,7 @@ - + diff --git a/res/xml/bottom_row.xml b/res/xml/bottom_row.xml index bfd4e90..64673fc 100644 --- a/res/xml/bottom_row.xml +++ b/res/xml/bottom_row.xml @@ -2,7 +2,7 @@ - + diff --git a/res/xml/neo2.xml b/res/xml/neo2.xml index 96265f2..5bffb3c 100644 --- a/res/xml/neo2.xml +++ b/res/xml/neo2.xml @@ -41,7 +41,7 @@ - + diff --git a/res/xml/settings.xml b/res/xml/settings.xml index 4920d6c..5d7f025 100644 --- a/res/xml/settings.xml +++ b/res/xml/settings.xml @@ -1,10 +1,10 @@ - + + - diff --git a/srcs/juloo.keyboard2/Config.java b/srcs/juloo.keyboard2/Config.java index b2c23a5..6c1dced 100644 --- a/srcs/juloo.keyboard2/Config.java +++ b/srcs/juloo.keyboard2/Config.java @@ -25,7 +25,7 @@ final class Config // From preferences public int layout; // Or '-1' for the system defaults - public int programming_layout; // Or '-1' for none + public int second_layout; // Or '-1' for none public boolean show_numpad = false; public float swipe_dist_px; public boolean vibrateEnabled; @@ -46,7 +46,7 @@ final class Config // Dynamically set public boolean shouldOfferSwitchingToNextInputMethod; - public boolean shouldOfferSwitchingToProgramming; + public boolean shouldOfferSwitchingToSecond; public String actionLabel; // Might be 'null' public int actionId; // Meaningful only when 'actionLabel' isn't 'null' public boolean swapEnterActionKey; // Swap the "enter" and "action" keys @@ -65,7 +65,7 @@ final class Config sublabelTextSize = 0.22f; // default values layout = -1; - programming_layout = -1; + second_layout = -1; vibrateEnabled = true; longPressTimeout = 600; longPressInterval = 65; @@ -81,7 +81,7 @@ final class Config refresh(res); // initialized later shouldOfferSwitchingToNextInputMethod = false; - shouldOfferSwitchingToProgramming = false; + shouldOfferSwitchingToSecond = false; actionLabel = null; actionId = 0; swapEnterActionKey = false; @@ -115,10 +115,8 @@ final class Config { keyboardHeightPercent = _prefs.getInt("keyboard_height", 35); } - String layout_s = _prefs.getString("layout", "system"); - layout = layout_s.equals("system") ? -1 : layoutId_of_string(layout_s); - String prog_layout_s = _prefs.getString("programming_layout", "none"); - programming_layout = prog_layout_s.equals("none") ? -1 : layoutId_of_string(prog_layout_s); + layout = layoutId_of_string(_prefs.getString("layout", "none")); + second_layout = layoutId_of_string(_prefs.getString("second_layout", "none")); // The swipe distance is defined relatively to the "exact physical pixels // per inch of the screen", which isn't affected by the scaling settings. // Take the mean of both dimensions as an approximation of the diagonal. @@ -185,8 +183,8 @@ final class Config case ACTION: return (swapEnterActionKey && action_key != null) ? KeyValue.getKeyByName("enter") : action_key; - case SWITCH_PROGRAMMING: - return shouldOfferSwitchingToProgramming ? key : null; + case SWITCH_SECOND: + return shouldOfferSwitchingToSecond ? key : null; } break; case Keyevent: @@ -249,6 +247,7 @@ final class Config { switch (name) { + case "system": case "none": return -1; case "azerty": return R.xml.azerty; case "bangla": return R.xml.bangla; case "bgph1": return R.xml.local_bgph1; diff --git a/srcs/juloo.keyboard2/KeyEventHandler.java b/srcs/juloo.keyboard2/KeyEventHandler.java index 4623dec..5d23903 100644 --- a/srcs/juloo.keyboard2/KeyEventHandler.java +++ b/srcs/juloo.keyboard2/KeyEventHandler.java @@ -27,13 +27,14 @@ class KeyEventHandler implements Config.IKeyEventHandler switch (key.getEvent()) { case CONFIG: _recv.showKeyboardConfig(); break; - case SWITCH_TEXT: _recv.switchMain(); break; + case SWITCH_TEXT: + case SWITCH_SECOND_BACK: _recv.switchMain(); break; case SWITCH_NUMERIC: _recv.switchNumeric(); break; case SWITCH_EMOJI: _recv.setPane_emoji(); break; case SWITCH_BACK_EMOJI: _recv.setPane_normal(); break; case CHANGE_METHOD: _recv.switchToNextInputMethod(); break; case ACTION: _recv.performAction(); break; - case SWITCH_PROGRAMMING: _recv.switchProgramming(); break; + case SWITCH_SECOND: _recv.switchSecond(); break; case SWITCH_GREEKMATH: _recv.switchGreekmath(); break; case CAPS_LOCK: _recv.enableCapsLock(); break; } @@ -107,7 +108,7 @@ class KeyEventHandler implements Config.IKeyEventHandler public void switchMain(); public void switchNumeric(); - public void switchProgramming(); + public void switchSecond(); public void switchGreekmath(); public void sendKeyEvent(int eventAction, int eventCode, int meta); diff --git a/srcs/juloo.keyboard2/KeyValue.java b/srcs/juloo.keyboard2/KeyValue.java index e8155f6..0c19eb7 100644 --- a/srcs/juloo.keyboard2/KeyValue.java +++ b/srcs/juloo.keyboard2/KeyValue.java @@ -15,7 +15,8 @@ final class KeyValue SWITCH_BACK_EMOJI, CHANGE_METHOD, ACTION, - SWITCH_PROGRAMMING, + SWITCH_SECOND, + SWITCH_SECOND_BACK, SWITCH_GREEKMATH, CAPS_LOCK, } @@ -304,7 +305,8 @@ final class KeyValue addEventKey("switch_numeric", "123+", Event.SWITCH_NUMERIC, FLAG_SMALLER_FONT); addEventKey("switch_emoji", 0x01, Event.SWITCH_EMOJI, FLAG_SMALLER_FONT); addEventKey("switch_back_emoji", "ABC", Event.SWITCH_BACK_EMOJI, 0); - addEventKey("switch_programming", "Prog", Event.SWITCH_PROGRAMMING, FLAG_SMALLER_FONT); + addEventKey("switch_second", 0x13, Event.SWITCH_SECOND, FLAG_SMALLER_FONT); + addEventKey("switch_second_back", 0x14, Event.SWITCH_SECOND_BACK, FLAG_SMALLER_FONT); addEventKey("switch_greekmath", "πλ∇¬", Event.SWITCH_GREEKMATH, FLAG_SMALLER_FONT); addEventKey("change_method", 0x09, Event.CHANGE_METHOD, FLAG_SMALLER_FONT); addEventKey("action", "Action", Event.ACTION, FLAG_SMALLER_FONT); // Will always be replaced diff --git a/srcs/juloo.keyboard2/Keyboard2.java b/srcs/juloo.keyboard2/Keyboard2.java index 7bf9812..d2fdb2c 100644 --- a/srcs/juloo.keyboard2/Keyboard2.java +++ b/srcs/juloo.keyboard2/Keyboard2.java @@ -157,9 +157,9 @@ public class Keyboard2 extends InputMethodService refreshAccentsOption(imm, subtype); } } - _config.shouldOfferSwitchingToProgramming = - _config.programming_layout != -1 && - _currentTextLayout != _config.programming_layout; + _config.shouldOfferSwitchingToSecond = + _config.second_layout != -1 && + _currentTextLayout != _config.second_layout; } private String actionLabel_of_imeAction(int action) @@ -343,17 +343,17 @@ public class Keyboard2 extends InputMethodService _keyboardView.setKeyboard(getLayout(R.xml.greekmath)); } - public void switchProgramming() + public void switchSecond() { - if (_config.programming_layout == -1) + if (_config.second_layout == -1) return; KeyboardData layout = - getLayout(_config.programming_layout).mapKeys(new KeyboardData.MapKeyValues() { + getLayout(_config.second_layout).mapKeys(new KeyboardData.MapKeyValues() { public KeyValue apply(KeyValue key, boolean localized) { if (key.getKind() == KeyValue.Kind.Event - && key.getEvent() == KeyValue.Event.SWITCH_PROGRAMMING) - return KeyValue.getKeyByName("switch_text"); + && key.getEvent() == KeyValue.Event.SWITCH_SECOND) + return KeyValue.getKeyByName("switch_second_back"); return key; } }); diff --git a/srcs/juloo.keyboard2/LayoutListPreference.java b/srcs/juloo.keyboard2/LayoutListPreference.java new file mode 100644 index 0000000..9e3072c --- /dev/null +++ b/srcs/juloo.keyboard2/LayoutListPreference.java @@ -0,0 +1,25 @@ +package juloo.keyboard2; + +import android.content.Context; +import android.content.res.Resources; +import android.content.res.TypedArray; +import android.preference.ListPreference; +import android.util.AttributeSet; + +public class LayoutListPreference extends ListPreference +{ + public LayoutListPreference(Context context, AttributeSet attrs) + { + super(context, attrs); + final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.LayoutListPreference); + String defaultString = a.getString(R.styleable.LayoutListPreference_defaultString); + a.recycle(); + Resources res = context.getResources(); + String[] entries = res.getStringArray(R.array.pref_layout_entries); + entries[0] = defaultString; + setEntries(entries); + setEntryValues(res.getStringArray(R.array.pref_layout_values)); + setSummary("%s"); + setDefaultValue("none"); + } +} diff --git a/srcs/special_font/09.svg b/srcs/special_font/09.svg index 049cc30..ebdc956 100644 --- a/srcs/special_font/09.svg +++ b/srcs/special_font/09.svg @@ -1,6 +1,2 @@ - - - - - - + + diff --git a/srcs/special_font/13.svg b/srcs/special_font/13.svg new file mode 100644 index 0000000..6b4f78a --- /dev/null +++ b/srcs/special_font/13.svg @@ -0,0 +1,2 @@ + + diff --git a/srcs/special_font/14.svg b/srcs/special_font/14.svg new file mode 100644 index 0000000..48b39cc --- /dev/null +++ b/srcs/special_font/14.svg @@ -0,0 +1,2 @@ + + diff --git a/srcs/special_font/result.ttf b/srcs/special_font/result.ttf index f81838f461415be7d0b605dd313e469d996a378f..31a4892a1dc4ae941032ffbd53627bb08b7aa8d4 100644 GIT binary patch delta 1062 zcmbtTUr19?82`>WcYky?9qu~+OxxXc(-hQ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