Commit Graph

556 Commits

Author SHA1 Message Date
Jules Aguillon
6ac973cfda Don't cap indication length
This was inadvertently changed when the anti-circle gesture was
introduced, which use the same rendering logic.
2024-06-06 00:30:22 +02:00
Jules Aguillon
cf1aaa3bdf Add compose sequences for Greek, Cyrillic, Hebrew and more
Parse key names from keysymdef.h, which is distributed with Xorg. The
Greek, Cyrillic and Hebrew sequences referenced these keysyms.

This increases the number of sequences from 2043 to 2668.
2024-05-29 15:56:08 +02:00
Jules Aguillon
39b3f50aa3 Allow compose sequence ending with more symbols
Change the compose state machine definition to allow final states that
are wider than 16-bits.

This increases the number of sequences that can be used from
en_US_UTF_8_Compose.pre from 2013 to 2043 (of 3201).
2024-05-29 15:02:08 +02:00
Jules Aguillon
93d58571cc
Fix overflow due to navigation on the right and cutouts (#641)
Take display cutouts and navigation bars when computing the keyboard
width on SDK >= 30.
2024-05-29 12:00:41 +02:00
Jules Aguillon
1a290f96f2
Configure anticircle gesture per-key (#644)
This adds the new 'anticircle' attribute to layouts '<key>' elements
that configure the key to send when doing a anti-clockwise circle
gesture on it.

Labels are drawn the same way as indication.

Updated docs.
2024-05-29 11:59:54 +02:00
Jules Aguillon
304375268d Fix uninitialized bottom_row when editing custom layout
This happen when opening the settings from the launcher activity without
ever opening the keyboard.

To remove this bug entirely, the KeyboardData.init method is removed,
the pieces needing initialization are now cached in Config.
2024-05-29 11:56:26 +02:00
Jules Aguillon
9d89297c15 Fix off-by-one error in 1-row layouts 2024-05-27 23:59:09 +02:00
Jules Aguillon
46f3b41393 Support the nnbsp character 2024-05-26 00:49:15 +02:00
Jules Aguillon
4906f8105f
Circle and round trip gestures (#640)
This implements clockwise/anticlockwise circle and round trip gestures
inspired by Messagease.

The circle gestures start after a small threshold to avoid making the
regular swipe too hard to aim.

The gestures do:

- circle: The center symbol with Shift applied, with a fallback on Fn
- round trip: Same as the circle gesture but applied to a side symbol
- anticlockwise circle: Nothing currently. It is intended to be made
  configurable per-layout in the future.

The new Gesture class keeps track of what the pointer is doing while it moves
on a key. It replaces the 'selected_direction' integer.
2024-05-25 21:19:44 +02:00
Quinn Cypher
a91332a903
Pull the emoji list from unicode.org (#612)
- Removing unused information (names and descriptions) from the Emoji class
- Creating a Gradle task that generates a more efficient res/raw/emojis.txt file from the most recent Unicode standard
- Saving recently used emoji preferences as emoji values rather than names
- Migrating old user preferences to the new system
2024-05-08 13:02:19 +02:00
Spike
53e04d5784
Compass-point synonyms for edge keys in layouts (#628) 2024-05-08 12:51:11 +02:00
alotbsol555
c7d33356bc
Add settings button to launcher app (#629) 2024-05-05 11:22:34 +02:00
Jules Aguillon
69ab869079
Hangul support (#595)
* Hangul support

This works with two new kinds of keys (Hangul_initial and Hangul_medial)
that carry a precomposed hangul syllable and act as modifiers.

The hangul syllables are composed algorithmically.

* Add shift layer to Dubeolsik layout
2024-05-02 20:52:18 +02:00
Jules Aguillon
d96414c6c6 Allow the newline character '\n' in layouts 2024-05-02 19:37:18 +02:00
Jules Aguillon
0f11a88418
More precise and faster spacebar slider (#593)
* Make slider speed independent from swipe distance

Swipe distances other than the default resulted in a slider that were
not easy to control.

* refactor: Add class Pointers.Sliding

It holds the states and the code needed to make the slider work.
'Pointer.sliding' is set to [null] when sliding is not in progress.

The implementation is changed not to depend on [downX] and [dx] but
instead use the pointer's [x] coordinate directly.

* Move the cursor further for faster slides

In sliding mode, compute the speed of the pointer and use it to increase
at which the cursor moves.

* refactor: Separate kind for cursor movement keys

This allows to define a key that moves the cursor more than one position
at a time.

This will be used to avoid lag during fast slider movements.

* Reduce lag when sliding quickly on the spacebar

Avoid sending key events in a loop while sliding quickly in a cursor
movement key. Key of kind Cursor_move are "multiplied", meaning a single
key event represents a movement of more than one position, reducing the
number of key events sent.
This is only for cursor move keys.
2024-05-02 19:31:48 +02:00
alotbsol555
82e0840568
allow for <fn ...> in <modmap> (#626) 2024-05-02 12:09:39 +02:00
Jules Aguillon
c7ed2bcae9 Clear cache when changing layout
Due to the modmap, the cache must be cleared when switching layout to or
from a layout that contain a modmap.

This is broken since 3f6b6fd23, which moves the modmap handling into
KeyModifier.
2024-05-02 12:06:15 +02:00
JapanYoshi
5386541db3
Add more accented characters to KeyModifier.java (#622) 2024-04-25 13:24:52 +02:00
Jules Aguillon
78f85e52a2 Fix space key without a symbol
The symbol on the space key was accidentally lost in be97364 when the
string "\r" (Java's only way to write "\x0D") was not replaced by
"\xE00D".
2024-04-03 23:59:18 +02:00
Jules Aguillon
3f6b6fd232 refactor: Apply the modmap in KeyModifier
This makes possible to apply other modifiers to mapped keys and ensures
that the modmap really override the shift key behavior.
2024-04-01 23:01:21 +02:00
Jules Aguillon
e604f6fd57 refactor: Implement Compose without global state
Thanks to the previous commit, a modifier key can now be more complex
than just a KeyValue.Modifier. This allows a more elegant implementation
of the compose key, that could be taken as a base for other features
(eg. unicode hex entry, hangul)

The COMPOSE_PENDING modifier is removed as keys of kind Compose_pending
can act as a modifier. This has the advantage of highlighting the key
that was last pressed in the sequence.

Rules are added to Pointers: Non-special but latchable keys must clear
latches and cannot be locked with a long press. These rules were not
needed before but were intended.
2024-03-18 01:00:22 +01:00
Jules Aguillon
dc3a303af1 refactor: Allow modifier of other key kinds
Allow keys of a kind other than Modifier to be a modifier.

This requires writing a compareTo function for KeyValue. Fields are
compared in this order: Kind, value, flags, symbol.
2024-03-18 00:40:15 +01:00
Jules Aguillon
ec8e78d5cc refactor: Use Pointers.Modifiers.has less
The performance characteristics of this function will change in future
plans.
2024-03-18 00:09:32 +01:00
Jules Aguillon
0549c6c8a1 Fix potential out of bounds access
The preferred pos mechanism could cause an out of bounds access on 1 row
layouts.
2024-03-16 23:42:37 +01:00
Jules Aguillon
5c19140609 refactor: Pointers: Flag for sliding state 2024-03-11 00:38:37 +01:00
Jules Aguillon
47e2009da4 refactor: Add latched flag to Pointers 2024-03-11 00:29:12 +01:00
Jules Aguillon
b33bcd8865 refactor: Use internal flags in Pointers
'FLAG_LOCKED' and 'FLAG_FAKE_PTR' are only used within Pointers.
Define new flags in Pointers and remove these from KeyValue. Also allows
to define new flags.
2024-03-11 00:24:25 +01:00
Yogesh-B
a1de69bcc4
Gujarati phonetic layout (#562)
added shift modifier characters
Add support for gujarati numerals

Co-authored-by: yogesh-b <yogesh@improwised.com>
2024-03-03 23:12:52 +01:00
Jules Aguillon
5e5937b0f4 Fix auto-capitalisation disabling locked shift
Shift locked via the "caps lock" key use the "fake pointer" mechanism
that is also used by auto-capitalisation.

Make sure that unlatching a fake pointer do not disabled a locked
modifier.

The implementation is moved into the Pointers class for a safer API and
easier implementation.
2024-03-03 17:14:01 +01:00
Jules Aguillon
8b5d971fb5 Modify the number row according to the numpad script
The same way as the numpad is modified.
2024-02-28 23:19:50 +01:00
Jules Aguillon
8c7559d8f6 Fix localized numpad outputing wester arabic numbers
The number keys were constructed in the wrong way: the rendered symbol
was correct but not the underlying character that is typed.
2024-02-28 20:42:52 +01:00
Jules Aguillon
b8e673b614 Ensure the layout contain the config key
Without the config key, the user risk being locked in a custom layout
that lacks an escape key like 'switch_numpad', 'change_method', etc..
2024-02-22 19:10:31 +01:00
Jules Aguillon
e40558677e Allow to remove the compose key in the settings 2024-02-17 23:28:31 +01:00
Jules Aguillon
146d520325 compose: Grey out keys that are not in sequence
Keys that are not in the pending compose sequence are greyed out with
the new 'FLAG_GREYED' flag.
2024-02-17 23:28:31 +01:00
Jules Aguillon
065d9520e5 Dim secondary keys in every themes
Themes do not dim secondary keys the same way due to the "offset"
mechanism. Instead, use a ratio that is the same for every themes.

It's still possible to override this ratio per theme.
2024-02-17 23:28:31 +01:00
Jules Aguillon
bb60ed9b13 Fix KeyValue flags layout
The kind field wasn't large enough to hold the new Compose_pending kind.
The flags field is reduced in size by removing a free spot.

The FLAGS_BITS mask is defined in a safer way.
2024-02-17 23:28:31 +01:00
Jules Aguillon
d56e4d129e compose: Add glyph 2024-02-17 23:28:31 +01:00
Jules Aguillon
e9f734b6cc compose: Don't remove keys not in sequence
Keys that are not part of any possible sequences are now dimmed and
still usable instead of being removed, which felt weird.
2024-02-17 23:28:31 +01:00
Jules Aguillon
63e7ac2e94 compose: Add X11 compose sequences
compile.py implements a parser for X11's Compose.pre files. A lot of
code is necessary to interpret character names but thanksfully, the name
of most characters is contained in the file.

The state machine is compiled into two char arrays which unfortunately
requires an expensive initialisation and allocation.
2024-02-17 23:28:31 +01:00
Jules Aguillon
8c29073260 Compose key
The COMPOSE_PENDING modifier indicate whether a compose sequence is in
progress. The new key of kind Compose_pending sets the current state of
the sequence.

The compose sequences are compiled into a state machine by a python
script into a compact encoding.

The state of the pending compose is determined by the index of a state.
2024-02-17 23:28:31 +01:00
Jules Aguillon
d96577963e Don't invert the pin entry layout
The pin entry layout shouldn't be inverted as the letter indications
would be meaningless and the order would be opposite to what the option
specifies.

The enter and action key are swapped as the automatic swapping is also
removed.
2024-02-14 22:52:25 +01:00
Jules Aguillon
f4d88cc087 Fix various linter warnings
Among others:
- Use `apply` instead of `commit` when saving shared preferences.
- Avoid inlined Api
- Remove unused resources
2024-02-10 18:10:49 +01:00
Jules Aguillon
d5676d683f Fix compatibility with Android 3.0
Incompatible APIs were used in the custom layouts and the extra keys
options.

Add @TargetApi annotations to help catch similar issues in the future
with the help of 'gradle lint'.
2024-02-10 17:33:42 +01:00
Jules Aguillon
332413ed3c Drop support for Android versions below 3.0
Android 3.0 (API level 11) was released in Feb 2011.

These versions were already unsupported due to unavoidable calls to:
- MotionEvent.getActionMasked() (API 8)

And avoidable calls to:
- SharedPreferences.Editor.putStringSet() (API 11)
2024-02-10 17:24:15 +01:00
RetrogisusDEV
93d8af4505
Custom border settings (#524) 2024-02-10 11:38:46 +01:00
Jules Aguillon
be053b082c Add more Russian vowels combined with acute accent 2024-02-06 23:32:58 +01:00
Jules Aguillon
2c52e94e0b Workaround cursor slider bug in Acode
Moving the cursor with setSelection has no effect on Acode, for which
the fallback must be used.
2024-02-04 00:29:07 +01:00
Jules Aguillon
bbc6226839 Redefined the key margin options in percent
Define the key margin options relative to the baseline dimensions of
keys. This removes the doubling of the horizontal margin in landscape
mode.
2024-01-28 19:38:29 +01:00
Jules Aguillon
c5f2c0b727 Send down event for modifiers on time
This allows to use modifiers in combination with other inputs like a
mouse click, for example under termux-x11.

The key down event and notification about modifiers changing are sent
down to KeyEventHandler. A mutable state remember for which modifier
down events have been sent.

When pressing down a modifier with one finger and typing with the
other, it might appear that the modifier is released after the first
time an other key is pressed and then pressed and released for the
following keys.
This prevents unintentionally type two modified keys instead of one
when the second key is pressed while the other is not yet released.
2024-01-26 00:17:51 +01:00
Jules Aguillon
5beacf32b7 Add Russian vowels combined with the acute accent 2024-01-21 19:47:03 +01:00
Jules Aguillon
ad7314a016 Move layout definitions into srcs/layouts
This separates the layout definitions from the special layouts
(bottom_row, greekmath) and other unrelated files (method, settings).

This is also a more intuitive location for layouts and make the resource
directory easier to navigate.

Under the hood, layouts are copied back into
build/generated-resources/xml.
2024-01-21 16:34:49 +01:00
RetrogisusDEV
a55506e607 Light and dark themes for the launcher and settings 2024-01-20 22:37:51 +01:00
Jules Aguillon
95bd9312a7 Allow hidding the keyboard switching key
The keyboard switching key is now selected by default in the Extra Keys
option and can be deselected.
2024-01-15 23:26:40 +01:00
Jules Aguillon
0a86f9ab01 Always show the keyboard switching key
Android's shouldOfferSwitchingToNextInputMethod() method might return
false when an other IME is installed, perhaps when the other IME doesn't
specify android:supportsSwitchingToNextInputMethod="true".
2024-01-15 23:15:16 +01:00
Jules Aguillon
70d777253c Use switchToNextInputMethod instead of switchToPreviousInputMethod
This is warranted by the API.
2024-01-15 22:10:11 +01:00
Jules Aguillon
d7fa5ffa9a Refactor: Clearer names for CHANGE_METHOD* events
The keys are not renamed to retain compatibility.
2024-01-15 22:09:15 +01:00
Jules Aguillon
b114c78bf1 Refactor: Keyboard2View: Take layout id attr
Removes EmojiBottomRow.
2024-01-13 23:22:26 +01:00
Jules Aguillon
eddf9c6c11 Refactor: New namespace for preference classes 2024-01-13 20:59:05 +01:00
Jules Aguillon
148f3dfc05 prefs: Show custom layout names if provided
Show the name of custom layouts in the list if it's provided using the
`name` attribute.
This should make managing several custom layouts easier.
2024-01-10 23:39:19 +01:00
Jules Aguillon
b319356a08 Fix crash on shift with empty keys
Tapping shift might call `Utils.capitalize_string` on some symbols
(notably custom keys), which crashes on empty string.

This also happens on builtin layouts with `key1="\"`.
2024-01-10 00:17:09 +01:00
Jules Aguillon
73267d68fb Revert "Remove the vibration settings"
This reverts commits ef03dfed5c and
ff01678ba6.

The "vibration duration" slider is bought back.
The "vibration enabled" option is replaced by "custom vibration", which switch between the system haptic feedback or the custom vibration.

The slider is greyed when "custom vibration" is unchecked and is
allowed to have a value of 0 to disable vibrations within the app.

The intermediate values "light", "medium" and "strong" are removed and
no migration of the setting is made.
2024-01-09 00:43:28 +01:00
Jules Aguillon
409362ddb4 launcher: Remove intro video when not supported
Previously, this would trigger an error popup and make the activity
unresponsive.
2024-01-03 00:48:26 +01:00
Jules Aguillon
c524caa6f1 Remove unsupported API readAllBytes 2024-01-01 21:04:54 +01:00
Jules Aguillon
49a6a30773 Add an introduction video in the launcher activity
A video is more intuitive than a written description and doesn't need
translations.
2023-12-31 13:18:15 +01:00
Jules Aguillon
4a5a125aea Bring the voice IME chooser with a long press 2023-12-30 01:24:21 +01:00
Jules Aguillon
51a41ec90a Voice IME chooser popup
Bring a popup for choosing the voice IME when the voice key is pressed
for the first time or the list of voice IMEs installed on the device
change.

A preference stores the last selected IME and the last seen list of
IMEs.
2023-12-30 00:56:55 +01:00
Jules Aguillon
7e7a5e4425 Separate arabic layouts with hindu or arabic numerals
This reverts the Tusinian layout (1af4e45) and instead introduce a new
arabic PC layout with arabic numbers.

Layouts are renamed:
- arab_pc => arab_pc_hindu
- arab_pc_tn => arab_pc
2023-12-26 17:16:29 +01:00
Jules Aguillon
9ff8179d49 Add layout attribute 'numpad_script'
This new attribute is now used instead of 'script' for modifying the
numpad according to the selected layout's script.
If not provided, it defaults to the value of 'script'.
2023-12-26 17:05:51 +01:00
Jules Aguillon
2db4ae3730 Fix the number row showing up on top of pinentry
This wasn't intended and was caused by the "current_layout_unmodified"
optimisation.
2023-12-21 20:59:30 +01:00
RetrogisusDEV
df04eae85f Launcher activity: Add "Select keyboard" button 2023-12-17 20:10:39 +01:00
Jules Aguillon
d7c230e173 prefs: Use QWERTY (US) as the default custom layout
This layout definition contains some documentation and is a better
default than no text.
2023-12-17 12:41:19 +01:00
Jules Aguillon
478d8082f4 Improve layout parsing errors
Add location information to all error and improve "expected tag" errors.
2023-12-17 12:12:23 +01:00
Jules Aguillon
7af6adcf11 prefs: Report errors while editing custom layouts
Errors are obtained by running the parser, validation is throttle to
when the user stops editing for a second.
2023-12-17 11:58:41 +01:00
Jules Aguillon
dd327cc812 prefs: Render line numbers in custom layout input box
Line numbers will help reporting errors. Also, disable line breaking to
improve readability.
2023-12-10 19:44:50 +01:00
deftkHD
684d5c7b70
Use Gradle (#452) 2023-11-25 20:11:12 +01:00
Jules Aguillon
44adb55544 Separately persisted current layout in landscape mode
Remember the selected layout in portrait and landscape mode
independently.
This allows to define a layout specific to landscape without having to
switch manually.
2023-11-19 20:10:45 +01:00
Jules Aguillon
15de829138 Persist current selected layout 2023-11-19 19:07:54 +01:00
RetrogisusDEV
80c6f97767 Add Desert and Jungle themes 2023-11-19 11:33:39 +01:00
Jules Aguillon
148bed769a Add left/right slider to the emoji pane
This entirely changes the implementation of the bottom row in the emoji
pane.
2023-10-28 20:14:32 +02:00
Jules Aguillon
2d164ca64f Add '₽' to Russian layout and to the Fn layer
Other currencies are moved on the Fn layer for consistency with the
compose key.
2023-10-21 11:56:56 +02:00
Jules Aguillon
33653a94cb Add page_up, page_down, home, end to extra keys
The new keys are placed on the corner of the arrow keys. Key
descriptions are added.

They are removed from the Fn layer to avoid showing up twice.
2023-10-20 12:20:25 +02:00
Jules Aguillon
d5cbcb37e3 Preferred position for locale extra_keys
`method.xml` is now able to specify a preferred position for each extra
keys in term of an other key to which it should be placed nearby.

It's implemented for French as an example.
2023-09-24 16:35:24 +02:00
Jules Aguillon
66b1bdc9c9 Refactor: Preferred positions for extra keys
The new PreferredPos class represents where an extra key should be
placed
Currently used to place keys at the same positions they were placed
before.
2023-09-15 18:00:27 +02:00
Jules Aguillon
d771e9d2c7 Refactor: Compute key positions in layouts
`KeyboardData.getKeys()` now returns a map of the keys present on the
layout to their position. Positions are the row, column and swipe
direction.

The computed map is cached in the KeyboardData object as it might be
accessed later by `findKeyWithValue`, which now do less work.
2023-09-10 11:43:56 +02:00
Jules Aguillon
44e2e86f19 Capitalize the first letter of custom keys
This is more useful than turning the entire string full caps.
2023-09-09 14:32:03 +02:00
Jules Aguillon
92a8db5e93 Update auto-capitalisation state when input starts
The initial capitalisation state given by the editor
(`info.initialCapsMode`) is always 0 in many editors.

For some text input types, update the state when typing starts,
disregarding the value given by `info.initialCapsMode`.
2023-09-09 14:15:44 +02:00
Jules Aguillon
687d88f4f7 Per-script numpad
The numeric layout and the optional right hand side numpad are modified
to show the digits belonging to the script used in the current layout.

The numpads are still defined as it was before. The digits are changed
in `modify_numpad` if needed.
2023-09-03 23:38:55 +02:00
Jules Aguillon
b079e5cf43 Consistent layout for optional numpad
Modify the optional right hand numpad the same way as the numeric
layout.
2023-09-03 23:36:49 +02:00
Jules Aguillon
816269aed0 Remove unused editing keys from the settings
These keys don't seem to have a purpose, which is confusing.
2023-09-03 15:05:23 +02:00
Jules Aguillon
9b917e79b1 Fix regression on Ctrl on space bar slider
This makes Ctrl+move_cursor the same as before 5123ce5.
2023-08-26 23:44:41 +02:00
Jules Aguillon
f4c11d99ed Disable automatically Shift when pressing Ctrl
Automatic capitalisation might interferes with keyboard shortcuts.
2023-08-26 23:37:22 +02:00
Jules Aguillon
cf76118548 Add missing combining accents
Implement the combinations that were previously not possible and were
commented out.

Also remove `apply_dead_char` and `apply_combining` and make all
dead-keys definitions uniform.
2023-08-20 01:03:14 +02:00
Jules Aguillon
40498e7b4c Refactor: Allow combining diacritics modifiers
Change the API of `KeyModifier.Map_char` to allow returning a string
instead of a single 16 bits char.

This allows to return combining diacritics.

This also gets rid of `apply_map_or_dead_char`, maps can have their own
fallback.
2023-08-20 00:44:22 +02:00
Eluc
6cb6f2541b
Add Bitcoin symbol to Fn+b (#434) 2023-08-18 12:14:20 +02:00
Jules Aguillon
5123ce5417 Fix slider movements changing input focus
The slider was repeatedly sending arrow keys, which change the focused
input when the end of a text box is hit.

A new key is added that implements cursor movements using the
`InputConnection` API.
The new keys are defined as `KeyValue.Editing`, which are no longer only
context menu actions.

The behavior when a selection has started is changed. The selection is
modified instead of cleared even when shift isn't pressed or the
selection would become empty.

Fallbacks to sending arrow keys for editors that do not support the API,
like Termux.
2023-08-17 12:47:44 +02:00
Jules Aguillon
2dc0ce066d Fix inconsistent initial spacing between keys
Settings defined with `get_dip_pref` had a wrong default value on first
launch.

The "right" default value was used after the shared preferences are
populated.
2023-08-16 18:25:20 +02:00
Jules Aguillon
5822f98bbb Migrate layouts preferences
The new `layouts` preference replaces three previous preferences:

    layout
    second_layout
    custom_layout

Add a preference migration function, which first migration is to
migrate layouts into the new preference.

The migration must also be called from the SettingsActivity as it might
use a different preference store due to the boot-aware preference copy.
2023-08-16 12:21:40 +02:00
Jules Aguillon
613aa283bd LayoutsPreference: Remove cross button for custom layouts
Remove the cross button on the right of custom layouts to reduce
accidental removal.
A remove button is added in the dialog for modifying the layout.
2023-08-16 12:21:38 +02:00
Jules Aguillon
ddceb69d4e LayoutsPreference: Modify custom layout
Clicking on a custom layout opens a dialog for modifying the layout
description instead of the dialog for selecting a layout.
2023-08-16 12:21:25 +02:00
Jules Aguillon
4584e8289b Remove unused class LayoutListPreference
This class is not used since the introduction of [LayoutsPreference].
2023-08-16 12:21:25 +02:00