Skip to content

Commit 900f26e

Browse files
committed
Add additional modifier icons for cyrillic layers and a preference setting for the right shift key to enable toggling the layer.
Also bump the version number and update the tests.
1 parent cc2fd91 commit 900f26e

File tree

14 files changed

+412
-30
lines changed

14 files changed

+412
-30
lines changed

app/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ android {
1212
minSdk = 29
1313
targetSdk = 33
1414
versionCode = 1
15-
versionName = "0.77.2"
15+
versionName = "0.78"
1616
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
1717
}
1818

app/src/main/java/io/github/rickybrent/minimal_symlayer_keyboard/InputMethodService.kt

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ class InputMethodService : AndroidInputMethodService() {
180180
private var lastCaps = false
181181
private var lastCyrillicLayer = false
182182

183+
private var cyrillicLayerToggleEnabled = false
184+
183185
private var autoCapitalize = false
184186
private var showToolbar = false
185187
private var isInputViewActive = false
@@ -362,7 +364,8 @@ class InputMethodService : AndroidInputMethodService() {
362364
} else {
363365
shift.onKeyDown()
364366
}
365-
cyrillicLayer.onRightShiftDown()
367+
if (cyrillicLayerToggleEnabled)
368+
cyrillicLayer.onRightShiftDown()
366369
updateStatusIconIfNeeded(true)
367370
}
368371
KeyEvent.KEYCODE_SYM -> {
@@ -532,11 +535,12 @@ class InputMethodService : AndroidInputMethodService() {
532535
}
533536
KeyEvent.KEYCODE_SHIFT_RIGHT -> {
534537
shift.onKeyUp()
535-
cyrillicLayer.onRightShiftUp()
536-
// Check if Cyrillic layer was toggled and provide haptic feedback
537-
if (cyrillicLayer.wasJustToggled()) {
538-
vibrate()
539-
}
538+
if (cyrillicLayerToggleEnabled)
539+
cyrillicLayer.onRightShiftUp()
540+
// Check if Cyrillic layer was toggled and provide haptic feedback
541+
if (cyrillicLayer.wasJustToggled()) {
542+
vibrate()
543+
}
540544
updateStatusIconIfNeeded(true)
541545
}
542546
KeyEvent.KEYCODE_SYM -> {
@@ -805,16 +809,19 @@ class InputMethodService : AndroidInputMethodService() {
805809
}
806810
} else if(emojiMeta.get()) {
807811
showStatusIcon(R.drawable.meta)
808-
} else if(alt.get()) {
809-
showStatusIcon(if (alt.isLocked()) R.drawable.altlock else R.drawable.alt)
810812
} else if (dotCtrl.get()) {
811813
showStatusIcon(if (dotCtrl.isLocked()) R.drawable.ctrllock else R.drawable.ctrl)
814+
} else if(cyrillicLayer.isActive()) {
815+
if(shift.get() || caps.get())
816+
showStatusIcon(if (alt.get()) R.drawable.cyrillicshiftalt else R.drawable.cyrillicshift)
817+
else
818+
showStatusIcon(if (alt.get()) R.drawable.cyrillicalt else R.drawable.cyrillic)
819+
} else if(alt.get()) {
820+
showStatusIcon(if (alt.isLocked()) R.drawable.altlock else R.drawable.alt)
812821
} else if(shift.get()) {
813822
showStatusIcon(if(shift.isLocked()) R.drawable.shiftlock else R.drawable.shift)
814823
} else if(caps.get()) {
815824
showStatusIcon(if(caps.isLocked()) R.drawable.capslock else R.drawable.caps)
816-
} else if(cyrillicLayer.isActive()) {
817-
showStatusIcon(R.drawable.cyrillic)
818825
} else {
819826
hideStatusIcon()
820827
}
@@ -932,6 +939,7 @@ class InputMethodService : AndroidInputMethodService() {
932939
multipress.ignoreConsonantsOnFirstLevel = preferences.getBoolean("FirstLevelOnlyVowels", false)
933940
multipress.ligaturesEnabled = preferences.getBoolean("pref_enable_ligatures", false)
934941

942+
cyrillicLayerToggleEnabled = preferences.getBoolean("pref_enable_cyrillic_layer", false)
935943

936944
val templateId = preferences.getString("FirstLevelTemplate", "fr")
937945
if(templates.containsKey(templateId)) {
@@ -945,6 +953,8 @@ class InputMethodService : AndroidInputMethodService() {
945953
emojiMeta.shortPressKeyCode = preferenceToKeyCode(preferences.getString("pref_emojimeta_tap", "emoji"))
946954
emojiMeta.longPressKeyCode = preferenceToKeyCode(preferences.getString("pref_emojimeta_long_press", "0"))
947955
emojiMeta.modKeyCode = preferenceToKeyCode(preferences.getString("pref_emojimeta_hold", "meta"))
956+
957+
// TODO: Separate modifier and special-key logic and add better handling for sym and right shift.
948958
}
949959

950960
private fun preferenceToKeyCode(preferenceValue: String?): Int {
Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
1-
<?xml version="1.0" encoding="utf-8"?>
21
<vector xmlns:android="http://schemas.android.com/apk/res/android"
32
android:width="24dp"
43
android:height="24dp"
54
android:viewportWidth="24"
65
android:viewportHeight="24">
7-
8-
<!-- Background circle -->
9-
<path
10-
android:fillColor="#FF5722"
11-
android:pathData="M12,12m-10,0a10,10 0,1 1,20 0a10,10 0,1 1,-20 0" />
12-
13-
<!-- Cyrillic "Я" character -->
14-
<path
15-
android:fillColor="#FFFFFF"
16-
android:pathData="M7,6 L7,18 L9,18 L9,14 L11,14 L11,18 L13,18 L13,14 L15,14 L15,18 L17,18 L17,6 L15,6 L15,12 L13,12 L13,6 L11,6 L11,12 L9,12 L9,6 Z" />
6+
<!-- Cyrillic "Я" character -->
7+
<path
8+
android:pathData="m12.412,3.846c-1.757,0 -3.177,0.384 -4.21,1.206C7.159,5.874 6.637,7.141 6.637,8.7c-0,0.697 0.12,1.34 0.367,1.922l0.002,0.005 0.002,0.004c0.251,0.563 0.6,1.053 1.04,1.458v0.002l0.002,0.002c0.443,0.399 0.963,0.718 1.55,0.956h0.002v0.002c0.375,0.15 0.8,0.196 1.211,0.271L6.06,20.154h3.154l4.499,-6.601h1.697l0,6.601h2.53l0,-16.308zM12.412,6.127h2.997L15.409,11.272l-2.997,0c-1.071,0 -1.863,-0.224 -2.416,-0.623 -0.524,-0.386 -0.793,-0.979 -0.793,-1.948 0,-0.953 0.268,-1.541 0.795,-1.929l0.002,-0.002h0.002c0.553,-0.413 1.342,-0.643 2.41,-0.643z"
9+
android:fillColor="#ffffff"/>
1710
</vector>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="24"
5+
android:viewportHeight="24">
6+
<!-- Cyrillic "Я" character -->
7+
<path
8+
android:pathData="m6.353,7.692c-1.757,0 -3.177,0.384 -4.21,1.206 -1.043,0.822 -1.566,2.089 -1.566,3.648 -0,0.697 0.12,1.34 0.367,1.922l0.002,0.005 0.002,0.004c0.251,0.563 0.6,1.053 1.04,1.458v0.002l0.002,0.002c0.443,0.399 0.963,0.718 1.55,0.956h0.002v0.002c0.375,0.15 0.8,0.196 1.211,0.271L0,24L3.154,24L7.653,17.399L9.35,17.399L9.35,24h2.53L11.88,7.692ZM6.353,9.973L9.349,9.973L9.349,15.118l-2.997,0c-1.071,0 -1.863,-0.224 -2.416,-0.623 -0.524,-0.386 -0.793,-0.979 -0.793,-1.948 0,-0.953 0.268,-1.541 0.795,-1.929l0.002,-0.002h0.002C4.496,10.203 5.284,9.973 6.353,9.973Z"
9+
android:fillColor="#ffffff"/>
10+
<!-- Alt -->
11+
<path
12+
android:pathData="m13.146,15.117v2.285h2.336l4.844,6.641h2.65,1.024v-2.285h-2.354l-4.84,-6.631v-0.01zM19.091,15.117 L19.112,15.154 20.751,17.402L24,17.402v-2.285z"
13+
android:fillColor="#ffffff"/>
14+
</vector>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="24"
5+
android:viewportHeight="24">
6+
<!-- Cyrillic "Я" character -->
7+
<path
8+
android:pathData="m6.353,7.692c-1.757,0 -3.177,0.384 -4.21,1.206 -1.043,0.822 -1.566,2.089 -1.566,3.648 -0,0.697 0.12,1.34 0.367,1.922l0.002,0.005 0.002,0.004c0.251,0.563 0.6,1.053 1.04,1.458v0.002l0.002,0.002c0.443,0.399 0.963,0.718 1.55,0.956h0.002v0.002c0.375,0.15 0.8,0.196 1.211,0.271L0,24L3.154,24L7.653,17.399L9.35,17.399L9.35,24h2.53L11.88,7.692ZM6.353,9.973L9.349,9.973L9.349,15.118l-2.997,0c-1.071,0 -1.863,-0.224 -2.416,-0.623 -0.524,-0.386 -0.793,-0.979 -0.793,-1.948 0,-0.953 0.268,-1.541 0.795,-1.929l0.002,-0.002h0.002C4.496,10.203 5.284,9.973 6.353,9.973Z"
9+
android:fillColor="#ffffff"/>
10+
<!-- Shift -->
11+
<path
12+
android:pathData="M17.693,0.311 L11.389,8.133h3.469v2.613h0.469,5.203L20.529,8.133h3.469zM17.693,3.359 L19.959,6.209L18.605,6.209L18.605,8.822L16.781,8.822L16.781,6.209h-1.355z"
13+
android:fillColor="#ffffff"/>
14+
</vector>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="24"
5+
android:viewportHeight="24">
6+
<!-- Cyrillic "Я" character -->
7+
<path
8+
android:pathData="m6.353,7.692c-1.757,0 -3.177,0.384 -4.21,1.206 -1.043,0.822 -1.566,2.089 -1.566,3.648 -0,0.697 0.12,1.34 0.367,1.922l0.002,0.005 0.002,0.004c0.251,0.563 0.6,1.053 1.04,1.458v0.002l0.002,0.002c0.443,0.399 0.963,0.718 1.55,0.956h0.002v0.002c0.375,0.15 0.8,0.196 1.211,0.271L0,24L3.154,24L7.653,17.399L9.35,17.399L9.35,24h2.53L11.88,7.692ZM6.353,9.973L9.349,9.973L9.349,15.118l-2.997,0c-1.071,0 -1.863,-0.224 -2.416,-0.623 -0.524,-0.386 -0.793,-0.979 -0.793,-1.948 0,-0.953 0.268,-1.541 0.795,-1.929l0.002,-0.002h0.002C4.496,10.203 5.284,9.973 6.353,9.973Z"
9+
android:fillColor="#ffffff"/>
10+
<!-- Shift -->
11+
<path
12+
android:pathData="M17.693,0.311 L11.389,8.133h3.469v2.613h0.469,5.203L20.529,8.133h3.469zM17.693,3.359 L19.959,6.209L18.605,6.209L18.605,8.822L16.781,8.822L16.781,6.209h-1.355z"
13+
android:fillColor="#ffffff"/>
14+
<!-- Alt -->
15+
<path
16+
android:pathData="m13.146,15.117v2.285h2.336l4.844,6.641h2.65,1.024v-2.285h-2.354l-4.84,-6.631v-0.01zM19.091,15.117 L19.112,15.154 20.751,17.402L24,17.402v-2.285z"
17+
android:fillColor="#ffffff"/>
18+
</vector>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:aapt="http://schemas.android.com/aapt"
3+
android:width="64dp"
4+
android:height="64dp"
5+
android:viewportWidth="64"
6+
android:viewportHeight="64">
7+
<path
8+
android:pathData="M13.583,1.612L50.417,1.612A11.971,11.971 0,0 1,62.388 13.583L62.388,50.417A11.971,11.971 0,0 1,50.417 62.388L13.583,62.388A11.971,11.971 0,0 1,1.612 50.417L1.612,13.583A11.971,11.971 0,0 1,13.583 1.612z"
9+
android:strokeLineJoin="round"
10+
android:strokeWidth="3.224"
11+
android:fillColor="#ffffff"
12+
android:strokeLineCap="round">
13+
<aapt:attr name="android:strokeColor">
14+
<gradient
15+
android:startX="8.233"
16+
android:startY="8.233"
17+
android:endX="55.767"
18+
android:endY="55.768"
19+
android:type="linear">
20+
<item android:offset="0.501" android:color="#FFB6B6B6"/>
21+
<item android:offset="0.501" android:color="#FF474747"/>
22+
</gradient>
23+
</aapt:attr>
24+
</path>
25+
<path
26+
android:fillColor="#FF000000"
27+
android:pathData="M44.742,44.863V34.367,29.992h3.145l-8.276,-8.276 -8.276,8.276h3.145v4.375,10.495zM39.611,17.545 L54.929,32.932H47.682v10.495,4.375H31.54V43.427,32.932h-7.247z"
28+
android:strokeLineJoin="round"
29+
android:strokeWidth="1.87519"
30+
android:strokeLineCap="round"/>
31+
</vector>

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,25 @@
7878
<item>meta</item>
7979
<item>none</item>
8080
</string-array>
81+
82+
<string-array name="shiftright_tap_entries">
83+
<item>Shift</item>
84+
</string-array>
85+
<string-array name="shiftright_tap_values">
86+
<item>shift</item>
87+
</string-array>
88+
<string-array name="shiftright_long_press_entries">
89+
<item>—</item>
90+
<item>Cyrillic layer (Toggle)</item>
91+
</string-array>
92+
<string-array name="shiftright_long_press_values">
93+
<item>none</item>
94+
<item>cyrillic</item>
95+
</string-array>
96+
<string-array name="shiftright_hold_entries">
97+
<item>Shift + [Key]</item>
98+
</string-array>
99+
<string-array name="shiftright_hold_values">
100+
<item>shift</item>
101+
</string-array>
81102
</resources>

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
app:holdEntries="@array/emojimeta_hold_entries"
4444
app:holdValues="@array/emojimeta_hold_values" />
4545
</PreferenceCategory>
46-
<PreferenceCategory android:title="Accented characters">
46+
<PreferenceCategory android:title="Additional characters">
4747
<SwitchPreference
4848
android:key="UseFirstLevel"
4949
android:defaultValue="false"
@@ -74,6 +74,13 @@
7474
android:defaultValue="false"
7575
app:widgetLayout="@layout/settings_widget_switch"
7676
/>
77+
<SwitchPreference
78+
android:key="pref_enable_cyrillic_layer"
79+
android:title="Enable Cyrillic Layer"
80+
android:summary="Long press right-shift to toggle Cyrillic layer"
81+
android:defaultValue="false"
82+
app:widgetLayout="@layout/settings_widget_switch"
83+
/>
7784
</PreferenceCategory>
7885
<PreferenceCategory android:title="Timing">
7986
<SeekBarPreference

app/src/test/java/io/github/rickybrent/minimal_symlayer_keyboard/CyrillicLayerTest.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ class CyrillicLayerTest {
4343
@Test
4444
fun testCyrillicMappings() {
4545
// Test lowercase mappings
46-
assertEquals('а', CyrillicMappings.getCyrillicChar(android.view.KeyEvent.KEYCODE_A, false))
47-
assertEquals('б', CyrillicMappings.getCyrillicChar(android.view.KeyEvent.KEYCODE_B, false))
48-
assertEquals('в', CyrillicMappings.getCyrillicChar(android.view.KeyEvent.KEYCODE_V, false))
49-
46+
assertEquals('ф', CyrillicMappings.getCyrillicChar(android.view.KeyEvent.KEYCODE_A, false))
47+
assertEquals('и', CyrillicMappings.getCyrillicChar(android.view.KeyEvent.KEYCODE_B, false))
48+
assertEquals('м', CyrillicMappings.getCyrillicChar(android.view.KeyEvent.KEYCODE_V, false))
49+
5050
// Test uppercase mappings
51-
assertEquals('А', CyrillicMappings.getCyrillicChar(android.view.KeyEvent.KEYCODE_A, true))
52-
assertEquals('Б', CyrillicMappings.getCyrillicChar(android.view.KeyEvent.KEYCODE_B, true))
53-
assertEquals('В', CyrillicMappings.getCyrillicChar(android.view.KeyEvent.KEYCODE_V, true))
51+
assertEquals('Ф', CyrillicMappings.getCyrillicChar(android.view.KeyEvent.KEYCODE_A, true))
52+
assertEquals('И', CyrillicMappings.getCyrillicChar(android.view.KeyEvent.KEYCODE_B, true))
53+
assertEquals('М', CyrillicMappings.getCyrillicChar(android.view.KeyEvent.KEYCODE_V, true))
5454

5555
// Test non-existent mappings
5656
assertNull(CyrillicMappings.getCyrillicChar(android.view.KeyEvent.KEYCODE_F1, false))

0 commit comments

Comments
 (0)