From e01a2733b14e6c19cad3b5048a0b43f0563d7d51 Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Mon, 24 Oct 2022 00:17:55 +0200 Subject: Add the pin entry layout The layout is used for phone number and datetime input boxes as well as some numbers. It is easier to use when the full numeric layout is not needed. --- srcs/juloo.keyboard2/Keyboard2.java | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'srcs/juloo.keyboard2/Keyboard2.java') diff --git a/srcs/juloo.keyboard2/Keyboard2.java b/srcs/juloo.keyboard2/Keyboard2.java index 35d5b26..972f266 100644 --- a/srcs/juloo.keyboard2/Keyboard2.java +++ b/srcs/juloo.keyboard2/Keyboard2.java @@ -225,15 +225,28 @@ public class Keyboard2 extends InputMethodService Log.d(TAG, "actionLabel: "+_config.actionLabel); } + private int chooseLayout(EditorInfo info) + { + switch (info.inputType & InputType.TYPE_MASK_CLASS) + { + case InputType.TYPE_CLASS_NUMBER: + if ((info.inputType & (InputType.TYPE_NUMBER_FLAG_DECIMAL | InputType.TYPE_NUMBER_FLAG_SIGNED)) != 0) + return R.xml.numeric; + return R.xml.pin; + case InputType.TYPE_CLASS_PHONE: + case InputType.TYPE_CLASS_DATETIME: + return R.xml.pin; + default: + return _currentTextLayout; + } + } + @Override public void onStartInputView(EditorInfo info, boolean restarting) { refreshConfig(); refresh_action_label(info); - if ((info.inputType & InputType.TYPE_CLASS_NUMBER) != 0) - _keyboardView.setKeyboard(getLayout(R.xml.numeric)); - else - _keyboardView.setKeyboard(getLayout(_currentTextLayout)); + _keyboardView.setKeyboard(getLayout(chooseLayout(info))); _autocap.started(info, getCurrentInputConnection()); setInputView(_keyboardView); if (_debug_logs) -- cgit v1.2.3