Skip to content

Commit df17936

Browse files
committed
Improve some things
1 parent dddefc2 commit df17936

File tree

6 files changed

+154
-43
lines changed

6 files changed

+154
-43
lines changed

README.md

Lines changed: 115 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -24,49 +24,130 @@ In its current version, it does not have any user interface or settings, and it
2424

2525
The keyboard layout is based on the QWERTY layout of the Unihertz Titan Pocket, extended to allow access to most characters and symbols expected on a full-sized keyboard.
2626

27+
## Accented characters
28+
29+
You can select a template that specifies the characters that can be accessed by multiple key presses in quick succession (_multipress_).
30+
There is an option to disable the multipress feature for consonants.
31+
32+
### French
33+
34+
| Key | Multipress |
35+
| --- | --- |
36+
| `a` | `à`, `â`, `æ` |
37+
| `e` | `é`, `è`, `ê`, `ë` |
38+
| `i` | `î`, `ï` |
39+
| `o` | `ô`, `œ` |
40+
| `u` | `ù`, `û`, `ü` |
41+
| `y` | `ÿ` |
42+
| `c` | `ç` |
43+
44+
### Spanish
45+
46+
| Key | Multipress |
47+
| --- | --- |
48+
| `a` | `á` |
49+
| `e` | `é` |
50+
| `i` | `í` |
51+
| `o` | `ó` |
52+
| `u` | `ú` |
53+
54+
### German
55+
56+
| Key | Multipress |
57+
| --- | --- |
58+
| `a` | `ä` |
59+
| `o` | `ö` |
60+
| `u` | `ü` |
61+
| `s` | `ß` |
62+
63+
### Portuguese
64+
65+
| Key | Multipress |
66+
| --- | --- |
67+
| `a` | `á`, `â`, `à`, `ã` |
68+
| `e` | `é`, `ê` |
69+
| `i` | `í` |
70+
| `o` | `ó`, `ô`, `õ` |
71+
| `u` | `ú` |
72+
| `c` | `ç` |
73+
74+
### French + ES/DE/PT (default)
75+
76+
| Key | Multipress |
77+
| --- | --- |
78+
| `a` | `à`, `â`, `á`, `ä`, `ã` |
79+
| `e` | `é`, `è`, `ê`, `ë` |
80+
| `i` | `î`, `í`, `ï`, `ì` |
81+
| `o` | `ô`, `ó`, `ò`, `ö`, `õ` |
82+
| `u` | `ù`, `û`, `ú`, `ü` |
83+
| `c` | `ç` |
84+
85+
### áàâäã
86+
87+
| Key | Multipress |
88+
| --- | --- |
89+
| `a` | `á`, `à`, `â`, `ä`, `ã` |
90+
| `e` | `é`, `è`, `ê`, `ë`, `` |
91+
| `i` | `í`, `ì`, `î`, `ï`, `ĩ` |
92+
| `o` | `ó`, `ò`, `ô`, `ö`, `õ` |
93+
| `u` | `ú`, `ù`, `û`, `ü`, `ũ` |
94+
95+
### àáâäã
96+
97+
| Key | Multipress |
98+
| --- | --- |
99+
| `a` | `à`, `á`, `â`, `ä`, `ã` |
100+
| `e` | `è`, `é`, `ê`, `ë`, `` |
101+
| `i` | `ì`, `í`, `î`, `ï`, `ĩ` |
102+
| `o` | `ò`, `ó`, `ô`, `ö`, `õ` |
103+
| `u` | `ù`, `ú`, `û`, `ü`, `ũ` |
104+
27105
## Additional characters
28106

29-
The following table shows the characters that can be accessed by multiple key presses in quick succession (_multipress_), as well as the characters accessible using a long press (and subsequent multipresses).
107+
The following table shows the characters that can be accessed with a long press and subsequent multipresses.
30108
The characters in bold are the ones that are marked on the labels of the keys.
31109

32-
| Key | Multipress | Long press | `sym` modifier |
33-
| --- | --- | --- | --- |
34-
| **`q`** | | **`0`**, `°` (degree) | _Tab_ |
35-
| **`w`** | | **`1`**, `&`, `` | _Up arrow_ |
36-
| **`e`** | `é`, `è`, `ê`, `ë` | **`2`**, ``, `` | `` |
37-
| **`r`** | | **`3`**, `®` | |
38-
| **`t`** | | **`(`**, `[`, `{`, `<`, ``, ``, `` | |
39-
| **`y`** | | **`)`**, `]`, `}`, `>`, `` | _Home_ |
40-
| **`u`** | `ù`, `û`, `ú`, `ü` | **`-`**, `` (em dash), `` (en dash), `` | _Page down_ |
41-
| **`i`** | `î`, `í`, `ï`, `ì` | **`_`**, `\|` | _Page up_ |
42-
| **`o`** | `ô`, `ó`, `ò`, `ö`, `õ` | **`/`**, `\`, `œ`, `º` (masc. ordinal), `÷` | _End_ |
43-
| **`p`** | | **`:`**, `;`, `` | _Escape_ |
44-
| | | |
45-
| **`a`** | `à`, `â`, `á`, `ä`, `ã` | **`@`**, `æ`, `ª`, `` | _Left arrow_ |
46-
| **`s`** | | **`4`**, `ß`, `§`, `` | _Down arrow_ |
47-
| **`d`** | | **`5`**, ``, ``, `` | _Right arrow_ |
48-
| **`f`** | | **`6`**, `^` | |
49-
| **`g`** | | **`*`**, ``, `·` | |
50-
| **`h`** | | **`#`**, `²`, `` | _Left arrow_ |
51-
| **`j`** | | **`+`**, `=`, ``, ``, `±` | _Down arrow_ |
52-
| **`k`** | | **`"`**, `%`, ``, `` | _Up arrow_ |
53-
| **`l`** | | **`'`**, `` ` `` | _Right arrow_ |
54-
| | | |
55-
| **`z`** | | **`!`**, `¡`, `` | _Tab_ |
56-
| **`x`** | | **`7`**, `×`, `χ` | _Cut_* |
57-
| **`c`** | | **`8`**, `©`, `¢`, ``, ``, ``, `` | _Copy_* |
58-
| **`v`** | | **`9`**, ``, `` | _Paste_* |
59-
| **` ` (space bar)** | | ` ` (tab), | _Shift modifier_ |
60-
| **`b`** | | **`.`**, ``, `ß`, ``, `` | `$` |
61-
| **`n`** | | **`,`**, `ñ`, `¬`, `` | `=` |
62-
| **`m`** | | **`?`**, `$`, ``, `£`, `¿` | `%` |
63-
64-
_* The Cut/Copy/Paste actions are only available when no modifier is pressed._
110+
| Key | Long press |
111+
| --- | --- |
112+
| **`q`** | **`0`**, `°` (degree) |
113+
| **`w`** | **`1`**, `&`, `` |
114+
| **`e`** | **`2`**, ``, `` |
115+
| **`r`** | **`3`**, `®` |
116+
| **`t`** | **`(`**, `[`, `{`, `<`, ``, ``, `` |
117+
| **`y`** | **`)`**, `]`, `}`, `>`, `` |
118+
| **`u`** | **`-`**, `` (em dash), `` (en dash), `` |
119+
| **`i`** | **`_`**, `\|` |
120+
| **`o`** | `ô`, `ó`, `ò`, `ö`, `õ` | **`/`**, `\`, `œ`, `º` (masc. ordinal), `÷` |
121+
| **`p`** | **`:`**, `;`, `` |
122+
| | |
123+
| **`a`** | **`@`**, `æ`, `ª`, `` |
124+
| **`s`** | **`4`**, `ß`, `§`, `` |
125+
| **`d`** | **`5`**, ``, ``, `` |
126+
| **`f`** | **`6`**, `^` |
127+
| **`g`** | **`*`**, ``, `·` |
128+
| **`h`** | **`#`**, `²`, `` |
129+
| **`j`** | **`+`**, `=`, ``, ``, `±` |
130+
| **`k`** | **`"`**, `%`, ``, `` |
131+
| **`l`** | **`'`**, `` ` `` |
132+
| | |
133+
| **`z`** | **`!`**, `¡`, `` |
134+
| **`x`** | **`7`**, `×`, `χ` |
135+
| **`c`** | **`8`**, `ç` `©`, `¢`, ``, ``, ``, `` |
136+
| **`v`** | **`9`**, ``, `` |
137+
| **` ` (space bar)** | ` ` (tab), |
138+
| **`b`** | **`.`**, ``, `ß`, ``, `` |
139+
| **`n`** | **`,`**, `ñ`, `¬`, `` |
140+
| **`m`** | **`?`**, `$`, ``, `£`, `¿` |
65141

66142
## `sym` modifier map
67143

144+
Using the `sym` modifier, you can access more keys and symbols.
145+
For instance, you can use `WASD` or `HJKL` to navigate in text.
146+
68147
![`sym` modifier map](readme-symbehavior.png)
69148

149+
The Cut/Copy/Paste actions are only available when no modifier is pressed.
150+
70151
# Customizing and contributing
71152

72153
Feel free to adjust the layout to your needs by modifying the code and building your own version. If you think your changes could be useful to others, please consider contributing them back to this project or making a public fork.

app/src/main/java/io/github/oin/titanpocketkeyboard/InputMethodService.kt

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,22 @@ fun makeKeyEvent(original: KeyEvent, code: Int, metaState: Int, action: Int, sou
4242

4343
val templates = hashMapOf(
4444
"fr" to hashMapOf(
45-
KeyEvent.KEYCODE_A to arrayOf('`', '^', '´', '¨', '~', MPSUBST_BYPASS),
45+
KeyEvent.KEYCODE_A to arrayOf('`', '^', 'æ', MPSUBST_BYPASS),
46+
KeyEvent.KEYCODE_E to arrayOf('´', '`', '^', '¨', MPSUBST_BYPASS),
47+
KeyEvent.KEYCODE_I to arrayOf('^', '¨', MPSUBST_BYPASS),
48+
KeyEvent.KEYCODE_O to arrayOf('^', 'œ', MPSUBST_BYPASS),
49+
KeyEvent.KEYCODE_U to arrayOf('`', '^', '¨', MPSUBST_BYPASS),
50+
KeyEvent.KEYCODE_Y to arrayOf('¨', MPSUBST_BYPASS),
51+
KeyEvent.KEYCODE_C to arrayOf('ç', MPSUBST_BYPASS),
52+
KeyEvent.KEYCODE_SPACE to arrayOf(MPSUBST_STR_DOTSPACE)
53+
),
54+
"fr-ext" to hashMapOf(
55+
KeyEvent.KEYCODE_A to arrayOf('`', '^', '´', '¨', 'æ', '~', MPSUBST_BYPASS),
4656
KeyEvent.KEYCODE_E to arrayOf('´', '`', '^', '¨', MPSUBST_BYPASS),
4757
KeyEvent.KEYCODE_I to arrayOf('^', '´', '¨', '`', MPSUBST_BYPASS),
48-
KeyEvent.KEYCODE_O to arrayOf('^', '´', '`', '¨', '~', MPSUBST_BYPASS),
58+
KeyEvent.KEYCODE_O to arrayOf('^', '´', 'œ', '¨', '~', '`', MPSUBST_BYPASS),
4959
KeyEvent.KEYCODE_U to arrayOf('`', '^', '´', '¨', MPSUBST_BYPASS),
60+
KeyEvent.KEYCODE_Y to arrayOf('¨', MPSUBST_BYPASS),
5061
KeyEvent.KEYCODE_C to arrayOf('ç', MPSUBST_BYPASS),
5162
KeyEvent.KEYCODE_SPACE to arrayOf(MPSUBST_STR_DOTSPACE)
5263
),
@@ -62,6 +73,7 @@ val templates = hashMapOf(
6273
KeyEvent.KEYCODE_A to arrayOf('¨', MPSUBST_BYPASS),
6374
KeyEvent.KEYCODE_O to arrayOf('¨', MPSUBST_BYPASS),
6475
KeyEvent.KEYCODE_U to arrayOf('¨', MPSUBST_BYPASS),
76+
KeyEvent.KEYCODE_S to arrayOf('ß', MPSUBST_BYPASS),
6577
KeyEvent.KEYCODE_SPACE to arrayOf(MPSUBST_STR_DOTSPACE)
6678
),
6779
"pt" to hashMapOf(
@@ -103,7 +115,7 @@ class InputMethodService : AndroidInputMethodService() {
103115
private var autoCapitalize = false
104116

105117
private val multipress = MultipressController(arrayOf(
106-
templates["fr"]!!,
118+
templates["fr-ext"]!!,
107119
hashMapOf(
108120
KeyEvent.KEYCODE_Q to arrayOf(MPSUBST_TOGGLE_ALT, '°', MPSUBST_TOGGLE_SHIFT, MPSUBST_BYPASS),
109121
KeyEvent.KEYCODE_W to arrayOf(MPSUBST_TOGGLE_ALT, '&', '', MPSUBST_TOGGLE_SHIFT, MPSUBST_BYPASS),
@@ -126,7 +138,7 @@ class InputMethodService : AndroidInputMethodService() {
126138
KeyEvent.KEYCODE_L to arrayOf(MPSUBST_TOGGLE_ALT, MPSUBST_BACKTICK, MPSUBST_TOGGLE_SHIFT, MPSUBST_BYPASS),
127139
KeyEvent.KEYCODE_Z to arrayOf(MPSUBST_TOGGLE_ALT, '¡', '', MPSUBST_TOGGLE_SHIFT, MPSUBST_BYPASS),
128140
KeyEvent.KEYCODE_X to arrayOf(MPSUBST_TOGGLE_ALT, '×', 'χ', MPSUBST_TOGGLE_SHIFT, MPSUBST_BYPASS),
129-
KeyEvent.KEYCODE_C to arrayOf(MPSUBST_TOGGLE_ALT, '©', '¢', '', '', '', '', MPSUBST_TOGGLE_SHIFT, MPSUBST_BYPASS),
141+
KeyEvent.KEYCODE_C to arrayOf(MPSUBST_TOGGLE_ALT, 'ç', '©', '¢', '', '', '', '', MPSUBST_TOGGLE_SHIFT, MPSUBST_BYPASS),
130142
KeyEvent.KEYCODE_V to arrayOf(MPSUBST_TOGGLE_ALT, '', '', MPSUBST_TOGGLE_SHIFT, MPSUBST_BYPASS),
131143
KeyEvent.KEYCODE_B to arrayOf(MPSUBST_TOGGLE_ALT, '', 'ß', '', '', MPSUBST_TOGGLE_SHIFT, MPSUBST_BYPASS),
132144
KeyEvent.KEYCODE_N to arrayOf(MPSUBST_TOGGLE_ALT, '~', '¬', '', MPSUBST_TOGGLE_SHIFT, MPSUBST_BYPASS),
@@ -501,6 +513,7 @@ class InputMethodService : AndroidInputMethodService() {
501513
multipress.multipressThreshold = preferences.getInt("MultipressThreshold", 750)
502514
multipress.ignoreFirstLevel = !preferences.getBoolean("UseFirstLevel", true)
503515
multipress.ignoreDotSpace = !preferences.getBoolean("DotSpace", true)
516+
multipress.ignoreConsonantsOnFirstLevel = preferences.getBoolean("FirstLevelOnlyVowels", false)
504517

505518
val templateId = preferences.getString("FirstLevelTemplate", "fr")
506519
if(templates.containsKey(templateId)) {

app/src/main/java/io/github/oin/titanpocketkeyboard/MultipressController.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ class MultipressController(val substitutions: Array<HashMap<Int, Array<Char>>>)
5959
* Whether to ignore `MPSUBST_STR_DOTSPACE`.
6060
*/
6161
var ignoreDotSpace = false
62+
/**
63+
* Whether to ignore consonants on the first level.
64+
*/
65+
var ignoreConsonantsOnFirstLevel = false
6266

6367
private var last: Int = 0
6468
private var lastTime: Long = 0
@@ -98,6 +102,11 @@ class MultipressController(val substitutions: Array<HashMap<Int, Array<Char>>>)
98102
longPressCount = 0
99103
}
100104

105+
//FIXME: Rather than doing this, mark these undesirables another way
106+
if(ignoreConsonantsOnFirstLevel && longPressCount == 0 && keyCode in arrayOf(KeyEvent.KEYCODE_C, KeyEvent.KEYCODE_S)) {
107+
return MPSUBST_BYPASS
108+
}
109+
101110
val map = substitutions[longPressCount]
102111
var substitution: Char
103112
if(keyCode in map) {

app/src/main/res/values/arrays.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<item>Spanish</item>
55
<item>German</item>
66
<item>Portuguese</item>
7+
<item>French+ES/DE/PT</item>
78
<item>áàâäã</item>
89
<item>àáâäã</item>
910
</string-array>
@@ -12,6 +13,7 @@
1213
<item>es</item>
1314
<item>de</item>
1415
<item>pt</item>
16+
<item>fr-ext</item>
1517
<item>order1</item>
1618
<item>order2</item>
1719
</string-array>

app/src/main/res/xml/method.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<input-method xmlns:android="http://schemas.android.com/apk/res/android">
3-
<subtype
4-
android:imeSubtypeLocale="fr_FR"
5-
android:imeSubtypeMode="keyboard" />
3+
<!-- <subtype-->
4+
<!-- android:imeSubtypeLocale="en_US"-->
5+
<!-- android:imeSubtypeMode="keyboard" />-->
66
</input-method>

app/src/main/res/xml/preferences.xml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,22 @@
1919
android:key="UseFirstLevel"
2020
android:defaultValue="true"
2121
android:title="Enable"
22-
android:summary="Enable accented characters by multipressing vowels"
22+
android:summary="Enable accented characters by multipressing (mostly) vowels"
2323
/>
2424
<ListPreference
2525
android:key="FirstLevelTemplate"
26-
android:defaultValue="fr"
26+
android:defaultValue="fr-ext"
2727
android:title="Template"
2828
android:summary="%s"
2929
android:entries="@array/first_level_template"
3030
android:entryValues="@array/first_level_template_values"
3131
/>
32+
<SwitchPreference
33+
android:key="FirstLevelOnlyVowels"
34+
android:defaultValue="false"
35+
android:title="Only vowels"
36+
android:summary="Disable multipress for consonants (like ç or ß)"
37+
/>
3238
</PreferenceCategory>
3339
<PreferenceCategory android:title="Timing">
3440
<SeekBarPreference

0 commit comments

Comments
 (0)