diff options
-rw-r--r-- | java/res/drawable-hdpi/sym_keyboard_search_holo.png | bin | 1218 -> 1988 bytes | |||
-rw-r--r-- | java/res/drawable-mdpi/sym_keyboard_search_holo.png | bin | 819 -> 1298 bytes | |||
-rw-r--r-- | java/res/drawable-xhdpi/sym_keyboard_search_holo.png | bin | 1769 -> 2924 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, 82 insertions, 49 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 86b925217..72d9e24bf 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 423dff7f5..709012a73 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 118f4f9aa..1009706cb 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 4cabe93a8..bc1bb0801 100644 --- a/java/res/values/attrs.xml +++ b/java/res/values/attrs.xml @@ -38,11 +38,16 @@ 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 some text, in the proportion of key height. --> + <!-- Size of the text for keys with multiple letters, 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 004dab7c5..28859b670 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</item> + <item name="iconSearchKey">@drawable/sym_keyboard_search_holo</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 275a262d9..af1eefc12 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"> + <string-array name="sudden_jumping_touch_event_device_list" translatable="false"> <!-- 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 f56b52388..c3db1b318 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.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.KeyboardIconsSet; +import com.android.inputmethod.keyboard.internal.KeyboardParams; 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) { - if (sRtlParenthesisMap.containsKey(code)) { + public static int getRtlParenthesisCode(int code, boolean isRtl) { + if (isRtl && sRtlParenthesisMap.containsKey(code)) { return sRtlParenthesisMap.get(code); } else { return code; @@ -195,27 +195,35 @@ public class Key { /** * This constructor is being used only for key in popup mini keyboard. */ - public Key(Resources res, KeyboardParams params, CharSequence popupCharacter, int x, int y, - int width, int height, int edgeFlags) { + 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) { mHeight = height - params.mVerticalGap; mHorizontalGap = params.mHorizontalGap; mVerticalGap = params.mVerticalGap; mVisualInsetsLeft = mVisualInsetsRight = 0; mWidth = width - mHorizontalGap; mEdgeFlags = edgeFlags; - mHintLabel = null; + mHintLabel = hintLabel; mLabelOption = 0; mFunctional = false; mSticky = false; mRepeatable = false; mPopupCharacters = null; mMaxPopupColumn = 0; - 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)); + mLabel = PopupCharactersParser.getLabel(popupSpec); + mOutputText = PopupCharactersParser.getOutputText(popupSpec); + mCode = code; + mIcon = params.mIconsSet.getIcon(PopupCharactersParser.getIconId(popupSpec)); // Horizontal gap is divided equally to both sides of the key. mX = x + mHorizontalGap / 2; mY = y; @@ -344,7 +352,7 @@ public class Key { Keyboard.CODE_UNSPECIFIED); if (code == Keyboard.CODE_UNSPECIFIED && !TextUtils.isEmpty(mLabel)) { final int firstChar = mLabel.charAt(0); - mCode = params.mIsRtlKeyboard ? getRtlParenthesisCode(firstChar) : firstChar; + mCode = getRtlParenthesisCode(firstChar, params.mIsRtlKeyboard); } 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 bc021a690..5f824537e 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java @@ -211,6 +211,7 @@ 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; @@ -222,9 +223,19 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { public KeyDrawParams(TypedArray a) { mKeyBackground = a.getDrawable(R.styleable.KeyboardView_keyBackground); - mKeyLetterRatio = getRatio(a, R.styleable.KeyboardView_keyLetterRatio); + 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); + } 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); @@ -253,9 +264,11 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { } public void updateKeyHeight(int keyHeight) { - mKeyLetterSize = (int)(keyHeight * mKeyLetterRatio); + if (mKeyLetterRatio >= 0.0f) + mKeyLetterSize = (int)(keyHeight * mKeyLetterRatio); + if (mKeyLabelRatio >= 0.0f) + mKeyLabelSize = (int)(keyHeight * mKeyLabelRatio); mKeyLargeLetterSize = (int)(keyHeight * mKeyLargeLetterRatio); - mKeyLabelSize = (int)(keyHeight * mKeyLabelRatio); mKeyHintLetterSize = (int)(keyHeight * mKeyHintLetterRatio); mKeyUppercaseLetterSize = (int)(keyHeight * mKeyUppercaseLetterRatio); mKeyHintLabelSize = (int)(keyHeight * mKeyHintLabelRatio); @@ -681,15 +694,6 @@ 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) { @@ -733,6 +737,12 @@ 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 5fa9b8fc4..69cbcb154 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(); - mPopupPanel.setShifted(keyboard.isShiftedOrShiftLocked()); + popupPanel.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 17c253963..ff4e72853 100644 --- a/java/src/com/android/inputmethod/keyboard/MiniKeyboard.java +++ b/java/src/com/android/inputmethod/keyboard/MiniKeyboard.java @@ -17,7 +17,6 @@ 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; @@ -235,9 +234,10 @@ 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; - Rect bounds = null; - int maxWidth = 0; + int maxWidth = minKeyWidth; for (CharSequence popupSpec : popupCharacters) { final CharSequence label = PopupCharactersParser.getLabel(popupSpec.toString()); // If the label is single letter, minKeyWidth is enough to hold @@ -247,18 +247,13 @@ public class MiniKeyboard extends Keyboard { paint = new Paint(); paint.setAntiAlias(true); } - 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(); + final int width = (int)view.getDefaultLabelWidth(label, paint) + padding; + if (maxWidth < width) { + maxWidth = width; + } } } - final int horizontalPadding = (int) view.getContext().getResources() - .getDimension(R.dimen.mini_keyboard_key_horizontal_padding); - return Math.max(minKeyWidth, maxWidth + horizontalPadding); + return maxWidth; } @Override @@ -267,7 +262,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, params.getX(n, row), + final Key key = new Key(mResources, params, label.toString(), 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 c4428dc60..7ace46cac 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 MiniKeyboard miniKeyboard = (MiniKeyboard)getKeyboard(); - if (miniKeyboard.setShifted(shifted)) { + final Keyboard keyboard = getKeyboard(); + if (keyboard.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 4ccaa72d2..980115200 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardParams.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardParams.java @@ -64,6 +64,15 @@ 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); @@ -83,6 +92,12 @@ 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 229bf0f4c..7559108f3 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 = keyboard.mIsRtlKeyboard - ? Key.getRtlParenthesisCode(rawPrimaryCode) : rawPrimaryCode; + final int primaryCode = Key.getRtlParenthesisCode( + rawPrimaryCode, keyboard.mIsRtlKeyboard); final CharSequence beforeText = ic != null ? ic.getTextBeforeCursor(1, 0) : ""; final int toLeft = (ic == null || TextUtils.isEmpty(beforeText)) |