From 78a461f7406a5ac76b686c646e8229fc8bb2a0d0 Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Mon, 30 Jan 2023 23:46:02 +0100 Subject: Modification step for the special layout Refactor, follow up of 90b7944. Add a modification step to the "special" layouts: numpad, greekmath, pin entry. Remove the apply_key0 function, which is not expressive enough. Add an enum instead of yet an other "switch_" function. --- srcs/juloo.keyboard2/KeyEventHandler.java | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'srcs/juloo.keyboard2/KeyEventHandler.java') diff --git a/srcs/juloo.keyboard2/KeyEventHandler.java b/srcs/juloo.keyboard2/KeyEventHandler.java index 3031972..5b0762e 100644 --- a/srcs/juloo.keyboard2/KeyEventHandler.java +++ b/srcs/juloo.keyboard2/KeyEventHandler.java @@ -44,8 +44,8 @@ class KeyEventHandler implements Config.IKeyEventHandler switch (key.getEvent()) { case CONFIG: _recv.showKeyboardConfig(); break; - case SWITCH_TEXT: _recv.switch_text(); break; - case SWITCH_NUMERIC: _recv.switch_layout(R.xml.numeric); break; + case SWITCH_TEXT: _recv.set_layout(Layout.Current); break; + 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; @@ -54,9 +54,9 @@ class KeyEventHandler implements Config.IKeyEventHandler if (conn != null) conn.performEditorAction(actionId); break; - case SWITCH_SECOND: _recv.switch_second(); break; - case SWITCH_SECOND_BACK: _recv.switch_primary(); break; - case SWITCH_GREEKMATH: _recv.switch_layout(R.xml.greekmath); break; + case SWITCH_SECOND: _recv.set_layout(Layout.Secondary); break; + case SWITCH_SECOND_BACK: _recv.set_layout(Layout.Primary); break; + case SWITCH_GREEKMATH: _recv.set_layout(Layout.Greekmath); break; case CAPS_LOCK: _recv.set_shift_state(true, true); break; } break; @@ -168,20 +168,23 @@ class KeyEventHandler implements Config.IKeyEventHandler conn.performContextMenuAction(id); } + public enum Layout + { + Current, // The primary or secondary layout + Primary, + Secondary, + Numeric, + Greekmath + } + public static interface IReceiver { public void switchToNextInputMethod(); public void setPane_emoji(); public void setPane_normal(); public void showKeyboardConfig(); - - public void switch_text(); - public void switch_primary(); - public void switch_second(); - public void switch_layout(int layout_id); - + public void set_layout(Layout l); public void set_shift_state(boolean state, boolean lock); - public InputConnection getCurrentInputConnection(); } -- cgit v1.2.3