From 17752016713b92a55e9c2356d07b7ed51c67416b Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" <takaoka@google.com> Date: Thu, 27 Sep 2012 15:27:51 +0900 Subject: [PATCH] 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 --- .../touch-position-correction.xml | 60 +++++++++++++++++++ java/res/values/styles.xml | 2 +- java/res/values/touch-position-correction.xml | 18 +++--- java/res/xml-land/kbd_number.xml | 1 + java/res/xml-land/kbd_phone.xml | 1 + java/res/xml-land/kbd_phone_symbols.xml | 1 + java/res/xml-sw600dp-land/kbd_number.xml | 1 + java/res/xml-sw600dp-land/kbd_phone.xml | 1 + .../xml-sw600dp-land/kbd_phone_symbols.xml | 1 + java/res/xml-sw600dp/kbd_10_10_7_symbols.xml | 1 + .../xml-sw600dp/kbd_10_10_7_symbols_shift.xml | 1 + java/res/xml-sw600dp/kbd_number.xml | 1 + java/res/xml-sw600dp/kbd_phone.xml | 1 + java/res/xml-sw600dp/kbd_phone_symbols.xml | 1 + java/res/xml-sw768dp-land/kbd_number.xml | 1 + java/res/xml-sw768dp-land/kbd_phone.xml | 1 + .../xml-sw768dp-land/kbd_phone_symbols.xml | 1 + java/res/xml-sw768dp/kbd_number.xml | 1 + java/res/xml-sw768dp/kbd_phone.xml | 1 + java/res/xml-sw768dp/kbd_phone_symbols.xml | 1 + java/res/xml-sw768dp/kbd_thai_symbols.xml | 2 +- .../xml-sw768dp/kbd_thai_symbols_shift.xml | 2 +- java/res/xml/kbd_10_10_7_symbols.xml | 1 + java/res/xml/kbd_10_10_7_symbols_shift.xml | 1 + java/res/xml/kbd_number.xml | 1 + java/res/xml/kbd_pcqwerty.xml | 2 +- java/res/xml/kbd_pcqwerty_symbols.xml | 2 +- java/res/xml/kbd_phone.xml | 1 + java/res/xml/kbd_phone_symbols.xml | 1 + java/res/xml/kbd_symbols.xml | 1 + java/res/xml/kbd_symbols_shift.xml | 1 + java/res/xml/kbd_thai.xml | 2 +- java/res/xml/kbd_thai_symbols.xml | 1 + java/res/xml/kbd_thai_symbols_shift.xml | 1 + .../inputmethod/keyboard/ProximityInfo.java | 32 +++++----- .../internal/TouchPositionCorrection.java | 6 +- 36 files changed, 124 insertions(+), 30 deletions(-) create mode 100644 java/res/values-sw600dp/touch-position-correction.xml 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 0000000000..f77d3ae836 --- /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 d520392215..928c5f5d00 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 41b435ad01..7df86f467c 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 7cc0fb2748..8d31df1f85 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 aa54b83909..2f8fc3560e 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 41ba6cf3b9..0e6bcdd6a8 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 cb86b3b2f2..63dfc90d01 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 71c7c04a17..b6161111b4 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 39bdae3c78..9b0bee026c 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 66254dea0c..dd545b5ef8 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 3c5ed5e092..c36f0097e9 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 4a8b08c2a9..71d6622678 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 f63f1c6484..5fdbea27b7 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 a0f55b7325..ce24d2b39c 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 3ad25a3922..de8d559040 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 abe7e7c41d..f88a076f66 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 641464dbe4..eaa413e7de 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 b20123c80c..1b46edd50d 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 fa9bf1bf49..947ede0505 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 e1a359e84d..dd9a6aebd7 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 0cd9a61ea8..5ddf57446f 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 a68fec458b..135222b22a 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 7e075df48e..4d9861b73c 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 25db3c84d9..a2d67caf40 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 8b0deea972..aa8872f26c 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 777c71af33..5155bc510d 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 a2297f7026..bfb39e8aa9 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 91637b62c3..dab3d494a2 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 7f59a855aa..ba4e4646d3 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 f6612a2f73..47e08d57f8 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 41a5571ef0..932ec017eb 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 b4a4a0b925..294bffb5b8 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 7e075df48e..4d9861b73c 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 25db3c84d9..a2d67caf40 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 6e138946f3..06a9e9252f 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 811a620b30..d8950a7132 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) { -- GitLab