diff options
| -rw-r--r-- | res/xml/pin.xml | 27 | ||||
| -rw-r--r-- | srcs/juloo.keyboard2/Keyboard2.java | 21 | ||||
| -rw-r--r-- | srcs/juloo.keyboard2/KeyboardData.java | 3 |
3 files changed, 46 insertions, 5 deletions
diff --git a/res/xml/pin.xml b/res/xml/pin.xml new file mode 100644 index 0000000..0f0b3c6 --- /dev/null +++ b/res/xml/pin.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8"?> +<keyboard width="6.0" bottom_row="false" extra_keys="false" num_pad="false"> + <row> + <key shift="1.0" key0="1"/> + <key key0="2"/> + <key key0="3"/> + <key key0="backspace" key2="delete"/> + </row> + <row> + <key shift="1.0" key0="4"/> + <key key0="5"/> + <key key0="6"/> + <key key0="(" key3=":"/> + </row> + <row> + <key shift="1.0" key0="7"/> + <key key0="8"/> + <key key0="9"/> + <key key0=")" key3="/"/> + </row> + <row> + <key shift="1.0" key0="*" key1="switch_text" key3="switch_numeric"/> + <key key0="0" key3="+" key4="space"/> + <key key0="\#" key1="up" key2="right" key3="left" key4="down" edgekeys="true"/> + <key key0="enter" key2="action"/> + </row> +</keyboard> 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) diff --git a/srcs/juloo.keyboard2/KeyboardData.java b/srcs/juloo.keyboard2/KeyboardData.java index 21acde7..0d0a85b 100644 --- a/srcs/juloo.keyboard2/KeyboardData.java +++ b/srcs/juloo.keyboard2/KeyboardData.java @@ -136,10 +136,11 @@ class KeyboardData boolean bottom_row = parser.getAttributeBooleanValue(null, "bottom_row", true); boolean extra_keys = parser.getAttributeBooleanValue(null, "extra_keys", true); boolean num_pad = parser.getAttributeBooleanValue(null, "num_pad", true); + float specified_kw = parser.getAttributeFloatValue(null, "width", 0f); ArrayList<Row> rows = new ArrayList<Row>(); while (expect_tag(parser, "row")) rows.add(Row.parse(parser)); - float kw = compute_max_width(rows); + float kw = (specified_kw != 0f) ? specified_kw : compute_max_width(rows); if (bottom_row) rows.add(_bottomRow.updateWidth(kw)); return new KeyboardData(rows, kw, extra_keys, num_pad); |
