abouttreesummaryrefslogcommitdiff
path: root/srcs/juloo.keyboard2/Keyboard2.java
diff options
context:
space:
mode:
authorJules Aguillon2025-12-18 19:15:32 +0100
committerGitHub2025-12-18 19:15:32 +0100
commit41777fdda61715a59be241f0be9a8e3385222888 (patch)
treebcddb5a4a29af2caf37e1f565efcfbffdd6814be /srcs/juloo.keyboard2/Keyboard2.java
parentbe0aa07a2a728509b6244e00247bfe2fff5c66e0 (diff)
downloadunexpected-keyboard-41777fdda61715a59be241f0be9a8e3385222888.tar.gz
unexpected-keyboard-41777fdda61715a59be241f0be9a8e3385222888.zip
Disable selection mode in text editors (#1141)
* Disable selection mode in text editors Selection mode removes the space bar key (which is replaced by the Esc key) and can be annoying in Emacs for example. Text editor users probably have the `esc` key available. * Refactor: Move EditorInfo related code to EditorConfig Add the new EditorConfig class that handles configuration extracted from the EditorInfo. It is accessible from the Config class for convenience. This aims at reducing the length of already large classes and group the code that was spread over several classes.
Diffstat (limited to 'srcs/juloo.keyboard2/Keyboard2.java')
-rw-r--r--srcs/juloo.keyboard2/Keyboard2.java65
1 files changed, 11 insertions, 54 deletions
diff --git a/srcs/juloo.keyboard2/Keyboard2.java b/srcs/juloo.keyboard2/Keyboard2.java
index 0297cc4..f0408e0 100644
--- a/srcs/juloo.keyboard2/Keyboard2.java
+++ b/srcs/juloo.keyboard2/Keyboard2.java
@@ -38,7 +38,6 @@ public class Keyboard2 extends InputMethodService
private KeyboardData _localeTextLayout;
private ViewGroup _emojiPane = null;
private ViewGroup _clipboard_pane = null;
- public int actionId; // Action performed by the Action key.
private Handler _handler;
private Config _config;
@@ -202,44 +201,6 @@ public class Keyboard2 extends InputMethodService
_localeTextLayout = default_layout;
}
- private String actionLabel_of_imeAction(int action)
- {
- int res;
- switch (action)
- {
- case EditorInfo.IME_ACTION_NEXT: res = R.string.key_action_next; break;
- case EditorInfo.IME_ACTION_DONE: res = R.string.key_action_done; break;
- case EditorInfo.IME_ACTION_GO: res = R.string.key_action_go; break;
- case EditorInfo.IME_ACTION_PREVIOUS: res = R.string.key_action_prev; break;
- case EditorInfo.IME_ACTION_SEARCH: res = R.string.key_action_search; break;
- case EditorInfo.IME_ACTION_SEND: res = R.string.key_action_send; break;
- case EditorInfo.IME_ACTION_UNSPECIFIED:
- case EditorInfo.IME_ACTION_NONE:
- default: return null;
- }
- return getResources().getString(res);
- }
-
- private void refresh_action_label(EditorInfo info)
- {
- // First try to look at 'info.actionLabel', if it isn't set, look at
- // 'imeOptions'.
- if (info.actionLabel != null)
- {
- _config.actionLabel = info.actionLabel.toString();
- actionId = info.actionId;
- _config.swapEnterActionKey = false;
- }
- else
- {
- int action = info.imeOptions & EditorInfo.IME_MASK_ACTION;
- _config.actionLabel = actionLabel_of_imeAction(action); // Might be null
- actionId = action;
- _config.swapEnterActionKey =
- (info.imeOptions & EditorInfo.IME_FLAG_NO_ENTER_ACTION) == 0;
- }
- }
-
/** Might re-create the keyboard view. [_keyboardView.setKeyboard()] and
[setInputView()] must be called soon after. */
private void refresh_config()
@@ -258,19 +219,15 @@ public class Keyboard2 extends InputMethodService
_keyboardView.reset();
}
- private KeyboardData refresh_special_layout(EditorInfo info)
+ private KeyboardData refresh_special_layout()
{
- switch (info.inputType & InputType.TYPE_MASK_CLASS)
+ if (_config.editor_config.numeric_layout)
{
- case InputType.TYPE_CLASS_NUMBER:
- case InputType.TYPE_CLASS_PHONE:
- case InputType.TYPE_CLASS_DATETIME:
- if (_config.selected_number_layout == NumberLayout.PIN)
- return loadPinentry(R.xml.pin);
- else if (_config.selected_number_layout == NumberLayout.NUMBER)
- return loadNumpad(R.xml.numeric);
- default:
- break;
+ switch (_config.selected_number_layout)
+ {
+ case PIN: return loadPinentry(R.xml.pin);
+ case NUMBER: return loadNumpad(R.xml.numeric);
+ }
}
return null;
}
@@ -278,11 +235,11 @@ public class Keyboard2 extends InputMethodService
@Override
public void onStartInputView(EditorInfo info, boolean restarting)
{
+ _config.editor_config.refresh(info, getResources());
refresh_config();
- refresh_action_label(info);
- _currentSpecialLayout = refresh_special_layout(info);
+ _currentSpecialLayout = refresh_special_layout();
_keyboardView.setKeyboard(current_layout());
- _keyeventhandler.started(info);
+ _keyeventhandler.started(_config);
setInputView(_keyboardView);
Logs.debug_startup_input_view(info, _config);
}
@@ -453,7 +410,7 @@ public class Keyboard2 extends InputMethodService
case ACTION:
InputConnection conn = getCurrentInputConnection();
if (conn != null)
- conn.performEditorAction(actionId);
+ conn.performEditorAction(_config.editor_config.actionId);
break;
case SWITCH_FORWARD: