abouttreesummaryrefslogcommitdiff
path: root/srcs/juloo.keyboard2/Autocapitalisation.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/Autocapitalisation.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/Autocapitalisation.java')
-rw-r--r--srcs/juloo.keyboard2/Autocapitalisation.java39
1 files changed, 6 insertions, 33 deletions
diff --git a/srcs/juloo.keyboard2/Autocapitalisation.java b/srcs/juloo.keyboard2/Autocapitalisation.java
index ec730d5..31d9a7b 100644
--- a/srcs/juloo.keyboard2/Autocapitalisation.java
+++ b/srcs/juloo.keyboard2/Autocapitalisation.java
@@ -2,8 +2,6 @@ package juloo.keyboard2;
import android.os.Handler;
import android.text.InputType;
-import android.text.TextUtils;
-import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.view.KeyEvent;
@@ -22,10 +20,6 @@ public final class Autocapitalisation
/** Keep track of the cursor to recognize cursor movements from typing. */
int _cursor;
- static int SUPPORTED_CAPS_MODES =
- InputType.TYPE_TEXT_FLAG_CAP_SENTENCES |
- InputType.TYPE_TEXT_FLAG_CAP_WORDS;
-
public Autocapitalisation(Handler h, Callback cb)
{
_handler = h;
@@ -37,18 +31,19 @@ public final class Autocapitalisation
* [started] does initialisation work and must be called before any other
* event.
*/
- public void started(EditorInfo info, InputConnection ic)
+ public void started(Config config, InputConnection ic)
{
_ic = ic;
- _caps_mode = info.inputType & TextUtils.CAP_MODE_SENTENCES;
- if (!Config.globalConfig().autocapitalisation || _caps_mode == 0)
+ EditorConfig ec = config.editor_config;
+ if (!config.autocapitalisation || ec.caps_mode == 0)
{
_enabled = false;
return;
}
_enabled = true;
- _should_enable_shift = (info.initialCapsMode != 0);
- _should_update_caps_mode = started_should_update_state(info.inputType);
+ _caps_mode = ec.caps_mode;
+ _should_enable_shift = ec.caps_initially_enabled;
+ _should_update_caps_mode = ec.caps_initially_updated;
callback_now(true);
}
@@ -178,26 +173,4 @@ public final class Autocapitalisation
return false;
}
}
-
- /** Whether the caps state should be updated when input starts. [inputType]
- is the field from the editor info object. */
- boolean started_should_update_state(int inputType)
- {
- int class_ = inputType & InputType.TYPE_MASK_CLASS;
- int variation = inputType & InputType.TYPE_MASK_VARIATION;
- if (class_ != InputType.TYPE_CLASS_TEXT)
- return false;
- switch (variation)
- {
- case InputType.TYPE_TEXT_VARIATION_LONG_MESSAGE:
- case InputType.TYPE_TEXT_VARIATION_NORMAL:
- case InputType.TYPE_TEXT_VARIATION_PERSON_NAME:
- case InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE:
- case InputType.TYPE_TEXT_VARIATION_EMAIL_SUBJECT:
- case InputType.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT:
- return true;
- default:
- return false;
- }
- }
}