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

Commit aa546072 authored by Tadashi G. Takaoka's avatar Tadashi G. Takaoka Committed by Android (Google) Code Review
Browse files

Merge "Support per-Key and per-Keyboard key visual attributes" into jb-mr1-dev

parents 67d0a597 dc34da21
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -49,6 +49,8 @@
        <attr name="keyPopupHintLetterPadding" format="dimension" />
        <!-- Right padding of shifted letter hint to the edge of the key.-->
        <attr name="keyShiftedLetterHintPadding" format="dimension" />
        <!-- Blur radius of key text shadow. -->
        <attr name="keyTextShadowRadius" format="float" />

        <!-- Layout resource for key press feedback.-->
        <attr name="keyPreviewLayout" format="reference" />
@@ -320,7 +322,6 @@
        <!-- Color to use for the label in a key. -->
        <attr name="keyTextColor" format="color" />
        <attr name="keyTextShadowColor" format="color" />
        <attr name="keyTextShadowRadius" format="float" />
        <!-- Color to use for the label in a key when in inactivated state. -->
        <attr name="keyTextInactivatedColor" format="color" />
        <!-- Key hint letter (= one character hint label) color -->
+73 −42
Original line number Diff line number Diff line
@@ -31,8 +31,10 @@ import android.text.TextUtils;
import android.util.Log;
import android.util.Xml;

import com.android.inputmethod.keyboard.internal.KeyDrawParams;
import com.android.inputmethod.keyboard.internal.KeySpecParser;
import com.android.inputmethod.keyboard.internal.KeyStyle;
import com.android.inputmethod.keyboard.internal.KeyVisualAttributes;
import com.android.inputmethod.keyboard.internal.KeyboardIconsSet;
import com.android.inputmethod.keyboard.internal.KeyboardParams;
import com.android.inputmethod.keyboard.internal.KeyboardRow;
@@ -132,6 +134,8 @@ public class Key {
    private static final int ACTION_FLAGS_ALT_CODE_WHILE_TYPING = 0x04;
    private static final int ACTION_FLAGS_ENABLE_LONG_PRESS = 0x08;

    public final KeyVisualAttributes mKeyVisualAttributes;

    private final OptionalAttributes mOptionalAttributes;

    private static class OptionalAttributes {
@@ -202,6 +206,7 @@ public class Key {
        mX = x + params.mHorizontalGap / 2;
        mY = y;
        mHitBox.set(x, y, x + width + 1, y + height);
        mKeyVisualAttributes = null;

        mHashCode = computeHashCode(this);
    }
@@ -357,11 +362,9 @@ public class Key {
                    disabledIconId, previewIconId,
                    visualInsetsLeft, visualInsetsRight);
        }

        mHashCode = computeHashCode(this);

        mKeyVisualAttributes = KeyVisualAttributes.newInstance(keyAttr);
        keyAttr.recycle();

        mHashCode = computeHashCode(this);
        if (hasShiftedLetterHint() && TextUtils.isEmpty(mHintLabel)) {
            Log.w(TAG, "hasShiftedLetterHint specified without keyHintLabel: " + this);
        }
@@ -478,133 +481,161 @@ public class Key {
        return this instanceof Spacer;
    }

    public boolean isShift() {
    public final boolean isShift() {
        return mCode == CODE_SHIFT;
    }

    public boolean isModifier() {
    public final boolean isModifier() {
        return mCode == CODE_SHIFT || mCode == CODE_SWITCH_ALPHA_SYMBOL;
    }

    public boolean isRepeatable() {
    public final boolean isRepeatable() {
        return (mActionFlags & ACTION_FLAGS_IS_REPEATABLE) != 0;
    }

    public boolean noKeyPreview() {
    public final boolean noKeyPreview() {
        return (mActionFlags & ACTION_FLAGS_NO_KEY_PREVIEW) != 0;
    }

    public boolean altCodeWhileTyping() {
    public final boolean altCodeWhileTyping() {
        return (mActionFlags & ACTION_FLAGS_ALT_CODE_WHILE_TYPING) != 0;
    }

    public boolean isLongPressEnabled() {
    public final boolean isLongPressEnabled() {
        // We need not start long press timer on the key which has activated shifted letter.
        return (mActionFlags & ACTION_FLAGS_ENABLE_LONG_PRESS) != 0
                && (mLabelFlags & LABEL_FLAGS_SHIFTED_LETTER_ACTIVATED) == 0;
    }

    public Typeface selectTypeface(final Typeface defaultTypeface) {
    public final Typeface selectTypeface(final KeyDrawParams params) {
        // TODO: Handle "bold" here too?
        if ((mLabelFlags & LABEL_FLAGS_FONT_NORMAL) != 0) {
            return Typeface.DEFAULT;
        } else if ((mLabelFlags & LABEL_FLAGS_FONT_MONO_SPACE) != 0) {
            return Typeface.MONOSPACE;
        } else {
            return defaultTypeface;
            return params.mTypeface;
        }
    }

    public int selectTextSize(final int letterSize, final int largeLetterSize, final int labelSize,
            final int largeLabelSize, final int hintLabelSize) {
    public final int selectTextSize(final KeyDrawParams params) {
        switch (mLabelFlags & LABEL_FLAGS_FOLLOW_KEY_TEXT_RATIO_MASK) {
        case LABEL_FLAGS_FOLLOW_KEY_LETTER_RATIO:
            return letterSize;
            return params.mLetterSize;
        case LABEL_FLAGS_FOLLOW_KEY_LARGE_LETTER_RATIO:
            return largeLetterSize;
            return params.mLargeLetterSize;
        case LABEL_FLAGS_FOLLOW_KEY_LABEL_RATIO:
            return labelSize;
            return params.mLabelSize;
        case LABEL_FLAGS_FOLLOW_KEY_LARGE_LABEL_RATIO:
            return largeLabelSize;
            return params.mLargeLabelSize;
        case LABEL_FLAGS_FOLLOW_KEY_HINT_LABEL_RATIO:
            return hintLabelSize;
            return params.mHintLabelSize;
        default: // No follow key ratio flag specified.
            return StringUtils.codePointCount(mLabel) == 1 ? letterSize : labelSize;
            return StringUtils.codePointCount(mLabel) == 1 ? params.mLetterSize : params.mLabelSize;
        }
    }

    public final int selectTextColor(final KeyDrawParams params) {
        return isShiftedLetterActivated() ? params.mTextInactivatedColor : params.mTextColor;
    }

    public final int selectHintTextSize(final KeyDrawParams params) {
        if (hasHintLabel()) {
            return params.mHintLabelSize;
        } else if (hasShiftedLetterHint()) {
            return params.mShiftedLetterHintSize;
        } else {
            return params.mHintLetterSize;
        }
    }

    public final int selectHintTextColor(final KeyDrawParams params) {
        if (hasHintLabel()) {
            return params.mHintLabelColor;
        } else if (hasShiftedLetterHint()) {
            return isShiftedLetterActivated() ? params.mShiftedLetterHintActivatedColor
                    : params.mShiftedLetterHintInactivatedColor;
        } else {
            return params.mHintLetterColor;
        }
    }

    public final int selectMoreKeyTextSize(final KeyDrawParams params) {
        return hasLabelsInMoreKeys() ? params.mLabelSize : params.mLetterSize;
    }

    public boolean isAlignLeft() {
    public final boolean isAlignLeft() {
        return (mLabelFlags & LABEL_FLAGS_ALIGN_LEFT) != 0;
    }

    public boolean isAlignRight() {
    public final boolean isAlignRight() {
        return (mLabelFlags & LABEL_FLAGS_ALIGN_RIGHT) != 0;
    }

    public boolean isAlignLeftOfCenter() {
    public final boolean isAlignLeftOfCenter() {
        return (mLabelFlags & LABEL_FLAGS_ALIGN_LEFT_OF_CENTER) != 0;
    }

    public boolean hasPopupHint() {
    public final boolean hasPopupHint() {
        return (mLabelFlags & LABEL_FLAGS_HAS_POPUP_HINT) != 0;
    }

    public boolean hasShiftedLetterHint() {
    public final boolean hasShiftedLetterHint() {
        return (mLabelFlags & LABEL_FLAGS_HAS_SHIFTED_LETTER_HINT) != 0;
    }

    public boolean hasHintLabel() {
    public final boolean hasHintLabel() {
        return (mLabelFlags & LABEL_FLAGS_HAS_HINT_LABEL) != 0;
    }

    public boolean hasLabelWithIconLeft() {
    public final boolean hasLabelWithIconLeft() {
        return (mLabelFlags & LABEL_FLAGS_WITH_ICON_LEFT) != 0;
    }

    public boolean hasLabelWithIconRight() {
    public final boolean hasLabelWithIconRight() {
        return (mLabelFlags & LABEL_FLAGS_WITH_ICON_RIGHT) != 0;
    }

    public boolean needsXScale() {
    public final boolean needsXScale() {
        return (mLabelFlags & LABEL_FLAGS_AUTO_X_SCALE) != 0;
    }

    public boolean isShiftedLetterActivated() {
    public final boolean isShiftedLetterActivated() {
        return (mLabelFlags & LABEL_FLAGS_SHIFTED_LETTER_ACTIVATED) != 0;
    }

    public int getMoreKeysColumn() {
    public final int getMoreKeysColumn() {
        return mMoreKeysColumnAndFlags & MORE_KEYS_COLUMN_MASK;
    }

    public boolean isFixedColumnOrderMoreKeys() {
    public final boolean isFixedColumnOrderMoreKeys() {
        return (mMoreKeysColumnAndFlags & MORE_KEYS_FLAGS_FIXED_COLUMN_ORDER) != 0;
    }

    public boolean hasLabelsInMoreKeys() {
    public final boolean hasLabelsInMoreKeys() {
        return (mMoreKeysColumnAndFlags & MORE_KEYS_FLAGS_HAS_LABELS) != 0;
    }

    public int getMoreKeyLabelFlags() {
    public final int getMoreKeyLabelFlags() {
        return hasLabelsInMoreKeys()
                ? LABEL_FLAGS_FOLLOW_KEY_LABEL_RATIO
                : LABEL_FLAGS_FOLLOW_KEY_LETTER_RATIO;
    }

    public boolean needsDividersInMoreKeys() {
    public final boolean needsDividersInMoreKeys() {
        return (mMoreKeysColumnAndFlags & MORE_KEYS_FLAGS_NEEDS_DIVIDERS) != 0;
    }

    public boolean hasEmbeddedMoreKey() {
    public final boolean hasEmbeddedMoreKey() {
        return (mMoreKeysColumnAndFlags & MORE_KEYS_FLAGS_EMBEDDED_MORE_KEY) != 0;
    }

    public String getOutputText() {
    public final String getOutputText() {
        final OptionalAttributes attrs = mOptionalAttributes;
        return (attrs != null) ? attrs.mOutputText : null;
    }

    public int getAltCode() {
    public final int getAltCode() {
        final OptionalAttributes attrs = mOptionalAttributes;
        return (attrs != null) ? attrs.mAltCode : CODE_UNSPECIFIED;
    }
@@ -627,12 +658,12 @@ public class Key {
                ? iconSet.getIconDrawable(previewIconId) : iconSet.getIconDrawable(mIconId);
    }

    public int getDrawX() {
    public final int getDrawX() {
        final OptionalAttributes attrs = mOptionalAttributes;
        return (attrs == null) ? mX : mX + attrs.mVisualInsetsLeft;
    }

    public int getDrawWidth() {
    public final int getDrawWidth() {
        final OptionalAttributes attrs = mOptionalAttributes;
        return (attrs == null) ? mWidth
                : mWidth - attrs.mVisualInsetsLeft - attrs.mVisualInsetsRight;
@@ -656,7 +687,7 @@ public class Key {
        mPressed = false;
    }

    public boolean isEnabled() {
    public final boolean isEnabled() {
        return mEnabled;
    }

@@ -748,7 +779,7 @@ public class Key {
     * @return the drawable state of the key.
     * @see android.graphics.drawable.StateListDrawable#setState(int[])
     */
    public int[] getCurrentDrawableState() {
    public final int[] getCurrentDrawableState() {
        switch (mBackgroundType) {
        case BACKGROUND_TYPE_FUNCTIONAL:
            return mPressed ? KEY_STATE_FUNCTIONAL_PRESSED : KEY_STATE_FUNCTIONAL_NORMAL;
+3 −13
Original line number Diff line number Diff line
@@ -16,10 +16,10 @@

package com.android.inputmethod.keyboard;

import android.graphics.Typeface;
import android.util.Log;
import android.util.SparseArray;

import com.android.inputmethod.keyboard.internal.KeyVisualAttributes;
import com.android.inputmethod.keyboard.internal.KeyboardIconsSet;
import com.android.inputmethod.keyboard.internal.KeyboardParams;
import com.android.inputmethod.latin.CollectionUtils;
@@ -97,11 +97,7 @@ public class Keyboard {
    public final int mVerticalGap;

    /** Per keyboard key visual parameters */
    public final Typeface mKeyTypeface;
    public final float mKeyLetterRatio;
    public final int mKeyLetterSize;
    public final float mKeyHintLetterRatio;
    public final float mKeyShiftedLetterHintRatio;
    public final KeyVisualAttributes mKeyVisualAttributes;

    public final int mMostCommonKeyHeight;
    public final int mMostCommonKeyWidth;
@@ -132,13 +128,7 @@ public class Keyboard {
        mMostCommonKeyWidth = params.mMostCommonKeyWidth;
        mMoreKeysTemplate = params.mMoreKeysTemplate;
        mMaxMoreKeysKeyboardColumn = params.mMaxMoreKeysKeyboardColumn;

        mKeyTypeface = params.mKeyTypeface;
        mKeyLetterRatio = params.mKeyLetterRatio;
        mKeyLetterSize = params.mKeyLetterSize;
        mKeyHintLetterRatio = params.mKeyHintLetterRatio;
        mKeyShiftedLetterHintRatio = params.mKeyShiftedLetterHintRatio;

        mKeyVisualAttributes = params.mKeyVisualAttributes;
        mTopPadding = params.mTopPadding;
        mVerticalGap = params.mVerticalGap;

+122 −93

File changed.

Preview size limit exceeded, changes collapsed.

+58 −40
Original line number Diff line number Diff line
@@ -63,9 +63,25 @@ import java.util.WeakHashMap;
/**
 * A view that is responsible for detecting key presses and touch movements.
 *
 * @attr ref R.styleable#KeyboardView_keyHysteresisDistance
 * @attr ref R.styleable#KeyboardView_verticalCorrection
 * @attr ref R.styleable#KeyboardView_popupLayout
 * @attr ref R.styleable#MainKeyboardView_autoCorrectionSpacebarLedEnabled
 * @attr ref R.styleable#MainKeyboardView_autoCorrectionSpacebarLedIcon
 * @attr ref R.styleable#MainKeyboardView_spacebarTextRatio
 * @attr ref R.styleable#MainKeyboardView_spacebarTextColor
 * @attr ref R.styleable#MainKeyboardView_spacebarTextShadowColor
 * @attr ref R.styleable#MainKeyboardView_languageOnSpacebarFinalAlpha
 * @attr ref R.styleable#MainKeyboardView_languageOnSpacebarFadeoutAnimator
 * @attr ref R.styleable#MainKeyboardView_altCodeKeyWhileTypingFadeoutAnimator
 * @attr ref R.styleable#MainKeyboardView_altCodeKeyWhileTypingFadeinAnimator
 * @attr ref R.styleable#MainKeyboardView_keyHysteresisDistance
 * @attr ref R.styleable#MainKeyboardView_touchNoiseThresholdTime
 * @attr ref R.styleable#MainKeyboardView_touchNoiseThresholdDistance
 * @attr ref R.styleable#MainKeyboardView_slidingKeyInputEnable
 * @attr ref R.styleable#MainKeyboardView_keyRepeatStartTimeout
 * @attr ref R.styleable#MainKeyboardView_keyRepeatInterval
 * @attr ref R.styleable#MainKeyboardView_longPressKeyTimeout
 * @attr ref R.styleable#MainKeyboardView_longPressShiftKeyTimeout
 * @attr ref R.styleable#MainKeyboardView_ignoreAltCodeKeyTimeout
 * @attr ref R.styleable#MainKeyboardView_showMoreKeysKeyboardAtTouchPoint
 */
public class MainKeyboardView extends KeyboardView implements PointerTracker.KeyEventHandler,
        SuddenJumpingTouchEventHandler.ProcessMotionEvent {
@@ -150,7 +166,7 @@ public class MainKeyboardView extends KeyboardView implements PointerTracker.Key
        }

        @Override
        public void handleMessage(Message msg) {
        public void handleMessage(final Message msg) {
            final MainKeyboardView keyboardView = getOuterInstance();
            final PointerTracker tracker = (PointerTracker) msg.obj;
            switch (msg.what) {
@@ -174,14 +190,14 @@ public class MainKeyboardView extends KeyboardView implements PointerTracker.Key
            }
        }

        private void startKeyRepeatTimer(PointerTracker tracker, long delay) {
        private void startKeyRepeatTimer(final PointerTracker tracker, final long delay) {
            final Key key = tracker.getKey();
            if (key == null) return;
            sendMessageDelayed(obtainMessage(MSG_REPEAT_KEY, key.mCode, 0, tracker), delay);
        }

        @Override
        public void startKeyRepeatTimer(PointerTracker tracker) {
        public void startKeyRepeatTimer(final PointerTracker tracker) {
            startKeyRepeatTimer(tracker, mKeyRepeatStartTimeout);
        }

@@ -195,7 +211,7 @@ public class MainKeyboardView extends KeyboardView implements PointerTracker.Key
        }

        @Override
        public void startLongPressTimer(int code) {
        public void startLongPressTimer(final int code) {
            cancelLongPressTimer();
            final int delay;
            switch (code) {
@@ -212,7 +228,7 @@ public class MainKeyboardView extends KeyboardView implements PointerTracker.Key
        }

        @Override
        public void startLongPressTimer(PointerTracker tracker) {
        public void startLongPressTimer(final PointerTracker tracker) {
            cancelLongPressTimer();
            if (tracker == null) {
                return;
@@ -266,7 +282,7 @@ public class MainKeyboardView extends KeyboardView implements PointerTracker.Key
        }

        @Override
        public void startTypingStateTimer(Key typedKey) {
        public void startTypingStateTimer(final Key typedKey) {
            if (typedKey.isModifier() || typedKey.altCodeWhileTyping()) {
                return;
            }
@@ -322,11 +338,11 @@ public class MainKeyboardView extends KeyboardView implements PointerTracker.Key
        }
    }

    public MainKeyboardView(Context context, AttributeSet attrs) {
    public MainKeyboardView(final Context context, final AttributeSet attrs) {
        this(context, attrs, R.attr.mainKeyboardViewStyle);
    }

    public MainKeyboardView(Context context, AttributeSet attrs, int defStyle) {
    public MainKeyboardView(final Context context, final AttributeSet attrs, final int defStyle) {
        super(context, attrs, defStyle);

        mTouchScreenRegulator = new SuddenJumpingTouchEventHandler(getContext(), this);
@@ -377,7 +393,7 @@ public class MainKeyboardView extends KeyboardView implements PointerTracker.Key
                altCodeKeyWhileTypingFadeinAnimatorResId, this);
    }

    private ObjectAnimator loadObjectAnimator(int resId, Object target) {
    private ObjectAnimator loadObjectAnimator(final int resId, final Object target) {
        if (resId == 0) return null;
        final ObjectAnimator animator = (ObjectAnimator)AnimatorInflater.loadAnimator(
                getContext(), resId);
@@ -392,7 +408,7 @@ public class MainKeyboardView extends KeyboardView implements PointerTracker.Key
        return mLanguageOnSpacebarAnimAlpha;
    }

    public void setLanguageOnSpacebarAnimAlpha(int alpha) {
    public void setLanguageOnSpacebarAnimAlpha(final int alpha) {
        mLanguageOnSpacebarAnimAlpha = alpha;
        invalidateKey(mSpaceKey);
    }
@@ -401,12 +417,12 @@ public class MainKeyboardView extends KeyboardView implements PointerTracker.Key
        return mAltCodeKeyWhileTypingAnimAlpha;
    }

    public void setAltCodeKeyWhileTypingAnimAlpha(int alpha) {
    public void setAltCodeKeyWhileTypingAnimAlpha(final int alpha) {
        mAltCodeKeyWhileTypingAnimAlpha = alpha;
        updateAltCodeKeyWhileTyping();
    }

    public void setKeyboardActionListener(KeyboardActionListener listener) {
    public void setKeyboardActionListener(final KeyboardActionListener listener) {
        mKeyboardActionListener = listener;
        PointerTracker.setKeyboardActionListener(listener);
    }
@@ -443,7 +459,7 @@ public class MainKeyboardView extends KeyboardView implements PointerTracker.Key
     * @param keyboard the keyboard to display in this view
     */
    @Override
    public void setKeyboard(Keyboard keyboard) {
    public void setKeyboard(final Keyboard keyboard) {
        // Remove any pending messages, except dismissing preview and key repeat.
        mKeyTimerHandler.cancelLongPressTimer();
        super.setKeyboard(keyboard);
@@ -468,11 +484,11 @@ public class MainKeyboardView extends KeyboardView implements PointerTracker.Key
    }

    // Note that this method is called from a non-UI thread.
    public void setMainDictionaryAvailability(boolean mainDictionaryAvailable) {
    public void setMainDictionaryAvailability(final boolean mainDictionaryAvailable) {
        PointerTracker.setMainDictionaryAvailability(mainDictionaryAvailable);
    }

    public void setGestureHandlingEnabledByUser(boolean gestureHandlingEnabledByUser) {
    public void setGestureHandlingEnabledByUser(final boolean gestureHandlingEnabledByUser) {
        PointerTracker.setGestureHandlingEnabledByUser(gestureHandlingEnabledByUser);
    }

@@ -484,7 +500,7 @@ public class MainKeyboardView extends KeyboardView implements PointerTracker.Key
        return mHasDistinctMultitouch;
    }

    public void setDistinctMultitouch(boolean hasDistinctMultitouch) {
    public void setDistinctMultitouch(final boolean hasDistinctMultitouch) {
        mHasDistinctMultitouch = hasDistinctMultitouch;
    }

@@ -515,7 +531,8 @@ public class MainKeyboardView extends KeyboardView implements PointerTracker.Key
        super.cancelAllMessages();
    }

    private boolean openMoreKeysKeyboardIfRequired(Key parentKey, PointerTracker tracker) {
    private boolean openMoreKeysKeyboardIfRequired(final Key parentKey,
            final PointerTracker tracker) {
        // Check if we have a popup layout specified first.
        if (mMoreKeysLayout == 0) {
            return false;
@@ -530,7 +547,7 @@ public class MainKeyboardView extends KeyboardView implements PointerTracker.Key
    }

    // This default implementation returns a more keys panel.
    protected MoreKeysPanel onCreateMoreKeysPanel(Key parentKey) {
    protected MoreKeysPanel onCreateMoreKeysPanel(final Key parentKey) {
        if (parentKey.mMoreKeys == null)
            return null;

@@ -556,7 +573,7 @@ public class MainKeyboardView extends KeyboardView implements PointerTracker.Key
     * @return true if the long press is handled, false otherwise. Subclasses should call the
     * method on the base class if the subclass doesn't wish to handle the call.
     */
    protected boolean onLongPress(Key parentKey, PointerTracker tracker) {
    protected boolean onLongPress(final Key parentKey, final PointerTracker tracker) {
        if (ProductionFlag.IS_EXPERIMENTAL) {
            ResearchLogger.mainKeyboardView_onLongPress();
        }
@@ -580,20 +597,20 @@ public class MainKeyboardView extends KeyboardView implements PointerTracker.Key
        return openMoreKeysPanel(parentKey, tracker);
    }

    private boolean invokeCustomRequest(int code) {
    private boolean invokeCustomRequest(final int code) {
        return mKeyboardActionListener.onCustomRequest(code);
    }

    private void invokeCodeInput(int primaryCode) {
    private void invokeCodeInput(final int primaryCode) {
        mKeyboardActionListener.onCodeInput(
                primaryCode, Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE);
    }

    private void invokeReleaseKey(int primaryCode) {
    private void invokeReleaseKey(final int primaryCode) {
        mKeyboardActionListener.onReleaseKey(primaryCode, false);
    }

    private boolean openMoreKeysPanel(Key parentKey, PointerTracker tracker) {
    private boolean openMoreKeysPanel(final Key parentKey, final PointerTracker tracker) {
        MoreKeysPanel moreKeysPanel = mMoreKeysPanelCache.get(parentKey);
        if (moreKeysPanel == null) {
            moreKeysPanel = onCreateMoreKeysPanel(parentKey);
@@ -644,7 +661,7 @@ public class MainKeyboardView extends KeyboardView implements PointerTracker.Key
    }

    @Override
    public boolean onTouchEvent(MotionEvent me) {
    public boolean onTouchEvent(final MotionEvent me) {
        if (getKeyboard() == null) {
            return false;
        }
@@ -652,7 +669,7 @@ public class MainKeyboardView extends KeyboardView implements PointerTracker.Key
    }

    @Override
    public boolean processMotionEvent(MotionEvent me) {
    public boolean processMotionEvent(final MotionEvent me) {
        final boolean nonDistinctMultitouch = !mHasDistinctMultitouch;
        final int action = me.getActionMasked();
        final int pointerCount = me.getPointerCount();
@@ -819,7 +836,7 @@ public class MainKeyboardView extends KeyboardView implements PointerTracker.Key
     *         otherwise
     */
    @Override
    public boolean dispatchHoverEvent(MotionEvent event) {
    public boolean dispatchHoverEvent(final MotionEvent event) {
        if (AccessibilityUtils.getInstance().isTouchExplorationEnabled()) {
            final PointerTracker tracker = PointerTracker.getPointerTracker(0, this);
            return AccessibleKeyboardViewProxy.getInstance().dispatchHoverEvent(event, tracker);
@@ -829,7 +846,7 @@ public class MainKeyboardView extends KeyboardView implements PointerTracker.Key
        return false;
    }

    public void updateShortcutKey(boolean available) {
    public void updateShortcutKey(final boolean available) {
        final Keyboard keyboard = getKeyboard();
        if (keyboard == null) return;
        final Key shortcutKey = keyboard.getKey(Keyboard.CODE_SHORTCUT);
@@ -846,8 +863,8 @@ public class MainKeyboardView extends KeyboardView implements PointerTracker.Key
        }
    }

    public void startDisplayLanguageOnSpacebar(boolean subtypeChanged,
            boolean needsToDisplayLanguage, boolean hasMultipleEnabledIMEsOrSubtypes) {
    public void startDisplayLanguageOnSpacebar(final boolean subtypeChanged,
            final boolean needsToDisplayLanguage, final boolean hasMultipleEnabledIMEsOrSubtypes) {
        mNeedsToDisplayLanguage = needsToDisplayLanguage;
        mHasMultipleEnabledIMEsOrSubtypes = hasMultipleEnabledIMEsOrSubtypes;
        final ObjectAnimator animator = mLanguageOnSpacebarFadeoutAnimator;
@@ -869,14 +886,15 @@ public class MainKeyboardView extends KeyboardView implements PointerTracker.Key
        invalidateKey(mSpaceKey);
    }

    public void updateAutoCorrectionState(boolean isAutoCorrection) {
    public void updateAutoCorrectionState(final boolean isAutoCorrection) {
        if (!mAutoCorrectionSpacebarLedEnabled) return;
        mAutoCorrectionSpacebarLedOn = isAutoCorrection;
        invalidateKey(mSpaceKey);
    }

    @Override
    protected void onDrawKeyTopVisuals(Key key, Canvas canvas, Paint paint, KeyDrawParams params) {
    protected void onDrawKeyTopVisuals(final Key key, final Canvas canvas, final Paint paint,
            final KeyDrawParams params) {
        if (key.altCodeWhileTyping() && key.isEnabled()) {
            params.mAnimAlpha = mAltCodeKeyWhileTypingAnimAlpha;
        }
@@ -894,7 +912,7 @@ public class MainKeyboardView extends KeyboardView implements PointerTracker.Key
        }
    }

    private boolean fitsTextIntoWidth(final int width, String text, Paint paint) {
    private boolean fitsTextIntoWidth(final int width, final String text, final Paint paint) {
        paint.setTextScaleX(1.0f);
        final float textWidth = getLabelWidth(text, paint);
        if (textWidth < width) return true;
@@ -907,7 +925,7 @@ public class MainKeyboardView extends KeyboardView implements PointerTracker.Key
    }

    // Layout language name on spacebar.
    private String layoutLanguageOnSpacebar(Paint paint, InputMethodSubtype subtype,
    private String layoutLanguageOnSpacebar(final Paint paint, final InputMethodSubtype subtype,
            final int width) {
        // Choose appropriate language name to fit into the width.
        String text = getFullDisplayName(subtype, getResources());
@@ -928,7 +946,7 @@ public class MainKeyboardView extends KeyboardView implements PointerTracker.Key
        return "";
    }

    private void drawSpacebar(Key key, Canvas canvas, Paint paint) {
    private void drawSpacebar(final Key key, final Canvas canvas, final Paint paint) {
        final int width = key.mWidth;
        final int height = key.mHeight;

@@ -983,7 +1001,7 @@ public class MainKeyboardView extends KeyboardView implements PointerTracker.Key
    //  zz    azerty T      AZERTY    AZERTY

    // Get InputMethodSubtype's full display name in its locale.
    static String getFullDisplayName(InputMethodSubtype subtype, Resources res) {
    static String getFullDisplayName(final InputMethodSubtype subtype, final Resources res) {
        if (SubtypeLocale.isNoLanguage(subtype)) {
            return SubtypeLocale.getKeyboardLayoutSetDisplayName(subtype);
        }
@@ -992,7 +1010,7 @@ public class MainKeyboardView extends KeyboardView implements PointerTracker.Key
    }

    // Get InputMethodSubtype's short display name in its locale.
    static String getShortDisplayName(InputMethodSubtype subtype) {
    static String getShortDisplayName(final InputMethodSubtype subtype) {
        if (SubtypeLocale.isNoLanguage(subtype)) {
            return "";
        }
@@ -1001,7 +1019,7 @@ public class MainKeyboardView extends KeyboardView implements PointerTracker.Key
    }

    // Get InputMethodSubtype's middle display name in its locale.
    static String getMiddleDisplayName(InputMethodSubtype subtype) {
    static String getMiddleDisplayName(final InputMethodSubtype subtype) {
        if (SubtypeLocale.isNoLanguage(subtype)) {
            return SubtypeLocale.getKeyboardLayoutSetDisplayName(subtype);
        }
Loading