Implement temporary upper case hint icon

This change partially implements the requested feature. The following
are not supported yet.
- Non-letter key handling on automatic temporary upper case layout.
- Non-letter key handling on shift chording in caps lock layout.
- Hint icons for manual temporary upper case layout are not final ones.

Bug: 3193390

Change-Id: I636da99d1be05b1337935d87c6f4d140661e1cc8
main
Tadashi G. Takaoka 2010-11-13 00:16:34 -08:00
parent c1e2e827b5
commit 10227a71a0
21 changed files with 43 additions and 35 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 719 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 549 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 770 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 362 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 360 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 671 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -106,12 +106,15 @@
<attr name="keyOutputText" format="string" /> <attr name="keyOutputText" format="string" />
<!-- The label to display on the key. --> <!-- The label to display on the key. -->
<attr name="keyLabel" format="string" /> <attr name="keyLabel" format="string" />
<!-- The label to display on the key when keyboard is in temporary shift mode. --> <!-- The unicode that this key generates in manual temporary upper case mode. -->
<attr name="temporaryShiftKeyLabel" format="string" /> <attr name="manualTemporaryUpperCaseCode" format="integer" />
<!-- The icon to display on the key instead of the label. --> <!-- The icon to display on the key instead of the label. -->
<attr name="keyIcon" format="reference" /> <attr name="keyIcon" format="reference" />
<!-- The hint icon to display on the key in conjunction with the label --> <!-- The hint icon to display on the key in conjunction with the label -->
<attr name="keyHintIcon" format="reference" /> <attr name="keyHintIcon" format="reference" />
<!-- The hint icon to display on the key when keyboard is in manual temporary upper case
mode. -->
<attr name="manualTemporaryUpperCaseHintIcon" format="reference" />
</declare-styleable> </declare-styleable>
<declare-styleable name="BaseKeyboard_Row"> <declare-styleable name="BaseKeyboard_Row">

View File

@ -66,8 +66,9 @@
<default> <default>
<Key <Key
latin:keyLabel="\'" latin:keyLabel="\'"
latin:temporaryShiftKeyLabel="&quot;" latin:manualTemporaryUpperCaseCode="34"
latin:keyHintIcon="@drawable/key_hint_quote_holo" latin:keyHintIcon="@drawable/key_hint_quote_holo"
latin:manualTemporaryUpperCaseHintIcon="@drawable/key_hint_quote_large_holo"
latin:popupKeyboard="@xml/kbd_popup_template" latin:popupKeyboard="@xml/kbd_popup_template"
latin:popupCharacters="&quot;" /> latin:popupCharacters="&quot;" />
</default> </default>

View File

@ -64,14 +64,16 @@
<default> <default>
<Key <Key
latin:keyLabel="," latin:keyLabel=","
latin:temporaryShiftKeyLabel="!" latin:manualTemporaryUpperCaseCode="33"
latin:keyHintIcon="@drawable/key_hint_exclamation_holo" latin:keyHintIcon="@drawable/key_hint_exclamation_holo"
latin:manualTemporaryUpperCaseHintIcon="@drawable/key_hint_exclamation_large_holo"
latin:popupKeyboard="@xml/kbd_popup_template" latin:popupKeyboard="@xml/kbd_popup_template"
latin:popupCharacters="!" /> latin:popupCharacters="!" />
<Key <Key
latin:keyLabel="." latin:keyLabel="."
latin:temporaryShiftKeyLabel="\?" latin:manualTemporaryUpperCaseCode="63"
latin:keyHintIcon="@drawable/key_hint_question_holo" latin:keyHintIcon="@drawable/key_hint_question_holo"
latin:manualTemporaryUpperCaseHintIcon="@drawable/key_hint_question_large_holo"
latin:popupKeyboard="@xml/kbd_popup_template" latin:popupKeyboard="@xml/kbd_popup_template"
latin:popupCharacters="\?" /> latin:popupCharacters="\?" />
</default> </default>

View File

@ -55,10 +55,11 @@
latin:popupKeyboard="@xml/popup_smileys" /> latin:popupKeyboard="@xml/popup_smileys" />
<Key <Key
latin:keyLabel="=" latin:keyLabel="="
latin:temporaryShiftKeyLabel="+" latin:manualTemporaryUpperCaseCode="43"
latin:keyHintIcon="@drawable/key_hint_plus_holo" latin:keyHintIcon="@drawable/key_hint_plus_holo"
latin:manualTemporaryUpperCaseHintIcon="@drawable/key_hint_plus_large_holo"
latin:popupKeyboard="@xml/kbd_popup_template" latin:popupKeyboard="@xml/kbd_popup_template"
latin:popupCharacters="&gt;" /> latin:popupCharacters="+" />
</default> </default>
</switch> </switch>
<Key <Key
@ -77,8 +78,9 @@
<default> <default>
<Key <Key
latin:keyLabel="-" latin:keyLabel="-"
latin:temporaryShiftKeyLabel="/" latin:manualTemporaryUpperCaseCode="47"
latin:keyHintIcon="@drawable/key_hint_slash_holo" latin:keyHintIcon="@drawable/key_hint_slash_holo"
latin:manualTemporaryUpperCaseHintIcon="@drawable/key_hint_slash_large_holo"
latin:popupKeyboard="@xml/kbd_popup_template" latin:popupKeyboard="@xml/kbd_popup_template"
latin:popupCharacters="/" /> latin:popupCharacters="/" />
</default> </default>
@ -95,16 +97,18 @@
> >
<Key <Key
latin:keyLabel="_" latin:keyLabel="_"
latin:temporaryShiftKeyLabel=":" latin:manualTemporaryUpperCaseCode="58"
latin:keyHintIcon="@drawable/key_hint_colon_holo" latin:keyHintIcon="@drawable/key_hint_colon_holo"
latin:manualTemporaryUpperCaseHintIcon="@drawable/key_hint_colon_large_holo"
latin:popupKeyboard="@xml/kbd_popup_template" latin:popupKeyboard="@xml/kbd_popup_template"
latin:popupCharacters=":" /> latin:popupCharacters=":" />
</case> </case>
<default> <default>
<Key <Key
latin:keyLabel="_" latin:keyLabel="_"
latin:temporaryShiftKeyLabel="\@" latin:manualTemporaryUpperCaseCode="64"
latin:keyHintIcon="@drawable/key_hint_at_holo" latin:keyHintIcon="@drawable/key_hint_at_holo"
latin:manualTemporaryUpperCaseHintIcon="@drawable/key_hint_at_large_holo"
latin:popupKeyboard="@xml/kbd_popup_template" latin:popupKeyboard="@xml/kbd_popup_template"
latin:popupCharacters="\@" /> latin:popupCharacters="\@" />
</default> </default>

View File

@ -178,17 +178,23 @@ public class BaseKeyboard {
* being the most important. * being the most important.
*/ */
public int[] codes; public int[] codes;
/** The unicode that this key generates in manual temporary upper case mode. */
public int manualTemporaryUpperCaseCode;
/** Label to display */ /** Label to display */
public CharSequence label; public CharSequence label;
/** Label to display when keyboard is in temporary shift mode */
public CharSequence temporaryShiftLabel;
/** Icon to display instead of a label. Icon takes precedence over a label */ /** Icon to display instead of a label. Icon takes precedence over a label */
public Drawable icon; public Drawable icon;
/** Hint icon to display on the key in conjunction with the label */ /** Hint icon to display on the key in conjunction with the label */
public Drawable hintIcon; public Drawable hintIcon;
/** Preview version of the icon, for the preview popup */ /** Preview version of the icon, for the preview popup */
/**
* The hint icon to display on the key when keyboard is in manual temporary upper case
* mode.
*/
public Drawable manualTemporaryUpperCaseHintIcon;
public Drawable iconPreview; public Drawable iconPreview;
/** Width of the key, not including the gap */ /** Width of the key, not including the gap */
public int width; public int width;
@ -320,9 +326,13 @@ public class BaseKeyboard {
setDefaultBounds(icon); setDefaultBounds(icon);
hintIcon = a.getDrawable(R.styleable.BaseKeyboard_Key_keyHintIcon); hintIcon = a.getDrawable(R.styleable.BaseKeyboard_Key_keyHintIcon);
setDefaultBounds(hintIcon); setDefaultBounds(hintIcon);
manualTemporaryUpperCaseHintIcon = a.getDrawable(
R.styleable.BaseKeyboard_Key_manualTemporaryUpperCaseHintIcon);
setDefaultBounds(manualTemporaryUpperCaseHintIcon);
label = a.getText(R.styleable.BaseKeyboard_Key_keyLabel); label = a.getText(R.styleable.BaseKeyboard_Key_keyLabel);
temporaryShiftLabel = a.getText(R.styleable.BaseKeyboard_Key_temporaryShiftKeyLabel); manualTemporaryUpperCaseCode = a.getInt(
R.styleable.BaseKeyboard_Key_manualTemporaryUpperCaseCode, 0);
text = a.getText(R.styleable.BaseKeyboard_Key_keyOutputText); text = a.getText(R.styleable.BaseKeyboard_Key_keyOutputText);
if (codes == null && !TextUtils.isEmpty(label)) { if (codes == null && !TextUtils.isEmpty(label)) {

View File

@ -772,6 +772,8 @@ public class BaseKeyboardView extends View implements PointerTracker.UIProxy {
final int kbdPaddingTop = getPaddingTop(); final int kbdPaddingTop = getPaddingTop();
final Key[] keys = mKeys; final Key[] keys = mKeys;
final Key invalidKey = mInvalidatedKey; final Key invalidKey = mInvalidatedKey;
final boolean isTemporaryUpperCase = (mKeyboard instanceof LatinKeyboard
&& ((LatinKeyboard)mKeyboard).isTemporaryUpperCase());
paint.setColor(mKeyTextColor); paint.setColor(mKeyTextColor);
boolean drawSingleKey = false; boolean drawSingleKey = false;
@ -807,17 +809,6 @@ public class BaseKeyboardView extends View implements PointerTracker.UIProxy {
boolean drawHintIcon = true; boolean drawHintIcon = true;
if (label != null) { if (label != null) {
// If keyboard is multi-touch capable and in temporary upper case state and key has
// tempoarary shift label, label should be hint character and hint icon should not
// be drawn.
if (mHasDistinctMultitouch
&& mKeyboard instanceof LatinKeyboard
&& ((LatinKeyboard)mKeyboard).isTemporaryUpperCase()
&& key.temporaryShiftLabel != null) {
label = key.temporaryShiftLabel.toString();
drawHintIcon = false;
}
// For characters, use large font. For labels like "Done", use small font. // For characters, use large font. For labels like "Done", use small font.
final int labelSize; final int labelSize;
if (label.length() > 1 && key.codes.length < 2) { if (label.length() > 1 && key.codes.length < 2) {
@ -862,7 +853,10 @@ public class BaseKeyboardView extends View implements PointerTracker.UIProxy {
int drawableHeight = key.height; int drawableHeight = key.height;
int drawableX = 0; int drawableX = 0;
int drawableY = HINT_ICON_VERTICAL_ADJUSTMENT_PIXEL; int drawableY = HINT_ICON_VERTICAL_ADJUSTMENT_PIXEL;
drawIcon(canvas, key.hintIcon, drawableX, drawableY, drawableWidth, drawableHeight); Drawable icon = (isTemporaryUpperCase
&& key.manualTemporaryUpperCaseHintIcon != null)
? key.manualTemporaryUpperCaseHintIcon : key.hintIcon;
drawIcon(canvas, icon, drawableX, drawableY, drawableWidth, drawableHeight);
} }
canvas.translate(-key.x - kbdPaddingLeft, -key.y - kbdPaddingTop); canvas.translate(-key.x - kbdPaddingLeft, -key.y - kbdPaddingTop);
} }

View File

@ -419,12 +419,6 @@ public class PointerTracker {
if (key.codes[0] == BaseKeyboard.KEYCODE_SHIFT) { if (key.codes[0] == BaseKeyboard.KEYCODE_SHIFT) {
mHandler.startLongPressShiftTimer(mLongPressShiftKeyTimeout, keyIndex, this); mHandler.startLongPressShiftTimer(mLongPressShiftKeyTimeout, keyIndex, this);
} else { } else {
// If keyboard is in temporary upper case state and the key has temporary shift label,
// non-shift long press should not be started. On distinct multi touch device, when
// pressing shift key (in temporary upper case), hint icon should not be drawn on key
// top. So we should disable long press for such key.
if (isTemporaryUpperCase() && key.temporaryShiftLabel != null)
return;
mHandler.startLongPressTimer(mLongPressKeyTimeout, keyIndex, this); mHandler.startLongPressTimer(mLongPressKeyTimeout, keyIndex, this);
} }
} }
@ -462,10 +456,10 @@ public class PointerTracker {
code = key.codes[mTapCount]; code = key.codes[mTapCount];
} }
// If keyboard is in temporary upper case state and key has temporary shift label, // If keyboard is in manual temporary upper case state and key has manual temporary
// alternate character code should be sent. // shift code, alternate character code should be sent.
if (isTemporaryUpperCase() && key.temporaryShiftLabel != null) { if (isTemporaryUpperCase() && key.manualTemporaryUpperCaseCode != 0) {
code = key.temporaryShiftLabel.charAt(0); code = key.manualTemporaryUpperCaseCode;
codes[0] = code; codes[0] = code;
} }