Don't send touch coordinates if proximity characters correction is disabled

Bug: 6225317
Change-Id: I4fa65e020d838f53066d4a071f58fb6f40583e0b
This commit is contained in:
Tadashi G. Takaoka 2012-03-28 17:33:25 +09:00
parent a501caa9a5
commit 8dcad2ed47
42 changed files with 176 additions and 50 deletions

View file

@ -424,5 +424,7 @@
<enum name="number" value="9" /> <enum name="number" value="9" />
</attr> </attr>
<attr name="elementKeyboard" format="reference"/> <attr name="elementKeyboard" format="reference"/>
<!-- Enable proximity characters correction. Disabled by default. -->
<attr name="enableProximityCharsCorrection" format="boolean" />
</declare-styleable> </declare-styleable>
</resources> </resources>

View file

@ -23,7 +23,8 @@
latin:keyboardLocale="ar" > latin:keyboardLocale="ar" >
<Element <Element
latin:elementName="alphabet" latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_arabic" /> latin:elementKeyboard="@xml/kbd_arabic"
latin:enableProximityCharsCorrection="true" />
<Element <Element
latin:elementName="symbols" latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" /> latin:elementKeyboard="@xml/kbd_symbols" />

View file

@ -23,7 +23,8 @@
latin:keyboardLocale="be"> latin:keyboardLocale="be">
<Element <Element
latin:elementName="alphabet" latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_east_slavic" /> latin:elementKeyboard="@xml/kbd_east_slavic"
latin:enableProximityCharsCorrection="true" />
<Element <Element
latin:elementName="symbols" latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" /> latin:elementKeyboard="@xml/kbd_symbols" />

View file

@ -23,7 +23,8 @@
latin:keyboardLocale="bg"> latin:keyboardLocale="bg">
<Element <Element
latin:elementName="alphabet" latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_bulgarian" /> latin:elementKeyboard="@xml/kbd_bulgarian"
latin:enableProximityCharsCorrection="true" />
<Element <Element
latin:elementName="symbols" latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" /> latin:elementKeyboard="@xml/kbd_symbols" />

View file

@ -23,7 +23,8 @@
latin:keyboardLocale="cs"> latin:keyboardLocale="cs">
<Element <Element
latin:elementName="alphabet" latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_qwertz" /> latin:elementKeyboard="@xml/kbd_qwertz"
latin:enableProximityCharsCorrection="true" />
<Element <Element
latin:elementName="symbols" latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" /> latin:elementKeyboard="@xml/kbd_symbols" />

View file

@ -23,7 +23,8 @@
latin:keyboardLocale="da"> latin:keyboardLocale="da">
<Element <Element
latin:elementName="alphabet" latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_nordic" /> latin:elementKeyboard="@xml/kbd_nordic"
latin:enableProximityCharsCorrection="true" />
<Element <Element
latin:elementName="symbols" latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" /> latin:elementKeyboard="@xml/kbd_symbols" />

View file

@ -23,7 +23,8 @@
latin:keyboardLocale="de"> latin:keyboardLocale="de">
<Element <Element
latin:elementName="alphabet" latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_qwerty" /> latin:elementKeyboard="@xml/kbd_qwerty"
latin:enableProximityCharsCorrection="true" />
<Element <Element
latin:elementName="symbols" latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" /> latin:elementKeyboard="@xml/kbd_symbols" />

View file

@ -23,7 +23,8 @@
latin:keyboardLocale="de"> latin:keyboardLocale="de">
<Element <Element
latin:elementName="alphabet" latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_qwertz" /> latin:elementKeyboard="@xml/kbd_qwertz"
latin:enableProximityCharsCorrection="true" />
<Element <Element
latin:elementName="symbols" latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" /> latin:elementKeyboard="@xml/kbd_symbols" />

View file

@ -23,7 +23,8 @@
latin:keyboardLocale="el"> latin:keyboardLocale="el">
<Element <Element
latin:elementName="alphabet" latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_greek" /> latin:elementKeyboard="@xml/kbd_greek"
latin:enableProximityCharsCorrection="true" />
<Element <Element
latin:elementName="symbols" latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" /> latin:elementKeyboard="@xml/kbd_symbols" />

View file

@ -23,7 +23,8 @@
latin:keyboardLocale="es,es_US"> latin:keyboardLocale="es,es_US">
<Element <Element
latin:elementName="alphabet" latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_spanish" /> latin:elementKeyboard="@xml/kbd_spanish"
latin:enableProximityCharsCorrection="true" />
<Element <Element
latin:elementName="symbols" latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_spanish_symbols" /> latin:elementKeyboard="@xml/kbd_spanish_symbols" />

View file

@ -23,7 +23,8 @@
latin:keyboardLocale="et"> latin:keyboardLocale="et">
<Element <Element
latin:elementName="alphabet" latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_nordic" /> latin:elementKeyboard="@xml/kbd_nordic"
latin:enableProximityCharsCorrection="true" />
<Element <Element
latin:elementName="symbols" latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" /> latin:elementKeyboard="@xml/kbd_symbols" />

View file

@ -23,7 +23,8 @@
latin:keyboardLocale="fa" > latin:keyboardLocale="fa" >
<Element <Element
latin:elementName="alphabet" latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_farsi" /> latin:elementKeyboard="@xml/kbd_farsi"
latin:enableProximityCharsCorrection="true" />
<Element <Element
latin:elementName="symbols" latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" /> latin:elementKeyboard="@xml/kbd_symbols" />

View file

@ -23,7 +23,8 @@
latin:keyboardLocale="fi"> latin:keyboardLocale="fi">
<Element <Element
latin:elementName="alphabet" latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_nordic" /> latin:elementKeyboard="@xml/kbd_nordic"
latin:enableProximityCharsCorrection="true" />
<Element <Element
latin:elementName="symbols" latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" /> latin:elementKeyboard="@xml/kbd_symbols" />

View file

@ -23,7 +23,8 @@
latin:keyboardLocale="fr_CA"> latin:keyboardLocale="fr_CA">
<Element <Element
latin:elementName="alphabet" latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_qwerty" /> latin:elementKeyboard="@xml/kbd_qwerty"
latin:enableProximityCharsCorrection="true" />
<Element <Element
latin:elementName="symbols" latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" /> latin:elementKeyboard="@xml/kbd_symbols" />

View file

@ -23,7 +23,8 @@
latin:keyboardLocale="fr_CH"> latin:keyboardLocale="fr_CH">
<Element <Element
latin:elementName="alphabet" latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_qwertz" /> latin:elementKeyboard="@xml/kbd_qwertz"
latin:enableProximityCharsCorrection="true" />
<Element <Element
latin:elementName="symbols" latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" /> latin:elementKeyboard="@xml/kbd_symbols" />

View file

@ -23,7 +23,8 @@
latin:keyboardLocale="fr"> latin:keyboardLocale="fr">
<Element <Element
latin:elementName="alphabet" latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_azerty" /> latin:elementKeyboard="@xml/kbd_azerty"
latin:enableProximityCharsCorrection="true" />
<Element <Element
latin:elementName="symbols" latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_azerty_symbols" /> latin:elementKeyboard="@xml/kbd_azerty_symbols" />

View file

@ -23,6 +23,23 @@
latin:keyboardLocale="hi"> latin:keyboardLocale="hi">
<Element <Element
latin:elementName="alphabet" latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_hindi"
latin:enableProximityCharsCorrection="true" />
<Element
latin:elementName="alphabetAutomaticShifted"
latin:elementKeyboard="@xml/kbd_hindi"
latin:enableProximityCharsCorrection="true" />
<!-- On these shifted alphabet layouts the proximity characters correction should be disabled
because the letters on these layouts aren't the ones in different case of the above
unshifted layouts. -->
<Element
latin:elementName="alphabetManualShifted"
latin:elementKeyboard="@xml/kbd_hindi" />
<Element
latin:elementName="alphabetShiftLocked"
latin:elementKeyboard="@xml/kbd_hindi" />
<Element
latin:elementName="alphabetShiftLockShifted"
latin:elementKeyboard="@xml/kbd_hindi" /> latin:elementKeyboard="@xml/kbd_hindi" />
<Element <Element
latin:elementName="symbols" latin:elementName="symbols"

View file

@ -23,7 +23,8 @@
latin:keyboardLocale="hr"> latin:keyboardLocale="hr">
<Element <Element
latin:elementName="alphabet" latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_qwertz" /> latin:elementKeyboard="@xml/kbd_qwertz"
latin:enableProximityCharsCorrection="true" />
<Element <Element
latin:elementName="symbols" latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" /> latin:elementKeyboard="@xml/kbd_symbols" />

View file

@ -23,7 +23,8 @@
latin:keyboardLocale="hu"> latin:keyboardLocale="hu">
<Element <Element
latin:elementName="alphabet" latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_qwertz" /> latin:elementKeyboard="@xml/kbd_qwertz"
latin:enableProximityCharsCorrection="true" />
<Element <Element
latin:elementName="symbols" latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" /> latin:elementKeyboard="@xml/kbd_symbols" />

View file

@ -23,7 +23,8 @@
latin:keyboardLocale="is"> latin:keyboardLocale="is">
<Element <Element
latin:elementName="alphabet" latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_nordic" /> latin:elementKeyboard="@xml/kbd_nordic"
latin:enableProximityCharsCorrection="true" />
<Element <Element
latin:elementName="symbols" latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" /> latin:elementKeyboard="@xml/kbd_symbols" />

View file

@ -23,7 +23,8 @@
latin:keyboardLocale="iw"> latin:keyboardLocale="iw">
<Element <Element
latin:elementName="alphabet" latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_hebrew" /> latin:elementKeyboard="@xml/kbd_hebrew"
latin:enableProximityCharsCorrection="true" />
<Element <Element
latin:elementName="symbols" latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" /> latin:elementKeyboard="@xml/kbd_symbols" />

View file

@ -23,6 +23,23 @@
latin:keyboardLocale="ka"> latin:keyboardLocale="ka">
<Element <Element
latin:elementName="alphabet" latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_georgian"
latin:enableProximityCharsCorrection="true" />
<Element
latin:elementName="alphabetAutomaticShifted"
latin:elementKeyboard="@xml/kbd_georgian"
latin:enableProximityCharsCorrection="true" />
<!-- On these shifted alphabet layouts the proximity characters correction should be disabled
because the letters on these layouts aren't the ones in different case of the above
unshifted layouts. -->
<Element
latin:elementName="alphabetManualShifted"
latin:elementKeyboard="@xml/kbd_georgian" />
<Element
latin:elementName="alphabetShiftLocked"
latin:elementKeyboard="@xml/kbd_georgian" />
<Element
latin:elementName="alphabetShiftLockShifted"
latin:elementKeyboard="@xml/kbd_georgian" /> latin:elementKeyboard="@xml/kbd_georgian" />
<Element <Element
latin:elementName="symbols" latin:elementName="symbols"

View file

@ -23,7 +23,8 @@
latin:keyboardLocale="ky"> latin:keyboardLocale="ky">
<Element <Element
latin:elementName="alphabet" latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_east_slavic" /> latin:elementKeyboard="@xml/kbd_east_slavic"
latin:enableProximityCharsCorrection="true" />
<Element <Element
latin:elementName="symbols" latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" /> latin:elementKeyboard="@xml/kbd_symbols" />

View file

@ -23,7 +23,8 @@
latin:keyboardLocale="mk"> latin:keyboardLocale="mk">
<Element <Element
latin:elementName="alphabet" latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_south_slavic" /> latin:elementKeyboard="@xml/kbd_south_slavic"
latin:enableProximityCharsCorrection="true" />
<Element <Element
latin:elementName="symbols" latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" /> latin:elementKeyboard="@xml/kbd_symbols" />

View file

@ -23,7 +23,8 @@
latin:keyboardLocale="nb"> latin:keyboardLocale="nb">
<Element <Element
latin:elementName="alphabet" latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_nordic" /> latin:elementKeyboard="@xml/kbd_nordic"
latin:enableProximityCharsCorrection="true" />
<Element <Element
latin:elementName="symbols" latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" /> latin:elementKeyboard="@xml/kbd_symbols" />

View file

@ -23,7 +23,8 @@
latin:keyboardLocale="pl"> latin:keyboardLocale="pl">
<Element <Element
latin:elementName="alphabet" latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_qwerty" /> latin:elementKeyboard="@xml/kbd_qwerty"
latin:enableProximityCharsCorrection="true" />
<Element <Element
latin:elementName="symbols" latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" /> latin:elementKeyboard="@xml/kbd_symbols" />

View file

@ -23,7 +23,8 @@
latin:keyboardLocale="pt"> latin:keyboardLocale="pt">
<Element <Element
latin:elementName="alphabet" latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_qwerty" /> latin:elementKeyboard="@xml/kbd_qwerty"
latin:enableProximityCharsCorrection="true" />
<Element <Element
latin:elementName="symbols" latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" /> latin:elementKeyboard="@xml/kbd_symbols" />

View file

@ -23,7 +23,8 @@
latin:keyboardLocale="ro"> latin:keyboardLocale="ro">
<Element <Element
latin:elementName="alphabet" latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_qwerty" /> latin:elementKeyboard="@xml/kbd_qwerty"
latin:enableProximityCharsCorrection="true" />
<Element <Element
latin:elementName="symbols" latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" /> latin:elementKeyboard="@xml/kbd_symbols" />

View file

@ -23,7 +23,8 @@
latin:keyboardLocale="ru"> latin:keyboardLocale="ru">
<Element <Element
latin:elementName="alphabet" latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_east_slavic" /> latin:elementKeyboard="@xml/kbd_east_slavic"
latin:enableProximityCharsCorrection="true" />
<Element <Element
latin:elementName="symbols" latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" /> latin:elementKeyboard="@xml/kbd_symbols" />

View file

@ -23,7 +23,8 @@
latin:keyboardLocale="sk"> latin:keyboardLocale="sk">
<Element <Element
latin:elementName="alphabet" latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_qwerty" /> latin:elementKeyboard="@xml/kbd_qwerty"
latin:enableProximityCharsCorrection="true" />
<Element <Element
latin:elementName="symbols" latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" /> latin:elementKeyboard="@xml/kbd_symbols" />

View file

@ -23,7 +23,8 @@
latin:keyboardLocale="sl"> latin:keyboardLocale="sl">
<Element <Element
latin:elementName="alphabet" latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_qwerty" /> latin:elementKeyboard="@xml/kbd_qwerty"
latin:enableProximityCharsCorrection="true" />
<Element <Element
latin:elementName="symbols" latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" /> latin:elementKeyboard="@xml/kbd_symbols" />

View file

@ -23,7 +23,8 @@
latin:keyboardLocale="sr"> latin:keyboardLocale="sr">
<Element <Element
latin:elementName="alphabet" latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_south_slavic" /> latin:elementKeyboard="@xml/kbd_south_slavic"
latin:enableProximityCharsCorrection="true" />
<Element <Element
latin:elementName="symbols" latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" /> latin:elementKeyboard="@xml/kbd_symbols" />

View file

@ -23,7 +23,8 @@
latin:keyboardLocale="sv"> latin:keyboardLocale="sv">
<Element <Element
latin:elementName="alphabet" latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_nordic" /> latin:elementKeyboard="@xml/kbd_nordic"
latin:enableProximityCharsCorrection="true" />
<Element <Element
latin:elementName="symbols" latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" /> latin:elementKeyboard="@xml/kbd_symbols" />

View file

@ -23,6 +23,23 @@
latin:keyboardLocale="th"> latin:keyboardLocale="th">
<Element <Element
latin:elementName="alphabet" latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_thai"
latin:enableProximityCharsCorrection="true" />
<Element
latin:elementName="alphabetAutomaticShifted"
latin:elementKeyboard="@xml/kbd_thai"
latin:enableProximityCharsCorrection="true" />
<!-- On these shifted alphabet layouts the proximity characters correction should be disabled
because the letters on these layouts aren't the ones in different case of the above
unshifted layouts. -->
<Element
latin:elementName="alphabetManualShifted"
latin:elementKeyboard="@xml/kbd_thai" />
<Element
latin:elementName="alphabetShiftLocked"
latin:elementKeyboard="@xml/kbd_thai" />
<Element
latin:elementName="alphabetShiftLockShifted"
latin:elementKeyboard="@xml/kbd_thai" /> latin:elementKeyboard="@xml/kbd_thai" />
<Element <Element
latin:elementName="symbols" latin:elementName="symbols"

View file

@ -23,7 +23,8 @@
latin:keyboardLocale="tr"> latin:keyboardLocale="tr">
<Element <Element
latin:elementName="alphabet" latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_qwerty" /> latin:elementKeyboard="@xml/kbd_qwerty"
latin:enableProximityCharsCorrection="true" />
<Element <Element
latin:elementName="symbols" latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" /> latin:elementKeyboard="@xml/kbd_symbols" />

View file

@ -23,7 +23,8 @@
latin:keyboardLocale="uk"> latin:keyboardLocale="uk">
<Element <Element
latin:elementName="alphabet" latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_east_slavic" /> latin:elementKeyboard="@xml/kbd_east_slavic"
latin:enableProximityCharsCorrection="true" />
<Element <Element
latin:elementName="symbols" latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" /> latin:elementKeyboard="@xml/kbd_symbols" />

View file

@ -23,7 +23,8 @@
latin:keyboardLocale="vi"> latin:keyboardLocale="vi">
<Element <Element
latin:elementName="alphabet" latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_qwerty" /> latin:elementKeyboard="@xml/kbd_qwerty"
latin:enableProximityCharsCorrection="true" />
<Element <Element
latin:elementName="symbols" latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" /> latin:elementKeyboard="@xml/kbd_symbols" />

View file

@ -23,7 +23,8 @@
latin:keyboardLocale="en_GB,en_US"> latin:keyboardLocale="en_GB,en_US">
<Element <Element
latin:elementName="alphabet" latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_qwerty" /> latin:elementKeyboard="@xml/kbd_qwerty"
latin:enableProximityCharsCorrection="true" />
<Element <Element
latin:elementName="symbols" latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" /> latin:elementKeyboard="@xml/kbd_symbols" />

View file

@ -130,6 +130,7 @@ public class Keyboard {
private final HashMap<Integer, Key> mKeyCache = new HashMap<Integer, Key>(); private final HashMap<Integer, Key> mKeyCache = new HashMap<Integer, Key>();
private final ProximityInfo mProximityInfo; private final ProximityInfo mProximityInfo;
private final boolean mProximityCharsCorrectionEnabled;
public Keyboard(Params params) { public Keyboard(Params params) {
mId = params.mId; mId = params.mId;
@ -153,6 +154,19 @@ public class Keyboard {
mProximityInfo = new ProximityInfo(params.mId.mLocale.toString(), mProximityInfo = new ProximityInfo(params.mId.mLocale.toString(),
params.GRID_WIDTH, params.GRID_HEIGHT, mOccupiedWidth, mOccupiedHeight, params.GRID_WIDTH, params.GRID_HEIGHT, mOccupiedWidth, mOccupiedHeight,
mMostCommonKeyWidth, mMostCommonKeyHeight, mKeys, params.mTouchPositionCorrection); mMostCommonKeyWidth, mMostCommonKeyHeight, mKeys, params.mTouchPositionCorrection);
mProximityCharsCorrectionEnabled = params.mProximityCharsCorrectionEnabled;
}
public boolean hasProximityCharsCorrection(int code) {
if (!mProximityCharsCorrectionEnabled) {
return false;
}
// Note: The native code has the main keyboard layout only at this moment.
// TODO: Figure out how to handle proximity characters information of all layouts.
final boolean canAssumeNativeHasProximityCharsInfoOfAllKeys = (
mId.mElementId == KeyboardId.ELEMENT_ALPHABET
|| mId.mElementId == KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED);
return canAssumeNativeHasProximityCharsInfoOfAllKeys || Character.isLetter(code);
} }
public ProximityInfo getProximityInfo() { public ProximityInfo getProximityInfo() {
@ -230,6 +244,8 @@ public class Keyboard {
public int mMostCommonKeyHeight = 0; public int mMostCommonKeyHeight = 0;
public int mMostCommonKeyWidth = 0; public int mMostCommonKeyWidth = 0;
public boolean mProximityCharsCorrectionEnabled;
public final TouchPositionCorrection mTouchPositionCorrection = public final TouchPositionCorrection mTouchPositionCorrection =
new TouchPositionCorrection(); new TouchPositionCorrection();
@ -647,6 +663,10 @@ public class Keyboard {
mParams.mTouchPositionCorrection.setEnabled(enabled); mParams.mTouchPositionCorrection.setEnabled(enabled);
} }
public void setProximityCharsCorrectionEnabled(boolean enabled) {
mParams.mProximityCharsCorrectionEnabled = enabled;
}
public Keyboard build() { public Keyboard build() {
return new Keyboard(mParams); return new Keyboard(mParams);
} }
@ -753,9 +773,9 @@ public class Keyboard {
params.mMaxMoreKeysKeyboardColumn = keyAttr.getInt( params.mMaxMoreKeysKeyboardColumn = keyAttr.getInt(
R.styleable.Keyboard_Key_maxMoreKeysColumn, 5); R.styleable.Keyboard_Key_maxMoreKeysColumn, 5);
params.mThemeId = keyboardAttr.getInt(R.styleable.Keyboard_themeId, 0);
params.mIconsSet.loadIcons(keyboardAttr); params.mIconsSet.loadIcons(keyboardAttr);
params.mThemeId = keyboardAttr.getInt(R.styleable.Keyboard_themeId, 0);
final int resourceId = keyboardAttr.getResourceId( final int resourceId = keyboardAttr.getResourceId(
R.styleable.Keyboard_touchPositionCorrectionData, 0); R.styleable.Keyboard_touchPositionCorrectionData, 0);
params.mTouchPositionCorrection.setEnabled(resourceId != 0); params.mTouchPositionCorrection.setEnabled(resourceId != 0);

View file

@ -28,6 +28,7 @@ import android.view.inputmethod.EditorInfo;
import com.android.inputmethod.compat.EditorInfoCompatUtils; import com.android.inputmethod.compat.EditorInfoCompatUtils;
import com.android.inputmethod.compat.InputTypeCompatUtils; import com.android.inputmethod.compat.InputTypeCompatUtils;
import com.android.inputmethod.keyboard.KeyboardSet.Params.ElementParams;
import com.android.inputmethod.latin.LatinIME; import com.android.inputmethod.latin.LatinIME;
import com.android.inputmethod.latin.LatinImeLogger; import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.LocaleUtils; import com.android.inputmethod.latin.LocaleUtils;
@ -53,7 +54,7 @@ public class KeyboardSet {
private static final String TAG = KeyboardSet.class.getSimpleName(); private static final String TAG = KeyboardSet.class.getSimpleName();
private static final boolean DEBUG_CACHE = LatinImeLogger.sDBG; private static final boolean DEBUG_CACHE = LatinImeLogger.sDBG;
private static final String TAG_KEYBOARD_SET = TAG; private static final String TAG_KEYBOARD_SET = "KeyboardSet";
private static final String TAG_ELEMENT = "Element"; private static final String TAG_ELEMENT = "Element";
private final Context mContext; private final Context mContext;
@ -104,10 +105,14 @@ public class KeyboardSet {
Locale mLocale; Locale mLocale;
int mOrientation; int mOrientation;
int mWidth; int mWidth;
// KeyboardSet element id to keyboard layout XML id map. // KeyboardSet element id to element's parameters map.
final HashMap<Integer, Integer> mKeyboardSetElementIdToXmlIdMap = final HashMap<Integer, ElementParams> mKeyboardSetElementIdToParamsMap =
new HashMap<Integer, Integer>(); new HashMap<Integer, ElementParams>();
Params() {}
static class ElementParams {
int mKeyboardXmlId;
boolean mProximityCharsCorrectionEnabled;
}
} }
public static void clearKeyboardCache() { public static void clearKeyboardCache() {
@ -141,20 +146,21 @@ public class KeyboardSet {
break; break;
} }
Integer keyboardXmlId = mParams.mKeyboardSetElementIdToXmlIdMap.get(keyboardSetElementId); ElementParams elementParams = mParams.mKeyboardSetElementIdToParamsMap.get(
if (keyboardXmlId == null) { keyboardSetElementId);
keyboardXmlId = mParams.mKeyboardSetElementIdToXmlIdMap.get( if (elementParams == null) {
elementParams = mParams.mKeyboardSetElementIdToParamsMap.get(
KeyboardId.ELEMENT_ALPHABET); KeyboardId.ELEMENT_ALPHABET);
} }
final KeyboardId id = getKeyboardId(keyboardSetElementId); final KeyboardId id = getKeyboardId(keyboardSetElementId);
try { try {
return getKeyboard(mContext, keyboardXmlId, id); return getKeyboard(mContext, elementParams, id);
} catch (RuntimeException e) { } catch (RuntimeException e) {
throw new KeyboardSetException(e, id); throw new KeyboardSetException(e, id);
} }
} }
private Keyboard getKeyboard(Context context, int keyboardXmlId, KeyboardId id) { private Keyboard getKeyboard(Context context, ElementParams elementParams, KeyboardId id) {
final Resources res = context.getResources(); final Resources res = context.getResources();
final SoftReference<Keyboard> ref = sKeyboardCache.get(id); final SoftReference<Keyboard> ref = sKeyboardCache.get(id);
Keyboard keyboard = (ref == null) ? null : ref.get(); Keyboard keyboard = (ref == null) ? null : ref.get();
@ -166,8 +172,10 @@ public class KeyboardSet {
if (id.isAlphabetKeyboard()) { if (id.isAlphabetKeyboard()) {
builder.setAutoGenerate(sKeysCache); builder.setAutoGenerate(sKeysCache);
} }
builder.load(keyboardXmlId, id); builder.load(elementParams.mKeyboardXmlId, id);
builder.setTouchPositionCorrectionEnabled(mParams.mTouchPositionCorrectionEnabled); builder.setTouchPositionCorrectionEnabled(mParams.mTouchPositionCorrectionEnabled);
builder.setProximityCharsCorrectionEnabled(
elementParams.mProximityCharsCorrectionEnabled);
keyboard = builder.build(); keyboard = builder.build();
} finally { } finally {
LocaleUtils.setSystemLocale(res, savedLocale); LocaleUtils.setSystemLocale(res, savedLocale);
@ -331,11 +339,14 @@ public class KeyboardSet {
TAG_ELEMENT, parser); TAG_ELEMENT, parser);
XmlParseUtils.checkEndTag(TAG_ELEMENT, parser); XmlParseUtils.checkEndTag(TAG_ELEMENT, parser);
final ElementParams elementParams = new ElementParams();
final int elementName = a.getInt( final int elementName = a.getInt(
R.styleable.KeyboardSet_Element_elementName, 0); R.styleable.KeyboardSet_Element_elementName, 0);
final int elementKeyboard = a.getResourceId( elementParams.mKeyboardXmlId = a.getResourceId(
R.styleable.KeyboardSet_Element_elementKeyboard, 0); R.styleable.KeyboardSet_Element_elementKeyboard, 0);
mParams.mKeyboardSetElementIdToXmlIdMap.put(elementName, elementKeyboard); elementParams.mProximityCharsCorrectionEnabled = a.getBoolean(
R.styleable.KeyboardSet_Element_enableProximityCharsCorrection, false);
mParams.mKeyboardSetElementIdToParamsMap.put(elementName, elementParams);
} finally { } finally {
a.recycle(); a.recycle();
} }

View file

@ -47,7 +47,9 @@ public class MoreKeysKeyboardView extends KeyboardView implements MoreKeysPanel
new KeyboardActionListener.Adapter() { new KeyboardActionListener.Adapter() {
@Override @Override
public void onCodeInput(int primaryCode, int x, int y) { public void onCodeInput(int primaryCode, int x, int y) {
mListener.onCodeInput(primaryCode, x, y); // Because a more keys keyboard doesn't need proximity characters correction, we don't
// send touch event coordinates.
mListener.onCodeInput(primaryCode, NOT_A_TOUCH_COORDINATE, NOT_A_TOUCH_COORDINATE);
} }
@Override @Override

View file

@ -1318,7 +1318,13 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
if (mSettingsValues.isWordSeparator(primaryCode)) { if (mSettingsValues.isWordSeparator(primaryCode)) {
didAutoCorrect = handleSeparator(primaryCode, x, y, spaceState); didAutoCorrect = handleSeparator(primaryCode, x, y, spaceState);
} else { } else {
handleCharacter(primaryCode, x, y, spaceState); final Keyboard keyboard = mKeyboardSwitcher.getKeyboard();
if (keyboard != null && keyboard.hasProximityCharsCorrection(primaryCode)) {
handleCharacter(primaryCode, x, y, spaceState);
} else {
handleCharacter(primaryCode, NOT_A_TOUCH_COORDINATE, NOT_A_TOUCH_COORDINATE,
spaceState);
}
} }
mExpectingUpdateSelection = true; mExpectingUpdateSelection = true;
mShouldSwitchToLastSubtype = true; mShouldSwitchToLastSubtype = true;