From fce8ff7ce2920861804ccfd3e3e7cb0ff3165a33 Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Sat, 29 Jul 2023 17:29:45 +0200 Subject: Add option to disable pin entry layout The pin entry layout might be inferior for some usecases and people might be more used to the numeric layout. --- srcs/juloo.keyboard2/Config.java | 2 ++ srcs/juloo.keyboard2/Keyboard2.java | 25 ++++++++++++++++--------- 2 files changed, 18 insertions(+), 9 deletions(-) (limited to 'srcs/juloo.keyboard2') diff --git a/srcs/juloo.keyboard2/Config.java b/srcs/juloo.keyboard2/Config.java index c6b3ed4..09db10d 100644 --- a/srcs/juloo.keyboard2/Config.java +++ b/srcs/juloo.keyboard2/Config.java @@ -52,6 +52,7 @@ final class Config public int theme; // Values are R.style.* public boolean autocapitalisation; public boolean switch_input_immediate; + public boolean pin_entry_enabled; // Dynamically set public boolean shouldOfferSwitchingToNextInputMethod; @@ -157,6 +158,7 @@ final class Config switch_input_immediate = _prefs.getBoolean("switch_input_immediate", false); extra_keys_param = ExtraKeysPreference.get_extra_keys(_prefs); extra_keys_custom = CustomExtraKeysPreference.get(_prefs); + pin_entry_enabled = _prefs.getBoolean("pin_entry_enabled", true); } KeyValue action_key() diff --git a/srcs/juloo.keyboard2/Keyboard2.java b/srcs/juloo.keyboard2/Keyboard2.java index 48e60db..3606213 100644 --- a/srcs/juloo.keyboard2/Keyboard2.java +++ b/srcs/juloo.keyboard2/Keyboard2.java @@ -71,6 +71,12 @@ public class Keyboard2 extends InputMethodService return KeyboardData.load(getResources(), layout_id); } + /** Load a layout that contains a numpad (eg. the pin entry). */ + KeyboardData loadNumpad(int layout_id) + { + return _config.modify_numpad(KeyboardData.load(getResources(), layout_id)); + } + @Override public void onCreate() { @@ -154,7 +160,7 @@ public class Keyboard2 extends InputMethodService } } if (default_layout == null) - default_layout = KeyboardData.load(getResources(), R.xml.latn_qwerty_us); + default_layout = loadLayout(R.xml.latn_qwerty_us); _localeTextLayout = default_layout; if (_config.second_layout == null) { @@ -235,20 +241,21 @@ public class Keyboard2 extends InputMethodService return null; } - private void refresh_special_layout(EditorInfo info) + private KeyboardData refresh_special_layout(EditorInfo info) { switch (info.inputType & InputType.TYPE_MASK_CLASS) { case InputType.TYPE_CLASS_NUMBER: case InputType.TYPE_CLASS_PHONE: case InputType.TYPE_CLASS_DATETIME: - _currentSpecialLayout = - _config.modify_numpad(KeyboardData.load(getResources(), R.xml.pin)); - break; + if (_config.pin_entry_enabled) + return loadNumpad(R.xml.pin); + else + return loadNumpad(R.xml.numeric); default: - _currentSpecialLayout = null; break; } + return null; } @Override @@ -256,7 +263,7 @@ public class Keyboard2 extends InputMethodService { refresh_config(); refresh_action_label(info); - refresh_special_layout(info); + _currentSpecialLayout = refresh_special_layout(info); _keyboardView.setKeyboard(current_layout()); _keyeventhandler.started(info); setInputView(_keyboardView); @@ -382,7 +389,7 @@ public class Keyboard2 extends InputMethodService break; case SWITCH_NUMERIC: - setSpecialLayout(_config.modify_numpad(loadLayout(R.xml.numeric))); + setSpecialLayout(loadNumpad(R.xml.numeric)); break; case SWITCH_EMOJI: @@ -422,7 +429,7 @@ public class Keyboard2 extends InputMethodService break; case SWITCH_GREEKMATH: - setSpecialLayout(_config.modify_numpad(loadLayout(R.xml.greekmath))); + setSpecialLayout(loadNumpad(R.xml.greekmath)); break; case CAPS_LOCK: -- cgit v1.2.3