am 17752016: Calculate default touch position correction data for keys on 4th row

* commit '17752016713b92a55e9c2356d07b7ed51c67416b':
  Calculate default touch position correction data for keys on 4th row
main
Tadashi G. Takaoka 2012-09-27 02:07:14 -07:00 committed by Android Git Automerger
commit aa08b55b09
36 changed files with 124 additions and 30 deletions

View File

@ -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>

View File

@ -19,7 +19,7 @@
<style name="Keyboard"> <style name="Keyboard">
<!-- This should be aligned with KeyboardSwitcher.KEYBOARD_THEMES[] --> <!-- This should be aligned with KeyboardSwitcher.KEYBOARD_THEMES[] -->
<item name="themeId">0</item> <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="rowHeight">25%p</item>
<item name="keyboardHeight">@dimen/keyboardHeight</item> <item name="keyboardHeight">@dimen/keyboardHeight</item>
<item name="maxKeyboardHeight">@fraction/maxKeyboardHeight</item> <item name="maxKeyboardHeight">@fraction/maxKeyboardHeight</item>

View File

@ -18,18 +18,22 @@
*/ */
--> -->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> <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: An entry of the touch_position_correction word should be:
1. (float) (touch_center_x - key_center_x) / key_width 1. correctionX: (touch_center_x - hitbox_center_x) / hitbox_width
2. (float) (touch_center_y - key_center_y) / key_height 2. correctionY: (touch_center_y - hitbox_center_y) / hitbox_height
3. (float) sweet_spot_radius / (key_width^2 + key_height^2) 3. correctionR: sweet_spot_radius / sqrt(hitbox_width^2 + hitbox_height^2)
--> -->
<string-array <string-array
name="touch_position_correction_data_empty" name="touch_position_correction_data_default"
translatable="false" 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>
<string-array <string-array

View File

@ -22,6 +22,7 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardHorizontalEdgesPadding="10%p" latin:keyboardHorizontalEdgesPadding="10%p"
latin:keyWidth="26.67%p" latin:keyWidth="26.67%p"
latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
> >
<include <include
latin:keyboardLayout="@xml/rows_number" /> latin:keyboardLayout="@xml/rows_number" />

View File

@ -22,6 +22,7 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardHorizontalEdgesPadding="10%p" latin:keyboardHorizontalEdgesPadding="10%p"
latin:keyWidth="26.67%p" latin:keyWidth="26.67%p"
latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
> >
<include <include
latin:keyboardLayout="@xml/rows_phone" /> latin:keyboardLayout="@xml/rows_phone" />

View File

@ -22,6 +22,7 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardHorizontalEdgesPadding="10%p" latin:keyboardHorizontalEdgesPadding="10%p"
latin:keyWidth="26.67%p" latin:keyWidth="26.67%p"
latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
> >
<include <include
latin:keyboardLayout="@xml/rows_phone_symbols" /> latin:keyboardLayout="@xml/rows_phone_symbols" />

View File

@ -22,6 +22,7 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardHorizontalEdgesPadding="10%p" latin:keyboardHorizontalEdgesPadding="10%p"
latin:keyWidth="18%p" latin:keyWidth="18%p"
latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
> >
<include <include
latin:keyboardLayout="@xml/rows_number" /> latin:keyboardLayout="@xml/rows_number" />

View File

@ -22,6 +22,7 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardHorizontalEdgesPadding="10%p" latin:keyboardHorizontalEdgesPadding="10%p"
latin:keyWidth="18%p" latin:keyWidth="18%p"
latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
> >
<include <include
latin:keyboardLayout="@xml/rows_phone" /> latin:keyboardLayout="@xml/rows_phone" />

View File

@ -22,6 +22,7 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardHorizontalEdgesPadding="10%p" latin:keyboardHorizontalEdgesPadding="10%p"
latin:keyWidth="18%p" latin:keyWidth="18%p"
latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
> >
<!-- Tablet doesn't have phone symbols keyboard --> <!-- Tablet doesn't have phone symbols keyboard -->
<include <include

View File

@ -20,6 +20,7 @@
<Keyboard <Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
> >
<include <include
latin:keyboardLayout="@xml/rows_10_10_7_symbols" /> latin:keyboardLayout="@xml/rows_10_10_7_symbols" />

View File

@ -20,6 +20,7 @@
<Keyboard <Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
> >
<include <include
latin:keyboardLayout="@xml/rows_10_10_7_symbols_shift" /> latin:keyboardLayout="@xml/rows_10_10_7_symbols_shift" />

View File

@ -21,6 +21,7 @@
<Keyboard <Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyWidth="18%p" latin:keyWidth="18%p"
latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
> >
<include <include
latin:keyboardLayout="@xml/rows_number" /> latin:keyboardLayout="@xml/rows_number" />

View File

@ -21,6 +21,7 @@
<Keyboard <Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyWidth="18%p" latin:keyWidth="18%p"
latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
> >
<include <include
latin:keyboardLayout="@xml/rows_phone" /> latin:keyboardLayout="@xml/rows_phone" />

View File

@ -21,6 +21,7 @@
<Keyboard <Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyWidth="18%p" latin:keyWidth="18%p"
latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
> >
<!-- Tablet doesn't have phone symbols keyboard --> <!-- Tablet doesn't have phone symbols keyboard -->
<include <include

View File

@ -22,6 +22,7 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardHorizontalEdgesPadding="10%p" latin:keyboardHorizontalEdgesPadding="10%p"
latin:keyWidth="13.250%p" latin:keyWidth="13.250%p"
latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
> >
<include <include
latin:keyboardLayout="@xml/rows_number" /> latin:keyboardLayout="@xml/rows_number" />

View File

@ -22,6 +22,7 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardHorizontalEdgesPadding="10%p" latin:keyboardHorizontalEdgesPadding="10%p"
latin:keyWidth="13.250%p" latin:keyWidth="13.250%p"
latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
> >
<include <include
latin:keyboardLayout="@xml/rows_phone" /> latin:keyboardLayout="@xml/rows_phone" />

View File

@ -22,6 +22,7 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyboardHorizontalEdgesPadding="10%p" latin:keyboardHorizontalEdgesPadding="10%p"
latin:keyWidth="13.250%p" latin:keyWidth="13.250%p"
latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
> >
<!-- Tablet doesn't have phone symbols keyboard --> <!-- Tablet doesn't have phone symbols keyboard -->
<include <include

View File

@ -21,6 +21,7 @@
<Keyboard <Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyWidth="13.250%p" latin:keyWidth="13.250%p"
latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
> >
<include <include
latin:keyboardLayout="@xml/rows_number" /> latin:keyboardLayout="@xml/rows_number" />

View File

@ -21,6 +21,7 @@
<Keyboard <Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyWidth="13.250%p" latin:keyWidth="13.250%p"
latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
> >
<include <include
latin:keyboardLayout="@xml/rows_phone" /> latin:keyboardLayout="@xml/rows_phone" />

View File

@ -21,6 +21,7 @@
<Keyboard <Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyWidth="13.250%p" latin:keyWidth="13.250%p"
latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
> >
<!-- Tablet doesn't have phone symbols keyboard --> <!-- Tablet doesn't have phone symbols keyboard -->
<include <include

View File

@ -24,7 +24,7 @@
latin:verticalGap="@fraction/key_bottom_gap_5row" latin:verticalGap="@fraction/key_bottom_gap_5row"
latin:keyLetterSize="@fraction/key_letter_ratio_5row" latin:keyLetterSize="@fraction/key_letter_ratio_5row"
latin:keyShiftedLetterHintRatio="@fraction/key_uppercase_letter_ratio_5row" latin:keyShiftedLetterHintRatio="@fraction/key_uppercase_letter_ratio_5row"
latin:touchPositionCorrectionData="@null" latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
> >
<include <include
latin:keyboardLayout="@xml/rows_thai_symbols" /> latin:keyboardLayout="@xml/rows_thai_symbols" />

View File

@ -24,7 +24,7 @@
latin:verticalGap="@fraction/key_bottom_gap_5row" latin:verticalGap="@fraction/key_bottom_gap_5row"
latin:keyLetterSize="@fraction/key_letter_ratio_5row" latin:keyLetterSize="@fraction/key_letter_ratio_5row"
latin:keyShiftedLetterHintRatio="@fraction/key_uppercase_letter_ratio_5row" latin:keyShiftedLetterHintRatio="@fraction/key_uppercase_letter_ratio_5row"
latin:touchPositionCorrectionData="@null" latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
> >
<include <include
latin:keyboardLayout="@xml/rows_thai_symbols_shift" /> latin:keyboardLayout="@xml/rows_thai_symbols_shift" />

View File

@ -20,6 +20,7 @@
<Keyboard <Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
> >
<include <include
latin:keyboardLayout="@xml/rows_symbols" /> latin:keyboardLayout="@xml/rows_symbols" />

View File

@ -20,6 +20,7 @@
<Keyboard <Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
> >
<include <include
latin:keyboardLayout="@xml/rows_symbols_shift" /> latin:keyboardLayout="@xml/rows_symbols_shift" />

View File

@ -21,6 +21,7 @@
<Keyboard <Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyWidth="26.67%p" latin:keyWidth="26.67%p"
latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
> >
<include <include
latin:keyboardLayout="@xml/rows_number" /> latin:keyboardLayout="@xml/rows_number" />

View File

@ -24,7 +24,7 @@
latin:verticalGap="@fraction/key_bottom_gap_5row" latin:verticalGap="@fraction/key_bottom_gap_5row"
latin:keyLetterSize="@fraction/key_letter_ratio_5row" latin:keyLetterSize="@fraction/key_letter_ratio_5row"
latin:keyShiftedLetterHintRatio="@fraction/key_uppercase_letter_ratio_5row" latin:keyShiftedLetterHintRatio="@fraction/key_uppercase_letter_ratio_5row"
latin:touchPositionCorrectionData="@null" latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
> >
<include <include
latin:keyboardLayout="@xml/rows_pcqwerty" /> latin:keyboardLayout="@xml/rows_pcqwerty" />

View File

@ -24,7 +24,7 @@
latin:verticalGap="@fraction/key_bottom_gap_5row" latin:verticalGap="@fraction/key_bottom_gap_5row"
latin:keyLetterSize="@fraction/key_letter_ratio_5row" latin:keyLetterSize="@fraction/key_letter_ratio_5row"
latin:keyShiftedLetterHintRatio="@fraction/key_uppercase_letter_ratio_5row" latin:keyShiftedLetterHintRatio="@fraction/key_uppercase_letter_ratio_5row"
latin:touchPositionCorrectionData="@null" latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
> >
<include <include
latin:keyboardLayout="@xml/rows_pcqwerty_symbols" /> latin:keyboardLayout="@xml/rows_pcqwerty_symbols" />

View File

@ -21,6 +21,7 @@
<Keyboard <Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyWidth="26.67%p" latin:keyWidth="26.67%p"
latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
> >
<include <include
latin:keyboardLayout="@xml/rows_phone" /> latin:keyboardLayout="@xml/rows_phone" />

View File

@ -21,6 +21,7 @@
<Keyboard <Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:keyWidth="26.67%p" latin:keyWidth="26.67%p"
latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
> >
<include <include
latin:keyboardLayout="@xml/rows_phone_symbols" /> latin:keyboardLayout="@xml/rows_phone_symbols" />

View File

@ -20,6 +20,7 @@
<Keyboard <Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
> >
<include <include
latin:keyboardLayout="@xml/rows_symbols" /> latin:keyboardLayout="@xml/rows_symbols" />

View File

@ -20,6 +20,7 @@
<Keyboard <Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
> >
<include <include
latin:keyboardLayout="@xml/rows_symbols_shift" /> latin:keyboardLayout="@xml/rows_symbols_shift" />

View File

@ -24,7 +24,7 @@
latin:verticalGap="@fraction/key_bottom_gap_5row" latin:verticalGap="@fraction/key_bottom_gap_5row"
latin:keyLetterSize="@fraction/key_letter_ratio_5row" latin:keyLetterSize="@fraction/key_letter_ratio_5row"
latin:keyShiftedLetterHintRatio="@fraction/key_uppercase_letter_ratio_5row" latin:keyShiftedLetterHintRatio="@fraction/key_uppercase_letter_ratio_5row"
latin:touchPositionCorrectionData="@null" latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
> >
<include <include
latin:keyboardLayout="@xml/rows_thai" /> latin:keyboardLayout="@xml/rows_thai" />

View File

@ -20,6 +20,7 @@
<Keyboard <Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
> >
<include <include
latin:keyboardLayout="@xml/rows_symbols" /> latin:keyboardLayout="@xml/rows_symbols" />

View File

@ -20,6 +20,7 @@
<Keyboard <Keyboard
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
> >
<include <include
latin:keyboardLayout="@xml/rows_symbols_shift" /> latin:keyboardLayout="@xml/rows_symbols_shift" />

View File

@ -25,15 +25,15 @@ import com.android.inputmethod.latin.JniUtils;
import java.util.Arrays; 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 /** MAX_PROXIMITY_CHARS_SIZE must be the same as MAX_PROXIMITY_CHARS_SIZE_INTERNAL
* in defines.h */ * in defines.h */
public static final int MAX_PROXIMITY_CHARS_SIZE = 16; public static final int MAX_PROXIMITY_CHARS_SIZE = 16;
/** Number of key widths from current touch point to search for nearest keys. */ /** Number of key widths from current touch point to search for nearest keys. */
private static float SEARCH_DISTANCE = 1.2f; private static float SEARCH_DISTANCE = 1.2f;
private static final Key[] EMPTY_KEY_ARRAY = new Key[0]; 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 mGridWidth;
private final int mGridHeight; private final int mGridHeight;
private final int mGridSize; private final int mGridSize;
@ -43,6 +43,7 @@ public class ProximityInfo {
private final int mKeyboardMinWidth; private final int mKeyboardMinWidth;
private final int mKeyboardHeight; private final int mKeyboardHeight;
private final int mMostCommonKeyWidth; private final int mMostCommonKeyWidth;
private final int mMostCommonKeyHeight;
private final Key[] mKeys; private final Key[] mKeys;
private final Key[][] mGridNeighbors; private final Key[][] mGridNeighbors;
private final String mLocaleStr; private final String mLocaleStr;
@ -63,7 +64,7 @@ public class ProximityInfo {
mCellHeight = (height + mGridHeight - 1) / mGridHeight; mCellHeight = (height + mGridHeight - 1) / mGridHeight;
mKeyboardMinWidth = minWidth; mKeyboardMinWidth = minWidth;
mKeyboardHeight = height; mKeyboardHeight = height;
mKeyHeight = mostCommonKeyHeight; mMostCommonKeyHeight = mostCommonKeyHeight;
mMostCommonKeyWidth = mostCommonKeyWidth; mMostCommonKeyWidth = mostCommonKeyWidth;
mKeys = keys; mKeys = keys;
mGridNeighbors = new Key[mGridSize][]; mGridNeighbors = new Key[mGridSize][];
@ -142,22 +143,22 @@ public class ProximityInfo {
sweetSpotCenterXs = new float[keyCount]; sweetSpotCenterXs = new float[keyCount];
sweetSpotCenterYs = new float[keyCount]; sweetSpotCenterYs = new float[keyCount];
sweetSpotRadii = 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++) { for (int i = 0; i < keyCount; i++) {
final Key key = keys[i]; final Key key = keys[i];
final Rect hitBox = key.mHitBox; 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()) { if (row < touchPositionCorrection.getRows()) {
final int hitBoxWidth = hitBox.width(); final int hitBoxWidth = hitBox.width();
final int hitBoxHeight = hitBox.height(); final int hitBoxHeight = hitBox.height();
final float x = touchPositionCorrection.getX(row); final float hitBoxDiagonal = (float)Math.hypot(hitBoxWidth, hitBoxHeight);
final float y = touchPositionCorrection.getY(row); sweetSpotCenterXs[i] += touchPositionCorrection.getX(row) * hitBoxWidth;
final float radius = touchPositionCorrection.getRadius(row); sweetSpotCenterYs[i] += touchPositionCorrection.getY(row) * hitBoxHeight;
sweetSpotCenterXs[i] = hitBox.exactCenterX() + x * hitBoxWidth; sweetSpotRadii[i] = touchPositionCorrection.getRadius(row) * hitBoxDiagonal;
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);
} }
} }
} else { } 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; final int destLength = dest.length;
if (destLength < 1) { if (destLength < 1) {
return; 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) { if (mGridNeighbors == null) {
return EMPTY_KEY_ARRAY; return EMPTY_KEY_ARRAY;
} }

View File

@ -18,7 +18,7 @@ package com.android.inputmethod.keyboard.internal;
import com.android.inputmethod.latin.LatinImeLogger; import com.android.inputmethod.latin.LatinImeLogger;
public class TouchPositionCorrection { public final class TouchPositionCorrection {
private static final int TOUCH_POSITION_CORRECTION_RECORD_SIZE = 3; private static final int TOUCH_POSITION_CORRECTION_RECORD_SIZE = 3;
private boolean mEnabled; private boolean mEnabled;
@ -80,7 +80,9 @@ public class TouchPositionCorrection {
} }
public float getX(final int row) { 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) { public float getY(final int row) {