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
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 0000000..f77d3ae
--- /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 d520392..928c5f5 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 41b435a..7df86f4 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 7cc0fb2..8d31df1 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 aa54b83..2f8fc35 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 41ba6cf..0e6bcdd 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 cb86b3b..63dfc90 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 71c7c04..b616111 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 39bdae3..9b0bee0 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 66254de..dd545b5 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 3c5ed5e..c36f009 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 4a8b08c..71d6622 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 f63f1c6..5fdbea2 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 a0f55b7..ce24d2b 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 3ad25a3..de8d559 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 abe7e7c..f88a076 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 641464d..eaa413e 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 b20123c..1b46edd 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 fa9bf1b..947ede0 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 e1a359e..dd9a6ae 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 0cd9a61..5ddf574 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 a68fec4..135222b 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 7e075df..4d9861b 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 25db3c8..a2d67ca 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 8b0deea..aa8872f 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 777c71a..5155bc5 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 a2297f7..bfb39e8 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 91637b6..dab3d49 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 7f59a85..ba4e464 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 f6612a2..47e08d5 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 41a5571..932ec01 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 b4a4a0b..294bffb 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 7e075df..4d9861b 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 25db3c8..a2d67ca 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 6e13894..06a9e92 100644
--- a/java/src/com/android/inputmethod/keyboard/ProximityInfo.java
+++ b/java/src/com/android/inputmethod/keyboard/ProximityInfo.java
@@ -25,15 +25,15 @@
 
 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 @@
     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 @@
         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 @@
             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 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 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 811a620..d8950a7 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 @@
 
 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 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) {