diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml index 34ce527f1..4dfa5ab97 100644 --- a/java/res/values/attrs.xml +++ b/java/res/values/attrs.xml @@ -16,7 +16,6 @@ - @@ -34,8 +33,6 @@ - - @@ -140,6 +137,9 @@ + + + diff --git a/java/res/values/styles.xml b/java/res/values/styles.xml index c6ea2a5f8..30c0e5a38 100644 --- a/java/res/values/styles.xml +++ b/java/res/values/styles.xml @@ -17,6 +17,8 @@ + + @@ -214,10 +231,12 @@ name="Keyboard.IceCreamSandwich" parent="Keyboard" > + 5 @fraction/keyboard_top_padding_ics @fraction/keyboard_bottom_padding_ics @fraction/key_horizontal_gap_ics @fraction/key_bottom_gap_ics + @array/touch_position_correction_data_ice_cream_sandwich diff --git a/java/res/values/themes-basic.xml b/java/res/values/themes-basic.xml index 29cb9cc7d..ff9fed55f 100644 --- a/java/res/values/themes-basic.xml +++ b/java/res/values/themes-basic.xml @@ -16,7 +16,6 @@ diff --git a/java/res/values/themes-gingerbread.xml b/java/res/values/themes-gingerbread.xml index c4a0f804a..be853eb0f 100644 --- a/java/res/values/themes-gingerbread.xml +++ b/java/res/values/themes-gingerbread.xml @@ -16,7 +16,6 @@ diff --git a/java/res/values/themes-ics.xml b/java/res/values/themes-ics.xml index dd2b6a334..618aaed79 100644 --- a/java/res/values/themes-ics.xml +++ b/java/res/values/themes-ics.xml @@ -16,7 +16,6 @@ diff --git a/java/res/values/themes-stone-bold.xml b/java/res/values/themes-stone-bold.xml index 6e864bed0..fdf9c51f5 100644 --- a/java/res/values/themes-stone-bold.xml +++ b/java/res/values/themes-stone-bold.xml @@ -16,7 +16,6 @@ diff --git a/java/res/values/themes-stone.xml b/java/res/values/themes-stone.xml index 64c557035..cb3edc58f 100644 --- a/java/res/values/themes-stone.xml +++ b/java/res/values/themes-stone.xml @@ -16,7 +16,6 @@ diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java index 46836da67..3cdde09a9 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java @@ -247,54 +247,50 @@ public class KeyboardBuilder { mParams = params; - final TypedArray a = context.obtainStyledAttributes(R.styleable.KeyboardTheme); - mParams.mThemeId = a.getInt(R.styleable.KeyboardTheme_themeId, 0); - a.recycle(); + setTouchPositionCorrectionData(context, params); - if (!setTouchPositionCorrectionData(context)) { - // In the regression test, setTouchPositionCorrectionData() fails - mParams.mTouchPositionCorrectionXs = null; - mParams.mTouchPositionCorrectionYs = null; - mParams.mTouchPositionCorrectionRadii = null; - } - - mParams.GRID_WIDTH = res.getInteger(R.integer.config_keyboard_grid_width); - mParams.GRID_HEIGHT = res.getInteger(R.integer.config_keyboard_grid_height); + params.GRID_WIDTH = res.getInteger(R.integer.config_keyboard_grid_width); + params.GRID_HEIGHT = res.getInteger(R.integer.config_keyboard_grid_height); } - private boolean setTouchPositionCorrectionData(Context context) { - final TypedArray a = context.obtainStyledAttributes(R.styleable.KeyboardTheme); - final int resourceId = a.getResourceId( - R.styleable.KeyboardTheme_touchPositionCorrectionData, 0); + private static void setTouchPositionCorrectionData(Context context, KeyboardParams params) { + params.mTouchPositionCorrectionXs = null; + params.mTouchPositionCorrectionYs = null; + params.mTouchPositionCorrectionRadii = null; + + final TypedArray a = context.obtainStyledAttributes(R.styleable.Keyboard); + params.mThemeId = a.getInt(R.styleable.Keyboard_themeId, 0); + final int resourceId = a.getResourceId(R.styleable.Keyboard_touchPositionCorrectionData, 0); if (resourceId == 0) { - // In the regression test, we cannot use theme resources - // TODO: Fix this - return false; + if (LatinImeLogger.sDBG) + throw new RuntimeException("touchPositionCorrectionData is not defined"); + return; } + final String[] data = context.getResources().getStringArray(resourceId); a.recycle(); final int dataLength = data.length; if (dataLength % TOUCH_POSITION_CORRECTION_RECORD_SIZE != 0) { - if (LatinImeLogger.sDBG) { + if (LatinImeLogger.sDBG) throw new RuntimeException("the size of touch position correction data is invalid"); - } - return false; + return; } + final int length = dataLength / TOUCH_POSITION_CORRECTION_RECORD_SIZE; - mParams.mTouchPositionCorrectionXs = new float[length]; - mParams.mTouchPositionCorrectionYs = new float[length]; - mParams.mTouchPositionCorrectionRadii = new float[length]; + params.mTouchPositionCorrectionXs = new float[length]; + params.mTouchPositionCorrectionYs = new float[length]; + params.mTouchPositionCorrectionRadii = new float[length]; try { for (int i = 0; i < dataLength; ++i) { final int type = i % TOUCH_POSITION_CORRECTION_RECORD_SIZE; final int index = i / TOUCH_POSITION_CORRECTION_RECORD_SIZE; final float value = Float.parseFloat(data[i]); if (type == 0) { - mParams.mTouchPositionCorrectionXs[index] = value; + params.mTouchPositionCorrectionXs[index] = value; } else if (type == 1) { - mParams.mTouchPositionCorrectionYs[index] = value; + params.mTouchPositionCorrectionYs[index] = value; } else { - mParams.mTouchPositionCorrectionRadii[index] = value; + params.mTouchPositionCorrectionRadii[index] = value; } } } catch (NumberFormatException e) { @@ -302,9 +298,10 @@ public class KeyboardBuilder { throw new RuntimeException( "the number format for touch position correction data is invalid"); } - return false; + params.mTouchPositionCorrectionXs = null; + params.mTouchPositionCorrectionYs = null; + params.mTouchPositionCorrectionRadii = null; } - return true; } public KeyboardBuilder load(KeyboardId id) {