am 10d76cdc: Merge "Fix touch position correction data passing" into jb-mr1-dev
* commit '10d76cdcd6fe08c6df01d6f72f58e1215836000e': Fix touch position correction data passingmain
commit
4156a11d35
|
@ -96,7 +96,7 @@ public class KeyboardLayoutSet {
|
|||
String mKeyboardLayoutSetName;
|
||||
int mMode;
|
||||
EditorInfo mEditorInfo;
|
||||
boolean mTouchPositionCorrectionEnabled;
|
||||
boolean mDisableTouchPositionCorrectionDataForTest;
|
||||
boolean mVoiceKeyEnabled;
|
||||
boolean mVoiceKeyOnMain;
|
||||
boolean mNoSettingsKey;
|
||||
|
@ -167,7 +167,9 @@ public class KeyboardLayoutSet {
|
|||
}
|
||||
final int keyboardXmlId = elementParams.mKeyboardXmlId;
|
||||
builder.load(keyboardXmlId, id);
|
||||
builder.setTouchPositionCorrectionEnabled(mParams.mTouchPositionCorrectionEnabled);
|
||||
if (mParams.mDisableTouchPositionCorrectionDataForTest) {
|
||||
builder.disableTouchPositionCorrectionDataForTest();
|
||||
}
|
||||
builder.setProximityCharsCorrectionEnabled(
|
||||
elementParams.mProximityCharsCorrectionEnabled);
|
||||
keyboard = builder.build();
|
||||
|
@ -264,8 +266,9 @@ public class KeyboardLayoutSet {
|
|||
return this;
|
||||
}
|
||||
|
||||
public void setTouchPositionCorrectionEnabled(final boolean enabled) {
|
||||
mParams.mTouchPositionCorrectionEnabled = enabled;
|
||||
// For test only
|
||||
public void disableTouchPositionCorrectionDataForTest() {
|
||||
mParams.mDisableTouchPositionCorrectionDataForTest = true;
|
||||
}
|
||||
|
||||
public KeyboardLayoutSet build() {
|
||||
|
|
|
@ -44,7 +44,6 @@ public class ProximityInfo {
|
|||
private final int mKeyboardHeight;
|
||||
private final int mMostCommonKeyWidth;
|
||||
private final Key[] mKeys;
|
||||
private final TouchPositionCorrection mTouchPositionCorrection;
|
||||
private final Key[][] mGridNeighbors;
|
||||
private final String mLocaleStr;
|
||||
|
||||
|
@ -67,14 +66,13 @@ public class ProximityInfo {
|
|||
mKeyHeight = mostCommonKeyHeight;
|
||||
mMostCommonKeyWidth = mostCommonKeyWidth;
|
||||
mKeys = keys;
|
||||
mTouchPositionCorrection = touchPositionCorrection;
|
||||
mGridNeighbors = new Key[mGridSize][];
|
||||
if (minWidth == 0 || height == 0) {
|
||||
// No proximity required. Keyboard might be more keys keyboard.
|
||||
return;
|
||||
}
|
||||
computeNearestNeighbors();
|
||||
mNativeProximityInfo = createNativeProximityInfo();
|
||||
mNativeProximityInfo = createNativeProximityInfo(touchPositionCorrection);
|
||||
}
|
||||
|
||||
public static ProximityInfo createDummyProximityInfo() {
|
||||
|
@ -106,12 +104,12 @@ public class ProximityInfo {
|
|||
|
||||
private native void releaseProximityInfoNative(long nativeProximityInfo);
|
||||
|
||||
private final long createNativeProximityInfo() {
|
||||
private final long createNativeProximityInfo(
|
||||
final TouchPositionCorrection touchPositionCorrection) {
|
||||
final Key[][] gridNeighborKeys = mGridNeighbors;
|
||||
final int keyboardWidth = mKeyboardMinWidth;
|
||||
final int keyboardHeight = mKeyboardHeight;
|
||||
final Key[] keys = mKeys;
|
||||
final TouchPositionCorrection touchPositionCorrection = mTouchPositionCorrection;
|
||||
final int[] proximityCharsArray = new int[mGridSize * MAX_PROXIMITY_CHARS_SIZE];
|
||||
Arrays.fill(proximityCharsArray, Constants.NOT_A_CODE);
|
||||
for (int i = 0; i < mGridSize; ++i) {
|
||||
|
@ -148,12 +146,12 @@ public class ProximityInfo {
|
|||
final Key key = keys[i];
|
||||
final Rect hitBox = key.mHitBox;
|
||||
final int row = hitBox.top / mKeyHeight;
|
||||
if (row < touchPositionCorrection.mRadii.length) {
|
||||
if (row < touchPositionCorrection.getRows()) {
|
||||
final int hitBoxWidth = hitBox.width();
|
||||
final int hitBoxHeight = hitBox.height();
|
||||
final float x = touchPositionCorrection.mXs[row];
|
||||
final float y = touchPositionCorrection.mYs[row];
|
||||
final float radius = touchPositionCorrection.mRadii[row];
|
||||
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
|
||||
|
|
|
@ -177,9 +177,9 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
|
|||
return this;
|
||||
}
|
||||
|
||||
// TODO: Remove this method.
|
||||
public void setTouchPositionCorrectionEnabled(final boolean enabled) {
|
||||
mParams.mTouchPositionCorrection.setEnabled(enabled);
|
||||
// For test only
|
||||
public void disableTouchPositionCorrectionDataForTest() {
|
||||
mParams.mTouchPositionCorrection.setEnabled(false);
|
||||
}
|
||||
|
||||
public void setProximityCharsCorrectionEnabled(final boolean enabled) {
|
||||
|
@ -314,7 +314,6 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
|
|||
|
||||
final int resourceId = keyboardAttr.getResourceId(
|
||||
R.styleable.Keyboard_touchPositionCorrectionData, 0);
|
||||
params.mTouchPositionCorrection.setEnabled(resourceId != 0);
|
||||
if (resourceId != 0) {
|
||||
final String[] data = mResources.getStringArray(resourceId);
|
||||
params.mTouchPositionCorrection.load(data);
|
||||
|
|
|
@ -21,10 +21,10 @@ import com.android.inputmethod.latin.LatinImeLogger;
|
|||
public class TouchPositionCorrection {
|
||||
private static final int TOUCH_POSITION_CORRECTION_RECORD_SIZE = 3;
|
||||
|
||||
public boolean mEnabled;
|
||||
public float[] mXs;
|
||||
public float[] mYs;
|
||||
public float[] mRadii;
|
||||
private boolean mEnabled;
|
||||
private float[] mXs;
|
||||
private float[] mYs;
|
||||
private float[] mRadii;
|
||||
|
||||
public void load(final String[] data) {
|
||||
final int dataLength = data.length;
|
||||
|
@ -53,24 +53,41 @@ public class TouchPositionCorrection {
|
|||
mRadii[index] = value;
|
||||
}
|
||||
}
|
||||
mEnabled = dataLength > 0;
|
||||
} catch (NumberFormatException e) {
|
||||
if (LatinImeLogger.sDBG) {
|
||||
throw new RuntimeException(
|
||||
"the number format for touch position correction data is invalid");
|
||||
}
|
||||
mEnabled = false;
|
||||
mXs = null;
|
||||
mYs = null;
|
||||
mRadii = null;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Remove this method.
|
||||
// For test only
|
||||
public void setEnabled(final boolean enabled) {
|
||||
mEnabled = enabled;
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return mEnabled && mXs != null && mYs != null && mRadii != null
|
||||
&& mXs.length > 0 && mYs.length > 0 && mRadii.length > 0;
|
||||
return mEnabled;
|
||||
}
|
||||
|
||||
public int getRows() {
|
||||
return mRadii.length;
|
||||
}
|
||||
|
||||
public float getX(final int row) {
|
||||
return mXs[row];
|
||||
}
|
||||
|
||||
public float getY(final int row) {
|
||||
return mYs[row];
|
||||
}
|
||||
|
||||
public float getRadius(final int row) {
|
||||
return mRadii[row];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue