Skip to content

Commit

Permalink
Fix Issue #84
Browse files Browse the repository at this point in the history
and several calculation results...
  • Loading branch information
soowon-kang committed Dec 6, 2020
1 parent c4a58a1 commit 1988eac
Showing 1 changed file with 39 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ class KeyLogCollector(
KOR,
ENG,
NUMBER,
SPECIAL;
SPECIAL,
BACKSPACE;
}

class CollectorService : AccessibilityService() {
Expand Down Expand Up @@ -235,7 +236,7 @@ class KeyLogCollector(
* When previous key log does not exists (so, previous text is empty) then
*/
val curKeyType = if (curDecomposedText.length < prevDecomposedText.length) {
KeyType.SPECIAL
KeyType.BACKSPACE
} else {
getKeyType(curKey)
}
Expand All @@ -258,16 +259,26 @@ class KeyLogCollector(
): Float {
if (fromKey.isEmpty()) return Float.MIN_VALUE
if (toKey.isEmpty()) return Float.MIN_VALUE
if (fromKeyType != toKeyType) return Float.MIN_VALUE
if (toKeyType !in arrayOf(KeyType.ENG, KeyType.KOR)) return Float.MIN_VALUE
//if (fromKeyType != toKeyType) return Float.MIN_VALUE
//if (toKeyType !in arrayOf(KeyType.ENG, KeyType.KOR)) return Float.MIN_VALUE
val fromKeyValue = if (fromKeyType == KeyType.BACKSPACE)
"backspace"
else
fromKey

val toKeyValue = if (toKeyType == KeyType.BACKSPACE)
"backspace"
else
toKey


val (fromX, fromY) = findPosition(
key = fromKey,
key = fromKeyValue,
keyType = fromKeyType,
isChunjiin = isChunjiin
) ?: return Float.MIN_VALUE
val (toX, toY) = findPosition(
key = toKey,
key = toKeyValue,
keyType = toKeyType,
isChunjiin = isChunjiin
) ?: return Float.MIN_VALUE
Expand All @@ -283,9 +294,9 @@ class KeyLogCollector(
keyType: KeyType,
isChunjiin: Boolean
): Pair<Float, Float>? = when {
keyType == KeyType.KOR && isChunjiin -> CHUNJIIN
keyType == KeyType.KOR && !isChunjiin -> QWERTY_KOR
keyType == KeyType.ENG -> QWERTY_ENG
isChunjiin -> CHUNJIIN
!isChunjiin -> QWERTY_KOR
else -> null
}?.get(key)

Expand Down Expand Up @@ -336,7 +347,7 @@ class KeyLogCollector(
* Coordinates for CHUNJIIN
*/
private val KEYS_CHUNJIIN = arrayOf(
"l",
"",
"",
"",
"backspace",
Expand All @@ -352,13 +363,13 @@ class KeyLogCollector(
"",
"",
"",
",",
".",
"?",
"!",
"",
"",
" ",
"@",
"",
"",
"",
Expand All @@ -379,7 +390,8 @@ class KeyLogCollector(
"",
"",
"",
""
"",
"\n"
)
private val COORDINATE_X_CHUNJIIN = arrayOf(
1f,
Expand All @@ -401,10 +413,10 @@ class KeyLogCollector(
4f,
4f,
4f,
4f,
2f,
2f,
3f,
4f,
2f,
2f,
1f,
Expand All @@ -425,7 +437,8 @@ class KeyLogCollector(
1f,
1f,
1f,
1f
1f,
4f,
)
private val COORDINATE_Y_CHUNJIIN = arrayOf(
1f,
Expand All @@ -447,10 +460,10 @@ class KeyLogCollector(
3f,
3f,
3f,
3f,
4f,
4f,
4f,
4f,
1f,
1f,
1f,
Expand All @@ -471,7 +484,8 @@ class KeyLogCollector(
1f,
1f,
1f,
1f
1f,
2f
)
private val CHUNJIIN = KEYS_CHUNJIIN.mapIndexed { index, key ->
Triple(key, COORDINATE_X_CHUNJIIN[index], COORDINATE_Y_CHUNJIIN[index])
Expand Down Expand Up @@ -526,7 +540,8 @@ class KeyLogCollector(
"backspace",
"@",
" ",
"."
".",
"\n"
)
private val COORDINATE_X_QWERTY_KOR = arrayOf(
1f,
Expand Down Expand Up @@ -575,7 +590,8 @@ class KeyLogCollector(
9.5f,
3f,
6f,
8.5f
8.5f,
10f
)
private val COORDINATE_Y_QWERTY_KOR = arrayOf(
1f,
Expand Down Expand Up @@ -624,6 +640,7 @@ class KeyLogCollector(
4f,
5f,
5f,
5f,
5f
)
private val QWERTY_KOR = KEYS_QWERTY_KOR.mapIndexed { index, key ->
Expand Down Expand Up @@ -672,7 +689,8 @@ class KeyLogCollector(
"backspace",
"@",
" ",
"."
".",
"\n"
)
private val COORDINATE_X_QWERTY_ENG = arrayOf(
1f,
Expand Down Expand Up @@ -714,7 +732,8 @@ class KeyLogCollector(
9.5f,
3f,
6f,
8.5f
8.5f,
10f
)
private val COORDINATE_Y_QWERTY_ENG = arrayOf(
1f,
Expand Down Expand Up @@ -756,6 +775,7 @@ class KeyLogCollector(
4f,
5f,
5f,
5f,
5f
)
private val QWERTY_ENG = KEYS_QWERTY_ENG.mapIndexed { index, key ->
Expand Down

0 comments on commit 1988eac

Please sign in to comment.