Commit Graph

96 Commits

Author SHA1 Message Date
Jules Aguillon
78a461f740 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.
2023-01-30 23:46:02 +01:00
Jules Aguillon
90b7944129 Apply modify_layout to text layout only
Refactor. Allows to remove the 'extra_keys' and 'num_pad' flags and to
implement more complicated transformations to the layouts.
2023-01-30 22:33:01 +01:00
Jules Aguillon
6126578111 Avoid switching back from secondary layout automatically
Stay on the secondary layout after a config refresh or onStartInputView.
The information is kept until the keyboard is restarted.

Additionally, move tweaking the secondary layout to the Config class now
that physical equality is not needed.
2023-01-15 23:19:09 +01:00
Jules Aguillon
764cd882d2 Fix inaccessible text layout from pin
The "main" layout can now be pin layout. 'SWITCH_TEXT' and
'SWITCH_SECOND_BACK' don't mean to use that.
2022-12-29 12:43:02 +01:00
Jules Aguillon
8f972113ca Fix pin entry layout not showing up
The regular text layout was showing instead of the pin entry due to a
misuse of the 'switch' syntax.
2022-12-14 15:33:44 +01:00
Jules Aguillon
7d6306fbc9 Fix keyboard not showing up after rotation
'setInputView()' must be called on every 'onStartInputView()', not just
when the view is re-created.

This is broken since bf31872.
2022-12-14 15:04:11 +01:00
Jules Aguillon
bf31872955 Handle configuration change quickly
setInputView() was not called when the view was re-created through
refresh_config(). Also, the refresh_config() function was not able to
properly set the current layout.

Now keep the default layout (_localeTextLayout) and the current non-text
layout (if any, _currentSpecialLayout) separately to be able to refresh
them later.

setInputView() is called everytime the view is created instead of by
onStartInputView() specifically.

The setting activity now save the preferences to the protected storage
in onStop() instead of listening for onSharedPreferenceChanged.
2022-12-11 21:57:40 +01:00
Jules Aguillon
69994a55c5 Refactor: Pass layout as a KeyboardData instead of ID
Parse layouts sooner.
2022-11-26 22:14:29 +01:00
Jules Aguillon
6fb15b3f16 Stop using deprecated 'shouldOfferSwitchingToNextInputMethod'
This function has been introduced in API 19 and deprecated in API 28.
There was no version check for API 19 but instead of adding these,
simply remove the feature for API under 28.
2022-11-26 15:46:45 +01:00
Jules Aguillon
078dbcd5ff Refactor: Move editing code from to KeyEventHandler
Remove the code dealing with InputMethodConnection from 'Keyboard2' and
move it into 'KeyEventHandler', where more editing actions can now be
implemented.

Autocapitalisation is also moved, the IReceiver interface is simplified.
2022-11-13 16:28:39 +01:00
Jules Aguillon
51b330c616 Allow switching quickly between two layouts
A new option allow to choose a secondary layout, the switching key is
placed on the top edge of the space bar.

The "Programming layout" option was basically doing that but it was
possible to choose from a few layouts only. It is improved and renamed.

The 'LayoutListPreference' allows setting the string for the first entry
but otherwise share the rest of the array.

Add nice icons from materialdesignicons.
2022-11-13 00:24:23 +01:00
Jules Aguillon
f1ce6abe5a Direct-boot aware preferences
Store preferences in device protected storage, which is available before
the device is unlocked.
The keyboard was crashing when trying to access the encrypted
preferences.

The emoji pane uses a separate preferences file, the old data is lost.

The SettingsActivity can't easily use the new preferences storage.
Instead, it continues to use the "default" preferences store, which is
copied back to the protected storage when needed.
2022-11-11 14:27:02 +01:00
Jules Aguillon
30198acddd Enable pin layout for decimal and signed inputs
Decimal and signed inputs are more common than expected. Adding a few
keys is enough to support these.
2022-11-06 19:54:55 +01:00
Jules Aguillon
e01a2733b1 Add the pin entry layout
The layout is used for phone number and datetime input boxes as well as
some numbers.
It is easier to use when the full numeric layout is not needed.
2022-10-24 00:17:55 +02:00
Jules Aguillon
36e10a792f Add the capslock key
The key enable caps lock immediately. It does nothing if caps lock is
already enabled.

It is not present on the keyboard by default but a place is defined on
every layout, top-right of the shift key. It can be enabled in the
settings.

The icon is from materialdesignicons.com.
2022-10-23 21:37:04 +02:00
Jules Aguillon
f56b926857 Autocapitalisation: Avoid trigerring when Ctrl+Del
Autocapitalisation could trigger while repeatedly typing Ctrl+Del to
remove several words.
2022-10-16 22:34:21 +02:00
Jules Aguillon
158a3577be Disable fullscreen mode
This mode is annoying to some users and is disabled in most text views.

The keyboard has a fixed sized relative to the height of the screen in
landscape mode. The keyboard can't take more space than expected,
currently.

This might cause problems in the future and might be hidden behind an
option if one is found. Every text views so far seemed to behave fine.
2022-10-16 00:42:28 +02:00
Jules Aguillon
d9a8688237 Fix crash due to auto capitalisation
It is unclear how _autocap.started is not called first but nothing is
preventing to initialize things earlier.
2022-10-15 16:19:27 +02:00
Jules Aguillon
64e263a1af Fix an unexplained crash encountered in the wild
For some reason, 'subtype' can be null. Perhaps because the keyboard is
started before the IMM is ready.
2022-09-24 23:34:50 +02:00
Jules Aguillon
c778b4e8a2 Fix autocapitalisation randomly not triggered
The autocapitalisation is asking the editor about whether to enable
shift and must make sure to ask after the editor is done processing the
events.
2022-09-24 18:53:37 +02:00
Jules Aguillon
25a6e71ee8 Add the Extra Keys option
Allows to add more keys to the keyboard from a predefined list.
The implementation doesn't use MultiSelectListPreference because it
doesn't seem possible to change the item layout to properly show the
rendered symbols.
2022-09-19 11:41:18 +02:00
Jules Aguillon
85d798299e Standard auto-capitalisation only after space
Change the capitalisation algorithm to use Android's
'getCursorCapsMode'. This requires a bit of cursor calculations but
should feel more standard.

The auto completion only triggers after a space is typed or backspace is
pressed.
2022-07-30 17:56:31 +02:00
Jules Aguillon
bfde31da6e Avoid automatic capitalisation when using arrows
Disable capitalisation just after an arrow kind is pressed to avoid
interrupting navigation.
2022-07-24 23:32:14 +02:00
Jules Aguillon
324756535e Automatic capitalisation at beginning of sentences
Keep track of end-of-sentence characters while typing and automatically
enable shift when appropriate.

The last few characters just before the cursor need to be queried in
some cases: Begin of input, cursor has moved or text is deleted.
This might have a performance cost.

This normally only enable shift but it also needs to disable shift when
the cursor moves.
2022-07-24 20:02:48 +02:00
Jules Aguillon
d5836ebb97 Add key for switching to the greekmath pane
The key is placed on the 3rd row of the numeric pane, by taking some
space from the shift key.
2022-07-09 17:30:26 +02:00
Jules Aguillon
ab987c776c Fix localized key not in predefined position
The "loc " prefix for predefining a place for an "extra key" was broken
since 31d6a70.

The FLAG_LOCALIZED flag cannot be used anymore, as adding it to any key
would turn it into a different key that wouldn't be recognized by parts
of the code comparing the keys (placing the extra keys).

Add an other layer in KeyboardData to store such informations.
2022-06-24 20:26:27 +02:00
Jules Aguillon
4d104eacf3 Remove the option "Show every accents"
This option cannot be implemented easily now that the set of "accents"
(localized keys) isn't defined.
2022-06-06 00:55:16 +02:00
Jules Aguillon
31d6a70dfb Refactor: Remove KeyValue.name
This makes KeyValue objects smaller. 'equals' and 'hashCode' are now
implemented too. Key names are still used to recognise keys with special
meaning, but not for comparing keys anymore.
2022-06-06 00:23:45 +02:00
Jules Aguillon
5cc7fdf6d7 Refactor: Separate Events and Keyevents and use enums
Negative values for internal events are preventing further refactoring.

Add a new kind of key and split internal events (now Event) and
Android's key events (now Keyevent).

Use enums events and modifiers outside of the KeyValue class.
Internally, they are converted to and from integer.
2022-06-05 19:30:53 +02:00
Jules Aguillon
e10c587dc5 Refactor: Abstract KeyValue fields
The meaning of the public fields of KeyValue was quite complicated and
not handled consistently accross the app.

Make these fields private and add a more abstract API on top.

The meaning of these fields changed recently and it wasn't an easy
change. I plan on making more changes in the future.
2022-06-05 17:46:22 +02:00
Jules Aguillon
4127aa6f03 Stop using flags for modifiers
There was no free bits left to add new modifiers. Instead of increasing
the width of the 'flags' field, refactor the way modifiers are
represented and used.

Modifers are now represented as independent values and stored in the
'code' field. A flag is added to distinguish between modifiers and keys
with a key event.

The most notable change is that modifiers can no longer be or-ed into a
single value but have to be represented as an array.
2022-06-05 01:43:58 +02:00
Jules Aguillon
2e81cb5cf7 Automatically place localized keys on the layouts
Layouts no longer need to mention every localized keys and dead keys.
They are now placed automatically starting from the second row on the
bottom-right corner.

The "loc " prefix is not removed to still be able to define a more
optimal and consistent placement for some extra keys (eg. 'ß' near 's').

Programming layouts no longer need to place every dead keys.
2022-05-29 12:27:46 +02:00
Jules Aguillon
8e0d38c257 Fix crash when IME not enabled
This is unexpected but happened to a user. Perhaps because the OS
returned bogus or fake results in imm.getEnabledInputMethodList ?
2022-05-01 00:00:15 +02:00
Jules Aguillon
9a8c4f291d Fix compatibility with Android 6
Android 6 uses Java 1.7, the only incompatible feature in use was
lambdas.
2022-04-16 23:36:54 +02:00
Jules Aguillon
aa78229b2a Add the Programming Layout option
Allow specifying a layout for programming and add a key for switching to
it easily.

The switching key is placed on the top edge of the space bar.

The option has no effect by default because the ergonomic isn't ideal,
it needs to be enabled explicitly.
Users of Latin-script languages certainly prefer to use one layout (for
programming or not). This feature might be removed in favor of a better
language-switching mechanisms in the future.
2022-04-03 17:15:12 +02:00
Jules Aguillon
2eb615dbf6 Show the switching key if there's several languages
Ensure the switching key is shown when there's several subtypes enabled,
even if Android says not to show it.
2022-03-16 13:09:10 +01:00
Jules Aguillon
f9cd4ca2d8 Log editor infos while debugging
Useful when debugging why the keyboard doesn't work as expected with a
specific app.
2022-03-15 18:42:29 +01:00
Jules Aguillon
ee6e892ef4 Define localized keys as a set instead of flags
Using flags for removing keys like € and ß need too many flags and won't
scale to more localized keys.
2022-03-13 00:14:18 +01:00
Jules Aguillon
e303008e66 Fix action key not updating when switching field
The keyboard was updated before the action key is.
2022-03-05 20:21:37 +01:00
Jules Aguillon
14dabb6f51 Send key events for the modifiers
Before sending a key event while modifiers are active, send events for
the modifier keys.

Some applications don't look at the "metaState" flags but instead keep
track of the up and down events for the modifiers.

For example, the basic text views that are in every applications
correctly handle the "metaState" flags except for one binding:
Selecting text with the arrows while pressing shift.
2022-02-22 19:32:16 +01:00
Jules Aguillon
632a9ac590 Localize € and £
Show these characters only for users that have the corresponding locale
installed (a supported eu language for €, en-GB for £).
Add these characters to most layouts.
2022-02-19 21:48:48 +01:00
Jules Aguillon
1ff8526d24 Define the bottom row separately
Avoid divergences when the bottom row is modified.
2022-02-07 00:55:32 +01:00
Jules Aguillon
8631dfb723 Select theme depending on system settings
Automatically choose between the Dark and Light themes.
2022-01-30 23:29:50 +01:00
Jules Aguillon
2f47d2400b Improve Action key detection
There were two problems:
- The Action key was swapped when it shouldn't be. The flag
  'IME_FLAG_NO_ENTER_ACTION' wasn't interpreted correctly for inputs
  that specified both an action and this flag.
- The value 'IME_ACTION_UNSPECIFIED' should remove the Action key.
2022-01-30 12:17:31 +01:00
Jules Aguillon
e031de6b57 Globe key: Open keyboard switching dialog
instead of immediately switching to the next input method.
2022-01-23 19:40:45 +01:00
Jules Aguillon
cb95e99f50 Make action key labels translatable 2022-01-23 19:20:02 +01:00
Jules Aguillon
100e0b270d Fix crash when switching app 2022-01-20 21:22:09 +01:00
Moini
133b6ec2c1
German keyboard added (#20)
* Add German metadata translation

* Add German keyboard

Co-authored-by: Jules Aguillon <jules@j3s.fr>
2022-01-15 20:56:08 +01:00
Jules Aguillon
dfec26a93b Swap the Enter and Action keys when needed
When IME_FLAG_NO_ENTER_ACTION is set.
2022-01-10 00:27:22 +01:00
Jules Aguillon
53113cadd9 Add the Action key
It is placed on the top-right of the enter key on every layouts.
It sends a special event (performEditorAction) instead of writing a
newline.

The "actionId" is passed through the EditorInfo object in an obfuscated
way so it's not clear whether it's using the right one.
2022-01-09 20:26:06 +01:00