From bfc02a7005ab9a2950cbe09a13a88e4edcbb051e Mon Sep 17 00:00:00 2001 From: Ken Wakasa Date: Wed, 29 Aug 2012 04:33:39 -0700 Subject: [PATCH] Revert "Move resource related methods to ResourceUtils" This reverts commit 160dc0f98e513819a6ebf11a2d65cdc851389344 Change-Id: Ic5a3d9c70b8f6f2993d8455799945ec2633cad66 --- .../com/android/inputmethod/keyboard/Key.java | 5 +- .../inputmethod/keyboard/Keyboard.java | 90 ++++++++++++++----- .../inputmethod/keyboard/KeyboardView.java | 57 +++++++----- .../inputmethod/latin/ResourceUtils.java | 70 --------------- .../suggestions/SuggestionStripView.java | 19 ++-- 5 files changed, 118 insertions(+), 123 deletions(-) diff --git a/java/src/com/android/inputmethod/keyboard/Key.java b/java/src/com/android/inputmethod/keyboard/Key.java index 87fb8baea..178c9ff05 100644 --- a/java/src/com/android/inputmethod/keyboard/Key.java +++ b/java/src/com/android/inputmethod/keyboard/Key.java @@ -36,7 +36,6 @@ import com.android.inputmethod.keyboard.internal.KeySpecParser.MoreKeySpec; import com.android.inputmethod.keyboard.internal.KeyStyles.KeyStyle; import com.android.inputmethod.keyboard.internal.KeyboardIconsSet; import com.android.inputmethod.latin.R; -import com.android.inputmethod.latin.ResourceUtils; import com.android.inputmethod.latin.StringUtils; import org.xmlpull.v1.XmlPullParser; @@ -230,9 +229,9 @@ public class Key { mBackgroundType = style.getInt(keyAttr, R.styleable.Keyboard_Key_backgroundType, row.getDefaultBackgroundType()); - mVisualInsetsLeft = Math.round(ResourceUtils.getDimensionOrFraction(keyAttr, + mVisualInsetsLeft = Math.round(Keyboard.Builder.getDimensionOrFraction(keyAttr, R.styleable.Keyboard_Key_visualInsetsLeft, params.mBaseWidth, 0)); - mVisualInsetsRight = Math.round(ResourceUtils.getDimensionOrFraction(keyAttr, + mVisualInsetsRight = Math.round(Keyboard.Builder.getDimensionOrFraction(keyAttr, R.styleable.Keyboard_Key_visualInsetsRight, params.mBaseWidth, 0)); mIconId = KeySpecParser.getIconId(style.getString(keyAttr, R.styleable.Keyboard_Key_keyIcon)); diff --git a/java/src/com/android/inputmethod/keyboard/Keyboard.java b/java/src/com/android/inputmethod/keyboard/Keyboard.java index aa757f153..a5f9e9e75 100644 --- a/java/src/com/android/inputmethod/keyboard/Keyboard.java +++ b/java/src/com/android/inputmethod/keyboard/Keyboard.java @@ -39,7 +39,6 @@ import com.android.inputmethod.latin.LatinImeLogger; import com.android.inputmethod.latin.LocaleUtils.RunInLocale; import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.ResourceUtils; -import com.android.inputmethod.latin.StringUtils; import com.android.inputmethod.latin.SubtypeLocale; import com.android.inputmethod.latin.XmlParseUtils; @@ -566,13 +565,13 @@ public class Keyboard { mParams = params; TypedArray keyboardAttr = res.obtainAttributes(Xml.asAttributeSet(parser), R.styleable.Keyboard); - mRowHeight = (int)ResourceUtils.getDimensionOrFraction(keyboardAttr, + mRowHeight = (int)Builder.getDimensionOrFraction(keyboardAttr, R.styleable.Keyboard_rowHeight, params.mBaseHeight, params.mDefaultRowHeight); keyboardAttr.recycle(); TypedArray keyAttr = res.obtainAttributes(Xml.asAttributeSet(parser), R.styleable.Keyboard_Key); - mDefaultKeyWidth = ResourceUtils.getDimensionOrFraction(keyAttr, + mDefaultKeyWidth = Builder.getDimensionOrFraction(keyAttr, R.styleable.Keyboard_Key_keyWidth, params.mBaseWidth, params.mDefaultKeyWidth); mDefaultBackgroundType = keyAttr.getInt(R.styleable.Keyboard_Key_backgroundType, @@ -625,7 +624,7 @@ public class Keyboard { final int keyboardRightEdge = mParams.mOccupiedWidth - mParams.mHorizontalEdgesPadding; if (keyAttr.hasValue(R.styleable.Keyboard_Key_keyXPos)) { - final float keyXPos = ResourceUtils.getDimensionOrFraction(keyAttr, + final float keyXPos = Builder.getDimensionOrFraction(keyAttr, R.styleable.Keyboard_Key_keyXPos, mParams.mBaseWidth, 0); if (keyXPos < 0) { // If keyXPos is negative, the actual x-coordinate will be @@ -646,7 +645,7 @@ public class Keyboard { } public float getKeyWidth(TypedArray keyAttr, float keyXPos) { - final int widthType = ResourceUtils.getEnumValue(keyAttr, + final int widthType = Builder.getEnumValue(keyAttr, R.styleable.Keyboard_Key_keyWidth, KEYWIDTH_NOT_ENUM); switch (widthType) { case KEYWIDTH_FILL_RIGHT: @@ -656,7 +655,7 @@ public class Keyboard { // out the area up to the right edge of the keyboard. return keyboardRightEdge - keyXPos; default: // KEYWIDTH_NOT_ENUM - return ResourceUtils.getDimensionOrFraction(keyAttr, + return Builder.getDimensionOrFraction(keyAttr, R.styleable.Keyboard_Key_keyWidth, mParams.mBaseWidth, mDefaultKeyWidth); } @@ -769,14 +768,14 @@ public class Keyboard { keyboardHeight = keyboardAttr.getDimension( R.styleable.Keyboard_keyboardHeight, displayHeight / 2); } - final float maxKeyboardHeight = ResourceUtils.getDimensionOrFraction(keyboardAttr, + final float maxKeyboardHeight = getDimensionOrFraction(keyboardAttr, R.styleable.Keyboard_maxKeyboardHeight, displayHeight, displayHeight / 2); - float minKeyboardHeight = ResourceUtils.getDimensionOrFraction(keyboardAttr, + float minKeyboardHeight = getDimensionOrFraction(keyboardAttr, R.styleable.Keyboard_minKeyboardHeight, displayHeight, displayHeight / 2); if (minKeyboardHeight < 0) { // Specified fraction was negative, so it should be calculated against display // width. - minKeyboardHeight = -ResourceUtils.getDimensionOrFraction(keyboardAttr, + minKeyboardHeight = -getDimensionOrFraction(keyboardAttr, R.styleable.Keyboard_minKeyboardHeight, displayWidth, displayWidth / 2); } final Params params = mParams; @@ -785,27 +784,26 @@ public class Keyboard { params.mOccupiedHeight = (int)Math.max( Math.min(keyboardHeight, maxKeyboardHeight), minKeyboardHeight); params.mOccupiedWidth = params.mId.mWidth; - params.mTopPadding = (int)ResourceUtils.getDimensionOrFraction(keyboardAttr, + params.mTopPadding = (int)getDimensionOrFraction(keyboardAttr, R.styleable.Keyboard_keyboardTopPadding, params.mOccupiedHeight, 0); - params.mBottomPadding = (int)ResourceUtils.getDimensionOrFraction(keyboardAttr, + params.mBottomPadding = (int)getDimensionOrFraction(keyboardAttr, R.styleable.Keyboard_keyboardBottomPadding, params.mOccupiedHeight, 0); - params.mHorizontalEdgesPadding = (int)ResourceUtils.getDimensionOrFraction( - keyboardAttr, + params.mHorizontalEdgesPadding = (int)getDimensionOrFraction(keyboardAttr, R.styleable.Keyboard_keyboardHorizontalEdgesPadding, mParams.mOccupiedWidth, 0); params.mBaseWidth = params.mOccupiedWidth - params.mHorizontalEdgesPadding * 2 - params.mHorizontalCenterPadding; - params.mDefaultKeyWidth = (int)ResourceUtils.getDimensionOrFraction(keyAttr, + params.mDefaultKeyWidth = (int)getDimensionOrFraction(keyAttr, R.styleable.Keyboard_Key_keyWidth, params.mBaseWidth, params.mBaseWidth / DEFAULT_KEYBOARD_COLUMNS); - params.mHorizontalGap = (int)ResourceUtils.getDimensionOrFraction(keyboardAttr, + params.mHorizontalGap = (int)getDimensionOrFraction(keyboardAttr, R.styleable.Keyboard_horizontalGap, params.mBaseWidth, 0); - params.mVerticalGap = (int)ResourceUtils.getDimensionOrFraction(keyboardAttr, + params.mVerticalGap = (int)getDimensionOrFraction(keyboardAttr, R.styleable.Keyboard_verticalGap, params.mOccupiedHeight, 0); params.mBaseHeight = params.mOccupiedHeight - params.mTopPadding - params.mBottomPadding + params.mVerticalGap; - params.mDefaultRowHeight = (int)ResourceUtils.getDimensionOrFraction(keyboardAttr, + params.mDefaultRowHeight = (int)getDimensionOrFraction(keyboardAttr, R.styleable.Keyboard_rowHeight, params.mBaseHeight, params.mBaseHeight / DEFAULT_KEYBOARD_ROWS); @@ -1223,7 +1221,7 @@ public class Keyboard { // If does not have "index" attribute, that means this is wild-card for // the attribute. return !a.hasValue(index) - || StringUtils.containsInArray(value, a.getString(index).split("\\|")); + || stringArrayContains(a.getString(index).split("\\|"), value); } private static boolean matchTypedValue(TypedArray a, int index, int intValue, @@ -1234,10 +1232,19 @@ public class Keyboard { if (v == null) { return true; } - if (ResourceUtils.isIntegerValue(v)) { + if (isIntegerValue(v)) { return intValue == a.getInt(index, 0); - } else if (ResourceUtils.isStringValue(v)) { - return StringUtils.containsInArray(strValue, a.getString(index).split("\\|")); + } else if (isStringValue(v)) { + return stringArrayContains(a.getString(index).split("\\|"), strValue); + } + return false; + } + + private static boolean stringArrayContains(String[] array, String value) { + for (final String elem : array) { + if (elem.equals(value)) { + return true; + } } return false; } @@ -1327,6 +1334,47 @@ public class Keyboard { mRightEdgeKey = null; } + public static float getDimensionOrFraction(TypedArray a, int index, int base, + float defValue) { + final TypedValue value = a.peekValue(index); + if (value == null) { + return defValue; + } + if (isFractionValue(value)) { + return a.getFraction(index, base, base, defValue); + } else if (isDimensionValue(value)) { + return a.getDimension(index, defValue); + } + return defValue; + } + + public static int getEnumValue(TypedArray a, int index, int defValue) { + final TypedValue value = a.peekValue(index); + if (value == null) { + return defValue; + } + if (isIntegerValue(value)) { + return a.getInt(index, defValue); + } + return defValue; + } + + private static boolean isFractionValue(TypedValue v) { + return v.type == TypedValue.TYPE_FRACTION; + } + + private static boolean isDimensionValue(TypedValue v) { + return v.type == TypedValue.TYPE_DIMENSION; + } + + private static boolean isIntegerValue(TypedValue v) { + return v.type >= TypedValue.TYPE_FIRST_INT && v.type <= TypedValue.TYPE_LAST_INT; + } + + private static boolean isStringValue(TypedValue v) { + return v.type == TypedValue.TYPE_STRING; + } + private static String textAttr(String value, String name) { return value != null ? String.format(" %s=%s", name, value) : ""; } diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java index d4d4ce76b..a4797095f 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java @@ -43,7 +43,6 @@ import com.android.inputmethod.latin.CollectionUtils; import com.android.inputmethod.latin.Constants; import com.android.inputmethod.latin.LatinImeLogger; import com.android.inputmethod.latin.R; -import com.android.inputmethod.latin.ResourceUtils; import com.android.inputmethod.latin.StaticInnerHandlerWrapper; import com.android.inputmethod.latin.StringUtils; import com.android.inputmethod.latin.define.ProductionFlag; @@ -85,6 +84,9 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { // Miscellaneous constants private static final int[] LONG_PRESSABLE_STATE_SET = { android.R.attr.state_long_pressable }; + private static final float UNDEFINED_RATIO = -1.0f; + private static final int UNDEFINED_DIMENSION = -1; + // XML attributes protected final float mVerticalCorrection; protected final int mMoreKeysLayout; @@ -217,26 +219,20 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { public KeyDrawParams(final TypedArray a) { mKeyBackground = a.getDrawable(R.styleable.KeyboardView_keyBackground); - if (!ResourceUtils.isValidFraction(mKeyLetterRatio = ResourceUtils.getFraction(a, + if (!isValidFraction(mKeyLetterRatio = getFraction(a, R.styleable.KeyboardView_keyLetterSize))) { - mKeyLetterSize = ResourceUtils.getDimensionPixelSize(a, - R.styleable.KeyboardView_keyLetterSize); + mKeyLetterSize = getDimensionPixelSize(a, R.styleable.KeyboardView_keyLetterSize); } - if (!ResourceUtils.isValidFraction(mKeyLabelRatio = ResourceUtils.getFraction(a, + if (!isValidFraction(mKeyLabelRatio = getFraction(a, R.styleable.KeyboardView_keyLabelSize))) { - mKeyLabelSize = ResourceUtils.getDimensionPixelSize(a, - R.styleable.KeyboardView_keyLabelSize); + mKeyLabelSize = getDimensionPixelSize(a, R.styleable.KeyboardView_keyLabelSize); } - mKeyLargeLabelRatio = ResourceUtils.getFraction(a, - R.styleable.KeyboardView_keyLargeLabelRatio); - mKeyLargeLetterRatio = ResourceUtils.getFraction(a, - R.styleable.KeyboardView_keyLargeLetterRatio); - mKeyHintLetterRatio = ResourceUtils.getFraction(a, - R.styleable.KeyboardView_keyHintLetterRatio); - mKeyShiftedLetterHintRatio = ResourceUtils.getFraction(a, + mKeyLargeLabelRatio = getFraction(a, R.styleable.KeyboardView_keyLargeLabelRatio); + mKeyLargeLetterRatio = getFraction(a, R.styleable.KeyboardView_keyLargeLetterRatio); + mKeyHintLetterRatio = getFraction(a, R.styleable.KeyboardView_keyHintLetterRatio); + mKeyShiftedLetterHintRatio = getFraction(a, R.styleable.KeyboardView_keyShiftedLetterHintRatio); - mKeyHintLabelRatio = ResourceUtils.getFraction(a, - R.styleable.KeyboardView_keyHintLabelRatio); + mKeyHintLabelRatio = getFraction(a, R.styleable.KeyboardView_keyHintLabelRatio); mKeyLabelHorizontalPadding = a.getDimension( R.styleable.KeyboardView_keyLabelHorizontalPadding, 0); mKeyHintLetterPadding = a.getDimension( @@ -267,10 +263,10 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { mKeyTypeface = (keyboard.mKeyTypeface != null) ? keyboard.mKeyTypeface : mKeyTypefaceFromKeyboardView; final int keyHeight = keyboard.mMostCommonKeyHeight - keyboard.mVerticalGap; - if (ResourceUtils.isValidFraction(mKeyLetterRatio)) { + if (isValidFraction(mKeyLetterRatio)) { mKeyLetterSize = (int)(keyHeight * mKeyLetterRatio); } - if (ResourceUtils.isValidFraction(mKeyLabelRatio)) { + if (isValidFraction(mKeyLabelRatio)) { mKeyLabelSize = (int)(keyHeight * mKeyLabelRatio); } mKeyLargeLabelSize = (int)(keyHeight * mKeyLargeLabelRatio); @@ -345,15 +341,14 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { R.styleable.KeyboardView_keyPreviewOffset, 0); mPreviewHeight = a.getDimensionPixelSize( R.styleable.KeyboardView_keyPreviewHeight, 80); - mPreviewTextRatio = ResourceUtils.getFraction(a, - R.styleable.KeyboardView_keyPreviewTextRatio); + mPreviewTextRatio = getFraction(a, R.styleable.KeyboardView_keyPreviewTextRatio); mPreviewTextColor = a.getColor(R.styleable.KeyboardView_keyPreviewTextColor, 0); mLingerTimeout = a.getInt(R.styleable.KeyboardView_keyPreviewLingerTimeout, 0); } public void updateParams(final Keyboard keyboard, final KeyDrawParams keyDrawParams) { final int keyHeight = keyboard.mMostCommonKeyHeight - keyboard.mVerticalGap; - if (ResourceUtils.isValidFraction(mPreviewTextRatio)) { + if (isValidFraction(mPreviewTextRatio)) { mPreviewTextSize = (int)(keyHeight * mPreviewTextRatio); } mKeyLetterSize = keyDrawParams.mKeyLetterSize; @@ -392,6 +387,26 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { mPaint.setAntiAlias(true); } + static boolean isValidFraction(final float fraction) { + return fraction >= 0.0f; + } + + static float getFraction(final TypedArray a, final int index) { + final TypedValue value = a.peekValue(index); + if (value == null || value.type != TypedValue.TYPE_FRACTION) { + return UNDEFINED_RATIO; + } + return a.getFraction(index, 1, 1, UNDEFINED_RATIO); + } + + public static int getDimensionPixelSize(final TypedArray a, final int index) { + final TypedValue value = a.peekValue(index); + if (value == null || value.type != TypedValue.TYPE_DIMENSION) { + return UNDEFINED_DIMENSION; + } + return a.getDimensionPixelSize(index, UNDEFINED_DIMENSION); + } + /** * Attaches a keyboard to this view. The keyboard can be switched at any time and the * view will re-layout itself to accommodate the keyboard. diff --git a/java/src/com/android/inputmethod/latin/ResourceUtils.java b/java/src/com/android/inputmethod/latin/ResourceUtils.java index b3d7ac5bf..e01ac3dd4 100644 --- a/java/src/com/android/inputmethod/latin/ResourceUtils.java +++ b/java/src/com/android/inputmethod/latin/ResourceUtils.java @@ -17,16 +17,11 @@ package com.android.inputmethod.latin; import android.content.res.Resources; -import android.content.res.TypedArray; import android.os.Build; -import android.util.TypedValue; import java.util.HashMap; public final class ResourceUtils { - public static final float UNDEFINED_RATIO = -1.0f; - public static final int UNDEFINED_DIMENSION = -1; - private ResourceUtils() { // This utility class is not publicly instantiable. } @@ -50,69 +45,4 @@ public final class ResourceUtils { } return sDeviceOverrideValueMap.get(key); } - - public static boolean isValidFraction(final float fraction) { - return fraction >= 0.0f; - } - - public static float getFraction(final TypedArray a, final int index, final float defValue) { - final TypedValue value = a.peekValue(index); - if (value == null || !isFractionValue(value)) { - return defValue; - } - return a.getFraction(index, 1, 1, defValue); - } - - public static float getFraction(final TypedArray a, final int index) { - return getFraction(a, index, UNDEFINED_RATIO); - } - - public static int getDimensionPixelSize(final TypedArray a, final int index) { - final TypedValue value = a.peekValue(index); - if (value == null || !isDimensionValue(value)) { - return ResourceUtils.UNDEFINED_DIMENSION; - } - return a.getDimensionPixelSize(index, ResourceUtils.UNDEFINED_DIMENSION); - } - - public static float getDimensionOrFraction(TypedArray a, int index, int base, - float defValue) { - final TypedValue value = a.peekValue(index); - if (value == null) { - return defValue; - } - if (isFractionValue(value)) { - return a.getFraction(index, base, base, defValue); - } else if (isDimensionValue(value)) { - return a.getDimension(index, defValue); - } - return defValue; - } - - public static int getEnumValue(TypedArray a, int index, int defValue) { - final TypedValue value = a.peekValue(index); - if (value == null) { - return defValue; - } - if (isIntegerValue(value)) { - return a.getInt(index, defValue); - } - return defValue; - } - - public static boolean isFractionValue(TypedValue v) { - return v.type == TypedValue.TYPE_FRACTION; - } - - public static boolean isDimensionValue(TypedValue v) { - return v.type == TypedValue.TYPE_DIMENSION; - } - - public static boolean isIntegerValue(TypedValue v) { - return v.type >= TypedValue.TYPE_FIRST_INT && v.type <= TypedValue.TYPE_LAST_INT; - } - - public static boolean isStringValue(TypedValue v) { - return v.type == TypedValue.TYPE_STRING; - } } diff --git a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java index 9e8ab81b0..03263d274 100644 --- a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java +++ b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java @@ -61,7 +61,6 @@ import com.android.inputmethod.latin.AutoCorrection; import com.android.inputmethod.latin.CollectionUtils; import com.android.inputmethod.latin.LatinImeLogger; import com.android.inputmethod.latin.R; -import com.android.inputmethod.latin.ResourceUtils; import com.android.inputmethod.latin.StaticInnerHandlerWrapper; import com.android.inputmethod.latin.SuggestedWords; import com.android.inputmethod.latin.Utils; @@ -197,15 +196,15 @@ public class SuggestionStripView extends RelativeLayout implements OnClickListen R.styleable.SuggestionStripView, defStyle, R.style.SuggestionStripViewStyle); mSuggestionStripOption = a.getInt( R.styleable.SuggestionStripView_suggestionStripOption, 0); - final float alphaValidTypedWord = ResourceUtils.getFraction(a, + final float alphaValidTypedWord = getFraction(a, R.styleable.SuggestionStripView_alphaValidTypedWord, 1.0f); - final float alphaTypedWord = ResourceUtils.getFraction(a, + final float alphaTypedWord = getFraction(a, R.styleable.SuggestionStripView_alphaTypedWord, 1.0f); - final float alphaAutoCorrect = ResourceUtils.getFraction(a, + final float alphaAutoCorrect = getFraction(a, R.styleable.SuggestionStripView_alphaAutoCorrect, 1.0f); - final float alphaSuggested = ResourceUtils.getFraction(a, + final float alphaSuggested = getFraction(a, R.styleable.SuggestionStripView_alphaSuggested, 1.0f); - mAlphaObsoleted = ResourceUtils.getFraction(a, + mAlphaObsoleted = getFraction(a, R.styleable.SuggestionStripView_alphaSuggested, 1.0f); mColorValidTypedWord = applyAlpha(a.getColor( R.styleable.SuggestionStripView_colorValidTypedWord, 0), alphaValidTypedWord); @@ -218,13 +217,13 @@ public class SuggestionStripView extends RelativeLayout implements OnClickListen mSuggestionsCountInStrip = a.getInt( R.styleable.SuggestionStripView_suggestionsCountInStrip, DEFAULT_SUGGESTIONS_COUNT_IN_STRIP); - mCenterSuggestionWeight = ResourceUtils.getFraction(a, + mCenterSuggestionWeight = getFraction(a, R.styleable.SuggestionStripView_centerSuggestionPercentile, DEFAULT_CENTER_SUGGESTION_PERCENTILE); mMaxMoreSuggestionsRow = a.getInt( R.styleable.SuggestionStripView_maxMoreSuggestionsRow, DEFAULT_MAX_MORE_SUGGESTIONS_ROW); - mMinMoreSuggestionsWidth = ResourceUtils.getFraction(a, + mMinMoreSuggestionsWidth = getFraction(a, R.styleable.SuggestionStripView_minMoreSuggestionsWidth, 1.0f); a.recycle(); @@ -279,6 +278,10 @@ public class SuggestionStripView extends RelativeLayout implements OnClickListen return new BitmapDrawable(res, buffer); } + static float getFraction(final TypedArray a, final int index, final float defValue) { + return a.getFraction(index, 1, 1, defValue); + } + private CharSequence getStyledSuggestionWord(SuggestedWords suggestedWords, int pos) { final CharSequence word = suggestedWords.getWord(pos); final boolean isAutoCorrect = pos == 1 && suggestedWords.willAutoCorrect();