aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2012-09-27 15:27:51 +0900
committerTadashi G. Takaoka <takaoka@google.com>2012-09-27 17:55:58 +0900
commit17752016713b92a55e9c2356d07b7ed51c67416b (patch)
treee8bbc6b8aedb2366502e050705db40e05d596b92
parent4d1f3d11db7f8efb1fe7a9d3cba39c31a98c6e79 (diff)
downloadlatinime-17752016713b92a55e9c2356d07b7ed51c67416b.tar.gz
latinime-17752016713b92a55e9c2356d07b7ed51c67416b.tar.xz
latinime-17752016713b92a55e9c2356d07b7ed51c67416b.zip
Calculate default touch position correction data for keys on 4th row
This change also disables touch position correction for Phone/Dvorak keyboard. Bug: 7243101 Change-Id: Idfcc7ad1feabbe6a81635dceba5be087401fa18b
-rw-r--r--java/res/values-sw600dp/touch-position-correction.xml60
-rw-r--r--java/res/values/styles.xml2
-rw-r--r--java/res/values/touch-position-correction.xml18
-rw-r--r--java/res/xml-land/kbd_number.xml1
-rw-r--r--java/res/xml-land/kbd_phone.xml1
-rw-r--r--java/res/xml-land/kbd_phone_symbols.xml1
-rw-r--r--java/res/xml-sw600dp-land/kbd_number.xml1
-rw-r--r--java/res/xml-sw600dp-land/kbd_phone.xml1
-rw-r--r--java/res/xml-sw600dp-land/kbd_phone_symbols.xml1
-rw-r--r--java/res/xml-sw600dp/kbd_10_10_7_symbols.xml1
-rw-r--r--java/res/xml-sw600dp/kbd_10_10_7_symbols_shift.xml1
-rw-r--r--java/res/xml-sw600dp/kbd_number.xml1
-rw-r--r--java/res/xml-sw600dp/kbd_phone.xml1
-rw-r--r--java/res/xml-sw600dp/kbd_phone_symbols.xml1
-rw-r--r--java/res/xml-sw768dp-land/kbd_number.xml1
-rw-r--r--java/res/xml-sw768dp-land/kbd_phone.xml1
-rw-r--r--java/res/xml-sw768dp-land/kbd_phone_symbols.xml1
-rw-r--r--java/res/xml-sw768dp/kbd_number.xml1
-rw-r--r--java/res/xml-sw768dp/kbd_phone.xml1
-rw-r--r--java/res/xml-sw768dp/kbd_phone_symbols.xml1
-rw-r--r--java/res/xml-sw768dp/kbd_thai_symbols.xml2
-rw-r--r--java/res/xml-sw768dp/kbd_thai_symbols_shift.xml2
-rw-r--r--java/res/xml/kbd_10_10_7_symbols.xml1
-rw-r--r--java/res/xml/kbd_10_10_7_symbols_shift.xml1
-rw-r--r--java/res/xml/kbd_number.xml1
-rw-r--r--java/res/xml/kbd_pcqwerty.xml2
-rw-r--r--java/res/xml/kbd_pcqwerty_symbols.xml2
-rw-r--r--java/res/xml/kbd_phone.xml1
-rw-r--r--java/res/xml/kbd_phone_symbols.xml1
-rw-r--r--java/res/xml/kbd_symbols.xml1
-rw-r--r--java/res/xml/kbd_symbols_shift.xml1
-rw-r--r--java/res/xml/kbd_thai.xml2
-rw-r--r--java/res/xml/kbd_thai_symbols.xml1
-rw-r--r--java/res/xml/kbd_thai_symbols_shift.xml1
-rw-r--r--java/src/com/android/inputmethod/keyboard/ProximityInfo.java32
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/TouchPositionCorrection.java6
36 files changed, 124 insertions, 30 deletions
diff --git a/java/res/values-sw600dp/touch-position-correction.xml b/java/res/values-sw600dp/touch-position-correction.xml
new file mode 100644
index 000000000..f77d3ae83
--- /dev/null
+++ b/java/res/values-sw600dp/touch-position-correction.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2012, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <!-- Note that correctionX is obsolete (See com.android.inputmethod.keyboard.internal.TouchPositionCorrection)
+ An entry of the touch_position_correction word should be:
+ 1. correctionX: (touch_center_x - hitbox_center_x) / hitbox_width
+ 2. correctionY: (touch_center_y - hitbox_center_y) / hitbox_height
+ 3. correctionR: sweet_spot_radius / sqrt(hitbox_width^2 + hitbox_height^2)
+ -->
+
+ <string-array
+ name="touch_position_correction_data_default"
+ translatable="false"
+ >
+ <!-- The default touch position data (See com.android.inputmethod.keyboard.ProximityInfo)
+ correctionX = 0.0f
+ correctionY = 0.0f
+ correctionR = DEFAULT_TOUCH_POSITION_CORRECTION_RADIUS
+ -->
+ </string-array>
+
+ <string-array
+ name="touch_position_correction_data_gingerbread"
+ translatable="false"
+ >
+ <!-- The default touch position data (See com.android.inputmethod.keyboard.ProximityInfo)
+ correctionX = 0.0f
+ correctionY = 0.0f
+ correctionR = DEFAULT_TOUCH_POSITION_CORRECTION_RADIUS
+ -->
+ </string-array>
+
+ <string-array
+ name="touch_position_correction_data_ice_cream_sandwich"
+ translatable="false"
+ >
+ <!-- The default touch position data (See com.android.inputmethod.keyboard.ProximityInfo)
+ correctionX = 0.0f
+ correctionY = 0.0f
+ correctionR = DEFAULT_TOUCH_POSITION_CORRECTION_RADIUS
+ -->
+ </string-array>
+</resources>
diff --git a/java/res/values/styles.xml b/java/res/values/styles.xml
index d52039221..928c5f5d0 100644
--- a/java/res/values/styles.xml
+++ b/java/res/values/styles.xml
@@ -19,7 +19,7 @@
<style name="Keyboard">
<!-- This should be aligned with KeyboardSwitcher.KEYBOARD_THEMES[] -->
<item name="themeId">0</item>
- <item name="touchPositionCorrectionData">@array/touch_position_correction_data_empty</item>
+ <item name="touchPositionCorrectionData">@array/touch_position_correction_data_default</item>
<item name="rowHeight">25%p</item>
<item name="keyboardHeight">@dimen/keyboardHeight</item>
<item name="maxKeyboardHeight">@fraction/maxKeyboardHeight</item>
diff --git a/java/res/values/touch-position-correction.xml b/java/res/values/touch-position-correction.xml
index 41b435ad0..7df86f467 100644
--- a/java/res/values/touch-position-correction.xml
+++ b/java/res/values/touch-position-correction.xml
@@ -18,18 +18,22 @@
*/
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <!--
+ <!-- Note that correctionX is obsolete (See com.android.inputmethod.keyboard.internal.TouchPositionCorrection)
An entry of the touch_position_correction word should be:
- 1. (float) (touch_center_x - key_center_x) / key_width
- 2. (float) (touch_center_y - key_center_y) / key_height
- 3. (float) sweet_spot_radius / (key_width^2 + key_height^2)
- -->
+ 1. correctionX: (touch_center_x - hitbox_center_x) / hitbox_width
+ 2. correctionY: (touch_center_y - hitbox_center_y) / hitbox_height
+ 3. correctionR: sweet_spot_radius / sqrt(hitbox_width^2 + hitbox_height^2)
+ -->
<string-array
- name="touch_position_correction_data_empty"
+ name="touch_position_correction_data_default"
translatable="false"
>
- <!-- empty -->
+ <!-- The default touch position data (See com.android.inputmethod.keyboard.ProximityInfo)
+ correctionX = 0.0f
+ correctionY = 0.0f
+ correctionR = DEFAULT_TOUCH_POSITION_CORRECTION_RADIUS
+ -->
</string-array>
<string-array
diff --git a/java/res/xml-land/kbd_number.xml b/java/res/xml-land/kbd_number.xml
index 7cc0fb274..8d31df1f8 100644
--- a/java/res/xml-land/kbd_number.xml
+++ b/java/res/xml-land/kbd_number.xml
@@ -22,6 +22,7 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardHorizontalEdgesPadding="10%p"
latin:keyWidth="26.67%p"
+ latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
>
<include
latin:keyboardLayout="@xml/rows_number" />
diff --git a/java/res/xml-land/kbd_phone.xml b/java/res/xml-land/kbd_phone.xml
index aa54b8390..2f8fc3560 100644
--- a/java/res/xml-land/kbd_phone.xml
+++ b/java/res/xml-land/kbd_phone.xml
@@ -22,6 +22,7 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardHorizontalEdgesPadding="10%p"
latin:keyWidth="26.67%p"
+ latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
>
<include
latin:keyboardLayout="@xml/rows_phone" />
diff --git a/java/res/xml-land/kbd_phone_symbols.xml b/java/res/xml-land/kbd_phone_symbols.xml
index 41ba6cf3b..0e6bcdd6a 100644
--- a/java/res/xml-land/kbd_phone_symbols.xml
+++ b/java/res/xml-land/kbd_phone_symbols.xml
@@ -22,6 +22,7 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardHorizontalEdgesPadding="10%p"
latin:keyWidth="26.67%p"
+ latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
>
<include
latin:keyboardLayout="@xml/rows_phone_symbols" />
diff --git a/java/res/xml-sw600dp-land/kbd_number.xml b/java/res/xml-sw600dp-land/kbd_number.xml
index cb86b3b2f..63dfc90d0 100644
--- a/java/res/xml-sw600dp-land/kbd_number.xml
+++ b/java/res/xml-sw600dp-land/kbd_number.xml
@@ -22,6 +22,7 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardHorizontalEdgesPadding="10%p"
latin:keyWidth="18%p"
+ latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
>
<include
latin:keyboardLayout="@xml/rows_number" />
diff --git a/java/res/xml-sw600dp-land/kbd_phone.xml b/java/res/xml-sw600dp-land/kbd_phone.xml
index 71c7c04a1..b6161111b 100644
--- a/java/res/xml-sw600dp-land/kbd_phone.xml
+++ b/java/res/xml-sw600dp-land/kbd_phone.xml
@@ -22,6 +22,7 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardHorizontalEdgesPadding="10%p"
latin:keyWidth="18%p"
+ latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
>
<include
latin:keyboardLayout="@xml/rows_phone" />
diff --git a/java/res/xml-sw600dp-land/kbd_phone_symbols.xml b/java/res/xml-sw600dp-land/kbd_phone_symbols.xml
index 39bdae3c7..9b0bee026 100644
--- a/java/res/xml-sw600dp-land/kbd_phone_symbols.xml
+++ b/java/res/xml-sw600dp-land/kbd_phone_symbols.xml
@@ -22,6 +22,7 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardHorizontalEdgesPadding="10%p"
latin:keyWidth="18%p"
+ latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
>
<!-- Tablet doesn't have phone symbols keyboard -->
<include
diff --git a/java/res/xml-sw600dp/kbd_10_10_7_symbols.xml b/java/res/xml-sw600dp/kbd_10_10_7_symbols.xml
index 66254dea0..dd545b5ef 100644
--- a/java/res/xml-sw600dp/kbd_10_10_7_symbols.xml
+++ b/java/res/xml-sw600dp/kbd_10_10_7_symbols.xml
@@ -20,6 +20,7 @@
<Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
+ latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
>
<include
latin:keyboardLayout="@xml/rows_10_10_7_symbols" />
diff --git a/java/res/xml-sw600dp/kbd_10_10_7_symbols_shift.xml b/java/res/xml-sw600dp/kbd_10_10_7_symbols_shift.xml
index 3c5ed5e09..c36f0097e 100644
--- a/java/res/xml-sw600dp/kbd_10_10_7_symbols_shift.xml
+++ b/java/res/xml-sw600dp/kbd_10_10_7_symbols_shift.xml
@@ -20,6 +20,7 @@
<Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
+ latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
>
<include
latin:keyboardLayout="@xml/rows_10_10_7_symbols_shift" />
diff --git a/java/res/xml-sw600dp/kbd_number.xml b/java/res/xml-sw600dp/kbd_number.xml
index 4a8b08c2a..71d662267 100644
--- a/java/res/xml-sw600dp/kbd_number.xml
+++ b/java/res/xml-sw600dp/kbd_number.xml
@@ -21,6 +21,7 @@
<Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyWidth="18%p"
+ latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
>
<include
latin:keyboardLayout="@xml/rows_number" />
diff --git a/java/res/xml-sw600dp/kbd_phone.xml b/java/res/xml-sw600dp/kbd_phone.xml
index f63f1c648..5fdbea27b 100644
--- a/java/res/xml-sw600dp/kbd_phone.xml
+++ b/java/res/xml-sw600dp/kbd_phone.xml
@@ -21,6 +21,7 @@
<Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyWidth="18%p"
+ latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
>
<include
latin:keyboardLayout="@xml/rows_phone" />
diff --git a/java/res/xml-sw600dp/kbd_phone_symbols.xml b/java/res/xml-sw600dp/kbd_phone_symbols.xml
index a0f55b732..ce24d2b39 100644
--- a/java/res/xml-sw600dp/kbd_phone_symbols.xml
+++ b/java/res/xml-sw600dp/kbd_phone_symbols.xml
@@ -21,6 +21,7 @@
<Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyWidth="18%p"
+ latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
>
<!-- Tablet doesn't have phone symbols keyboard -->
<include
diff --git a/java/res/xml-sw768dp-land/kbd_number.xml b/java/res/xml-sw768dp-land/kbd_number.xml
index 3ad25a392..de8d55904 100644
--- a/java/res/xml-sw768dp-land/kbd_number.xml
+++ b/java/res/xml-sw768dp-land/kbd_number.xml
@@ -22,6 +22,7 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardHorizontalEdgesPadding="10%p"
latin:keyWidth="13.250%p"
+ latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
>
<include
latin:keyboardLayout="@xml/rows_number" />
diff --git a/java/res/xml-sw768dp-land/kbd_phone.xml b/java/res/xml-sw768dp-land/kbd_phone.xml
index abe7e7c41..f88a076f6 100644
--- a/java/res/xml-sw768dp-land/kbd_phone.xml
+++ b/java/res/xml-sw768dp-land/kbd_phone.xml
@@ -22,6 +22,7 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardHorizontalEdgesPadding="10%p"
latin:keyWidth="13.250%p"
+ latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
>
<include
latin:keyboardLayout="@xml/rows_phone" />
diff --git a/java/res/xml-sw768dp-land/kbd_phone_symbols.xml b/java/res/xml-sw768dp-land/kbd_phone_symbols.xml
index 641464dbe..eaa413e7d 100644
--- a/java/res/xml-sw768dp-land/kbd_phone_symbols.xml
+++ b/java/res/xml-sw768dp-land/kbd_phone_symbols.xml
@@ -22,6 +22,7 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardHorizontalEdgesPadding="10%p"
latin:keyWidth="13.250%p"
+ latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
>
<!-- Tablet doesn't have phone symbols keyboard -->
<include
diff --git a/java/res/xml-sw768dp/kbd_number.xml b/java/res/xml-sw768dp/kbd_number.xml
index b20123c80..1b46edd50 100644
--- a/java/res/xml-sw768dp/kbd_number.xml
+++ b/java/res/xml-sw768dp/kbd_number.xml
@@ -21,6 +21,7 @@
<Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyWidth="13.250%p"
+ latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
>
<include
latin:keyboardLayout="@xml/rows_number" />
diff --git a/java/res/xml-sw768dp/kbd_phone.xml b/java/res/xml-sw768dp/kbd_phone.xml
index fa9bf1bf4..947ede050 100644
--- a/java/res/xml-sw768dp/kbd_phone.xml
+++ b/java/res/xml-sw768dp/kbd_phone.xml
@@ -21,6 +21,7 @@
<Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyWidth="13.250%p"
+ latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
>
<include
latin:keyboardLayout="@xml/rows_phone" />
diff --git a/java/res/xml-sw768dp/kbd_phone_symbols.xml b/java/res/xml-sw768dp/kbd_phone_symbols.xml
index e1a359e84..dd9a6aebd 100644
--- a/java/res/xml-sw768dp/kbd_phone_symbols.xml
+++ b/java/res/xml-sw768dp/kbd_phone_symbols.xml
@@ -21,6 +21,7 @@
<Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyWidth="13.250%p"
+ latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
>
<!-- Tablet doesn't have phone symbols keyboard -->
<include
diff --git a/java/res/xml-sw768dp/kbd_thai_symbols.xml b/java/res/xml-sw768dp/kbd_thai_symbols.xml
index 0cd9a61ea..5ddf57446 100644
--- a/java/res/xml-sw768dp/kbd_thai_symbols.xml
+++ b/java/res/xml-sw768dp/kbd_thai_symbols.xml
@@ -24,7 +24,7 @@
latin:verticalGap="@fraction/key_bottom_gap_5row"
latin:keyLetterSize="@fraction/key_letter_ratio_5row"
latin:keyShiftedLetterHintRatio="@fraction/key_uppercase_letter_ratio_5row"
- latin:touchPositionCorrectionData="@null"
+ latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
>
<include
latin:keyboardLayout="@xml/rows_thai_symbols" />
diff --git a/java/res/xml-sw768dp/kbd_thai_symbols_shift.xml b/java/res/xml-sw768dp/kbd_thai_symbols_shift.xml
index a68fec458..135222b22 100644
--- a/java/res/xml-sw768dp/kbd_thai_symbols_shift.xml
+++ b/java/res/xml-sw768dp/kbd_thai_symbols_shift.xml
@@ -24,7 +24,7 @@
latin:verticalGap="@fraction/key_bottom_gap_5row"
latin:keyLetterSize="@fraction/key_letter_ratio_5row"
latin:keyShiftedLetterHintRatio="@fraction/key_uppercase_letter_ratio_5row"
- latin:touchPositionCorrectionData="@null"
+ latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
>
<include
latin:keyboardLayout="@xml/rows_thai_symbols_shift" />
diff --git a/java/res/xml/kbd_10_10_7_symbols.xml b/java/res/xml/kbd_10_10_7_symbols.xml
index 7e075df48..4d9861b73 100644
--- a/java/res/xml/kbd_10_10_7_symbols.xml
+++ b/java/res/xml/kbd_10_10_7_symbols.xml
@@ -20,6 +20,7 @@
<Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
+ latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
>
<include
latin:keyboardLayout="@xml/rows_symbols" />
diff --git a/java/res/xml/kbd_10_10_7_symbols_shift.xml b/java/res/xml/kbd_10_10_7_symbols_shift.xml
index 25db3c84d..a2d67caf4 100644
--- a/java/res/xml/kbd_10_10_7_symbols_shift.xml
+++ b/java/res/xml/kbd_10_10_7_symbols_shift.xml
@@ -20,6 +20,7 @@
<Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
+ latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
>
<include
latin:keyboardLayout="@xml/rows_symbols_shift" />
diff --git a/java/res/xml/kbd_number.xml b/java/res/xml/kbd_number.xml
index 8b0deea97..aa8872f26 100644
--- a/java/res/xml/kbd_number.xml
+++ b/java/res/xml/kbd_number.xml
@@ -21,6 +21,7 @@
<Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyWidth="26.67%p"
+ latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
>
<include
latin:keyboardLayout="@xml/rows_number" />
diff --git a/java/res/xml/kbd_pcqwerty.xml b/java/res/xml/kbd_pcqwerty.xml
index 777c71af3..5155bc510 100644
--- a/java/res/xml/kbd_pcqwerty.xml
+++ b/java/res/xml/kbd_pcqwerty.xml
@@ -24,7 +24,7 @@
latin:verticalGap="@fraction/key_bottom_gap_5row"
latin:keyLetterSize="@fraction/key_letter_ratio_5row"
latin:keyShiftedLetterHintRatio="@fraction/key_uppercase_letter_ratio_5row"
- latin:touchPositionCorrectionData="@null"
+ latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
>
<include
latin:keyboardLayout="@xml/rows_pcqwerty" />
diff --git a/java/res/xml/kbd_pcqwerty_symbols.xml b/java/res/xml/kbd_pcqwerty_symbols.xml
index a2297f702..bfb39e8aa 100644
--- a/java/res/xml/kbd_pcqwerty_symbols.xml
+++ b/java/res/xml/kbd_pcqwerty_symbols.xml
@@ -24,7 +24,7 @@
latin:verticalGap="@fraction/key_bottom_gap_5row"
latin:keyLetterSize="@fraction/key_letter_ratio_5row"
latin:keyShiftedLetterHintRatio="@fraction/key_uppercase_letter_ratio_5row"
- latin:touchPositionCorrectionData="@null"
+ latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
>
<include
latin:keyboardLayout="@xml/rows_pcqwerty_symbols" />
diff --git a/java/res/xml/kbd_phone.xml b/java/res/xml/kbd_phone.xml
index 91637b62c..dab3d494a 100644
--- a/java/res/xml/kbd_phone.xml
+++ b/java/res/xml/kbd_phone.xml
@@ -21,6 +21,7 @@
<Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyWidth="26.67%p"
+ latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
>
<include
latin:keyboardLayout="@xml/rows_phone" />
diff --git a/java/res/xml/kbd_phone_symbols.xml b/java/res/xml/kbd_phone_symbols.xml
index 7f59a855a..ba4e4646d 100644
--- a/java/res/xml/kbd_phone_symbols.xml
+++ b/java/res/xml/kbd_phone_symbols.xml
@@ -21,6 +21,7 @@
<Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyWidth="26.67%p"
+ latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
>
<include
latin:keyboardLayout="@xml/rows_phone_symbols" />
diff --git a/java/res/xml/kbd_symbols.xml b/java/res/xml/kbd_symbols.xml
index f6612a2f7..47e08d57f 100644
--- a/java/res/xml/kbd_symbols.xml
+++ b/java/res/xml/kbd_symbols.xml
@@ -20,6 +20,7 @@
<Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
+ latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
>
<include
latin:keyboardLayout="@xml/rows_symbols" />
diff --git a/java/res/xml/kbd_symbols_shift.xml b/java/res/xml/kbd_symbols_shift.xml
index 41a5571ef..932ec017e 100644
--- a/java/res/xml/kbd_symbols_shift.xml
+++ b/java/res/xml/kbd_symbols_shift.xml
@@ -20,6 +20,7 @@
<Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
+ latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
>
<include
latin:keyboardLayout="@xml/rows_symbols_shift" />
diff --git a/java/res/xml/kbd_thai.xml b/java/res/xml/kbd_thai.xml
index b4a4a0b92..294bffb5b 100644
--- a/java/res/xml/kbd_thai.xml
+++ b/java/res/xml/kbd_thai.xml
@@ -24,7 +24,7 @@
latin:verticalGap="@fraction/key_bottom_gap_5row"
latin:keyLetterSize="@fraction/key_letter_ratio_5row"
latin:keyShiftedLetterHintRatio="@fraction/key_uppercase_letter_ratio_5row"
- latin:touchPositionCorrectionData="@null"
+ latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
>
<include
latin:keyboardLayout="@xml/rows_thai" />
diff --git a/java/res/xml/kbd_thai_symbols.xml b/java/res/xml/kbd_thai_symbols.xml
index 7e075df48..4d9861b73 100644
--- a/java/res/xml/kbd_thai_symbols.xml
+++ b/java/res/xml/kbd_thai_symbols.xml
@@ -20,6 +20,7 @@
<Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
+ latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
>
<include
latin:keyboardLayout="@xml/rows_symbols" />
diff --git a/java/res/xml/kbd_thai_symbols_shift.xml b/java/res/xml/kbd_thai_symbols_shift.xml
index 25db3c84d..a2d67caf4 100644
--- a/java/res/xml/kbd_thai_symbols_shift.xml
+++ b/java/res/xml/kbd_thai_symbols_shift.xml
@@ -20,6 +20,7 @@
<Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
+ latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
>
<include
latin:keyboardLayout="@xml/rows_symbols_shift" />
diff --git a/java/src/com/android/inputmethod/keyboard/ProximityInfo.java b/java/src/com/android/inputmethod/keyboard/ProximityInfo.java
index 6e138946f..06a9e9252 100644
--- a/java/src/com/android/inputmethod/keyboard/ProximityInfo.java
+++ b/java/src/com/android/inputmethod/keyboard/ProximityInfo.java
@@ -25,15 +25,15 @@ import com.android.inputmethod.latin.JniUtils;
import java.util.Arrays;
-public class ProximityInfo {
+public final class ProximityInfo {
/** MAX_PROXIMITY_CHARS_SIZE must be the same as MAX_PROXIMITY_CHARS_SIZE_INTERNAL
* in defines.h */
public static final int MAX_PROXIMITY_CHARS_SIZE = 16;
/** Number of key widths from current touch point to search for nearest keys. */
private static float SEARCH_DISTANCE = 1.2f;
private static final Key[] EMPTY_KEY_ARRAY = new Key[0];
+ private static final float DEFAULT_TOUCH_POSITION_CORRECTION_RADIUS = 0.15f;
- private final int mKeyHeight;
private final int mGridWidth;
private final int mGridHeight;
private final int mGridSize;
@@ -43,6 +43,7 @@ public class ProximityInfo {
private final int mKeyboardMinWidth;
private final int mKeyboardHeight;
private final int mMostCommonKeyWidth;
+ private final int mMostCommonKeyHeight;
private final Key[] mKeys;
private final Key[][] mGridNeighbors;
private final String mLocaleStr;
@@ -63,7 +64,7 @@ public class ProximityInfo {
mCellHeight = (height + mGridHeight - 1) / mGridHeight;
mKeyboardMinWidth = minWidth;
mKeyboardHeight = height;
- mKeyHeight = mostCommonKeyHeight;
+ mMostCommonKeyHeight = mostCommonKeyHeight;
mMostCommonKeyWidth = mostCommonKeyWidth;
mKeys = keys;
mGridNeighbors = new Key[mGridSize][];
@@ -142,22 +143,22 @@ public class ProximityInfo {
sweetSpotCenterXs = new float[keyCount];
sweetSpotCenterYs = new float[keyCount];
sweetSpotRadii = new float[keyCount];
+ final float defaultRadius = DEFAULT_TOUCH_POSITION_CORRECTION_RADIUS
+ * (float)Math.hypot(mMostCommonKeyWidth, mMostCommonKeyHeight);
for (int i = 0; i < keyCount; i++) {
final Key key = keys[i];
final Rect hitBox = key.mHitBox;
- final int row = hitBox.top / mKeyHeight;
+ sweetSpotCenterXs[i] = hitBox.exactCenterX();
+ sweetSpotCenterYs[i] = hitBox.exactCenterY();
+ sweetSpotRadii[i] = defaultRadius;
+ final int row = hitBox.top / mMostCommonKeyHeight;
if (row < touchPositionCorrection.getRows()) {
final int hitBoxWidth = hitBox.width();
final int hitBoxHeight = hitBox.height();
- final float x = touchPositionCorrection.getX(row);
- final float y = touchPositionCorrection.getY(row);
- final float radius = touchPositionCorrection.getRadius(row);
- sweetSpotCenterXs[i] = hitBox.exactCenterX() + x * hitBoxWidth;
- sweetSpotCenterYs[i] = hitBox.exactCenterY() + y * hitBoxHeight;
- // Note that, in recent versions of Android, FloatMath is actually slower than
- // java.lang.Math due to the way the JIT optimizes java.lang.Math.
- sweetSpotRadii[i] = radius * (float)Math.sqrt(
- hitBoxWidth * hitBoxWidth + hitBoxHeight * hitBoxHeight);
+ final float hitBoxDiagonal = (float)Math.hypot(hitBoxWidth, hitBoxHeight);
+ sweetSpotCenterXs[i] += touchPositionCorrection.getX(row) * hitBoxWidth;
+ sweetSpotCenterYs[i] += touchPositionCorrection.getY(row) * hitBoxHeight;
+ sweetSpotRadii[i] = touchPositionCorrection.getRadius(row) * hitBoxDiagonal;
}
}
} else {
@@ -213,7 +214,8 @@ public class ProximityInfo {
}
}
- public void fillArrayWithNearestKeyCodes(int x, int y, int primaryKeyCode, int[] dest) {
+ public void fillArrayWithNearestKeyCodes(final int x, final int y, final int primaryKeyCode,
+ final int[] dest) {
final int destLength = dest.length;
if (destLength < 1) {
return;
@@ -238,7 +240,7 @@ public class ProximityInfo {
}
}
- public Key[] getNearestKeys(int x, int y) {
+ public Key[] getNearestKeys(final int x, final int y) {
if (mGridNeighbors == null) {
return EMPTY_KEY_ARRAY;
}
diff --git a/java/src/com/android/inputmethod/keyboard/internal/TouchPositionCorrection.java b/java/src/com/android/inputmethod/keyboard/internal/TouchPositionCorrection.java
index 811a620b3..d8950a713 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/TouchPositionCorrection.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/TouchPositionCorrection.java
@@ -18,7 +18,7 @@ package com.android.inputmethod.keyboard.internal;
import com.android.inputmethod.latin.LatinImeLogger;
-public class TouchPositionCorrection {
+public final class TouchPositionCorrection {
private static final int TOUCH_POSITION_CORRECTION_RECORD_SIZE = 3;
private boolean mEnabled;
@@ -80,7 +80,9 @@ public class TouchPositionCorrection {
}
public float getX(final int row) {
- return mXs[row];
+ return 0.0f;
+ // Touch position correction data for X coordinate is obsolete.
+ // return mXs[row];
}
public float getY(final int row) {