diff options
author | 2010-10-18 19:45:01 +0900 | |
---|---|---|
committer | 2010-10-19 01:16:07 +0900 | |
commit | b0a6f354aca8f643766719c663297e7be3fc6424 (patch) | |
tree | 47929136d46b4258e305838a3c3faa912dfef757 /java/src | |
parent | 86953d170d3a1c189628a373a5987cfc4c17c997 (diff) | |
download | latinime-b0a6f354aca8f643766719c663297e7be3fc6424.tar.gz latinime-b0a6f354aca8f643766719c663297e7be3fc6424.tar.xz latinime-b0a6f354aca8f643766719c663297e7be3fc6424.zip |
DO NOT MERGE. Add '...' (hint) to period/smiley keys which triggers mini popup by long-press.
bug: 3105185
Change-Id: I901e36aa12dad5968ba1a420fff6a2f2efb16da5
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/com/android/inputmethod/latin/LatinKeyboard.java | 16 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java | 28 |
2 files changed, 25 insertions, 19 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboard.java b/java/src/com/android/inputmethod/latin/LatinKeyboard.java index d04fc586a..096f3e702 100644 --- a/java/src/com/android/inputmethod/latin/LatinKeyboard.java +++ b/java/src/com/android/inputmethod/latin/LatinKeyboard.java @@ -61,7 +61,7 @@ public class LatinKeyboard extends Keyboard { private Key mShiftKey; private Key mEnterKey; private Key mF1Key; - private final Drawable mF1HintIcon; + private final Drawable mHintIcon; private Key mSpaceKey; private Key m123Key; private final int NUMBER_HINT_COUNT = 10; @@ -138,7 +138,7 @@ public class LatinKeyboard extends Keyboard { mButtonArrowRightIcon = res.getDrawable(R.drawable.sym_keyboard_language_arrows_right); m123MicIcon = res.getDrawable(R.drawable.sym_keyboard_123_mic); m123MicPreviewIcon = res.getDrawable(R.drawable.sym_keyboard_feedback_123_mic); - mF1HintIcon = res.getDrawable(R.drawable.hint_settings); + mHintIcon = res.getDrawable(R.drawable.hint_popup); setDefaultBounds(m123MicPreviewIcon); sSpacebarVerticalCorrection = res.getDimensionPixelOffset( R.dimen.spacebar_vertical_correction); @@ -241,7 +241,7 @@ public class LatinKeyboard extends Keyboard { break; default: if (mode == KeyboardSwitcher.MODE_IM) { - mEnterKey.icon = null; + mEnterKey.icon = mHintIcon; mEnterKey.iconPreview = null; mEnterKey.label = ":-)"; mEnterKey.text = ":-) "; @@ -403,9 +403,9 @@ public class LatinKeyboard extends Keyboard { } private void setMicF1Key(Key key) { - // HACK: draw mMicIcon and mF1HintIcon at the same time + // HACK: draw mMicIcon and mHintIcon at the same time final Drawable micWithSettingsHintDrawable = new BitmapDrawable(mRes, - drawSynthesizedSettingsHintImage(key.width, key.height, mMicIcon, mF1HintIcon)); + drawSynthesizedSettingsHintImage(key.width, key.height, mMicIcon, mHintIcon)); key.label = null; key.codes = new int[] { LatinKeyboardView.KEYCODE_VOICE }; @@ -418,7 +418,7 @@ public class LatinKeyboard extends Keyboard { key.label = label; key.codes = new int[] { label.charAt(0) }; key.popupResId = popupResId; - key.icon = mF1HintIcon; + key.icon = mHintIcon; key.iconPreview = null; } @@ -426,6 +426,10 @@ public class LatinKeyboard extends Keyboard { 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. */ diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java index b1b82b64d..5a015e93b 100644 --- a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java +++ b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java @@ -56,6 +56,8 @@ import java.util.WeakHashMap; * A view that renders a virtual {@link LatinKeyboard}. It handles rendering of keys and * detecting key presses and touch movements. * + * TODO: References to LatinKeyboard in this class should be replaced with ones to its base class. + * * @attr ref R.styleable#LatinKeyboardBaseView_keyBackground * @attr ref R.styleable#LatinKeyboardBaseView_keyPreviewLayout * @attr ref R.styleable#LatinKeyboardBaseView_keyPreviewOffset @@ -849,8 +851,8 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx paint.setShadowLayer(0, 0, 0, 0); // Usually don't draw icon if label is not null, but we draw icon for the number - // hint. - shouldDrawIcon = isNonMicLatinF1KeyOrNumberAtEdgeOfPopupChars(key); + // hint and popup hint. + shouldDrawIcon = shouldDrawLabelAndIcon(key); } if (key.icon != null && shouldDrawIcon) { // Special handing for the upper-right number hint icons @@ -858,7 +860,7 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx final int drawableHeight; final int drawableX; final int drawableY; - if (isLatinF1KeyOrNumberAtEdgeOfPopupChars(key)) { + if (shouldDrawIconFully(key)) { drawableWidth = key.width; drawableHeight = key.height; drawableX = 0; @@ -866,10 +868,8 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx } else { drawableWidth = key.icon.getIntrinsicWidth(); drawableHeight = key.icon.getIntrinsicHeight(); - drawableX = (key.width - padding.left - padding.right - drawableWidth) - / 2 + padding.left; - drawableY = (key.height - padding.top - padding.bottom - drawableHeight) - / 2 + padding.top; + drawableX = (key.width + padding.left - padding.right - drawableWidth) / 2; + drawableY = (key.height + padding.top - padding.bottom - drawableHeight) / 2; } canvas.translate(drawableX, drawableY); key.icon.setBounds(0, 0, drawableWidth, drawableHeight); @@ -942,8 +942,8 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx Key key = tracker.getKey(keyIndex); if (key == null) return; - // Should not draw number hint icons - if (key.icon != null && !isNonMicLatinF1KeyOrNumberAtEdgeOfPopupChars(key)) { + // Should not draw hint icon in key preview + if (key.icon != null && !shouldDrawLabelAndIcon(key)) { mPreviewText.setCompoundDrawables(null, null, null, key.iconPreview != null ? key.iconPreview : key.icon); mPreviewText.setText(null); @@ -1226,12 +1226,14 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx return false; } - private boolean isLatinF1KeyOrNumberAtEdgeOfPopupChars(Key key) { - return isNumberAtEdgeOfPopupChars(key) || isLatinF1Key(key); + private boolean shouldDrawIconFully(Key key) { + return isNumberAtEdgeOfPopupChars(key) || isLatinF1Key(key) + || LatinKeyboard.hasPuncOrSmileysPopup(key); } - private boolean isNonMicLatinF1KeyOrNumberAtEdgeOfPopupChars(Key key) { - return isNumberAtEdgeOfPopupChars(key) || isNonMicLatinF1Key(key); + private boolean shouldDrawLabelAndIcon(Key key) { + return isNumberAtEdgeOfPopupChars(key) || isNonMicLatinF1Key(key) + || LatinKeyboard.hasPuncOrSmileysPopup(key); } private boolean isLatinF1Key(Key key) { |