Merge "Disable touch position correction of MoreKeysKeyboard"
This commit is contained in:
commit
11cec73499
2 changed files with 23 additions and 2 deletions
|
@ -124,6 +124,7 @@
|
|||
<item name="keyboardTopPadding">0dp</item>
|
||||
<item name="keyboardBottomPadding">0dp</item>
|
||||
<item name="horizontalGap">0dp</item>
|
||||
<item name="touchPositionCorrectionData">@null</item>
|
||||
</style>
|
||||
<style
|
||||
name="MoreKeysKeyboardView"
|
||||
|
@ -231,6 +232,7 @@
|
|||
<item name="keyboardTopPadding">0dp</item>
|
||||
<item name="keyboardBottomPadding">0dp</item>
|
||||
<item name="horizontalGap">0dp</item>
|
||||
<item name="touchPositionCorrectionData">@null</item>
|
||||
</style>
|
||||
<style
|
||||
name="MoreKeysKeyboardView.Stone"
|
||||
|
@ -300,6 +302,7 @@
|
|||
<item name="keyboardTopPadding">0dp</item>
|
||||
<item name="keyboardBottomPadding">0dp</item>
|
||||
<item name="horizontalGap">0dp</item>
|
||||
<item name="touchPositionCorrectionData">@null</item>
|
||||
</style>
|
||||
<style
|
||||
name="MoreKeysKeyboardView.Gingerbread"
|
||||
|
@ -355,6 +358,7 @@
|
|||
<item name="keyboardTopPadding">0dp</item>
|
||||
<item name="keyboardBottomPadding">0dp</item>
|
||||
<item name="horizontalGap">0dp</item>
|
||||
<item name="touchPositionCorrectionData">@null</item>
|
||||
</style>
|
||||
<style
|
||||
name="MoreKeysKeyboardView.IceCreamSandwich"
|
||||
|
|
|
@ -18,6 +18,7 @@ package com.android.inputmethod.keyboard;
|
|||
|
||||
import android.graphics.Rect;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.inputmethod.keyboard.internal.TouchPositionCorrection;
|
||||
import com.android.inputmethod.latin.Constants;
|
||||
|
@ -26,11 +27,14 @@ import com.android.inputmethod.latin.JniUtils;
|
|||
import java.util.Arrays;
|
||||
|
||||
public final class ProximityInfo {
|
||||
private static final String TAG = ProximityInfo.class.getSimpleName();
|
||||
private static final boolean DEBUG = false;
|
||||
|
||||
/** 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 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;
|
||||
|
||||
|
@ -140,9 +144,13 @@ public final class ProximityInfo {
|
|||
}
|
||||
|
||||
if (touchPositionCorrection != null && touchPositionCorrection.isValid()) {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "touchPositionCorrection: ON");
|
||||
}
|
||||
sweetSpotCenterXs = new float[keyCount];
|
||||
sweetSpotCenterYs = new float[keyCount];
|
||||
sweetSpotRadii = new float[keyCount];
|
||||
final int rows = touchPositionCorrection.getRows();
|
||||
final float defaultRadius = DEFAULT_TOUCH_POSITION_CORRECTION_RADIUS
|
||||
* (float)Math.hypot(mMostCommonKeyWidth, mMostCommonKeyHeight);
|
||||
for (int i = 0; i < keyCount; i++) {
|
||||
|
@ -152,7 +160,7 @@ public final class ProximityInfo {
|
|||
sweetSpotCenterYs[i] = hitBox.exactCenterY();
|
||||
sweetSpotRadii[i] = defaultRadius;
|
||||
final int row = hitBox.top / mMostCommonKeyHeight;
|
||||
if (row < touchPositionCorrection.getRows()) {
|
||||
if (row < rows) {
|
||||
final int hitBoxWidth = hitBox.width();
|
||||
final int hitBoxHeight = hitBox.height();
|
||||
final float hitBoxDiagonal = (float)Math.hypot(hitBoxWidth, hitBoxHeight);
|
||||
|
@ -160,9 +168,18 @@ public final class ProximityInfo {
|
|||
sweetSpotCenterYs[i] += touchPositionCorrection.getY(row) * hitBoxHeight;
|
||||
sweetSpotRadii[i] = touchPositionCorrection.getRadius(row) * hitBoxDiagonal;
|
||||
}
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, String.format(
|
||||
" [%2d] row=%d x/y/r=%7.2f/%7.2f/%5.2f %s code=%s", i, row,
|
||||
sweetSpotCenterXs[i], sweetSpotCenterYs[i], sweetSpotRadii[i],
|
||||
row < rows ? "correct" : "default", Keyboard.printableCode(key.mCode)));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sweetSpotCenterXs = sweetSpotCenterYs = sweetSpotRadii = null;
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "touchPositionCorrection: OFF");
|
||||
}
|
||||
}
|
||||
|
||||
return setProximityInfoNative(mLocaleStr, MAX_PROXIMITY_CHARS_SIZE,
|
||||
|
|
Loading…
Reference in a new issue