diff options
Diffstat (limited to 'java/src/com/android/inputmethod/latin/LatinKeyboard.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/LatinKeyboard.java | 379 |
1 files changed, 144 insertions, 235 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboard.java b/java/src/com/android/inputmethod/latin/LatinKeyboard.java index 45a4a9508..15a8cf768 100644 --- a/java/src/com/android/inputmethod/latin/LatinKeyboard.java +++ b/java/src/com/android/inputmethod/latin/LatinKeyboard.java @@ -30,16 +30,16 @@ import android.graphics.PorterDuff; import android.graphics.Rect; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; -import android.inputmethodservice.Keyboard; import android.text.TextPaint; import android.util.Log; import android.view.ViewConfiguration; import android.view.inputmethod.EditorInfo; +import java.util.HashMap; import java.util.List; import java.util.Locale; -public class LatinKeyboard extends Keyboard { +public class LatinKeyboard extends BaseKeyboard { private static final boolean DEBUG_PREFERRED_LETTER = false; private static final String TAG = "LatinKeyboard"; @@ -48,7 +48,7 @@ public class LatinKeyboard extends Keyboard { private Drawable mShiftLockIcon; private Drawable mShiftLockPreviewIcon; - private Drawable mOldShiftIcon; + private final HashMap<Key, Drawable> mOldShiftIcons = new HashMap<Key, Drawable>(); private Drawable mSpaceIcon; private Drawable mSpaceAutoCompletionIndicator; private Drawable mSpacePreviewIcon; @@ -58,15 +58,11 @@ public class LatinKeyboard extends Keyboard { private Drawable m123MicPreviewIcon; private final Drawable mButtonArrowLeftIcon; private final Drawable mButtonArrowRightIcon; - private Key mShiftKey; private Key mEnterKey; private Key mF1Key; private final Drawable mHintIcon; private Key mSpaceKey; private Key m123Key; - private final int NUMBER_HINT_COUNT = 10; - private Key[] mNumberHintKeys; - private Drawable[] mNumberHintIcons = new Drawable[NUMBER_HINT_COUNT]; private int mSpaceKeyIndex = -1; private int mSpaceDragStartX; private int mSpaceDragLastDiff; @@ -74,7 +70,7 @@ public class LatinKeyboard extends Keyboard { private LanguageSwitcher mLanguageSwitcher; private final Resources mRes; private final Context mContext; - private int mMode; + private int mMode; // TODO: remove this and use the corresponding mode in the parent class // Whether this keyboard has voice icon on it private boolean mHasVoiceButton; // Whether voice icon is enabled at all @@ -89,13 +85,15 @@ public class LatinKeyboard extends Keyboard { private int mPrefLetterY; private int mPrefDistance; + // Default Enter key attributes + private final Drawable mDefaultEnterIcon; + private final Drawable mDefaultEnterPreview; + private final CharSequence mDefaultEnterLabel; + private final CharSequence mDefaultEnterText; + // TODO: generalize for any keyboardId private boolean mIsBlackSym; - // TODO: remove this attribute when either Keyboard.mDefaultVerticalGap or Key.parent becomes - // non-private. - private final int mVerticalGap; - private static final int SHIFT_OFF = 0; private static final int SHIFT_ON = 1; private static final int SHIFT_LOCKED = 2; @@ -123,8 +121,8 @@ public class LatinKeyboard extends Keyboard { super(context, xmlLayoutResId, mode); final Resources res = context.getResources(); mContext = context; - mMode = mode; mRes = res; + mMode = mode; mShiftLockIcon = res.getDrawable(R.drawable.sym_keyboard_shift_locked); mShiftLockPreviewIcon = res.getDrawable(R.drawable.sym_keyboard_feedback_shift_locked); setDefaultBounds(mShiftLockPreviewIcon); @@ -145,23 +143,16 @@ public class LatinKeyboard extends Keyboard { mIsAlphaKeyboard = xmlLayoutResId == R.xml.kbd_qwerty || xmlLayoutResId == R.xml.kbd_qwerty_black; mSpaceKeyIndex = indexOf(LatinIME.KEYCODE_SPACE); - initializeNumberHintResources(context); - // TODO remove this initialization after cleanup - mVerticalGap = super.getVerticalGap(); - } - private void initializeNumberHintResources(Context context) { - final Resources res = context.getResources(); - mNumberHintIcons[0] = res.getDrawable(R.drawable.keyboard_hint_0); - mNumberHintIcons[1] = res.getDrawable(R.drawable.keyboard_hint_1); - mNumberHintIcons[2] = res.getDrawable(R.drawable.keyboard_hint_2); - mNumberHintIcons[3] = res.getDrawable(R.drawable.keyboard_hint_3); - mNumberHintIcons[4] = res.getDrawable(R.drawable.keyboard_hint_4); - mNumberHintIcons[5] = res.getDrawable(R.drawable.keyboard_hint_5); - mNumberHintIcons[6] = res.getDrawable(R.drawable.keyboard_hint_6); - mNumberHintIcons[7] = res.getDrawable(R.drawable.keyboard_hint_7); - mNumberHintIcons[8] = res.getDrawable(R.drawable.keyboard_hint_8); - mNumberHintIcons[9] = res.getDrawable(R.drawable.keyboard_hint_9); + if (mEnterKey != null) { + mDefaultEnterIcon = mEnterKey.icon; + mDefaultEnterPreview = mEnterKey.iconPreview; + mDefaultEnterLabel = mEnterKey.label; + mDefaultEnterText = mEnterKey.text; + } else { + mDefaultEnterIcon = mDefaultEnterPreview = null; + mDefaultEnterLabel = mDefaultEnterText = null; + } } @Override @@ -184,170 +175,140 @@ public class LatinKeyboard extends Keyboard { break; } - // For number hints on the upper-right corner of key - if (mNumberHintKeys == null) { - // NOTE: This protected method is being called from the base class constructor before - // mNumberHintKeys gets initialized. - mNumberHintKeys = new Key[NUMBER_HINT_COUNT]; - } - int hintNumber = -1; - if (LatinKeyboardBaseView.isNumberAtLeftmostPopupChar(key)) { - hintNumber = key.popupCharacters.charAt(0) - '0'; - } else if (LatinKeyboardBaseView.isNumberAtRightmostPopupChar(key)) { - hintNumber = key.popupCharacters.charAt(key.popupCharacters.length() - 1) - '0'; - } - if (hintNumber >= 0 && hintNumber <= 9) { - mNumberHintKeys[hintNumber] = key; - } - return key; } - void setImeOptions(Resources res, int mode, int options) { + private static void resetKeyAttributes(Key key, CharSequence label) { + key.popupCharacters = null; + key.popupResId = 0; + key.text = null; + key.iconPreview = null; + key.icon = null; + key.hintIcon = null; + key.label = label; + } + + public void setImeOptions(Resources res, int mode, int options) { mMode = mode; - // TODO should clean up this method - if (mEnterKey != null) { - // Reset some of the rarely used attributes. - mEnterKey.popupCharacters = null; - mEnterKey.popupResId = 0; - mEnterKey.text = null; - switch (options&(EditorInfo.IME_MASK_ACTION|EditorInfo.IME_FLAG_NO_ENTER_ACTION)) { - case EditorInfo.IME_ACTION_GO: - mEnterKey.iconPreview = null; - mEnterKey.icon = null; - mEnterKey.label = res.getText(R.string.label_go_key); - break; - case EditorInfo.IME_ACTION_NEXT: - mEnterKey.iconPreview = null; - mEnterKey.icon = null; - mEnterKey.label = res.getText(R.string.label_next_key); - break; - case EditorInfo.IME_ACTION_DONE: - mEnterKey.iconPreview = null; - mEnterKey.icon = null; - mEnterKey.label = res.getText(R.string.label_done_key); - break; - case EditorInfo.IME_ACTION_SEARCH: - mEnterKey.iconPreview = res.getDrawable( - R.drawable.sym_keyboard_feedback_search); - mEnterKey.icon = res.getDrawable(mIsBlackSym ? - R.drawable.sym_bkeyboard_search : R.drawable.sym_keyboard_search); - mEnterKey.label = null; - break; - case EditorInfo.IME_ACTION_SEND: - mEnterKey.iconPreview = null; - mEnterKey.icon = null; - mEnterKey.label = res.getText(R.string.label_send_key); - break; - default: - if (mode == KeyboardSwitcher.MODE_IM) { - mEnterKey.icon = mHintIcon; - mEnterKey.iconPreview = null; - mEnterKey.label = ":-)"; - mEnterKey.text = ":-) "; - mEnterKey.popupResId = R.xml.popup_smileys; - } else { - mEnterKey.iconPreview = res.getDrawable( - R.drawable.sym_keyboard_feedback_return); - mEnterKey.icon = res.getDrawable(mIsBlackSym ? - R.drawable.sym_bkeyboard_return : R.drawable.sym_keyboard_return); - mEnterKey.label = null; - } - break; - } - // Set the initial size of the preview icon - if (mEnterKey.iconPreview != null) { - setDefaultBounds(mEnterKey.iconPreview); + if (mEnterKey == null) + return; + final boolean configDynamicKeyTopEnterKey = res.getBoolean( + R.bool.config_dynamic_key_top_enter_key); + if (configDynamicKeyTopEnterKey) { + switch (options & (EditorInfo.IME_MASK_ACTION | EditorInfo.IME_FLAG_NO_ENTER_ACTION)) { + case EditorInfo.IME_ACTION_GO: + resetKeyAttributes(mEnterKey, res.getText(R.string.label_go_key)); + break; + case EditorInfo.IME_ACTION_NEXT: + resetKeyAttributes(mEnterKey, res.getText(R.string.label_next_key)); + break; + case EditorInfo.IME_ACTION_DONE: + resetKeyAttributes(mEnterKey, res.getText(R.string.label_done_key)); + break; + case EditorInfo.IME_ACTION_SEARCH: + resetKeyAttributes(mEnterKey, null); + mEnterKey.iconPreview = res.getDrawable(R.drawable.sym_keyboard_feedback_search); + mEnterKey.icon = res.getDrawable(mIsBlackSym ? R.drawable.sym_bkeyboard_search + : R.drawable.sym_keyboard_search); + break; + case EditorInfo.IME_ACTION_SEND: + resetKeyAttributes(mEnterKey, res.getText(R.string.label_send_key)); + break; + default: + resetKeyAttributes(mEnterKey, mDefaultEnterLabel); + mEnterKey.text = mDefaultEnterText; + mEnterKey.icon = mDefaultEnterIcon; + mEnterKey.iconPreview = mDefaultEnterPreview; + break; } } + // Set the initial size of the preview icon + setDefaultBounds(mEnterKey.iconPreview); } - - void enableShiftLock() { - int index = getShiftKeyIndex(); - if (index >= 0) { - mShiftKey = getKeys().get(index); - if (mShiftKey instanceof LatinKey) { - ((LatinKey)mShiftKey).enableShiftLock(); + + public void enableShiftLock() { + for (final Key key : getShiftKeys()) { + if (key instanceof LatinKey) { + ((LatinKey)key).enableShiftLock(); } - mOldShiftIcon = mShiftKey.icon; + mOldShiftIcons.put(key, key.icon); } } - void setShiftLocked(boolean shiftLocked) { - if (mShiftKey != null) { - if (shiftLocked) { - mShiftKey.on = true; - mShiftKey.icon = mShiftLockIcon; - mShiftState = SHIFT_LOCKED; - } else { - mShiftKey.on = false; - mShiftKey.icon = mShiftLockIcon; - mShiftState = SHIFT_ON; - } + public void setShiftLocked(boolean shiftLocked) { + // TODO: cleanup this method with BaseKeyboard.Key + for (final Key key : getShiftKeys()) { + key.on = shiftLocked; + key.icon = mShiftLockIcon; } + mShiftState = shiftLocked ? SHIFT_LOCKED : SHIFT_ON; } - boolean isShiftLocked() { + public boolean isShiftLocked() { return mShiftState == SHIFT_LOCKED; } - + @Override public boolean setShifted(boolean shiftState) { + // TODO: cleanup this method with BaseKeyboard.Key. boolean shiftChanged = false; - if (mShiftKey != null) { + if (getShiftKeys().size() > 0) { + for (final Key key : getShiftKeys()) { + if (shiftState == false) { + key.on = false; + key.icon = mOldShiftIcons.get(key); + } else if (mShiftState == SHIFT_OFF) { + key.icon = mShiftLockIcon; + } + } if (shiftState == false) { shiftChanged = mShiftState != SHIFT_OFF; mShiftState = SHIFT_OFF; - mShiftKey.on = false; - mShiftKey.icon = mOldShiftIcon; - } else { - if (mShiftState == SHIFT_OFF) { - shiftChanged = mShiftState == SHIFT_OFF; - mShiftState = SHIFT_ON; - mShiftKey.icon = mShiftLockIcon; - } + } else if (mShiftState == SHIFT_OFF) { + shiftChanged = mShiftState == SHIFT_OFF; + mShiftState = SHIFT_ON; } + return shiftChanged; } else { return super.setShifted(shiftState); } - return shiftChanged; } @Override public boolean isShifted() { - if (mShiftKey != null) { + if (getShiftKeys().size() > 0) { return mShiftState != SHIFT_OFF; } else { return super.isShifted(); } } - /* package */ boolean isAlphaKeyboard() { + public boolean isTemporaryUpperCase() { + return mIsAlphaKeyboard && isShifted() && !isShiftLocked(); + } + + public boolean isAlphaKeyboard() { return mIsAlphaKeyboard; } public void setColorOfSymbolIcons(boolean isAutoCompletion, boolean isBlack) { mIsBlackSym = isBlack; + final Resources res = mRes; if (isBlack) { - mShiftLockIcon = mRes.getDrawable(R.drawable.sym_bkeyboard_shift_locked); - mSpaceIcon = mRes.getDrawable(R.drawable.sym_bkeyboard_space); - mMicIcon = mRes.getDrawable(R.drawable.sym_bkeyboard_mic); - m123MicIcon = mRes.getDrawable(R.drawable.sym_bkeyboard_123_mic); + mShiftLockIcon = res.getDrawable(R.drawable.sym_bkeyboard_shift_locked); + mSpaceIcon = res.getDrawable(R.drawable.sym_bkeyboard_space); + mMicIcon = res.getDrawable(R.drawable.sym_bkeyboard_mic); + m123MicIcon = res.getDrawable(R.drawable.sym_bkeyboard_123_mic); } else { - mShiftLockIcon = mRes.getDrawable(R.drawable.sym_keyboard_shift_locked); - mSpaceIcon = mRes.getDrawable(R.drawable.sym_keyboard_space); - mMicIcon = mRes.getDrawable(R.drawable.sym_keyboard_mic); - m123MicIcon = mRes.getDrawable(R.drawable.sym_keyboard_123_mic); + mShiftLockIcon = res.getDrawable(R.drawable.sym_keyboard_shift_locked); + mSpaceIcon = res.getDrawable(R.drawable.sym_keyboard_space); + mMicIcon = res.getDrawable(R.drawable.sym_keyboard_mic); + m123MicIcon = res.getDrawable(R.drawable.sym_keyboard_123_mic); } updateDynamicKeys(); if (mSpaceKey != null) { updateSpaceBarForLocale(isAutoCompletion, isBlack); } - updateNumberHintKeys(); - } - - private void setDefaultBounds(Drawable drawable) { - drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight()); } public void setVoiceMode(boolean hasVoiceButton, boolean hasVoice) { @@ -362,9 +323,11 @@ public class LatinKeyboard extends Keyboard { } private void update123Key() { + final boolean configDynamicKeyTopSymbolKey = mRes.getBoolean( + R.bool.config_dynamic_key_top_symbol_key); // Update KEYCODE_MODE_CHANGE key only on alphabet mode, not on symbol mode. if (m123Key != null && mIsAlphaKeyboard) { - if (mVoiceEnabled && !mHasVoiceButton) { + if (configDynamicKeyTopSymbolKey && mVoiceEnabled && !mHasVoiceButton) { m123Key.icon = m123MicIcon; m123Key.iconPreview = m123MicPreviewIcon; m123Key.label = null; @@ -403,14 +366,11 @@ public class LatinKeyboard extends Keyboard { } private void setMicF1Key(Key key) { - // HACK: draw mMicIcon and mHintIcon at the same time - final Drawable micWithSettingsHintDrawable = new BitmapDrawable(mRes, - drawSynthesizedSettingsHintImage(key.width, key.height, mMicIcon, mHintIcon)); - key.label = null; key.codes = new int[] { LatinKeyboardView.KEYCODE_VOICE }; key.popupResId = R.xml.popup_mic; - key.icon = micWithSettingsHintDrawable; + key.icon = mMicIcon; + key.hintIcon = mHintIcon; key.iconPreview = mMicPreviewIcon; } @@ -418,18 +378,11 @@ public class LatinKeyboard extends Keyboard { key.label = label; key.codes = new int[] { label.charAt(0) }; key.popupResId = popupResId; - key.icon = mHintIcon; + key.icon = null; + key.hintIcon = mHintIcon; key.iconPreview = null; } - public boolean isF1Key(Key key) { - return key == mF1Key; - } - - public static boolean hasPuncOrSmileysPopup(Key key) { - return key.popupResId == R.xml.popup_punctuation || key.popupResId == R.xml.popup_smileys; - } - /** * @return a key which should be invalidated. */ @@ -438,31 +391,24 @@ public class LatinKeyboard extends Keyboard { return mSpaceKey; } - private void updateNumberHintKeys() { - for (int i = 0; i < mNumberHintKeys.length; ++i) { - if (mNumberHintKeys[i] != null) { - mNumberHintKeys[i].icon = mNumberHintIcons[i]; - } - } - } - public boolean isLanguageSwitchEnabled() { return mLocale != null; } private void updateSpaceBarForLocale(boolean isAutoCompletion, boolean isBlack) { + final Resources res = mRes; // If application locales are explicitly selected. if (mLocale != null) { - mSpaceKey.icon = new BitmapDrawable(mRes, + mSpaceKey.icon = new BitmapDrawable(res, drawSpaceBar(OPACITY_FULLY_OPAQUE, isAutoCompletion, isBlack)); } else { // sym_keyboard_space_led can be shared with Black and White symbol themes. if (isAutoCompletion) { - mSpaceKey.icon = new BitmapDrawable(mRes, + mSpaceKey.icon = new BitmapDrawable(res, drawSpaceBar(OPACITY_FULLY_OPAQUE, isAutoCompletion, isBlack)); } else { - mSpaceKey.icon = isBlack ? mRes.getDrawable(R.drawable.sym_bkeyboard_space) - : mRes.getDrawable(R.drawable.sym_keyboard_space); + mSpaceKey.icon = isBlack ? res.getDrawable(R.drawable.sym_bkeyboard_space) + : res.getDrawable(R.drawable.sym_keyboard_space); } } } @@ -474,34 +420,6 @@ public class LatinKeyboard extends Keyboard { return bounds.width(); } - // Overlay two images: mainIcon and hintIcon. - private Bitmap drawSynthesizedSettingsHintImage( - int width, int height, Drawable mainIcon, Drawable hintIcon) { - if (mainIcon == null || hintIcon == null) - return null; - Rect hintIconPadding = new Rect(0, 0, 0, 0); - hintIcon.getPadding(hintIconPadding); - final Bitmap buffer = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); - final Canvas canvas = new Canvas(buffer); - canvas.drawColor(mRes.getColor(R.color.latinkeyboard_transparent), PorterDuff.Mode.CLEAR); - - // Draw main icon at the center of the key visual - // Assuming the hintIcon shares the same padding with the key's background drawable - final int drawableX = (width + hintIconPadding.left - hintIconPadding.right - - mainIcon.getIntrinsicWidth()) / 2; - final int drawableY = (height + hintIconPadding.top - hintIconPadding.bottom - - mainIcon.getIntrinsicHeight()) / 2; - setDefaultBounds(mainIcon); - canvas.translate(drawableX, drawableY); - mainIcon.draw(canvas); - canvas.translate(-drawableX, -drawableY); - - // Draw hint icon fully in the key - hintIcon.setBounds(0, 0, width, height); - hintIcon.draw(canvas); - return buffer; - } - // Layout local language name and left and right arrow on space bar. private static String layoutSpaceBar(Paint paint, Locale locale, Drawable lArrow, Drawable rArrow, int width, int height, float origTextSize, @@ -550,7 +468,8 @@ public class LatinKeyboard extends Keyboard { final int height = mSpaceIcon.getIntrinsicHeight(); final Bitmap buffer = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); final Canvas canvas = new Canvas(buffer); - canvas.drawColor(mRes.getColor(R.color.latinkeyboard_transparent), PorterDuff.Mode.CLEAR); + final Resources res = mRes; + canvas.drawColor(res.getColor(R.color.latinkeyboard_transparent), PorterDuff.Mode.CLEAR); // If application locales are explicitly selected. if (mLocale != null) { @@ -566,14 +485,14 @@ public class LatinKeyboard extends Keyboard { allowVariableTextSize); // Draw language text with shadow - final int shadowColor = mRes.getColor(isBlack + final int shadowColor = res.getColor(isBlack ? R.color.latinkeyboard_bar_language_shadow_black : R.color.latinkeyboard_bar_language_shadow_white); final float baseline = height * SPACEBAR_LANGUAGE_BASELINE; final float descent = paint.descent(); paint.setColor(shadowColor); canvas.drawText(language, width / 2, baseline - descent - 1, paint); - paint.setColor(mRes.getColor(R.color.latinkeyboard_bar_language_text)); + paint.setColor(res.getColor(R.color.latinkeyboard_bar_language_text)); canvas.drawText(language, width / 2, baseline - descent, paint); // Put arrows that are already layed out on either side of the text @@ -649,12 +568,12 @@ public class LatinKeyboard extends Keyboard { return mCurrentlyInSpace; } - void setPreferredLetters(int[] frequencies) { + public void setPreferredLetters(int[] frequencies) { mPrefLetterFrequencies = frequencies; mPrefLetter = 0; } - void keyReleased() { + public void keyReleased() { mCurrentlyInSpace = false; mSpaceDragLastDiff = 0; mPrefLetter = 0; @@ -670,10 +589,9 @@ public class LatinKeyboard extends Keyboard { * Does the magic of locking the touch gesture into the spacebar when * switching input languages. */ - boolean isInside(LatinKey key, int x, int y) { + public boolean isInside(LatinKey key, int x, int y) { final int code = key.codes[0]; - if (code == KEYCODE_SHIFT || - code == KEYCODE_DELETE) { + if (code == KEYCODE_SHIFT || code == KEYCODE_DELETE) { y -= key.height / 10; if (code == KEYCODE_SHIFT) x += key.width / 6; if (code == KEYCODE_DELETE) x -= key.width / 6; @@ -819,8 +737,7 @@ public class LatinKeyboard extends Keyboard { return textSize; } - // TODO LatinKey could be static class - class LatinKey extends Keyboard.Key { + public static class LatinKey extends BaseKeyboard.Key { // functional normal state (with properties) private final int[] KEY_STATE_FUNCTIONAL_NORMAL = { @@ -835,7 +752,7 @@ public class LatinKeyboard extends Keyboard { private boolean mShiftLockEnabled; - public LatinKey(Resources res, Keyboard.Row parent, int x, int y, + public LatinKey(Resources res, BaseKeyboard.Row parent, int x, int y, XmlResourceParser parser) { super(res, parent, x, y, parser); if (popupCharacters != null && popupCharacters.length() == 0) { @@ -868,13 +785,12 @@ public class LatinKeyboard extends Keyboard { */ @Override public boolean isInside(int x, int y) { - // TODO This should be done by parent.isInside(this, x, y) - // if Key.parent were protected. - boolean result = LatinKeyboard.this.isInside(this, x, y); + boolean result = (keyboard instanceof LatinKeyboard) + && ((LatinKeyboard)keyboard).isInside(this, x, y); return result; } - boolean isInsideSuper(int x, int y) { + private boolean isInsideSuper(int x, int y) { return super.isInside(x, y); } @@ -889,15 +805,6 @@ public class LatinKeyboard extends Keyboard { } return super.getCurrentDrawableState(); } - - @Override - public int squaredDistanceFrom(int x, int y) { - // We should count vertical gap between rows to calculate the center of this Key. - final int verticalGap = LatinKeyboard.this.mVerticalGap; - final int xDist = this.x + width / 2 - x; - final int yDist = this.y + (height + verticalGap) / 2 - y; - return xDist * xDist + yDist * yDist; - } } /** @@ -905,7 +812,7 @@ public class LatinKeyboard extends Keyboard { * languages by swiping the spacebar. It draws the current, previous and * next languages and moves them by the delta of touch movement on the spacebar. */ - class SlidingLocaleDrawable extends Drawable { + private class SlidingLocaleDrawable extends Drawable { private final int mWidth; private final int mHeight; @@ -926,17 +833,19 @@ public class LatinKeyboard extends Keyboard { setDefaultBounds(mBackground); mWidth = width; mHeight = height; - mTextPaint = new TextPaint(); - mTextPaint.setTextSize(getTextSizeFromTheme(android.R.style.TextAppearance_Medium, 18)); - mTextPaint.setColor(R.color.latinkeyboard_transparent); - mTextPaint.setTextAlign(Align.CENTER); - mTextPaint.setAlpha(OPACITY_FULLY_OPAQUE); - mTextPaint.setAntiAlias(true); + final TextPaint textPaint = new TextPaint(); + textPaint.setTextSize(getTextSizeFromTheme(android.R.style.TextAppearance_Medium, 18)); + textPaint.setColor(R.color.latinkeyboard_transparent); + textPaint.setTextAlign(Align.CENTER); + textPaint.setAlpha(OPACITY_FULLY_OPAQUE); + textPaint.setAntiAlias(true); + mTextPaint = textPaint; mMiddleX = (mWidth - mBackground.getIntrinsicWidth()) / 2; - mLeftDrawable = - mRes.getDrawable(R.drawable.sym_keyboard_feedback_language_arrows_left); - mRightDrawable = - mRes.getDrawable(R.drawable.sym_keyboard_feedback_language_arrows_right); + final Resources res = mRes; + mLeftDrawable = res.getDrawable( + R.drawable.sym_keyboard_feedback_language_arrows_left); + mRightDrawable = res.getDrawable( + R.drawable.sym_keyboard_feedback_language_arrows_right); mThreshold = ViewConfiguration.get(mContext).getScaledTouchSlop(); } |