diff options
Diffstat (limited to 'java')
-rw-r--r-- | java/res/drawable-hdpi/sym_keyboard_search_holo.png | bin | 1988 -> 1218 bytes | |||
-rw-r--r-- | java/res/drawable-mdpi/sym_keyboard_search_holo.png | bin | 1298 -> 819 bytes | |||
-rw-r--r-- | java/res/drawable-xhdpi/sym_keyboard_search_holo.png | bin | 2924 -> 1769 bytes | |||
-rw-r--r-- | java/res/values/attrs.xml | 7 | ||||
-rw-r--r-- | java/res/values/keyboard-icons-ics.xml | 2 | ||||
-rw-r--r-- | java/res/values/sudden-jumping-touch-event-device-list.xml | 2 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/keyboard/Key.java | 36 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/keyboard/KeyboardView.java | 36 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java | 2 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/keyboard/MiniKeyboard.java | 23 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java | 4 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/keyboard/internal/KeyboardParams.java | 15 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/latin/LatinIME.java | 4 |
13 files changed, 49 insertions, 82 deletions
diff --git a/java/res/drawable-hdpi/sym_keyboard_search_holo.png b/java/res/drawable-hdpi/sym_keyboard_search_holo.png Binary files differindex 72d9e24bf..86b925217 100644 --- a/java/res/drawable-hdpi/sym_keyboard_search_holo.png +++ b/java/res/drawable-hdpi/sym_keyboard_search_holo.png diff --git a/java/res/drawable-mdpi/sym_keyboard_search_holo.png b/java/res/drawable-mdpi/sym_keyboard_search_holo.png Binary files differindex 709012a73..423dff7f5 100644 --- a/java/res/drawable-mdpi/sym_keyboard_search_holo.png +++ b/java/res/drawable-mdpi/sym_keyboard_search_holo.png diff --git a/java/res/drawable-xhdpi/sym_keyboard_search_holo.png b/java/res/drawable-xhdpi/sym_keyboard_search_holo.png Binary files differindex 1009706cb..118f4f9aa 100644 --- a/java/res/drawable-xhdpi/sym_keyboard_search_holo.png +++ b/java/res/drawable-xhdpi/sym_keyboard_search_holo.png diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml index bc1bb0801..4cabe93a8 100644 --- a/java/res/values/attrs.xml +++ b/java/res/values/attrs.xml @@ -38,16 +38,11 @@ checkable+checked+pressed. --> <attr name="keyBackground" format="reference" /> - <!-- Size of the text for one letter keys. If not defined, keyLetterRatio takes effect. --> - <attr name="keyLetterSize" format="dimension" /> - <!-- Size of the text for keys with multiple letters. If not defined, keyLabelRatio takes - effect. --> - <attr name="keyLabelSize" format="dimension" /> <!-- Size of the text for one letter keys, in the proportion of key height. --> <attr name="keyLetterRatio" format="float" /> <!-- Large size of the text for one letter keys, in the proportion of key height. --> <attr name="keyLargeLetterRatio" format="float" /> - <!-- Size of the text for keys with multiple letters, in the proportion of key height. --> + <!-- Size of the text for keys with some text, in the proportion of key height. --> <attr name="keyLabelRatio" format="float" /> <!-- Size of the text for hint letter (= one character hint label), in the proportion of key height. --> diff --git a/java/res/values/keyboard-icons-ics.xml b/java/res/values/keyboard-icons-ics.xml index 28859b670..004dab7c5 100644 --- a/java/res/values/keyboard-icons-ics.xml +++ b/java/res/values/keyboard-icons-ics.xml @@ -25,7 +25,7 @@ <item name="iconSettingsKey">@drawable/sym_keyboard_settings_holo</item> <item name="iconSpaceKey">@drawable/sym_keyboard_space_holo</item> <item name="iconReturnKey">@drawable/sym_keyboard_return_holo</item> - <item name="iconSearchKey">@drawable/sym_keyboard_search_holo</item> + <item name="iconSearchKey">@drawable/sym_keyboard_search</item> <item name="iconTabKey">@drawable/sym_keyboard_tab_holo</item> <item name="iconShortcutKey">@drawable/sym_keyboard_voice_holo</item> <item name="iconShortcutForLabel">@drawable/sym_keyboard_label_mic_holo</item> diff --git a/java/res/values/sudden-jumping-touch-event-device-list.xml b/java/res/values/sudden-jumping-touch-event-device-list.xml index af1eefc12..275a262d9 100644 --- a/java/res/values/sudden-jumping-touch-event-device-list.xml +++ b/java/res/values/sudden-jumping-touch-event-device-list.xml @@ -18,7 +18,7 @@ */ --> <resources> - <string-array name="sudden_jumping_touch_event_device_list" translatable="false"> + <string-array name="sudden_jumping_touch_event_device_list"> <!-- Nexus One --> <item>passion</item> <!-- Droid --> diff --git a/java/src/com/android/inputmethod/keyboard/Key.java b/java/src/com/android/inputmethod/keyboard/Key.java index c3db1b318..f56b52388 100644 --- a/java/src/com/android/inputmethod/keyboard/Key.java +++ b/java/src/com/android/inputmethod/keyboard/Key.java @@ -26,10 +26,10 @@ import android.util.Xml; import com.android.inputmethod.keyboard.internal.KeyStyles; import com.android.inputmethod.keyboard.internal.KeyStyles.KeyStyle; -import com.android.inputmethod.keyboard.internal.KeyboardBuilder; -import com.android.inputmethod.keyboard.internal.KeyboardBuilder.ParseException; import com.android.inputmethod.keyboard.internal.KeyboardIconsSet; import com.android.inputmethod.keyboard.internal.KeyboardParams; +import com.android.inputmethod.keyboard.internal.KeyboardBuilder; +import com.android.inputmethod.keyboard.internal.KeyboardBuilder.ParseException; import com.android.inputmethod.keyboard.internal.PopupCharactersParser; import com.android.inputmethod.keyboard.internal.Row; import com.android.inputmethod.latin.R; @@ -184,8 +184,8 @@ public class Key { sRtlParenthesisMap.put(right, left); } - public static int getRtlParenthesisCode(int code, boolean isRtl) { - if (isRtl && sRtlParenthesisMap.containsKey(code)) { + public static int getRtlParenthesisCode(int code) { + if (sRtlParenthesisMap.containsKey(code)) { return sRtlParenthesisMap.get(code); } else { return code; @@ -195,35 +195,27 @@ public class Key { /** * This constructor is being used only for key in popup mini keyboard. */ - public Key(Resources res, KeyboardParams params, String popupSpec, - int x, int y, int width, int height, int edgeFlags) { - this(params, getRtlParenthesisCode(PopupCharactersParser.getCode(res, popupSpec), - params.mIsRtlKeyboard), - popupSpec, null, x, y, width, height, edgeFlags); - } - - /** - * This constructor is being used only for key in popup suggestions pane. - */ - public Key(KeyboardParams params, int code, String popupSpec, String hintLabel, - int x, int y, int width, int height, int edgeFlags) { + public Key(Resources res, KeyboardParams params, CharSequence popupCharacter, int x, int y, + int width, int height, int edgeFlags) { mHeight = height - params.mVerticalGap; mHorizontalGap = params.mHorizontalGap; mVerticalGap = params.mVerticalGap; mVisualInsetsLeft = mVisualInsetsRight = 0; mWidth = width - mHorizontalGap; mEdgeFlags = edgeFlags; - mHintLabel = hintLabel; + mHintLabel = null; mLabelOption = 0; mFunctional = false; mSticky = false; mRepeatable = false; mPopupCharacters = null; mMaxPopupColumn = 0; - mLabel = PopupCharactersParser.getLabel(popupSpec); - mOutputText = PopupCharactersParser.getOutputText(popupSpec); - mCode = code; - mIcon = params.mIconsSet.getIcon(PopupCharactersParser.getIconId(popupSpec)); + final String popupSpecification = popupCharacter.toString(); + mLabel = PopupCharactersParser.getLabel(popupSpecification); + mOutputText = PopupCharactersParser.getOutputText(popupSpecification); + final int code = PopupCharactersParser.getCode(res, popupSpecification); + mCode = params.mIsRtlKeyboard ? getRtlParenthesisCode(code) : code; + mIcon = params.mIconsSet.getIcon(PopupCharactersParser.getIconId(popupSpecification)); // Horizontal gap is divided equally to both sides of the key. mX = x + mHorizontalGap / 2; mY = y; @@ -352,7 +344,7 @@ public class Key { Keyboard.CODE_UNSPECIFIED); if (code == Keyboard.CODE_UNSPECIFIED && !TextUtils.isEmpty(mLabel)) { final int firstChar = mLabel.charAt(0); - mCode = getRtlParenthesisCode(firstChar, params.mIsRtlKeyboard); + mCode = params.mIsRtlKeyboard ? getRtlParenthesisCode(firstChar) : firstChar; } else if (code != Keyboard.CODE_UNSPECIFIED) { mCode = code; } else { diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java index 5f824537e..bc021a690 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java @@ -211,7 +211,6 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { private final float mKeyHintLetterRatio; private final float mKeyUppercaseLetterRatio; private final float mKeyHintLabelRatio; - private static final float UNDEFINED_RATIO = -1.0f; public final Rect mPadding = new Rect(); public int mKeyLetterSize; @@ -223,19 +222,9 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { public KeyDrawParams(TypedArray a) { mKeyBackground = a.getDrawable(R.styleable.KeyboardView_keyBackground); - if (a.hasValue(R.styleable.KeyboardView_keyLetterSize)) { - mKeyLetterRatio = UNDEFINED_RATIO; - mKeyLetterSize = a.getDimensionPixelSize(R.styleable.KeyboardView_keyLetterSize, 0); - } else { - mKeyLetterRatio = getRatio(a, R.styleable.KeyboardView_keyLetterRatio); - } - if (a.hasValue(R.styleable.KeyboardView_keyLabelSize)) { - mKeyLabelRatio = UNDEFINED_RATIO; - mKeyLabelSize = a.getDimensionPixelSize(R.styleable.KeyboardView_keyLabelSize, 0); - } else { - mKeyLabelRatio = getRatio(a, R.styleable.KeyboardView_keyLabelRatio); - } + mKeyLetterRatio = getRatio(a, R.styleable.KeyboardView_keyLetterRatio); mKeyLargeLetterRatio = getRatio(a, R.styleable.KeyboardView_keyLargeLetterRatio); + mKeyLabelRatio = getRatio(a, R.styleable.KeyboardView_keyLabelRatio); mKeyHintLetterRatio = getRatio(a, R.styleable.KeyboardView_keyHintLetterRatio); mKeyUppercaseLetterRatio = getRatio(a, R.styleable.KeyboardView_keyUppercaseLetterRatio); @@ -264,11 +253,9 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { } public void updateKeyHeight(int keyHeight) { - if (mKeyLetterRatio >= 0.0f) - mKeyLetterSize = (int)(keyHeight * mKeyLetterRatio); - if (mKeyLabelRatio >= 0.0f) - mKeyLabelSize = (int)(keyHeight * mKeyLabelRatio); + mKeyLetterSize = (int)(keyHeight * mKeyLetterRatio); mKeyLargeLetterSize = (int)(keyHeight * mKeyLargeLetterRatio); + mKeyLabelSize = (int)(keyHeight * mKeyLabelRatio); mKeyHintLetterSize = (int)(keyHeight * mKeyHintLetterRatio); mKeyUppercaseLetterSize = (int)(keyHeight * mKeyUppercaseLetterRatio); mKeyHintLabelSize = (int)(keyHeight * mKeyHintLabelRatio); @@ -694,6 +681,15 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { } } + // This method is currently being used only by MiniKeyboardBuilder + public int getDefaultLabelSizeAndSetPaint(Paint paint) { + // For characters, use large font. For labels like "Done", use small font. + final int labelSize = mKeyDrawParams.mKeyLabelSize; + paint.setTextSize(labelSize); + paint.setTypeface(mKeyDrawParams.mKeyTextStyle); + return labelSize; + } + private static final Rect sTextBounds = new Rect(); private static float getCharHeight(Paint paint) { @@ -737,12 +733,6 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { return sTextBounds.width(); } - public float getDefaultLabelWidth(CharSequence label, Paint paint) { - paint.setTextSize(mKeyDrawParams.mKeyLabelSize); - paint.setTypeface(mKeyDrawParams.mKeyTextStyle); - return getLabelWidth(label, paint); - } - private static void drawIcon(Canvas canvas, Drawable icon, int x, int y, int width, int height) { canvas.translate(x, y); diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java index 69cbcb154..5fa9b8fc4 100644 --- a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java @@ -463,7 +463,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke mPopupPanelPointerTrackerId = tracker.mPointerId; final Keyboard keyboard = getKeyboard(); - popupPanel.setShifted(keyboard.isShiftedOrShiftLocked()); + mPopupPanel.setShifted(keyboard.isShiftedOrShiftLocked()); final int pointX = (mConfigShowMiniKeyboardAtTouchedPoint) ? tracker.getLastX() : parentKey.mX + parentKey.mWidth / 2; final int pointY = parentKey.mY - keyboard.mVerticalGap; diff --git a/java/src/com/android/inputmethod/keyboard/MiniKeyboard.java b/java/src/com/android/inputmethod/keyboard/MiniKeyboard.java index ff4e72853..17c253963 100644 --- a/java/src/com/android/inputmethod/keyboard/MiniKeyboard.java +++ b/java/src/com/android/inputmethod/keyboard/MiniKeyboard.java @@ -17,6 +17,7 @@ package com.android.inputmethod.keyboard; import android.graphics.Paint; +import android.graphics.Rect; import com.android.inputmethod.keyboard.internal.KeyboardBuilder; import com.android.inputmethod.keyboard.internal.KeyboardParams; @@ -234,10 +235,9 @@ public class MiniKeyboard extends Keyboard { private static int getMaxKeyWidth(KeyboardView view, CharSequence[] popupCharacters, int minKeyWidth) { - final int padding = (int) view.getContext().getResources() - .getDimension(R.dimen.mini_keyboard_key_horizontal_padding); Paint paint = null; - int maxWidth = minKeyWidth; + Rect bounds = null; + int maxWidth = 0; for (CharSequence popupSpec : popupCharacters) { final CharSequence label = PopupCharactersParser.getLabel(popupSpec.toString()); // If the label is single letter, minKeyWidth is enough to hold @@ -247,13 +247,18 @@ public class MiniKeyboard extends Keyboard { paint = new Paint(); paint.setAntiAlias(true); } - final int width = (int)view.getDefaultLabelWidth(label, paint) + padding; - if (maxWidth < width) { - maxWidth = width; - } + final int labelSize = view.getDefaultLabelSizeAndSetPaint(paint); + paint.setTextSize(labelSize); + if (bounds == null) + bounds = new Rect(); + paint.getTextBounds(label.toString(), 0, label.length(), bounds); + if (maxWidth < bounds.width()) + maxWidth = bounds.width(); } } - return maxWidth; + final int horizontalPadding = (int) view.getContext().getResources() + .getDimension(R.dimen.mini_keyboard_key_horizontal_padding); + return Math.max(minKeyWidth, maxWidth + horizontalPadding); } @Override @@ -262,7 +267,7 @@ public class MiniKeyboard extends Keyboard { for (int n = 0; n < mPopupCharacters.length; n++) { final CharSequence label = mPopupCharacters[n]; final int row = n / params.mNumColumns; - final Key key = new Key(mResources, params, label.toString(), params.getX(n, row), + final Key key = new Key(mResources, params, label, params.getX(n, row), params.getY(row), params.mDefaultKeyWidth, params.mDefaultRowHeight, params.getRowFlags(row)); params.onAddKey(key); diff --git a/java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java b/java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java index 7ace46cac..c4428dc60 100644 --- a/java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java @@ -197,8 +197,8 @@ public class PopupMiniKeyboardView extends KeyboardView implements PopupPanel { @Override public void setShifted(boolean shifted) { - final Keyboard keyboard = getKeyboard(); - if (keyboard.setShifted(shifted)) { + final MiniKeyboard miniKeyboard = (MiniKeyboard)getKeyboard(); + if (miniKeyboard.setShifted(shifted)) { invalidateAllKeys(); } } diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardParams.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardParams.java index 980115200..4ccaa72d2 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardParams.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardParams.java @@ -64,15 +64,6 @@ public class KeyboardParams { public int mMostCommonKeyWidth = 0; - protected void clearKeys() { - mKeys.clear(); - mShiftKeys.clear(); - mShiftLockKeys.clear(); - mShiftedIcons.clear(); - mUnshiftedIcons.clear(); - clearHistogram(); - } - public void onAddKey(Key key) { mKeys.add(key); updateHistogram(key); @@ -92,12 +83,6 @@ public class KeyboardParams { private int mMaxCount = 0; private final Map<Integer, Integer> mHistogram = new HashMap<Integer, Integer>(); - private void clearHistogram() { - mMostCommonKeyWidth = 0; - mMaxCount = 0; - mHistogram.clear(); - } - private void updateHistogram(Key key) { final Integer width = key.mWidth + key.mHorizontalGap; final int count = (mHistogram.containsKey(width) ? mHistogram.get(width) : 0) + 1; diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 7559108f3..229bf0f4c 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -1708,8 +1708,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar final int rawPrimaryCode = suggestion.charAt(0); // Maybe apply the "bidi mirrored" conversions for parentheses final LatinKeyboard keyboard = mKeyboardSwitcher.getLatinKeyboard(); - final int primaryCode = Key.getRtlParenthesisCode( - rawPrimaryCode, keyboard.mIsRtlKeyboard); + final int primaryCode = keyboard.mIsRtlKeyboard + ? Key.getRtlParenthesisCode(rawPrimaryCode) : rawPrimaryCode; final CharSequence beforeText = ic != null ? ic.getTextBeforeCursor(1, 0) : ""; final int toLeft = (ic == null || TextUtils.isEmpty(beforeText)) |