From e07db71d26fd9cb2c0141d76bfd3cd01bb001899 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Wed, 28 Mar 2012 18:35:01 +0900 Subject: [PATCH] Remove SupportTouchPositionCorrection from subtype extra value Change-Id: Ieedff9ec212f5567405ca276b0f2194132ba7b0c --- java/res/xml-sw600dp-land/kbd_thai.xml | 1 + java/res/xml-sw600dp/kbd_thai.xml | 1 + java/res/xml-sw768dp-land/kbd_thai.xml | 1 + .../res/xml-sw768dp-land/kbd_thai_symbols.xml | 1 + .../kbd_thai_symbols_shift.xml | 1 + java/res/xml-sw768dp/kbd_thai.xml | 1 + java/res/xml-sw768dp/kbd_thai_symbols.xml | 1 + .../xml-sw768dp/kbd_thai_symbols_shift.xml | 1 + java/res/xml/method.xml | 69 ++++++++----------- .../inputmethod/keyboard/Keyboard.java | 30 +++----- .../inputmethod/keyboard/KeyboardSet.java | 12 ++-- .../keyboard/KeyboardSwitcher.java | 4 +- .../android/inputmethod/latin/LatinIME.java | 6 -- 13 files changed, 55 insertions(+), 74 deletions(-) diff --git a/java/res/xml-sw600dp-land/kbd_thai.xml b/java/res/xml-sw600dp-land/kbd_thai.xml index ac36ea5ff..b75980f2f 100644 --- a/java/res/xml-sw600dp-land/kbd_thai.xml +++ b/java/res/xml-sw600dp-land/kbd_thai.xml @@ -22,6 +22,7 @@ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" latin:rowHeight="20%p" latin:verticalGap="3.20%p" + latin:touchPositionCorrectionData="@null" > diff --git a/java/res/xml-sw600dp/kbd_thai.xml b/java/res/xml-sw600dp/kbd_thai.xml index ac36ea5ff..b75980f2f 100644 --- a/java/res/xml-sw600dp/kbd_thai.xml +++ b/java/res/xml-sw600dp/kbd_thai.xml @@ -22,6 +22,7 @@ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" latin:rowHeight="20%p" latin:verticalGap="3.20%p" + latin:touchPositionCorrectionData="@null" > diff --git a/java/res/xml-sw768dp-land/kbd_thai.xml b/java/res/xml-sw768dp-land/kbd_thai.xml index 4bfc9cb48..b2cdbc373 100644 --- a/java/res/xml-sw768dp-land/kbd_thai.xml +++ b/java/res/xml-sw768dp-land/kbd_thai.xml @@ -22,6 +22,7 @@ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" latin:rowHeight="20%p" latin:verticalGap="2.65%p" + latin:touchPositionCorrectionData="@null" > diff --git a/java/res/xml-sw768dp-land/kbd_thai_symbols.xml b/java/res/xml-sw768dp-land/kbd_thai_symbols.xml index a3feeaae3..1531458ea 100644 --- a/java/res/xml-sw768dp-land/kbd_thai_symbols.xml +++ b/java/res/xml-sw768dp-land/kbd_thai_symbols.xml @@ -22,6 +22,7 @@ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" latin:rowHeight="20%p" latin:verticalGap="2.65%p" + latin:touchPositionCorrectionData="@null" > diff --git a/java/res/xml-sw768dp-land/kbd_thai_symbols_shift.xml b/java/res/xml-sw768dp-land/kbd_thai_symbols_shift.xml index 8b4a8ea5b..fa30f24c0 100644 --- a/java/res/xml-sw768dp-land/kbd_thai_symbols_shift.xml +++ b/java/res/xml-sw768dp-land/kbd_thai_symbols_shift.xml @@ -22,6 +22,7 @@ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" latin:rowHeight="20%p" latin:verticalGap="2.65%p" + latin:touchPositionCorrectionData="@null" > diff --git a/java/res/xml-sw768dp/kbd_thai.xml b/java/res/xml-sw768dp/kbd_thai.xml index dd0ac36a6..593ccbd48 100644 --- a/java/res/xml-sw768dp/kbd_thai.xml +++ b/java/res/xml-sw768dp/kbd_thai.xml @@ -22,6 +22,7 @@ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" latin:rowHeight="20%p" latin:verticalGap="2.95%p" + latin:touchPositionCorrectionData="@null" > diff --git a/java/res/xml-sw768dp/kbd_thai_symbols.xml b/java/res/xml-sw768dp/kbd_thai_symbols.xml index 91cf8084f..e2e5f5d56 100644 --- a/java/res/xml-sw768dp/kbd_thai_symbols.xml +++ b/java/res/xml-sw768dp/kbd_thai_symbols.xml @@ -22,6 +22,7 @@ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" latin:rowHeight="20%p" latin:verticalGap="2.95%p" + latin:touchPositionCorrectionData="@null" > diff --git a/java/res/xml-sw768dp/kbd_thai_symbols_shift.xml b/java/res/xml-sw768dp/kbd_thai_symbols_shift.xml index 85745ac3d..a1358d4a2 100644 --- a/java/res/xml-sw768dp/kbd_thai_symbols_shift.xml +++ b/java/res/xml-sw768dp/kbd_thai_symbols_shift.xml @@ -22,6 +22,7 @@ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" latin:rowHeight="20%p" latin:verticalGap="2.95%p" + latin:touchPositionCorrectionData="@null" > diff --git a/java/res/xml/method.xml b/java/res/xml/method.xml index 1cdd68ad9..d6ded6689 100644 --- a/java/res/xml/method.xml +++ b/java/res/xml/method.xml @@ -74,236 +74,224 @@ android:label="@string/subtype_en_US" android:imeSubtypeLocale="en_US" android:imeSubtypeMode="keyboard" - android:imeSubtypeExtraValue="TrySuppressingImeSwitcher,AsciiCapable,SupportTouchPositionCorrection,EnabledWhenDefaultIsNotAsciiCapable" + android:imeSubtypeExtraValue="TrySuppressingImeSwitcher,AsciiCapable,EnabledWhenDefaultIsNotAsciiCapable" /> diff --git a/java/src/com/android/inputmethod/keyboard/Keyboard.java b/java/src/com/android/inputmethod/keyboard/Keyboard.java index 962379016..bc48b85ef 100644 --- a/java/src/com/android/inputmethod/keyboard/Keyboard.java +++ b/java/src/com/android/inputmethod/keyboard/Keyboard.java @@ -278,6 +278,7 @@ public class Keyboard { } } + // TODO: Remove this method. public void setEnabled(boolean enabled) { mEnabled = enabled; } @@ -616,29 +617,10 @@ public class Keyboard { mParams = params; - setTouchPositionCorrectionData(context, params); - params.GRID_WIDTH = res.getInteger(R.integer.config_keyboard_grid_width); params.GRID_HEIGHT = res.getInteger(R.integer.config_keyboard_grid_height); } - private static void setTouchPositionCorrectionData(Context context, Params params) { - final TypedArray a = context.obtainStyledAttributes( - null, R.styleable.Keyboard, R.attr.keyboardStyle, 0); - params.mThemeId = a.getInt(R.styleable.Keyboard_themeId, 0); - final int resourceId = a.getResourceId( - R.styleable.Keyboard_touchPositionCorrectionData, 0); - a.recycle(); - if (resourceId == 0) { - if (LatinImeLogger.sDBG) - Log.e(BUILDER_TAG, "touchPositionCorrectionData is not defined"); - return; - } - - final String[] data = context.getResources().getStringArray(resourceId); - params.mTouchPositionCorrection.load(data); - } - public void setAutoGenerate(KeyboardSet.KeysCache keysCache) { mParams.mKeysCache = keysCache; } @@ -660,6 +642,7 @@ public class Keyboard { return this; } + // TODO: Remove this method. public void setTouchPositionCorrectionEnabled(boolean enabled) { mParams.mTouchPositionCorrection.setEnabled(enabled); } @@ -771,6 +754,15 @@ public class Keyboard { R.styleable.Keyboard_Key_maxMoreKeysColumn, 5); 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); + if (resourceId != 0) { + final String[] data = mResources.getStringArray(resourceId); + params.mTouchPositionCorrection.load(data); + } } finally { keyAttr.recycle(); keyboardAttr.recycle(); diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSet.java b/java/src/com/android/inputmethod/keyboard/KeyboardSet.java index 52096c843..bb11a9b77 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardSet.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardSet.java @@ -63,8 +63,6 @@ public class KeyboardSet { new HashMap>(); private static final KeysCache sKeysCache = new KeysCache(); - private static final EditorInfo EMPTY_EDITOR_INFO = new EditorInfo(); - public static class KeyboardSetException extends RuntimeException { public final KeyboardId mKeyboardId; public KeyboardSetException(Throwable cause, KeyboardId keyboardId) { @@ -209,6 +207,8 @@ public class KeyboardSet { private final Params mParams = new Params(); + private static final EditorInfo EMPTY_EDITOR_INFO = new EditorInfo(); + public Builder(Context context, EditorInfo editorInfo) { mContext = context; mPackageName = context.getPackageName(); @@ -229,15 +229,13 @@ public class KeyboardSet { } // TODO: Use InputMethodSubtype object as argument. - public Builder setSubtype(Locale inputLocale, boolean asciiCapable, - boolean touchPositionCorrectionEnabled) { + public Builder setSubtype(Locale inputLocale, boolean asciiCapable) { final boolean deprecatedForceAscii = StringUtils.inPrivateImeOptions( mPackageName, LatinIME.IME_OPTION_FORCE_ASCII, mEditorInfo); final boolean forceAscii = EditorInfoCompatUtils.hasFlagForceAscii( mParams.mEditorInfo.imeOptions) || deprecatedForceAscii; mParams.mLocale = (forceAscii && !asciiCapable) ? Locale.US : inputLocale; - mParams.mTouchPositionCorrectionEnabled = touchPositionCorrectionEnabled; return this; } @@ -255,6 +253,10 @@ public class KeyboardSet { return this; } + public void setTouchPositionCorrectionEnabled(boolean enabled) { + mParams.mTouchPositionCorrectionEnabled = enabled; + } + public KeyboardSet build() { if (mParams.mOrientation == Configuration.ORIENTATION_UNDEFINED) throw new RuntimeException("Screen geometry is not specified"); diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java index 42dd6206c..93d8704de 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java @@ -140,9 +140,7 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions { builder.setSubtype( mSubtypeSwitcher.getInputLocale(), mSubtypeSwitcher.currentSubtypeContainsExtraValueKey( - LatinIME.SUBTYPE_EXTRA_VALUE_ASCII_CAPABLE), - mSubtypeSwitcher.currentSubtypeContainsExtraValueKey( - LatinIME.SUBTYPE_EXTRA_VALUE_SUPPORT_TOUCH_POSITION_CORRECTION)); + LatinIME.SUBTYPE_EXTRA_VALUE_ASCII_CAPABLE)); builder.setOptions( settingsValues.isVoiceKeyEnabled(editorInfo), settingsValues.isVoiceKeyOnMain(), diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 0669ee668..86c153958 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -124,12 +124,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar */ public static final String SUBTYPE_EXTRA_VALUE_ASCII_CAPABLE = "AsciiCapable"; - /** - * The subtype extra value used to indicate that the subtype keyboard layout supports touch - * position correction. - */ - public static final String SUBTYPE_EXTRA_VALUE_SUPPORT_TOUCH_POSITION_CORRECTION = - "SupportTouchPositionCorrection"; /** * The subtype extra value used to indicate that the subtype keyboard layout should be loaded * from the specified locale.