mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
Merge "Don't send touch coordinates if proximity characters correction is disabled"
This commit is contained in:
commit
499c5e8ad8
@ -424,5 +424,7 @@
|
||||
<enum name="number" value="9" />
|
||||
</attr>
|
||||
<attr name="elementKeyboard" format="reference"/>
|
||||
<!-- Enable proximity characters correction. Disabled by default. -->
|
||||
<attr name="enableProximityCharsCorrection" format="boolean" />
|
||||
</declare-styleable>
|
||||
</resources>
|
||||
|
@ -23,7 +23,8 @@
|
||||
latin:keyboardLocale="ar" >
|
||||
<Element
|
||||
latin:elementName="alphabet"
|
||||
latin:elementKeyboard="@xml/kbd_arabic" />
|
||||
latin:elementKeyboard="@xml/kbd_arabic"
|
||||
latin:enableProximityCharsCorrection="true" />
|
||||
<Element
|
||||
latin:elementName="symbols"
|
||||
latin:elementKeyboard="@xml/kbd_symbols" />
|
||||
|
@ -23,7 +23,8 @@
|
||||
latin:keyboardLocale="be">
|
||||
<Element
|
||||
latin:elementName="alphabet"
|
||||
latin:elementKeyboard="@xml/kbd_east_slavic" />
|
||||
latin:elementKeyboard="@xml/kbd_east_slavic"
|
||||
latin:enableProximityCharsCorrection="true" />
|
||||
<Element
|
||||
latin:elementName="symbols"
|
||||
latin:elementKeyboard="@xml/kbd_symbols" />
|
||||
|
@ -23,7 +23,8 @@
|
||||
latin:keyboardLocale="bg">
|
||||
<Element
|
||||
latin:elementName="alphabet"
|
||||
latin:elementKeyboard="@xml/kbd_bulgarian" />
|
||||
latin:elementKeyboard="@xml/kbd_bulgarian"
|
||||
latin:enableProximityCharsCorrection="true" />
|
||||
<Element
|
||||
latin:elementName="symbols"
|
||||
latin:elementKeyboard="@xml/kbd_symbols" />
|
||||
|
@ -23,7 +23,8 @@
|
||||
latin:keyboardLocale="cs">
|
||||
<Element
|
||||
latin:elementName="alphabet"
|
||||
latin:elementKeyboard="@xml/kbd_qwertz" />
|
||||
latin:elementKeyboard="@xml/kbd_qwertz"
|
||||
latin:enableProximityCharsCorrection="true" />
|
||||
<Element
|
||||
latin:elementName="symbols"
|
||||
latin:elementKeyboard="@xml/kbd_symbols" />
|
||||
|
@ -23,7 +23,8 @@
|
||||
latin:keyboardLocale="da">
|
||||
<Element
|
||||
latin:elementName="alphabet"
|
||||
latin:elementKeyboard="@xml/kbd_nordic" />
|
||||
latin:elementKeyboard="@xml/kbd_nordic"
|
||||
latin:enableProximityCharsCorrection="true" />
|
||||
<Element
|
||||
latin:elementName="symbols"
|
||||
latin:elementKeyboard="@xml/kbd_symbols" />
|
||||
|
@ -23,7 +23,8 @@
|
||||
latin:keyboardLocale="de">
|
||||
<Element
|
||||
latin:elementName="alphabet"
|
||||
latin:elementKeyboard="@xml/kbd_qwerty" />
|
||||
latin:elementKeyboard="@xml/kbd_qwerty"
|
||||
latin:enableProximityCharsCorrection="true" />
|
||||
<Element
|
||||
latin:elementName="symbols"
|
||||
latin:elementKeyboard="@xml/kbd_symbols" />
|
||||
|
@ -23,7 +23,8 @@
|
||||
latin:keyboardLocale="de">
|
||||
<Element
|
||||
latin:elementName="alphabet"
|
||||
latin:elementKeyboard="@xml/kbd_qwertz" />
|
||||
latin:elementKeyboard="@xml/kbd_qwertz"
|
||||
latin:enableProximityCharsCorrection="true" />
|
||||
<Element
|
||||
latin:elementName="symbols"
|
||||
latin:elementKeyboard="@xml/kbd_symbols" />
|
||||
|
@ -23,7 +23,8 @@
|
||||
latin:keyboardLocale="el">
|
||||
<Element
|
||||
latin:elementName="alphabet"
|
||||
latin:elementKeyboard="@xml/kbd_greek" />
|
||||
latin:elementKeyboard="@xml/kbd_greek"
|
||||
latin:enableProximityCharsCorrection="true" />
|
||||
<Element
|
||||
latin:elementName="symbols"
|
||||
latin:elementKeyboard="@xml/kbd_symbols" />
|
||||
|
@ -23,7 +23,8 @@
|
||||
latin:keyboardLocale="es,es_US">
|
||||
<Element
|
||||
latin:elementName="alphabet"
|
||||
latin:elementKeyboard="@xml/kbd_spanish" />
|
||||
latin:elementKeyboard="@xml/kbd_spanish"
|
||||
latin:enableProximityCharsCorrection="true" />
|
||||
<Element
|
||||
latin:elementName="symbols"
|
||||
latin:elementKeyboard="@xml/kbd_spanish_symbols" />
|
||||
|
@ -23,7 +23,8 @@
|
||||
latin:keyboardLocale="et">
|
||||
<Element
|
||||
latin:elementName="alphabet"
|
||||
latin:elementKeyboard="@xml/kbd_nordic" />
|
||||
latin:elementKeyboard="@xml/kbd_nordic"
|
||||
latin:enableProximityCharsCorrection="true" />
|
||||
<Element
|
||||
latin:elementName="symbols"
|
||||
latin:elementKeyboard="@xml/kbd_symbols" />
|
||||
|
@ -23,7 +23,8 @@
|
||||
latin:keyboardLocale="fa" >
|
||||
<Element
|
||||
latin:elementName="alphabet"
|
||||
latin:elementKeyboard="@xml/kbd_farsi" />
|
||||
latin:elementKeyboard="@xml/kbd_farsi"
|
||||
latin:enableProximityCharsCorrection="true" />
|
||||
<Element
|
||||
latin:elementName="symbols"
|
||||
latin:elementKeyboard="@xml/kbd_symbols" />
|
||||
|
@ -23,7 +23,8 @@
|
||||
latin:keyboardLocale="fi">
|
||||
<Element
|
||||
latin:elementName="alphabet"
|
||||
latin:elementKeyboard="@xml/kbd_nordic" />
|
||||
latin:elementKeyboard="@xml/kbd_nordic"
|
||||
latin:enableProximityCharsCorrection="true" />
|
||||
<Element
|
||||
latin:elementName="symbols"
|
||||
latin:elementKeyboard="@xml/kbd_symbols" />
|
||||
|
@ -23,7 +23,8 @@
|
||||
latin:keyboardLocale="fr_CA">
|
||||
<Element
|
||||
latin:elementName="alphabet"
|
||||
latin:elementKeyboard="@xml/kbd_qwerty" />
|
||||
latin:elementKeyboard="@xml/kbd_qwerty"
|
||||
latin:enableProximityCharsCorrection="true" />
|
||||
<Element
|
||||
latin:elementName="symbols"
|
||||
latin:elementKeyboard="@xml/kbd_symbols" />
|
||||
|
@ -23,7 +23,8 @@
|
||||
latin:keyboardLocale="fr_CH">
|
||||
<Element
|
||||
latin:elementName="alphabet"
|
||||
latin:elementKeyboard="@xml/kbd_qwertz" />
|
||||
latin:elementKeyboard="@xml/kbd_qwertz"
|
||||
latin:enableProximityCharsCorrection="true" />
|
||||
<Element
|
||||
latin:elementName="symbols"
|
||||
latin:elementKeyboard="@xml/kbd_symbols" />
|
||||
|
@ -23,7 +23,8 @@
|
||||
latin:keyboardLocale="fr">
|
||||
<Element
|
||||
latin:elementName="alphabet"
|
||||
latin:elementKeyboard="@xml/kbd_azerty" />
|
||||
latin:elementKeyboard="@xml/kbd_azerty"
|
||||
latin:enableProximityCharsCorrection="true" />
|
||||
<Element
|
||||
latin:elementName="symbols"
|
||||
latin:elementKeyboard="@xml/kbd_azerty_symbols" />
|
||||
|
@ -23,6 +23,23 @@
|
||||
latin:keyboardLocale="hi">
|
||||
<Element
|
||||
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" />
|
||||
<Element
|
||||
latin:elementName="symbols"
|
||||
|
@ -23,7 +23,8 @@
|
||||
latin:keyboardLocale="hr">
|
||||
<Element
|
||||
latin:elementName="alphabet"
|
||||
latin:elementKeyboard="@xml/kbd_qwertz" />
|
||||
latin:elementKeyboard="@xml/kbd_qwertz"
|
||||
latin:enableProximityCharsCorrection="true" />
|
||||
<Element
|
||||
latin:elementName="symbols"
|
||||
latin:elementKeyboard="@xml/kbd_symbols" />
|
||||
|
@ -23,7 +23,8 @@
|
||||
latin:keyboardLocale="hu">
|
||||
<Element
|
||||
latin:elementName="alphabet"
|
||||
latin:elementKeyboard="@xml/kbd_qwertz" />
|
||||
latin:elementKeyboard="@xml/kbd_qwertz"
|
||||
latin:enableProximityCharsCorrection="true" />
|
||||
<Element
|
||||
latin:elementName="symbols"
|
||||
latin:elementKeyboard="@xml/kbd_symbols" />
|
||||
|
@ -23,7 +23,8 @@
|
||||
latin:keyboardLocale="is">
|
||||
<Element
|
||||
latin:elementName="alphabet"
|
||||
latin:elementKeyboard="@xml/kbd_nordic" />
|
||||
latin:elementKeyboard="@xml/kbd_nordic"
|
||||
latin:enableProximityCharsCorrection="true" />
|
||||
<Element
|
||||
latin:elementName="symbols"
|
||||
latin:elementKeyboard="@xml/kbd_symbols" />
|
||||
|
@ -23,7 +23,8 @@
|
||||
latin:keyboardLocale="iw">
|
||||
<Element
|
||||
latin:elementName="alphabet"
|
||||
latin:elementKeyboard="@xml/kbd_hebrew" />
|
||||
latin:elementKeyboard="@xml/kbd_hebrew"
|
||||
latin:enableProximityCharsCorrection="true" />
|
||||
<Element
|
||||
latin:elementName="symbols"
|
||||
latin:elementKeyboard="@xml/kbd_symbols" />
|
||||
|
@ -23,6 +23,23 @@
|
||||
latin:keyboardLocale="ka">
|
||||
<Element
|
||||
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" />
|
||||
<Element
|
||||
latin:elementName="symbols"
|
||||
|
@ -23,7 +23,8 @@
|
||||
latin:keyboardLocale="ky">
|
||||
<Element
|
||||
latin:elementName="alphabet"
|
||||
latin:elementKeyboard="@xml/kbd_east_slavic" />
|
||||
latin:elementKeyboard="@xml/kbd_east_slavic"
|
||||
latin:enableProximityCharsCorrection="true" />
|
||||
<Element
|
||||
latin:elementName="symbols"
|
||||
latin:elementKeyboard="@xml/kbd_symbols" />
|
||||
|
@ -23,7 +23,8 @@
|
||||
latin:keyboardLocale="mk">
|
||||
<Element
|
||||
latin:elementName="alphabet"
|
||||
latin:elementKeyboard="@xml/kbd_south_slavic" />
|
||||
latin:elementKeyboard="@xml/kbd_south_slavic"
|
||||
latin:enableProximityCharsCorrection="true" />
|
||||
<Element
|
||||
latin:elementName="symbols"
|
||||
latin:elementKeyboard="@xml/kbd_symbols" />
|
||||
|
@ -23,7 +23,8 @@
|
||||
latin:keyboardLocale="nb">
|
||||
<Element
|
||||
latin:elementName="alphabet"
|
||||
latin:elementKeyboard="@xml/kbd_nordic" />
|
||||
latin:elementKeyboard="@xml/kbd_nordic"
|
||||
latin:enableProximityCharsCorrection="true" />
|
||||
<Element
|
||||
latin:elementName="symbols"
|
||||
latin:elementKeyboard="@xml/kbd_symbols" />
|
||||
|
@ -23,7 +23,8 @@
|
||||
latin:keyboardLocale="pl">
|
||||
<Element
|
||||
latin:elementName="alphabet"
|
||||
latin:elementKeyboard="@xml/kbd_qwerty" />
|
||||
latin:elementKeyboard="@xml/kbd_qwerty"
|
||||
latin:enableProximityCharsCorrection="true" />
|
||||
<Element
|
||||
latin:elementName="symbols"
|
||||
latin:elementKeyboard="@xml/kbd_symbols" />
|
||||
|
@ -23,7 +23,8 @@
|
||||
latin:keyboardLocale="pt">
|
||||
<Element
|
||||
latin:elementName="alphabet"
|
||||
latin:elementKeyboard="@xml/kbd_qwerty" />
|
||||
latin:elementKeyboard="@xml/kbd_qwerty"
|
||||
latin:enableProximityCharsCorrection="true" />
|
||||
<Element
|
||||
latin:elementName="symbols"
|
||||
latin:elementKeyboard="@xml/kbd_symbols" />
|
||||
|
@ -23,7 +23,8 @@
|
||||
latin:keyboardLocale="ro">
|
||||
<Element
|
||||
latin:elementName="alphabet"
|
||||
latin:elementKeyboard="@xml/kbd_qwerty" />
|
||||
latin:elementKeyboard="@xml/kbd_qwerty"
|
||||
latin:enableProximityCharsCorrection="true" />
|
||||
<Element
|
||||
latin:elementName="symbols"
|
||||
latin:elementKeyboard="@xml/kbd_symbols" />
|
||||
|
@ -23,7 +23,8 @@
|
||||
latin:keyboardLocale="ru">
|
||||
<Element
|
||||
latin:elementName="alphabet"
|
||||
latin:elementKeyboard="@xml/kbd_east_slavic" />
|
||||
latin:elementKeyboard="@xml/kbd_east_slavic"
|
||||
latin:enableProximityCharsCorrection="true" />
|
||||
<Element
|
||||
latin:elementName="symbols"
|
||||
latin:elementKeyboard="@xml/kbd_symbols" />
|
||||
|
@ -23,7 +23,8 @@
|
||||
latin:keyboardLocale="sk">
|
||||
<Element
|
||||
latin:elementName="alphabet"
|
||||
latin:elementKeyboard="@xml/kbd_qwerty" />
|
||||
latin:elementKeyboard="@xml/kbd_qwerty"
|
||||
latin:enableProximityCharsCorrection="true" />
|
||||
<Element
|
||||
latin:elementName="symbols"
|
||||
latin:elementKeyboard="@xml/kbd_symbols" />
|
||||
|
@ -23,7 +23,8 @@
|
||||
latin:keyboardLocale="sl">
|
||||
<Element
|
||||
latin:elementName="alphabet"
|
||||
latin:elementKeyboard="@xml/kbd_qwerty" />
|
||||
latin:elementKeyboard="@xml/kbd_qwerty"
|
||||
latin:enableProximityCharsCorrection="true" />
|
||||
<Element
|
||||
latin:elementName="symbols"
|
||||
latin:elementKeyboard="@xml/kbd_symbols" />
|
||||
|
@ -23,7 +23,8 @@
|
||||
latin:keyboardLocale="sr">
|
||||
<Element
|
||||
latin:elementName="alphabet"
|
||||
latin:elementKeyboard="@xml/kbd_south_slavic" />
|
||||
latin:elementKeyboard="@xml/kbd_south_slavic"
|
||||
latin:enableProximityCharsCorrection="true" />
|
||||
<Element
|
||||
latin:elementName="symbols"
|
||||
latin:elementKeyboard="@xml/kbd_symbols" />
|
||||
|
@ -23,7 +23,8 @@
|
||||
latin:keyboardLocale="sv">
|
||||
<Element
|
||||
latin:elementName="alphabet"
|
||||
latin:elementKeyboard="@xml/kbd_nordic" />
|
||||
latin:elementKeyboard="@xml/kbd_nordic"
|
||||
latin:enableProximityCharsCorrection="true" />
|
||||
<Element
|
||||
latin:elementName="symbols"
|
||||
latin:elementKeyboard="@xml/kbd_symbols" />
|
||||
|
@ -23,6 +23,23 @@
|
||||
latin:keyboardLocale="th">
|
||||
<Element
|
||||
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" />
|
||||
<Element
|
||||
latin:elementName="symbols"
|
||||
|
@ -23,7 +23,8 @@
|
||||
latin:keyboardLocale="tr">
|
||||
<Element
|
||||
latin:elementName="alphabet"
|
||||
latin:elementKeyboard="@xml/kbd_qwerty" />
|
||||
latin:elementKeyboard="@xml/kbd_qwerty"
|
||||
latin:enableProximityCharsCorrection="true" />
|
||||
<Element
|
||||
latin:elementName="symbols"
|
||||
latin:elementKeyboard="@xml/kbd_symbols" />
|
||||
|
@ -23,7 +23,8 @@
|
||||
latin:keyboardLocale="uk">
|
||||
<Element
|
||||
latin:elementName="alphabet"
|
||||
latin:elementKeyboard="@xml/kbd_east_slavic" />
|
||||
latin:elementKeyboard="@xml/kbd_east_slavic"
|
||||
latin:enableProximityCharsCorrection="true" />
|
||||
<Element
|
||||
latin:elementName="symbols"
|
||||
latin:elementKeyboard="@xml/kbd_symbols" />
|
||||
|
@ -23,7 +23,8 @@
|
||||
latin:keyboardLocale="vi">
|
||||
<Element
|
||||
latin:elementName="alphabet"
|
||||
latin:elementKeyboard="@xml/kbd_qwerty" />
|
||||
latin:elementKeyboard="@xml/kbd_qwerty"
|
||||
latin:enableProximityCharsCorrection="true" />
|
||||
<Element
|
||||
latin:elementName="symbols"
|
||||
latin:elementKeyboard="@xml/kbd_symbols" />
|
||||
|
@ -23,7 +23,8 @@
|
||||
latin:keyboardLocale="en_GB,en_US">
|
||||
<Element
|
||||
latin:elementName="alphabet"
|
||||
latin:elementKeyboard="@xml/kbd_qwerty" />
|
||||
latin:elementKeyboard="@xml/kbd_qwerty"
|
||||
latin:enableProximityCharsCorrection="true" />
|
||||
<Element
|
||||
latin:elementName="symbols"
|
||||
latin:elementKeyboard="@xml/kbd_symbols" />
|
||||
|
@ -130,6 +130,7 @@ public class Keyboard {
|
||||
private final HashMap<Integer, Key> mKeyCache = new HashMap<Integer, Key>();
|
||||
|
||||
private final ProximityInfo mProximityInfo;
|
||||
private final boolean mProximityCharsCorrectionEnabled;
|
||||
|
||||
public Keyboard(Params params) {
|
||||
mId = params.mId;
|
||||
@ -153,6 +154,19 @@ public class Keyboard {
|
||||
mProximityInfo = new ProximityInfo(params.mId.mLocale.toString(),
|
||||
params.GRID_WIDTH, params.GRID_HEIGHT, mOccupiedWidth, mOccupiedHeight,
|
||||
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() {
|
||||
@ -230,6 +244,8 @@ public class Keyboard {
|
||||
public int mMostCommonKeyHeight = 0;
|
||||
public int mMostCommonKeyWidth = 0;
|
||||
|
||||
public boolean mProximityCharsCorrectionEnabled;
|
||||
|
||||
public final TouchPositionCorrection mTouchPositionCorrection =
|
||||
new TouchPositionCorrection();
|
||||
|
||||
@ -647,6 +663,10 @@ public class Keyboard {
|
||||
mParams.mTouchPositionCorrection.setEnabled(enabled);
|
||||
}
|
||||
|
||||
public void setProximityCharsCorrectionEnabled(boolean enabled) {
|
||||
mParams.mProximityCharsCorrectionEnabled = enabled;
|
||||
}
|
||||
|
||||
public Keyboard build() {
|
||||
return new Keyboard(mParams);
|
||||
}
|
||||
@ -753,9 +773,9 @@ public class Keyboard {
|
||||
params.mMaxMoreKeysKeyboardColumn = keyAttr.getInt(
|
||||
R.styleable.Keyboard_Key_maxMoreKeysColumn, 5);
|
||||
|
||||
params.mThemeId = keyboardAttr.getInt(R.styleable.Keyboard_themeId, 0);
|
||||
params.mIconsSet.loadIcons(keyboardAttr);
|
||||
|
||||
params.mThemeId = keyboardAttr.getInt(R.styleable.Keyboard_themeId, 0);
|
||||
final int resourceId = keyboardAttr.getResourceId(
|
||||
R.styleable.Keyboard_touchPositionCorrectionData, 0);
|
||||
params.mTouchPositionCorrection.setEnabled(resourceId != 0);
|
||||
|
@ -28,6 +28,7 @@ import android.view.inputmethod.EditorInfo;
|
||||
|
||||
import com.android.inputmethod.compat.EditorInfoCompatUtils;
|
||||
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.LatinImeLogger;
|
||||
import com.android.inputmethod.latin.LocaleUtils;
|
||||
@ -53,7 +54,7 @@ public class KeyboardSet {
|
||||
private static final String TAG = KeyboardSet.class.getSimpleName();
|
||||
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 final Context mContext;
|
||||
@ -104,10 +105,14 @@ public class KeyboardSet {
|
||||
Locale mLocale;
|
||||
int mOrientation;
|
||||
int mWidth;
|
||||
// KeyboardSet element id to keyboard layout XML id map.
|
||||
final HashMap<Integer, Integer> mKeyboardSetElementIdToXmlIdMap =
|
||||
new HashMap<Integer, Integer>();
|
||||
Params() {}
|
||||
// KeyboardSet element id to element's parameters map.
|
||||
final HashMap<Integer, ElementParams> mKeyboardSetElementIdToParamsMap =
|
||||
new HashMap<Integer, ElementParams>();
|
||||
|
||||
static class ElementParams {
|
||||
int mKeyboardXmlId;
|
||||
boolean mProximityCharsCorrectionEnabled;
|
||||
}
|
||||
}
|
||||
|
||||
public static void clearKeyboardCache() {
|
||||
@ -141,20 +146,21 @@ public class KeyboardSet {
|
||||
break;
|
||||
}
|
||||
|
||||
Integer keyboardXmlId = mParams.mKeyboardSetElementIdToXmlIdMap.get(keyboardSetElementId);
|
||||
if (keyboardXmlId == null) {
|
||||
keyboardXmlId = mParams.mKeyboardSetElementIdToXmlIdMap.get(
|
||||
ElementParams elementParams = mParams.mKeyboardSetElementIdToParamsMap.get(
|
||||
keyboardSetElementId);
|
||||
if (elementParams == null) {
|
||||
elementParams = mParams.mKeyboardSetElementIdToParamsMap.get(
|
||||
KeyboardId.ELEMENT_ALPHABET);
|
||||
}
|
||||
final KeyboardId id = getKeyboardId(keyboardSetElementId);
|
||||
try {
|
||||
return getKeyboard(mContext, keyboardXmlId, id);
|
||||
return getKeyboard(mContext, elementParams, id);
|
||||
} catch (RuntimeException e) {
|
||||
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 SoftReference<Keyboard> ref = sKeyboardCache.get(id);
|
||||
Keyboard keyboard = (ref == null) ? null : ref.get();
|
||||
@ -166,8 +172,10 @@ public class KeyboardSet {
|
||||
if (id.isAlphabetKeyboard()) {
|
||||
builder.setAutoGenerate(sKeysCache);
|
||||
}
|
||||
builder.load(keyboardXmlId, id);
|
||||
builder.load(elementParams.mKeyboardXmlId, id);
|
||||
builder.setTouchPositionCorrectionEnabled(mParams.mTouchPositionCorrectionEnabled);
|
||||
builder.setProximityCharsCorrectionEnabled(
|
||||
elementParams.mProximityCharsCorrectionEnabled);
|
||||
keyboard = builder.build();
|
||||
} finally {
|
||||
LocaleUtils.setSystemLocale(res, savedLocale);
|
||||
@ -331,11 +339,14 @@ public class KeyboardSet {
|
||||
TAG_ELEMENT, parser);
|
||||
XmlParseUtils.checkEndTag(TAG_ELEMENT, parser);
|
||||
|
||||
final ElementParams elementParams = new ElementParams();
|
||||
final int elementName = a.getInt(
|
||||
R.styleable.KeyboardSet_Element_elementName, 0);
|
||||
final int elementKeyboard = a.getResourceId(
|
||||
elementParams.mKeyboardXmlId = a.getResourceId(
|
||||
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 {
|
||||
a.recycle();
|
||||
}
|
||||
|
@ -47,7 +47,9 @@ public class MoreKeysKeyboardView extends KeyboardView implements MoreKeysPanel
|
||||
new KeyboardActionListener.Adapter() {
|
||||
@Override
|
||||
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
|
||||
|
@ -1318,7 +1318,13 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||
if (mSettingsValues.isWordSeparator(primaryCode)) {
|
||||
didAutoCorrect = handleSeparator(primaryCode, x, y, spaceState);
|
||||
} 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;
|
||||
mShouldSwitchToLastSubtype = true;
|
||||
|
Loading…
Reference in New Issue
Block a user