Skip to content

Commit bc19c98

Browse files
committed
add layout/swipe capture! bump to version 0.0.12
1 parent 48aa73d commit bc19c98

12 files changed

Lines changed: 559 additions & 119 deletions

File tree

.github/workflows/pr-check.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: PR Check
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
7+
permissions:
8+
contents: read
9+
packages: read
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
check:
17+
name: Gradle check
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
24+
- name: Set up JDK 17
25+
uses: actions/setup-java@v4
26+
with:
27+
distribution: temurin
28+
java-version: '17'
29+
30+
- name: Set up Android SDK
31+
uses: android-actions/setup-android@v3
32+
33+
- name: Set up Gradle
34+
uses: gradle/actions/setup-gradle@v4
35+
36+
- name: Run check
37+
env:
38+
GH_PACKAGES_USER: ${{ github.actor }}
39+
GH_PACKAGES_TOKEN: ${{ secrets.GH_CI_TOKEN }}
40+
run: ./gradlew check --stacktrace

.idea/gradle.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/java/com/thelightphone/lp3keyboard/IMEService.kt

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,35 @@ import androidx.savedstate.SavedStateRegistry
1313
import androidx.savedstate.SavedStateRegistryController
1414
import androidx.savedstate.SavedStateRegistryOwner
1515
import androidx.savedstate.setViewTreeSavedStateRegistryOwner
16-
import com.thelightphone.lp3Keyboard.ui.DefaultLp3KeyboardViewModel
16+
import com.thelightphone.lp3Keyboard.ui.Lp3KeyboardSwipeCallback
1717
import com.thelightphone.lp3Keyboard.ui.Lp3KeyboardView
18-
import com.thelightphone.lp3Keyboard.ui.Lp3RepeatableKeyboardCallback
1918
import com.thelightphone.lp3Keyboard.ui.SpecialKey
19+
import com.thelightphone.lp3Keyboard.ui.viewmodel.EnQwertyLp3KeyboardViewModel
20+
import com.thelightphone.lp3Keyboard.ui.viewmodel.Lp3RepeatableKeyboardCallback
2021

2122
class IMEService : LifecycleInputMethodService(),
2223
ViewModelStoreOwner,
2324
SavedStateRegistryOwner,
2425
Lp3RepeatableKeyboardCallback {
2526

26-
private val viewModel: DefaultLp3KeyboardViewModel by lazy {
27+
private val viewModel: EnQwertyLp3KeyboardViewModel<*> by lazy {
2728
val factory = object : ViewModelProvider.Factory {
2829
@Suppress("UNCHECKED_CAST")
2930
override fun <T : androidx.lifecycle.ViewModel> create(modelClass: Class<T>): T {
30-
return DefaultLp3KeyboardViewModel(this@IMEService, ::tick) as T
31+
val dummySwipeCallback = object : Lp3KeyboardSwipeCallback<Unit> {}
32+
return EnQwertyLp3KeyboardViewModel(
33+
this@IMEService,
34+
dummySwipeCallback,
35+
::tick
36+
) as T
3137
}
3238
}
33-
ViewModelProvider(store, factory)[DefaultLp3KeyboardViewModel::class.java]
39+
ViewModelProvider(store, factory)[EnQwertyLp3KeyboardViewModel::class.java]
3440
}
3541

3642
override fun onCreateInputView(): View {
3743
val view = Lp3KeyboardView(this, viewModel)
38-
setCandidatesViewShown(false);
44+
setCandidatesViewShown(false)
3945
window?.window?.apply {
4046
decorView.let { decorView ->
4147
decorView.setViewTreeLifecycleOwner(this@IMEService)
@@ -65,7 +71,7 @@ class IMEService : LifecycleInputMethodService(),
6571
private val vibrator by lazy { getSystemService(Vibrator::class.java) }
6672

6773
private fun tick() {
68-
// 50ms feels good on LP#, other device motors may allow faster buzz
74+
// 50ms feels good on LP3, other device motors may allow faster buzz
6975
vibrator.vibrate(50)
7076
}
7177

@@ -94,6 +100,10 @@ class IMEService : LifecycleInputMethodService(),
94100
override fun onKeyPressed(code: Int) {
95101
}
96102

103+
override fun onSubmitWord(word: CharSequence) {
104+
currentInputConnection?.commitText("$word ", 1)
105+
}
106+
97107
override fun onSpecialKeyPressed(key: SpecialKey) {
98108
when (key) {
99109
SpecialKey.Space -> {
@@ -116,7 +126,8 @@ class IMEService : LifecycleInputMethodService(),
116126
SpecialKey.Backspace -> {
117127
val ic = currentInputConnection ?: return
118128
val before = ic.getTextBeforeCursor(1, 0)
119-
val charsToDelete = if (before != null && before.isNotEmpty() && Character.isLowSurrogate(before[0])) 2 else 1
129+
val charsToDelete =
130+
if (!before.isNullOrEmpty() && Character.isLowSurrogate(before[0])) 2 else 1
120131
ic.deleteSurroundingText(charsToDelete, 0)
121132
updateCapsMode()
122133
}
@@ -168,6 +179,7 @@ class IMEService : LifecycleInputMethodService(),
168179
currentInputConnection?.commitText(" ", 1)
169180
updateCapsMode()
170181
}
182+
171183
SpecialKey.Backspace -> {
172184
deletePrecedingWord()
173185
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
1414
# Kotlin code style for this project: "official" or "obsolete":
1515
kotlin.code.style=official
1616
android.useAndroidX=true
17-
projectVersion=0.0.11
17+
projectVersion=0.0.12

0 commit comments

Comments
 (0)