Skip to content

Commit 1e2d4df

Browse files
Move keyboard logic inside keyboard flavour (#583)
* Move keyboard logic inside keyboard flavour * fix: minor function issues due to refractor * fix: linting issues --------- Co-authored-by: angrezichatterbox <gouthammohanraj@gmail.com>
1 parent 3e8b09d commit 1e2d4df

38 files changed

Lines changed: 268 additions & 208 deletions

app/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ android {
136136
flavorDimensions.add("variants")
137137

138138
sourceSets {
139-
getByName("main").java.srcDirs("src/main/kotlin")
139+
getByName("main").java.srcDirs("src/main/java", "src/main/kotlin")
140140
named("test") {
141141
java.srcDirs("src/test/java", "src/test/kotlin")
142142
}

app/src/androidTestKeyboards/kotlin/be/scri/helpers/KeyboardTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import android.view.KeyEvent
55
import android.view.inputmethod.InputConnection
66
import android.widget.Button
77
import androidx.test.ext.junit.runners.AndroidJUnit4
8+
import be.scri.models.ScribeState
89
import be.scri.services.GeneralKeyboardIME
9-
import be.scri.services.GeneralKeyboardIME.ScribeState
1010
import io.mockk.every
1111
import io.mockk.mockk
1212
import io.mockk.verify
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3+
4+
<application>
5+
<service
6+
android:name=".services.EnglishKeyboardIME"
7+
android:exported="true"
8+
android:label="Scribe"
9+
android:permission="android.permission.BIND_INPUT_METHOD" >
10+
<intent-filter>
11+
<action android:name="android.view.InputMethod" />
12+
</intent-filter>
13+
14+
<meta-data
15+
android:name="android.view.im"
16+
android:resource="@xml/method_english" />
17+
</service>
18+
<service
19+
android:name=".services.FrenchKeyboardIME"
20+
android:exported="true"
21+
android:label="Scribe"
22+
android:permission="android.permission.BIND_INPUT_METHOD" >
23+
<intent-filter>
24+
<action android:name="android.view.InputMethod" />
25+
</intent-filter>
26+
27+
<meta-data
28+
android:name="android.view.im"
29+
android:resource="@xml/method_french" />
30+
</service>
31+
<service
32+
android:name=".services.GermanKeyboardIME"
33+
android:exported="true"
34+
android:label="Scribe"
35+
android:permission="android.permission.BIND_INPUT_METHOD" >
36+
<intent-filter>
37+
<action android:name="android.view.InputMethod" />
38+
</intent-filter>
39+
40+
<meta-data
41+
android:name="android.view.im"
42+
android:resource="@xml/method_german" />
43+
</service>
44+
<service
45+
android:name=".services.PortugueseKeyboardIME"
46+
android:exported="true"
47+
android:label="Scribe"
48+
android:permission="android.permission.BIND_INPUT_METHOD" >
49+
<intent-filter>
50+
<action android:name="android.view.InputMethod" />
51+
</intent-filter>
52+
53+
<meta-data
54+
android:name="android.view.im"
55+
android:resource="@xml/method_portuguese" />
56+
</service>
57+
<service
58+
android:name=".services.RussianKeyboardIME"
59+
android:exported="true"
60+
android:label="Scribe"
61+
android:permission="android.permission.BIND_INPUT_METHOD" >
62+
<intent-filter>
63+
<action android:name="android.view.InputMethod" />
64+
</intent-filter>
65+
66+
<meta-data
67+
android:name="android.view.im"
68+
android:resource="@xml/method_russian" />
69+
</service>
70+
<service
71+
android:name=".services.SpanishKeyboardIME"
72+
android:exported="true"
73+
android:label="Scribe"
74+
android:permission="android.permission.BIND_INPUT_METHOD" >
75+
<intent-filter>
76+
<action android:name="android.view.InputMethod" />
77+
</intent-filter>
78+
79+
<meta-data
80+
android:name="android.view.im"
81+
android:resource="@xml/method_spanish" />
82+
</service>
83+
<service
84+
android:name=".services.SwedishKeyboardIME"
85+
android:exported="true"
86+
android:label="Scribe"
87+
android:permission="android.permission.BIND_INPUT_METHOD" >
88+
<intent-filter>
89+
<action android:name="android.view.InputMethod" />
90+
</intent-filter>
91+
92+
<meta-data
93+
android:name="android.view.im"
94+
android:resource="@xml/method_swedish" />
95+
</service>
96+
<service
97+
android:name=".services.ItalianKeyboardIME"
98+
android:exported="true"
99+
android:label="Scribe"
100+
android:permission="android.permission.BIND_INPUT_METHOD" >
101+
<intent-filter>
102+
<action android:name="android.view.InputMethod" />
103+
</intent-filter>
104+
105+
<meta-data
106+
android:name="android.view.im"
107+
android:resource="@xml/method_italian" />
108+
</service>
109+
</application>
110+
111+
</manifest>

app/src/main/java/be/scri/helpers/AutocompletionHandler.kt renamed to app/src/keyboards/java/be/scri/helpers/AutocompletionHandler.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ package be.scri.helpers
44

55
import android.os.Handler
66
import android.os.Looper
7+
import be.scri.models.ScribeState
78
import be.scri.services.GeneralKeyboardIME
8-
import be.scri.services.GeneralKeyboardIME.ScribeState
99

1010
/**
1111
* Handles autocompletion when user is typing.

app/src/main/java/be/scri/helpers/BackspaceHandler.kt renamed to app/src/keyboards/java/be/scri/helpers/BackspaceHandler.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package be.scri.helpers
55
import android.text.TextUtils
66
import android.view.inputmethod.InputConnection
77
import be.scri.helpers.PreferencesHelper.getIsWordByWordDeletionEnabled
8+
import be.scri.models.ScribeState
89
import be.scri.services.GeneralKeyboardIME
910
import be.scri.services.GeneralKeyboardIME.Companion.MAX_TEXT_LENGTH
1011

@@ -91,7 +92,7 @@ class BackspaceHandler(
9192
val finalCommandBarText = ime.getCommandBarTextWithoutCursor()
9293
val isEmptyOrAHint = finalCommandBarText.isEmpty() || finalCommandBarText == ime.currentCommandBarHint
9394
val isGerman = ime.language == "German"
94-
val isPluralState = ime.currentState == GeneralKeyboardIME.ScribeState.PLURAL
95+
val isPluralState = ime.currentState == ScribeState.PLURAL
9596

9697
if (isEmptyOrAHint && isGerman && isPluralState) {
9798
ime.keyboard?.mShiftState = SHIFT_ON_ONE_CHAR

app/src/main/java/be/scri/helpers/KeyHandler.kt renamed to app/src/keyboards/java/be/scri/helpers/KeyHandler.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ package be.scri.helpers
55
import android.content.Context
66
import android.util.Log
77
import android.view.inputmethod.InputConnection
8+
import be.scri.models.ScribeState
89
import be.scri.services.GeneralKeyboardIME
9-
import be.scri.services.GeneralKeyboardIME.ScribeState
1010

1111
/**
1212
* Handles key events for the [GeneralKeyboardIME].
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// SPDX-License-Identifier: GPL-3.0-or-later
2+
package be.scri.helpers
3+
4+
import be.scri.helpers.english.ENInterfaceVariables
5+
import be.scri.helpers.french.FRInterfaceVariables
6+
import be.scri.helpers.german.DEInterfaceVariables
7+
import be.scri.helpers.italian.ITInterfaceVariables
8+
import be.scri.helpers.portuguese.PTInterfaceVariables
9+
import be.scri.helpers.russian.RUInterfaceVariables
10+
import be.scri.helpers.spanish.ESInterfaceVariables
11+
import be.scri.helpers.swedish.SVInterfaceVariables
12+
13+
/**
14+
* Object containing keyboard-specific constant mappings related to language-specific UI elements.
15+
*/
16+
object KeyboardLanguageMappingConstants {
17+
val translatePlaceholder =
18+
mapOf(
19+
"EN" to ENInterfaceVariables.TRANSLATE_KEY_LBL,
20+
"ES" to ESInterfaceVariables.TRANSLATE_KEY_LBL,
21+
"DE" to DEInterfaceVariables.TRANSLATE_KEY_LBL,
22+
"IT" to ITInterfaceVariables.TRANSLATE_KEY_LBL,
23+
"FR" to FRInterfaceVariables.TRANSLATE_KEY_LBL,
24+
"PT" to PTInterfaceVariables.TRANSLATE_KEY_LBL,
25+
"RU" to RUInterfaceVariables.TRANSLATE_KEY_LBL,
26+
"SV" to SVInterfaceVariables.TRANSLATE_KEY_LBL,
27+
)
28+
29+
val conjugatePlaceholder =
30+
mapOf(
31+
"EN" to ENInterfaceVariables.CONJUGATE_KEY_LBL,
32+
"ES" to ESInterfaceVariables.CONJUGATE_KEY_LBL,
33+
"DE" to DEInterfaceVariables.CONJUGATE_KEY_LBL,
34+
"IT" to ITInterfaceVariables.CONJUGATE_KEY_LBL,
35+
"FR" to FRInterfaceVariables.CONJUGATE_KEY_LBL,
36+
"PT" to PTInterfaceVariables.CONJUGATE_KEY_LBL,
37+
"RU" to RUInterfaceVariables.CONJUGATE_KEY_LBL,
38+
"SV" to SVInterfaceVariables.CONJUGATE_KEY_LBL,
39+
)
40+
41+
val pluralPlaceholder =
42+
mapOf(
43+
"EN" to ENInterfaceVariables.PLURAL_KEY_LBL,
44+
"ES" to ESInterfaceVariables.PLURAL_KEY_LBL,
45+
"DE" to DEInterfaceVariables.PLURAL_KEY_LBL,
46+
"IT" to ITInterfaceVariables.PLURAL_KEY_LBL,
47+
"FR" to FRInterfaceVariables.PLURAL_KEY_LBL,
48+
"PT" to PTInterfaceVariables.PLURAL_KEY_LBL,
49+
"RU" to RUInterfaceVariables.PLURAL_KEY_LBL,
50+
"SV" to SVInterfaceVariables.PLURAL_KEY_LBL,
51+
)
52+
}

app/src/main/java/be/scri/helpers/SpaceKeyProcessor.kt renamed to app/src/keyboards/java/be/scri/helpers/SpaceKeyProcessor.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
package be.scri.helpers
44

5+
import be.scri.models.ScribeState
56
import be.scri.services.GeneralKeyboardIME
6-
import be.scri.services.GeneralKeyboardIME.ScribeState
77

88
/**
99
* Processes key events specifically related to the space key.

app/src/main/java/be/scri/helpers/SuggestionHandler.kt renamed to app/src/keyboards/java/be/scri/helpers/SuggestionHandler.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ package be.scri.helpers
44

55
import android.os.Handler
66
import android.os.Looper
7+
import be.scri.models.ScribeState
78
import be.scri.services.GeneralKeyboardIME
8-
import be.scri.services.GeneralKeyboardIME.ScribeState
99

1010
/**
1111
* Handles auto-suggestions such as noun gender, plurality, case, and emojis.

app/src/main/java/be/scri/helpers/english/ENInterfaceVariables.kt renamed to app/src/keyboards/java/be/scri/helpers/english/ENInterfaceVariables.kt

File renamed without changes.

0 commit comments

Comments
 (0)