Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 35ff9454 authored by Tadashi G. Takaoka's avatar Tadashi G. Takaoka
Browse files

Separate inner classes of keyboard package out under internal package

Change-Id: Ia3969bd5ddec5aa5d81d05ad4cf676d818587922
parent ded498d4
Loading
Loading
Loading
Loading
+33 −29
Original line number Diff line number Diff line
@@ -32,9 +32,11 @@ import android.util.Log;
import android.util.Xml;

import com.android.inputmethod.keyboard.internal.KeySpecParser;
import com.android.inputmethod.keyboard.internal.KeySpecParser.MoreKeySpec;
import com.android.inputmethod.keyboard.internal.KeyStyles.KeyStyle;
import com.android.inputmethod.keyboard.internal.KeyStyle;
import com.android.inputmethod.keyboard.internal.KeyboardIconsSet;
import com.android.inputmethod.keyboard.internal.KeyboardParams;
import com.android.inputmethod.keyboard.internal.KeyboardRow;
import com.android.inputmethod.keyboard.internal.MoreKeySpec;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.ResourceUtils;
import com.android.inputmethod.latin.StringUtils;
@@ -166,8 +168,8 @@ public class Key {
    /**
     * This constructor is being used only for keys in more keys keyboard.
     */
    public Key(Keyboard.Params params, MoreKeySpec moreKeySpec, int x, int y, int width, int height,
            int labelFlags) {
    public Key(final KeyboardParams params, final MoreKeySpec moreKeySpec, final int x, final int y,
            final int width, final int height, final int labelFlags) {
        this(params, moreKeySpec.mLabel, null, moreKeySpec.mIconId, moreKeySpec.mCode,
                moreKeySpec.mOutputText, x, y, width, height, labelFlags);
    }
@@ -175,8 +177,9 @@ public class Key {
    /**
     * This constructor is being used only for key in popup suggestions pane.
     */
    public Key(Keyboard.Params params, String label, String hintLabel, int iconId,
            int code, String outputText, int x, int y, int width, int height, int labelFlags) {
    public Key(final KeyboardParams params, final String label, final String hintLabel,
            final int iconId, final int code, final String outputText, final int x, final int y,
            final int width, final int height, final int labelFlags) {
        mHeight = height - params.mVerticalGap;
        mWidth = width - params.mHorizontalGap;
        mHintLabel = hintLabel;
@@ -213,8 +216,8 @@ public class Key {
     * @param parser the XML parser containing the attributes for this key
     * @throws XmlPullParserException
     */
    public Key(Resources res, Keyboard.Params params, Keyboard.Builder.Row row,
            XmlPullParser parser) throws XmlPullParserException {
    public Key(final Resources res, final KeyboardParams params, final KeyboardRow row,
            final XmlPullParser parser) throws XmlPullParserException {
        final float horizontalGap = isSpacer() ? 0 : params.mHorizontalGap;
        final int keyHeight = row.mRowHeight;
        mHeight = keyHeight - params.mVerticalGap;
@@ -364,7 +367,7 @@ public class Key {
        }
    }

    private static boolean needsToUpperCase(int labelFlags, int keyboardElementId) {
    private static boolean needsToUpperCase(final int labelFlags, final int keyboardElementId) {
        if ((labelFlags & LABEL_FLAGS_PRESERVE_CASE) != 0) return false;
        switch (keyboardElementId) {
        case KeyboardId.ELEMENT_ALPHABET_MANUAL_SHIFTED:
@@ -377,7 +380,7 @@ public class Key {
        }
    }

    private static int computeHashCode(Key key) {
    private static int computeHashCode(final Key key) {
        return Arrays.hashCode(new Object[] {
                key.mX,
                key.mY,
@@ -404,7 +407,7 @@ public class Key {
        });
    }

    private boolean equals(Key o) {
    private boolean equals(final Key o) {
        if (this == o) return true;
        return o.mX == mX
                && o.mY == mY
@@ -427,7 +430,7 @@ public class Key {
    }

    @Override
    public boolean equals(Object o) {
    public boolean equals(final Object o) {
        return o instanceof Key && equals((Key)o);
    }

@@ -444,7 +447,7 @@ public class Key {
                KeyboardIconsSet.getIconName(mIconId), backgroundName(mBackgroundType));
    }

    private static String backgroundName(int backgroundType) {
    private static String backgroundName(final int backgroundType) {
        switch (backgroundType) {
        case BACKGROUND_TYPE_NORMAL: return "normal";
        case BACKGROUND_TYPE_FUNCTIONAL: return "functional";
@@ -455,19 +458,19 @@ public class Key {
        }
    }

    public void markAsLeftEdge(Keyboard.Params params) {
    public void markAsLeftEdge(final KeyboardParams params) {
        mHitBox.left = params.mHorizontalEdgesPadding;
    }

    public void markAsRightEdge(Keyboard.Params params) {
    public void markAsRightEdge(final KeyboardParams params) {
        mHitBox.right = params.mOccupiedWidth - params.mHorizontalEdgesPadding;
    }

    public void markAsTopEdge(Keyboard.Params params) {
    public void markAsTopEdge(final KeyboardParams params) {
        mHitBox.top = params.mTopPadding;
    }

    public void markAsBottomEdge(Keyboard.Params params) {
    public void markAsBottomEdge(final KeyboardParams params) {
        mHitBox.bottom = params.mOccupiedHeight + params.mBottomPadding;
    }

@@ -501,7 +504,7 @@ public class Key {
                && (mLabelFlags & LABEL_FLAGS_SHIFTED_LETTER_ACTIVATED) == 0;
    }

    public Typeface selectTypeface(Typeface defaultTypeface) {
    public Typeface selectTypeface(final Typeface defaultTypeface) {
        // TODO: Handle "bold" here too?
        if ((mLabelFlags & LABEL_FLAGS_FONT_NORMAL) != 0) {
            return Typeface.DEFAULT;
@@ -512,8 +515,8 @@ public class Key {
        }
    }

    public int selectTextSize(int letterSize, int largeLetterSize, int labelSize,
            int largeLabelSize, int hintLabelSize) {
    public int selectTextSize(final int letterSize, final int largeLetterSize, final int labelSize,
            final int largeLabelSize, final int hintLabelSize) {
        switch (mLabelFlags & LABEL_FLAGS_FOLLOW_KEY_TEXT_RATIO_MASK) {
        case LABEL_FLAGS_FOLLOW_KEY_LETTER_RATIO:
            return letterSize;
@@ -606,7 +609,7 @@ public class Key {
        return (attrs != null) ? attrs.mAltCode : CODE_UNSPECIFIED;
    }

    public Drawable getIcon(KeyboardIconsSet iconSet, int alpha) {
    public Drawable getIcon(final KeyboardIconsSet iconSet, final int alpha) {
        final OptionalAttributes attrs = mOptionalAttributes;
        final int disabledIconId = (attrs != null) ? attrs.mDisabledIconId : ICON_UNDEFINED;
        final int iconId = mEnabled ? mIconId : disabledIconId;
@@ -617,7 +620,7 @@ public class Key {
        return icon;
    }

    public Drawable getPreviewIcon(KeyboardIconsSet iconSet) {
    public Drawable getPreviewIcon(final KeyboardIconsSet iconSet) {
        final OptionalAttributes attrs = mOptionalAttributes;
        final int previewIconId = (attrs != null) ? attrs.mPreviewIconId : ICON_UNDEFINED;
        return previewIconId != ICON_UNDEFINED
@@ -657,7 +660,7 @@ public class Key {
        return mEnabled;
    }

    public void setEnabled(boolean enabled) {
    public void setEnabled(final boolean enabled) {
        mEnabled = enabled;
    }

@@ -667,9 +670,9 @@ public class Key {
     * @param y the y-coordinate of the point
     * @return whether or not the point falls on the key. If the key is attached to an edge, it
     * will assume that all points between the key and the edge are considered to be on the key.
     * @see #markAsLeftEdge(Keyboard.Params) etc.
     * @see #markAsLeftEdge(KeyboardParams) etc.
     */
    public boolean isOnKey(int x, int y) {
    public boolean isOnKey(final int x, final int y) {
        return mHitBox.contains(x, y);
    }

@@ -679,7 +682,7 @@ public class Key {
     * @param y the y-coordinate of the point
     * @return the square of the distance of the point from the nearest edge of the key
     */
    public int squaredDistanceToEdge(int x, int y) {
    public int squaredDistanceToEdge(final int x, final int y) {
        final int left = mX;
        final int right = left + mWidth;
        final int top = mY;
@@ -761,15 +764,16 @@ public class Key {
    }

    public static class Spacer extends Key {
        public Spacer(Resources res, Keyboard.Params params, Keyboard.Builder.Row row,
                XmlPullParser parser) throws XmlPullParserException {
        public Spacer(final Resources res, final KeyboardParams params, final KeyboardRow row,
                final XmlPullParser parser) throws XmlPullParserException {
            super(res, params, row, parser);
        }

        /**
         * This constructor is being used only for divider in more keys keyboard.
         */
        protected Spacer(Keyboard.Params params, int x, int y, int width, int height) {
        protected Spacer(final KeyboardParams params, final int x, final int y, final int width,
                final int height) {
            super(params, null, null, ICON_UNDEFINED, CODE_UNSPECIFIED,
                    null, x, y, width, height, 0);
        }
+8 −1114

File changed.

Preview size limit exceeded, changes collapsed.

+27 −40
Original line number Diff line number Diff line
@@ -35,7 +35,9 @@ import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodSubtype;

import com.android.inputmethod.compat.EditorInfoCompatUtils;
import com.android.inputmethod.keyboard.KeyboardLayoutSet.Params.ElementParams;
import com.android.inputmethod.keyboard.internal.KeyboardBuilder;
import com.android.inputmethod.keyboard.internal.KeyboardParams;
import com.android.inputmethod.keyboard.internal.KeysCache;
import com.android.inputmethod.latin.CollectionUtils;
import com.android.inputmethod.latin.InputAttributes;
import com.android.inputmethod.latin.InputTypeUtils;
@@ -78,31 +80,19 @@ public class KeyboardLayoutSet {
    public static class KeyboardLayoutSetException extends RuntimeException {
        public final KeyboardId mKeyboardId;

        public KeyboardLayoutSetException(Throwable cause, KeyboardId keyboardId) {
        public KeyboardLayoutSetException(final Throwable cause, final KeyboardId keyboardId) {
            super(cause);
            mKeyboardId = keyboardId;
        }
    }

    public static class KeysCache {
        private final HashMap<Key, Key> mMap = CollectionUtils.newHashMap();

        public void clear() {
            mMap.clear();
        }

        public Key get(Key key) {
            final Key existingKey = mMap.get(key);
            if (existingKey != null) {
                // Reuse the existing element that equals to "key" without adding "key" to the map.
                return existingKey;
            }
            mMap.put(key, key);
            return key;
        }
    private static class ElementParams {
        int mKeyboardXmlId;
        boolean mProximityCharsCorrectionEnabled;
        public ElementParams() {}
    }

    static class Params {
    private static class Params {
        String mKeyboardLayoutSetName;
        int mMode;
        EditorInfo mEditorInfo;
@@ -118,11 +108,7 @@ public class KeyboardLayoutSet {
        // Sparse array of KeyboardLayoutSet element parameters indexed by element's id.
        final SparseArray<ElementParams> mKeyboardLayoutSetElementIdToParamsMap =
                CollectionUtils.newSparseArray();

        static class ElementParams {
            int mKeyboardXmlId;
            boolean mProximityCharsCorrectionEnabled;
        }
        public Params() {}
    }

    public static void clearKeyboardCache() {
@@ -130,12 +116,12 @@ public class KeyboardLayoutSet {
        sKeysCache.clear();
    }

    private KeyboardLayoutSet(Context context, Params params) {
    KeyboardLayoutSet(final Context context, final Params params) {
        mContext = context;
        mParams = params;
    }

    public Keyboard getKeyboard(int baseKeyboardLayoutSetElementId) {
    public Keyboard getKeyboard(final int baseKeyboardLayoutSetElementId) {
        final int keyboardLayoutSetElementId;
        switch (mParams.mMode) {
        case KeyboardId.MODE_PHONE:
@@ -170,12 +156,12 @@ public class KeyboardLayoutSet {
        }
    }

    private Keyboard getKeyboard(ElementParams elementParams, final KeyboardId id) {
    private Keyboard getKeyboard(final ElementParams elementParams, final KeyboardId id) {
        final SoftReference<Keyboard> ref = sKeyboardCache.get(id);
        Keyboard keyboard = (ref == null) ? null : ref.get();
        if (keyboard == null) {
            final Keyboard.Builder<Keyboard.Params> builder =
                    new Keyboard.Builder<Keyboard.Params>(mContext, new Keyboard.Params());
            final KeyboardBuilder<KeyboardParams> builder =
                    new KeyboardBuilder<KeyboardParams>(mContext, new KeyboardParams());
            if (id.isAlphabetKeyboard()) {
                builder.setAutoGenerate(sKeysCache);
            }
@@ -202,7 +188,7 @@ public class KeyboardLayoutSet {
    // KeyboardLayoutSet element id that is a key in keyboard_set.xml.  Also that file specifies
    // which XML layout should be used for each keyboard.  The KeyboardId is an internal key for
    // Keyboard object.
    private KeyboardId getKeyboardId(int keyboardLayoutSetElementId) {
    private KeyboardId getKeyboardId(final int keyboardLayoutSetElementId) {
        final Params params = mParams;
        final boolean isSymbols = (keyboardLayoutSetElementId == KeyboardId.ELEMENT_SYMBOLS
                || keyboardLayoutSetElementId == KeyboardId.ELEMENT_SYMBOLS_SHIFTED);
@@ -225,7 +211,7 @@ public class KeyboardLayoutSet {

        private static final EditorInfo EMPTY_EDITOR_INFO = new EditorInfo();

        public Builder(Context context, EditorInfo editorInfo) {
        public Builder(final Context context, final EditorInfo editorInfo) {
            mContext = context;
            mPackageName = context.getPackageName();
            mResources = context.getResources();
@@ -238,7 +224,8 @@ public class KeyboardLayoutSet {
                    mPackageName, NO_SETTINGS_KEY, mEditorInfo);
        }

        public Builder setScreenGeometry(int deviceFormFactor, int orientation, int widthPixels) {
        public Builder setScreenGeometry(final int deviceFormFactor, final int orientation,
                final int widthPixels) {
            final Params params = mParams;
            params.mDeviceFormFactor = deviceFormFactor;
            params.mOrientation = orientation;
@@ -246,7 +233,7 @@ public class KeyboardLayoutSet {
            return this;
        }

        public Builder setSubtype(InputMethodSubtype subtype) {
        public Builder setSubtype(final InputMethodSubtype subtype) {
            final boolean asciiCapable = subtype.containsExtraValueKey(ASCII_CAPABLE);
            @SuppressWarnings("deprecation")
            final boolean deprecatedForceAscii = InputAttributes.inPrivateImeOptions(
@@ -263,8 +250,8 @@ public class KeyboardLayoutSet {
            return this;
        }

        public Builder setOptions(boolean voiceKeyEnabled, boolean voiceKeyOnMain,
                boolean languageSwitchKeyEnabled) {
        public Builder setOptions(final boolean voiceKeyEnabled, final boolean voiceKeyOnMain,
                final boolean languageSwitchKeyEnabled) {
            @SuppressWarnings("deprecation")
            final boolean deprecatedNoMicrophone = InputAttributes.inPrivateImeOptions(
                    null, NO_MICROPHONE_COMPAT, mEditorInfo);
@@ -277,7 +264,7 @@ public class KeyboardLayoutSet {
            return this;
        }

        public void setTouchPositionCorrectionEnabled(boolean enabled) {
        public void setTouchPositionCorrectionEnabled(final boolean enabled) {
            mParams.mTouchPositionCorrectionEnabled = enabled;
        }

@@ -298,7 +285,7 @@ public class KeyboardLayoutSet {
            return new KeyboardLayoutSet(mContext, mParams);
        }

        private void parseKeyboardLayoutSet(Resources res, int resId)
        private void parseKeyboardLayoutSet(final Resources res, final int resId)
                throws XmlPullParserException, IOException {
            final XmlResourceParser parser = res.getXml(resId);
            try {
@@ -318,7 +305,7 @@ public class KeyboardLayoutSet {
            }
        }

        private void parseKeyboardLayoutSetContent(XmlPullParser parser)
        private void parseKeyboardLayoutSetContent(final XmlPullParser parser)
                throws XmlPullParserException, IOException {
            int event;
            while ((event = parser.next()) != XmlPullParser.END_DOCUMENT) {
@@ -340,7 +327,7 @@ public class KeyboardLayoutSet {
            }
        }

        private void parseKeyboardLayoutSetElement(XmlPullParser parser)
        private void parseKeyboardLayoutSetElement(final XmlPullParser parser)
                throws XmlPullParserException, IOException {
            final TypedArray a = mResources.obtainAttributes(Xml.asAttributeSet(parser),
                    R.styleable.KeyboardLayoutSet_Element);
@@ -367,7 +354,7 @@ public class KeyboardLayoutSet {
            }
        }

        private static int getKeyboardMode(EditorInfo editorInfo) {
        private static int getKeyboardMode(final EditorInfo editorInfo) {
            if (editorInfo == null)
                return KeyboardId.MODE_TEXT;

+217 −210
Original line number Diff line number Diff line
@@ -20,15 +20,17 @@ import android.graphics.Paint;
import android.graphics.drawable.Drawable;
import android.view.View;

import com.android.inputmethod.keyboard.internal.KeySpecParser.MoreKeySpec;
import com.android.inputmethod.keyboard.internal.KeyboardBuilder;
import com.android.inputmethod.keyboard.internal.KeyboardIconsSet;
import com.android.inputmethod.keyboard.internal.KeyboardParams;
import com.android.inputmethod.keyboard.internal.MoreKeySpec;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.StringUtils;

public class MoreKeysKeyboard extends Keyboard {
    private final int mDefaultKeyCoordX;

    MoreKeysKeyboard(Builder.MoreKeysKeyboardParams params) {
    MoreKeysKeyboard(final MoreKeysKeyboardParams params) {
        super(params);
        mDefaultKeyCoordX = params.getDefaultKeyCoordX() + params.mDefaultKeyWidth / 2;
    }
@@ -37,14 +39,8 @@ public class MoreKeysKeyboard extends Keyboard {
        return mDefaultKeyCoordX;
    }

    public static class Builder extends Keyboard.Builder<Builder.MoreKeysKeyboardParams> {
        private final Key mParentKey;
        private final Drawable mDivider;

        private static final float LABEL_PADDING_RATIO = 0.2f;
        private static final float DIVIDER_RATIO = 0.2f;

        public static class MoreKeysKeyboardParams extends Keyboard.Params {
    /* package for test */
    static class MoreKeysKeyboardParams extends KeyboardParams {
        public boolean mIsFixedOrder;
        /* package */int mTopRowAdjustment;
        public int mNumRows;
@@ -71,9 +67,9 @@ public class MoreKeysKeyboard extends Keyboard {
         * @param isFixedColumnOrder if true, more keys should be laid out in fixed order.
         * @param dividerWidth width of divider, zero for no dividers.
         */
            public void setParameters(int numKeys, int maxColumns, int keyWidth, int rowHeight,
                    int coordXInParent, int parentKeyboardWidth, boolean isFixedColumnOrder,
                    int dividerWidth) {
        public void setParameters(final int numKeys, final int maxColumns, final int keyWidth,
                final int rowHeight, final int coordXInParent, final int parentKeyboardWidth,
                final boolean isFixedColumnOrder, final int dividerWidth) {
            mIsFixedOrder = isFixedColumnOrder;
            if (parentKeyboardWidth / keyWidth < maxColumns) {
                throw new IllegalArgumentException(
@@ -150,11 +146,11 @@ public class MoreKeysKeyboard extends Keyboard {
        }

        // Return key position according to column count (0 is default).
            /* package */int getColumnPos(int n) {
        /* package */int getColumnPos(final int n) {
            return mIsFixedOrder ? getFixedOrderColumnPos(n) : getAutomaticColumnPos(n);
        }

            private int getFixedOrderColumnPos(int n) {
        private int getFixedOrderColumnPos(final int n) {
            final int col = n % mNumColumns;
            final int row = n / mNumColumns;
            if (!isTopRow(row)) {
@@ -174,7 +170,7 @@ public class MoreKeysKeyboard extends Keyboard {
            }
        }

            private int getAutomaticColumnPos(int n) {
        private int getAutomaticColumnPos(final int n) {
            final int col = n % mNumColumns;
            final int row = n / mNumColumns;
            int leftKeys = mLeftKeys;
@@ -211,12 +207,12 @@ public class MoreKeysKeyboard extends Keyboard {
            return pos;
        }

            private static int getTopRowEmptySlots(int numKeys, int numColumns) {
        private static int getTopRowEmptySlots(final int numKeys, final int numColumns) {
            final int remainings = numKeys % numColumns;
            return remainings == 0 ? 0 : numColumns - remainings;
        }

            private int getOptimizedColumns(int numKeys, int maxColumns) {
        private int getOptimizedColumns(final int numKeys, final int maxColumns) {
            int numColumns = Math.min(numKeys, maxColumns);
            while (getTopRowEmptySlots(numKeys, numColumns) >= mNumRows) {
                numColumns--;
@@ -228,7 +224,7 @@ public class MoreKeysKeyboard extends Keyboard {
            return mLeftKeys * mColumnWidth;
        }

            public int getX(int n, int row) {
        public int getX(final int n, final int row) {
            final int x = getColumnPos(n) * mColumnWidth + getDefaultKeyCoordX();
            if (isTopRow(row)) {
                return x + mTopRowAdjustment * (mColumnWidth / 2);
@@ -236,29 +232,38 @@ public class MoreKeysKeyboard extends Keyboard {
            return x;
        }

            public int getY(int row) {
        public int getY(final int row) {
            return (mNumRows - 1 - row) * mDefaultRowHeight + mTopPadding;
        }

            public void markAsEdgeKey(Key key, int row) {
        public void markAsEdgeKey(final Key key, final int row) {
            if (row == 0)
                key.markAsTopEdge(this);
            if (isTopRow(row))
                key.markAsBottomEdge(this);
        }

            private boolean isTopRow(int rowCount) {
        private boolean isTopRow(final int rowCount) {
            return mNumRows > 1 && rowCount == mNumRows - 1;
        }
    }

    public static class Builder extends KeyboardBuilder<MoreKeysKeyboardParams> {
        private final Key mParentKey;
        private final Drawable mDivider;

        private static final float LABEL_PADDING_RATIO = 0.2f;
        private static final float DIVIDER_RATIO = 0.2f;


        /**
         * The builder of MoreKeysKeyboard.
         * @param containerView the container of {@link MoreKeysKeyboardView}.
         * @param parentKey the {@link Key} that invokes more keys keyboard.
         * @param parentKeyboardView the {@link KeyboardView} that contains the parentKey.
         */
        public Builder(View containerView, Key parentKey, KeyboardView parentKeyboardView) {
        public Builder(final View containerView, final Key parentKey,
                final KeyboardView parentKeyboardView) {
            super(containerView.getContext(), new MoreKeysKeyboardParams());
            final Keyboard parentKeyboard = parentKeyboardView.getKeyboard();
            load(parentKeyboard.mMoreKeysTemplate, parentKeyboard.mId);
@@ -300,7 +305,8 @@ public class MoreKeysKeyboard extends Keyboard {
                    dividerWidth);
        }

        private static int getMaxKeyWidth(KeyboardView view, Key parentKey, int minKeyWidth) {
        private static int getMaxKeyWidth(final KeyboardView view, final Key parentKey,
                final int minKeyWidth) {
            final int padding = (int)(view.getResources()
                    .getDimension(R.dimen.more_keys_keyboard_key_horizontal_padding)
                    + (parentKey.hasLabelsInMoreKeys() ? minKeyWidth * LABEL_PADDING_RATIO : 0));
@@ -322,24 +328,6 @@ public class MoreKeysKeyboard extends Keyboard {
            return maxWidth;
        }

        private static class MoreKeyDivider extends Key.Spacer {
            private final Drawable mIcon;

            public MoreKeyDivider(MoreKeysKeyboardParams params, Drawable icon, int x, int y) {
                super(params, x, y, params.mDividerWidth, params.mDefaultRowHeight);
                mIcon = icon;
            }

            @Override
            public Drawable getIcon(KeyboardIconsSet iconSet, int alpha) {
                // KeyboardIconsSet and alpha are unused. Use the icon that has been passed to the
                // constructor.
                // TODO: Drawable itself should have an alpha value.
                mIcon.setAlpha(128);
                return mIcon;
            }
        }

        @Override
        public MoreKeysKeyboard build() {
            final MoreKeysKeyboardParams params = mParams;
@@ -368,4 +356,23 @@ public class MoreKeysKeyboard extends Keyboard {
            return new MoreKeysKeyboard(params);
        }
    }

    private static class MoreKeyDivider extends Key.Spacer {
        private final Drawable mIcon;

        public MoreKeyDivider(final MoreKeysKeyboardParams params, final Drawable icon,
                final int x, final int y) {
            super(params, x, y, params.mDividerWidth, params.mDefaultRowHeight);
            mIcon = icon;
        }

        @Override
        public Drawable getIcon(final KeyboardIconsSet iconSet, final int alpha) {
            // KeyboardIconsSet and alpha are unused. Use the icon that has been passed to the
            // constructor.
            // TODO: Drawable itself should have an alpha value.
            mIcon.setAlpha(128);
            return mIcon;
        }
    }
}
+6 −5
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@ package com.android.inputmethod.keyboard;
import android.graphics.Rect;
import android.text.TextUtils;

import com.android.inputmethod.keyboard.Keyboard.Params.TouchPositionCorrection;
import com.android.inputmethod.keyboard.internal.TouchPositionCorrection;
import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.JniUtils;

@@ -48,9 +48,10 @@ public class ProximityInfo {
    private final Key[][] mGridNeighbors;
    private final String mLocaleStr;

    ProximityInfo(String localeStr, int gridWidth, int gridHeight, int minWidth, int height,
            int mostCommonKeyWidth, int mostCommonKeyHeight, final Key[] keys,
            TouchPositionCorrection touchPositionCorrection) {
    ProximityInfo(final String localeStr, final int gridWidth, final int gridHeight,
            final int minWidth, final int height, final int mostCommonKeyWidth,
            final int mostCommonKeyHeight, final Key[] keys,
            final TouchPositionCorrection touchPositionCorrection) {
        if (TextUtils.isEmpty(localeStr)) {
            mLocaleStr = "";
        } else {
@@ -81,7 +82,7 @@ public class ProximityInfo {
    }

    public static ProximityInfo createSpellCheckerProximityInfo(final int[] proximity,
            int rowSize, int gridWidth, int gridHeight) {
            final int rowSize, final int gridWidth, final int gridHeight) {
        final ProximityInfo spellCheckerProximityInfo = createDummyProximityInfo();
        spellCheckerProximityInfo.mNativeProximityInfo =
                spellCheckerProximityInfo.setProximityInfoNative("",
Loading