Draw popup hint "..." by text rendering

Bug: 4959808
Change-Id: I30456b91852904c6801cbdd6476406fd60e84551
main
Tadashi G. Takaoka 2011-06-28 00:54:14 +09:00
parent 55303bc634
commit 3040c8bcdd
24 changed files with 11 additions and 19 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 242 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 324 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 321 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 373 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 202 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 273 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 333 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 333 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 206 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 379 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 206 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 379 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 333 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 321 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 373 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 379 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 292 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 410 B

View File

@ -64,9 +64,6 @@
<attr name="keyUppercaseLetterInactivatedColor" format="color" /> <attr name="keyUppercaseLetterInactivatedColor" format="color" />
<attr name="keyUppercaseLetterActivatedColor" format="color" /> <attr name="keyUppercaseLetterActivatedColor" format="color" />
<!-- Popup hint icon "..." -->
<attr name="keyPopupHintIcon" format="reference" />
<!-- Layout resource for key press feedback.--> <!-- Layout resource for key press feedback.-->
<attr name="keyPreviewLayout" format="reference" /> <attr name="keyPreviewLayout" format="reference" />
<!-- The background for key press feedback. --> <!-- The background for key press feedback. -->

View File

@ -49,7 +49,6 @@
<item name="keyHintLabelColor">#E0E0E4E5</item> <item name="keyHintLabelColor">#E0E0E4E5</item>
<item name="keyUppercaseLetterInactivatedColor">#66E0E4E5</item> <item name="keyUppercaseLetterInactivatedColor">#66E0E4E5</item>
<item name="keyUppercaseLetterActivatedColor">#CCE0E4E5</item> <item name="keyUppercaseLetterActivatedColor">#CCE0E4E5</item>
<item name="keyPopupHintIcon">@drawable/hint_popup</item>
<item name="keyPreviewLayout">@layout/key_preview</item> <item name="keyPreviewLayout">@layout/key_preview</item>
<item name="keyPreviewBackground">@drawable/keyboard_key_feedback</item> <item name="keyPreviewBackground">@drawable/keyboard_key_feedback</item>
<item name="keyPreviewSpacebarBackground">@drawable/keyboard_key_feedback</item> <item name="keyPreviewSpacebarBackground">@drawable/keyboard_key_feedback</item>

View File

@ -100,7 +100,6 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
// Miscellaneous constants // Miscellaneous constants
private static final int[] LONG_PRESSABLE_STATE_SET = { android.R.attr.state_long_pressable }; private static final int[] LONG_PRESSABLE_STATE_SET = { android.R.attr.state_long_pressable };
private static final int HINT_ICON_VERTICAL_ADJUSTMENT_PIXEL = -1;
// XML attribute // XML attribute
private final int mKeyTextColor; private final int mKeyTextColor;
@ -125,12 +124,14 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
private final int mPreviewOffset; private final int mPreviewOffset;
private final int mPreviewHeight; private final int mPreviewHeight;
private final int mPopupLayout; private final int mPopupLayout;
private final Drawable mKeyPopupHintIcon;
private final int mKeyHintLetterColor; private final int mKeyHintLetterColor;
private final int mKeyHintLabelColor; private final int mKeyHintLabelColor;
private final int mKeyUppercaseLetterInactivatedColor; private final int mKeyUppercaseLetterInactivatedColor;
private final int mKeyUppercaseLetterActivatedColor; private final int mKeyUppercaseLetterActivatedColor;
// HORIZONTAL ELLIPSIS "...", character for popup hint.
private static final String POPUP_HINT_CHAR = "\u2026";
// Main keyboard // Main keyboard
private Keyboard mKeyboard; private Keyboard mKeyboard;
private int mKeyLetterSize; private int mKeyLetterSize;
@ -369,7 +370,6 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
mKeyTextColor = a.getColor(R.styleable.KeyboardView_keyTextColor, 0xFF000000); mKeyTextColor = a.getColor(R.styleable.KeyboardView_keyTextColor, 0xFF000000);
mKeyTextInactivatedColor = a.getColor( mKeyTextInactivatedColor = a.getColor(
R.styleable.KeyboardView_keyTextInactivatedColor, 0xFF000000); R.styleable.KeyboardView_keyTextInactivatedColor, 0xFF000000);
mKeyPopupHintIcon = a.getDrawable(R.styleable.KeyboardView_keyPopupHintIcon);
mKeyHintLetterColor = a.getColor(R.styleable.KeyboardView_keyHintLetterColor, 0); mKeyHintLetterColor = a.getColor(R.styleable.KeyboardView_keyHintLetterColor, 0);
mKeyHintLabelColor = a.getColor(R.styleable.KeyboardView_keyHintLabelColor, 0); mKeyHintLabelColor = a.getColor(R.styleable.KeyboardView_keyHintLabelColor, 0);
mKeyUppercaseLetterInactivatedColor = a.getColor( mKeyUppercaseLetterInactivatedColor = a.getColor(
@ -838,19 +838,15 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
} }
} }
// Draw popup hint icon "...". // Draw popup hint "..." at the bottom right corner of the key.
// TODO: Draw "..." by text.
if (key.hasPopupHint()) { if (key.hasPopupHint()) {
final int drawableWidth = keyDrawWidth; paint.setTextSize(mKeyHintLetterSize);
final int drawableHeight = key.mHeight; paint.setColor(mKeyHintLabelColor);
final int drawableX = 0; final int hintX = keyDrawWidth - getLabelCharWidth(paint);
final int drawableY = HINT_ICON_VERTICAL_ADJUSTMENT_PIXEL; // Using y-coordinate "key.mHeight - paint.descent()" draws "..." just on the bottom
final Drawable hintIcon = mKeyPopupHintIcon; // edge of the key. So we use slightly higher position by multiply descent length by 2.
drawIcon(canvas, hintIcon, drawableX, drawableY, drawableWidth, drawableHeight); final int hintY = key.mHeight - (int)paint.descent() * 2;
if (DEBUG_SHOW_ALIGN) { canvas.drawText(POPUP_HINT_CHAR, hintX, hintY, paint);
drawRectangle(canvas, drawableX, drawableY, drawableWidth, drawableHeight,
0x80c0c000, new Paint());
}
} }
canvas.translate(-keyDrawX - kbdPaddingLeft, -key.mY - kbdPaddingTop); canvas.translate(-keyDrawX - kbdPaddingLeft, -key.mY - kbdPaddingTop);