abouttreesummaryrefslogcommitdiff
path: root/srcs/juloo.keyboard2/Keyboard2.java
diff options
context:
space:
mode:
authorJules Aguillon2023-01-30 23:46:02 +0100
committerJules Aguillon2023-01-30 23:46:02 +0100
commit78a461f7406a5ac76b686c646e8229fc8bb2a0d0 (patch)
treed39a0aa97789bafee10ee61fd4bf7506f3432702 /srcs/juloo.keyboard2/Keyboard2.java
parent90b7944129ae0facc5c789f0a416f7ff36925a90 (diff)
downloadunexpected-keyboard-78a461f7406a5ac76b686c646e8229fc8bb2a0d0.tar.gz
unexpected-keyboard-78a461f7406a5ac76b686c646e8229fc8bb2a0d0.zip
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.
Diffstat (limited to 'srcs/juloo.keyboard2/Keyboard2.java')
-rw-r--r--srcs/juloo.keyboard2/Keyboard2.java57
1 files changed, 35 insertions, 22 deletions
diff --git a/srcs/juloo.keyboard2/Keyboard2.java b/srcs/juloo.keyboard2/Keyboard2.java
index 5070439..0065e0d 100644
--- a/srcs/juloo.keyboard2/Keyboard2.java
+++ b/srcs/juloo.keyboard2/Keyboard2.java
@@ -64,6 +64,17 @@ public class Keyboard2 extends InputMethodService
_keyboardView.setKeyboard(current_layout());
}
+ void setSpecialLayout(KeyboardData l)
+ {
+ _currentSpecialLayout = l;
+ _keyboardView.setKeyboard(l);
+ }
+
+ KeyboardData loadLayout(int layout_id)
+ {
+ return KeyboardData.load(getResources(), layout_id);
+ }
+
@Override
public void onCreate()
{
@@ -248,7 +259,8 @@ public class Keyboard2 extends InputMethodService
case InputType.TYPE_CLASS_NUMBER:
case InputType.TYPE_CLASS_PHONE:
case InputType.TYPE_CLASS_DATETIME:
- _currentSpecialLayout = KeyboardData.load_pin_entry(getResources());
+ _currentSpecialLayout =
+ _config.modify_numpad(KeyboardData.load_pin_entry(getResources()));
break;
default:
_currentSpecialLayout = null;
@@ -317,8 +329,7 @@ public class Keyboard2 extends InputMethodService
/** Not static */
public class Receiver implements KeyEventHandler.IReceiver
{
- public void switchToNextInputMethod()
- {
+ public void switchToNextInputMethod() {
InputMethodManager imm = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
imm.showInputMethodPicker();
// deprecated in version 28: imm.switchToNextInputMethod(getConnectionToken(), false);
@@ -342,26 +353,28 @@ public class Keyboard2 extends InputMethodService
_keyboardView.set_shift_state(state, lock);
}
- public void switch_text()
- {
- _currentSpecialLayout = null;
- _keyboardView.setKeyboard(current_layout());
- }
-
- public void switch_layout(int layout_id)
+ public void set_layout(KeyEventHandler.Layout l)
{
- _keyboardView.setKeyboard(KeyboardData.load(getResources(), layout_id));
- }
-
- public void switch_second()
- {
- if (_config.second_layout != null)
- setTextLayout(Current_text_layout.SECONDARY);
- }
-
- public void switch_primary()
- {
- setTextLayout(Current_text_layout.PRIMARY);
+ switch (l)
+ {
+ case Current:
+ _currentSpecialLayout = null;
+ _keyboardView.setKeyboard(current_layout());
+ break;
+ case Primary:
+ setTextLayout(Current_text_layout.PRIMARY);
+ break;
+ case Secondary:
+ if (_config.second_layout != null)
+ setTextLayout(Current_text_layout.SECONDARY);
+ break;
+ case Numeric:
+ setSpecialLayout(_config.modify_numpad(loadLayout(R.xml.numeric)));
+ break;
+ case Greekmath:
+ setSpecialLayout(_config.modify_numpad(loadLayout(R.xml.greekmath)));
+ break;
+ }
}
public void showKeyboardConfig()