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 0000000000000000000000000000000000000000..f77d3ae836dfb0d7e6d41e76700facbddd76f9aa --- /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 d520392215265d877f9a27631774d7f432d40dc7..928c5f5d009745235af5b3d029228faed22076ea 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 41b435ad013d692d9292c040b992e86054113402..7df86f467c33cff2d28d9d7f7e6d83a10765a613 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 7cc0fb2748edf46f568ef61496f71c6dd5c17e4d..8d31df1f85146183badc51dc8c054848b165166d 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 aa54b83909e2a8c16e72391b2834631d094d7905..2f8fc3560e0f666904146f3314fe8600f03e9fe3 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 41ba6cf3b947d1598f2d1f2bfb85c56730f325e5..0e6bcdd6a82a644f7d55541674f57c74dd38d635 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 cb86b3b2f2683cb1a29cf4153fa83d6a604140e8..63dfc90d0186e4b55b54e099bc32dc2acb9121c8 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 71c7c04a1768513e08c5f7be442e98bb5ae65450..b6161111b44b4d184c9c26379fb37b4c2f2b21a8 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 39bdae3c78647a6860c74882cc5d8ea14dab8815..9b0bee026cc250f40fbec05a904d8faf68bac0c8 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 66254dea0c9b904041d7aa5feece43d972c352a9..dd545b5ef8ae5af76ddb5e6a0aeaea0f37b1d812 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 3c5ed5e092e77175c2e062aad0bb5c0cf30a44fb..c36f0097e92236d9bf4f948e898b42c7f3a450af 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 4a8b08c2a9cacae1f0dbd286d00e50edf1fc60b3..71d6622678fa4f623ef23ffaf1a35757104993aa 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 f63f1c6484e717d190cb448fa652eb9529c39522..5fdbea27b7379042cb875141a06a8694e7e0287c 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 a0f55b73255e3e2d5287c1d02989e58f57ec8a27..ce24d2b39c55a9d3e714d57ddb65dead27483dbb 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 3ad25a3922c1ac7f72cbe9846cdc59f84577a692..de8d559040b5e9387117508e4040f601c5ae8f85 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 abe7e7c41de84ba69840689300183e6a3f248570..f88a076f66910cd0d5460a16b37aa8ed0a95bb9c 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 641464dbe4e12ce1763c99178603b2e39fb79948..eaa413e7de6fb67cad8083f6ce7cb98534afdae3 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 b20123c80c74bf7cc4d798177052f97e7eaf32b8..1b46edd50dfb5d809f4190280eae789cae6d2cb4 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 fa9bf1bf49ecaeba180f247648e9d38cb4075aee..947ede0505d2bd3de8d2227f6f94c975746597fe 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 e1a359e84d98f3c8a22be66c8e071cbfee9faa2b..dd9a6aebd741ad040c2990fed652f2f9916f751e 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 0cd9a61ea861e872446d96965adb021764fb570e..5ddf57446f1701ed30a7299399cebd8481a276ce 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 a68fec458bc0eb041324e59b81857730e7e4c61a..135222b22a228282d0311f5d94e9256fb0d78c3b 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 7e075df48ebddfdeb961549d065fd20f2b41d68d..4d9861b73c777125040fe0d2e96402fb7d90ac0e 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 25db3c84d9fd20a371acf31a43c547b4fe382df9..a2d67caf402ffd74ccc884c5560223ed3c479093 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 8b0deea9726e29a2a249bba4e91e9a47fa90d352..aa8872f26cc11e16dd2726b483825034705a8ab7 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 777c71af33ab497dce468d3a38bca9e5e42adf83..5155bc510d93ab07c18427f33f07e853b04604b6 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 a2297f702647a42f497a87bccbf95c14f98a9196..bfb39e8aa92a34668e3b431cd252be4a91d8bc79 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 91637b62c395a89dd90eaa4477369dfd6908ca61..dab3d494a212238715db6f99b486fdc06769bffc 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 7f59a855aadf4e21144281197997cb6eecd0da0e..ba4e4646d3c4f8a6888a1eb68a4a0f998248b7b5 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 f6612a2f73a62d84ed205c7d7e91df148a0473de..47e08d57f89377a169c90851142b2ff53b9995b0 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 41a5571ef01eadc1556685ad379ab944cae7edf2..932ec017eb77d47d5a100660d8ae1e0287d882e8 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 b4a4a0b925d839ce0f45a3c244ac84135438c705..294bffb5b8b621e707b4883e4d9684183b23dfb2 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 7e075df48ebddfdeb961549d065fd20f2b41d68d..4d9861b73c777125040fe0d2e96402fb7d90ac0e 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 25db3c84d9fd20a371acf31a43c547b4fe382df9..a2d67caf402ffd74ccc884c5560223ed3c479093 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 6e138946f3999eb4f822b4812dc54c427185f9cc..06a9e9252f9cd51c2722e1f6ed8621f06440f8b7 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 811a620b309a09da8c02491fe330168eb8c3ca5a..d8950a71320f92564f232f055205b49b0098f99f 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) {