am f3dfa550: Merge "Introduce noKeyPreview Key attribute"

* commit 'f3dfa55029a1ccaf7d98a456878ae0d9eab0ed06':
  Introduce noKeyPreview Key attribute
This commit is contained in:
Tadashi G. Takaoka 2011-11-18 16:31:12 -08:00 committed by Android Git Automerger
commit 3dc1495126
17 changed files with 90 additions and 77 deletions

View file

@ -221,6 +221,7 @@
<flag name="withIconLeft" value="0x1000" />
<flag name="withIconRight" value="0x2000" />
<flag name="autoXScale" value="0x4000" />
<flag name="noKeyPreview" value="0x8000" />
</attr>
<!-- The icon to display on the key instead of the label. -->
<attr name="keyIcon" format="enum">

View file

@ -44,24 +44,29 @@
latin:code="@integer/key_shift"
latin:keyIcon="iconShiftKey"
latin:keyIconShifted="iconShiftedShiftKey"
latin:keyLabelOption="noKeyPreview"
latin:backgroundType="sticky" />
<key-style
latin:styleName="deleteKeyStyle"
latin:code="@integer/key_delete"
latin:keyIcon="iconDeleteKey"
latin:keyLabelOption="noKeyPreview"
latin:backgroundType="functional"
latin:isRepeatable="true" />
<key-style
latin:styleName="returnKeyStyle"
latin:code="@integer/key_return"
latin:keyIcon="iconReturnKey"
latin:keyLabelOption="noKeyPreview"
latin:backgroundType="functional" />
<key-style
latin:styleName="spaceKeyStyle"
latin:code="@integer/key_space" />
latin:code="@integer/key_space"
latin:keyLabelOption="noKeyPreview" />
<key-style
latin:styleName="nonSpecialBackgroundSpaceKeyStyle"
latin:code="@integer/key_space" />
latin:code="@integer/key_space"
latin:keyLabelOption="noKeyPreview" />
<key-style
latin:styleName="smileyKeyStyle"
latin:keyLabel=":-)"
@ -73,11 +78,13 @@
latin:styleName="shortcutKeyStyle"
latin:code="@integer/key_shortcut"
latin:keyIcon="iconShortcutKey"
latin:keyLabelOption="noKeyPreview"
latin:parentStyle="f2PopupStyle" />
<key-style
latin:styleName="settingsKeyStyle"
latin:code="@integer/key_settings"
latin:keyIcon="iconSettingsKey"
latin:keyLabelOption="noKeyPreview"
latin:backgroundType="functional" />
<key-style
latin:styleName="tabKeyStyle"
@ -89,21 +96,25 @@
latin:styleName="toSymbolKeyStyle"
latin:code="@integer/key_switch_alpha_symbol"
latin:keyLabel="@string/label_to_symbol_key"
latin:keyLabelOption="noKeyPreview"
latin:backgroundType="functional" />
<key-style
latin:styleName="toAlphaKeyStyle"
latin:code="@integer/key_switch_alpha_symbol"
latin:keyLabel="@string/label_to_alpha_key"
latin:keyLabelOption="noKeyPreview"
latin:backgroundType="functional" />
<key-style
latin:styleName="toMoreSymbolKeyStyle"
latin:code="@integer/key_shift"
latin:keyLabel="@string/label_to_more_symbol_for_tablet_key"
latin:keyLabelOption="noKeyPreview"
latin:backgroundType="functional" />
<key-style
latin:styleName="backFromMoreSymbolKeyStyle"
latin:code="@integer/key_shift"
latin:keyLabel="@string/label_to_symbol_key"
latin:keyLabelOption="noKeyPreview"
latin:backgroundType="functional" />
<key-style
latin:styleName="comKeyStyle"

View file

@ -184,7 +184,7 @@
</Row>
<Row>
<Key
latin:keyStyle="tabKeyStyle"
latin:keyStyle="numTabKeyStyle"
latin:keyWidth="11.00%p" />
<Key
latin:keyStyle="nonSpecialBackgroundSpaceKeyStyle"

View file

@ -100,7 +100,7 @@
</Row>
<Row>
<Key
latin:keyStyle="tabKeyStyle"
latin:keyStyle="numTabKeyStyle"
latin:keyWidth="11.00%p" />
<Key
latin:keyStyle="nonSpecialBackgroundSpaceKeyStyle"

View file

@ -39,9 +39,7 @@
latin:keyStyle="numKeyStyle"
latin:keyWidth="9.25%p" />
<Key
latin:code="44"
latin:keyLabel="@string/label_pause_key"
latin:keyLabelOption="followKeyHintLabelRatio|autoXScale"
latin:keyStyle="numPauseKeyStyle"
latin:keyWidth="9.25%p" />
<Key
latin:keyStyle="num1KeyStyle"
@ -68,9 +66,7 @@
latin:keyStyle="numKeyStyle"
latin:keyWidth="9.25%p" />
<Key
latin:code="59"
latin:keyLabel="@string/label_wait_key"
latin:keyLabelOption="followKeyHintLabelRatio|autoXScale"
latin:keyStyle="numWaitKeyStyle"
latin:keyWidth="9.25%p" />
<Key
latin:keyStyle="num4KeyStyle"
@ -113,7 +109,7 @@
</Row>
<Row>
<Key
latin:keyStyle="tabKeyStyle"
latin:keyStyle="numTabKeyStyle"
latin:keyWidth="11.00%p" />
<Key
latin:keyStyle="nonSpecialBackgroundSpaceKeyStyle"

View file

@ -26,24 +26,29 @@
latin:code="@integer/key_shift"
latin:keyIcon="iconShiftKey"
latin:keyIconShifted="iconShiftedShiftKey"
latin:keyLabelOption="noKeyPreview"
latin:backgroundType="sticky" />
<key-style
latin:styleName="deleteKeyStyle"
latin:code="@integer/key_delete"
latin:keyIcon="iconDeleteKey"
latin:keyLabelOption="noKeyPreview"
latin:backgroundType="functional"
latin:isRepeatable="true" />
<key-style
latin:styleName="returnKeyStyle"
latin:code="@integer/key_return"
latin:keyIcon="iconReturnKey"
latin:keyLabelOption="noKeyPreview"
latin:backgroundType="functional" />
<key-style
latin:styleName="spaceKeyStyle"
latin:code="@integer/key_space" />
latin:code="@integer/key_space"
latin:keyLabelOption="noKeyPreview" />
<key-style
latin:styleName="nonSpecialBackgroundSpaceKeyStyle"
latin:code="@integer/key_space" />
latin:code="@integer/key_space"
latin:keyLabelOption="noKeyPreview" />
<key-style
latin:styleName="smileyKeyStyle"
latin:keyLabel=":-)"
@ -55,11 +60,13 @@
latin:styleName="settingsKeyStyle"
latin:code="@integer/key_settings"
latin:keyIcon="iconSettingsKey"
latin:keyLabelOption="noKeyPreview"
latin:backgroundType="functional" />
<key-style
latin:styleName="shortcutKeyStyle"
latin:code="@integer/key_shortcut"
latin:keyIcon="iconShortcutKey"
latin:keyLabelOption="noKeyPreview"
latin:backgroundType="functional" />
<key-style
latin:styleName="tabKeyStyle"
@ -71,25 +78,25 @@
latin:styleName="toSymbolKeyStyle"
latin:code="@integer/key_switch_alpha_symbol"
latin:keyLabel="@string/label_to_symbol_key"
latin:keyLabelOption="fontNormal"
latin:keyLabelOption="fontNormal|noKeyPreview"
latin:backgroundType="functional" />
<key-style
latin:styleName="toAlphaKeyStyle"
latin:code="@integer/key_switch_alpha_symbol"
latin:keyLabel="@string/label_to_alpha_key"
latin:keyLabelOption="fontNormal"
latin:keyLabelOption="fontNormal|noKeyPreview"
latin:backgroundType="functional" />
<key-style
latin:styleName="toMoreSymbolKeyStyle"
latin:code="@integer/key_shift"
latin:keyLabel="@string/label_to_more_symbol_for_tablet_key"
latin:keyLabelOption="fontNormal"
latin:keyLabelOption="fontNormal|noKeyPreview"
latin:backgroundType="functional" />
<key-style
latin:styleName="backFromMoreSymbolKeyStyle"
latin:code="@integer/key_shift"
latin:keyLabel="@string/label_to_symbol_key"
latin:keyLabelOption="fontNormal"
latin:keyLabelOption="fontNormal|noKeyPreview"
latin:backgroundType="functional" />
<key-style
latin:styleName="comKeyStyle"

View file

@ -32,7 +32,7 @@
>
<Row>
<Key
latin:keyStyle="tabKeyStyle"
latin:keyStyle="numTabKeyStyle"
latin:keyLabelOption="alignLeft"
latin:keyWidth="11.172%p" />
<Key

View file

@ -28,7 +28,7 @@
latin:keyboardLayout="@xml/kbd_numkey_styles" />
<Row>
<Key
latin:keyStyle="tabKeyStyle"
latin:keyStyle="numTabKeyStyle"
latin:keyLabelOption="alignLeft"
latin:keyWidth="11.172%p" />
<Key

View file

@ -28,7 +28,7 @@
latin:keyboardLayout="@xml/kbd_numkey_styles" />
<Row>
<Key
latin:keyStyle="tabKeyStyle"
latin:keyStyle="numTabKeyStyle"
latin:keyLabelOption="alignLeft"
latin:keyWidth="11.172%p" />
<Key
@ -41,9 +41,7 @@
latin:keyStyle="numKeyStyle"
latin:keyWidth="8.047%p" />
<Key
latin:code="44"
latin:keyLabel="@string/label_pause_key"
latin:keyLabelOption="followKeyHintLabelRatio|autoXScale"
latin:keyStyle="numPauseKeyStyle"
latin:keyWidth="8.047%p" />
<Key
latin:keyStyle="num1KeyStyle"
@ -71,9 +69,7 @@
latin:keyStyle="numKeyStyle"
latin:keyWidth="8.047%p" />
<Key
latin:code="59"
latin:keyLabel="@string/label_wait_key"
latin:keyLabelOption="followKeyHintLabelRatio|autoXScale"
latin:keyStyle="numWaitKeyStyle"
latin:keyWidth="8.047%p" />
<Key
latin:keyStyle="num4KeyStyle"

View file

@ -67,11 +67,13 @@
latin:code="@integer/key_shift"
latin:keyIcon="iconShiftKey"
latin:keyIconShifted="iconShiftedShiftKey"
latin:keyLabelOption="noKeyPreview"
latin:backgroundType="sticky" />
<key-style
latin:styleName="deleteKeyStyle"
latin:code="@integer/key_delete"
latin:keyIcon="iconDeleteKey"
latin:keyLabelOption="noKeyPreview"
latin:backgroundType="functional"
latin:isRepeatable="true" />
<!-- Return key style -->
@ -96,7 +98,7 @@
latin:styleName="returnKeyStyle"
latin:code="@integer/key_return"
latin:keyLabel="@string/label_go_key"
latin:keyLabelOption="autoXScale"
latin:keyLabelOption="autoXScale|noKeyPreview"
latin:backgroundType="action" />
</case>
<case
@ -106,7 +108,7 @@
latin:styleName="returnKeyStyle"
latin:code="@integer/key_return"
latin:keyLabel="@string/label_next_key"
latin:keyLabelOption="autoXScale"
latin:keyLabelOption="autoXScale|noKeyPreview"
latin:backgroundType="action" />
</case>
<case
@ -116,7 +118,7 @@
latin:styleName="returnKeyStyle"
latin:code="@integer/key_return"
latin:keyLabel="@string/label_done_key"
latin:keyLabelOption="autoXScale"
latin:keyLabelOption="autoXScale|noKeyPreview"
latin:backgroundType="action" />
</case>
<case
@ -126,7 +128,7 @@
latin:styleName="returnKeyStyle"
latin:code="@integer/key_return"
latin:keyLabel="@string/label_send_key"
latin:keyLabelOption="autoXScale"
latin:keyLabelOption="autoXScale|noKeyPreview"
latin:backgroundType="action" />
</case>
<case
@ -136,6 +138,7 @@
latin:styleName="returnKeyStyle"
latin:code="@integer/key_return"
latin:keyIcon="iconSearchKey"
latin:keyLabelOption="noKeyPreview"
latin:backgroundType="action" />
</case>
<default>
@ -143,22 +146,26 @@
latin:styleName="returnKeyStyle"
latin:code="@integer/key_return"
latin:keyIcon="iconReturnKey"
latin:keyLabelOption="noKeyPreview"
latin:backgroundType="functional" />
</default>
</switch>
<key-style
latin:styleName="spaceKeyStyle"
latin:code="@integer/key_space"
latin:keyLabelOption="noKeyPreview"
latin:backgroundType="functional" />
<key-style
latin:styleName="shortcutKeyStyle"
latin:code="@integer/key_shortcut"
latin:keyIcon="iconShortcutKey"
latin:keyLabelOption="noKeyPreview"
latin:parentStyle="f1PopupStyle" />
<key-style
latin:styleName="settingsKeyStyle"
latin:code="@integer/key_settings"
latin:keyIcon="iconSettingsKey"
latin:keyLabelOption="noKeyPreview"
latin:backgroundType="functional" />
<key-style
latin:styleName="tabKeyStyle"
@ -186,7 +193,7 @@
latin:code="@integer/key_switch_alpha_symbol"
latin:keyIcon="iconShortcutForLabel"
latin:keyLabel="@string/label_to_symbol_with_microphone_key"
latin:keyLabelOption="withIconRight"
latin:keyLabelOption="withIconRight|noKeyPreview"
latin:backgroundType="functional" />
</case>
<default>
@ -194,6 +201,7 @@
latin:styleName="toSymbolKeyStyle"
latin:code="@integer/key_switch_alpha_symbol"
latin:keyLabel="@string/label_to_symbol_key"
latin:keyLabelOption="noKeyPreview"
latin:backgroundType="functional" />
</default>
</switch>
@ -201,16 +209,19 @@
latin:styleName="toAlphaKeyStyle"
latin:code="@integer/key_switch_alpha_symbol"
latin:keyLabel="@string/label_to_alpha_key"
latin:keyLabelOption="noKeyPreview"
latin:backgroundType="functional" />
<key-style
latin:styleName="toMoreSymbolKeyStyle"
latin:code="@integer/key_shift"
latin:keyLabel="@string/label_to_more_symbol_key"
latin:keyLabelOption="noKeyPreview"
latin:backgroundType="functional" />
<key-style
latin:styleName="backFromMoreSymbolKeyStyle"
latin:code="@integer/key_shift"
latin:keyLabel="@string/label_to_symbol_key"
latin:keyLabelOption="noKeyPreview"
latin:backgroundType="functional" />
<key-style
latin:styleName="punctuationKeyStyle"

View file

@ -21,16 +21,22 @@
<merge
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
>
<key-style
latin:styleName="numKeyBaseStyle"
latin:keyLabelOption="noKeyPreview" />
<key-style
latin:styleName="numKeyStyle"
latin:keyLabelOption="largeLetter|followKeyLetterRatio" />
latin:keyLabelOption="largeLetter|followKeyLetterRatio"
latin:parentStyle="numKeyBaseStyle" />
<key-style
latin:styleName="numModeKeyStyle"
latin:keyLabelOption="fontNormal|followKeyLetterRatio" />
latin:keyLabelOption="fontNormal|followKeyLetterRatio"
latin:parentStyle="numKeyBaseStyle" />
<key-style
latin:styleName="numFunctionalKeyStyle"
latin:keyLabelOption="largeLetter|followKeyLetterRatio"
latin:backgroundType="functional" />
latin:backgroundType="functional"
latin:parentStyle="numKeyBaseStyle" />
<key-style
latin:styleName="numberKeyStyle"
latin:keyLabelOption="alignLeftOfCenter|hasHintLabel"
@ -99,8 +105,25 @@
latin:code="@integer/key_shift"
latin:keyLabel="@string/label_to_phone_numeric_key"
latin:parentStyle="numModeKeyStyle" />
<key-style
latin:styleName="numPauseKeyStyle"
latin:code="44"
latin:keyLabel="@string/label_pause_key"
latin:keyLabelOption="followKeyHintLabelRatio|autoXScale"
latin:parentStyle="numKeyBaseStyle" />
<key-style
latin:styleName="numWaitKeyStyle"
latin:code="59"
latin:keyLabel="@string/label_wait_key"
latin:keyLabelOption="followKeyHintLabelRatio|autoXScale"
latin:parentStyle="numKeyBaseStyle" />
<key-style
latin:styleName="numTabKeyStyle"
latin:keyLabelOption="noKeyPreview"
latin:parentStyle="tabKeyStyle" />
<key-style
latin:styleName="numSpaceKeyStyle"
latin:code="@integer/key_space"
latin:keyIcon="iconSpaceKey" />
latin:keyIcon="iconSpaceKey"
latin:parentStyle="numKeyBaseStyle" />
</merge>

View file

@ -42,13 +42,12 @@
</Row>
<Row>
<Key
latin:keyLabel="N" />
latin:keyLabel="N"
latin:keyStyle="numKeyBaseStyle" />
<!-- Pause is a comma. Check PhoneNumberUtils.java to see if this
has changed. -->
<Key
latin:code="44"
latin:keyLabel="@string/label_pause_key"
latin:keyLabelOption="followKeyHintLabelRatio|autoXScale" />
latin:keyStyle="numPauseKeyStyle" />
<Key
latin:keyLabel=","
latin:keyStyle="numKeyStyle" />
@ -62,9 +61,7 @@
latin:keyStyle="numStarKeyStyle" />
<!-- Wait is a semicolon. -->
<Key
latin:code="59"
latin:keyLabel="@string/label_wait_key"
latin:keyLabelOption="followKeyHintLabelRatio|autoXScale" />
latin:keyStyle="numWaitKeyStyle" />
<Key
latin:keyLabel="#"
latin:keyStyle="numKeyStyle" />

View file

@ -67,6 +67,7 @@ public class Key {
private static final int LABEL_OPTION_WITH_ICON_LEFT = 0x1000;
private static final int LABEL_OPTION_WITH_ICON_RIGHT = 0x2000;
private static final int LABEL_OPTION_AUTO_X_SCALE = 0x4000;
private static final int LABEL_OPTION_NO_KEY_PREVIEW = 0x8000;
/** Icon to display instead of a label. Icon takes precedence over a label */
private Drawable mIcon;
@ -386,6 +387,10 @@ public class Key {
return (mLabelOption & LABEL_OPTION_AUTO_X_SCALE) != 0;
}
public boolean noKeyPreview() {
return (mLabelOption & LABEL_OPTION_NO_KEY_PREVIEW) != 0;
}
public Drawable getIcon() {
return mIcon;
}

View file

@ -217,10 +217,6 @@ public class Keyboard {
return mId.isPhoneKeyboard();
}
public boolean isNumberKeyboard() {
return mId.isNumberKeyboard();
}
public CharSequence adjustLabelCase(CharSequence label) {
if (isShiftedOrShiftLocked() && !TextUtils.isEmpty(label) && label.length() < 3
&& Character.isLowerCase(label.charAt(0))) {

View file

@ -133,10 +133,6 @@ public class KeyboardId {
return mXmlId == R.xml.kbd_phone_shift;
}
public boolean isNumberKeyboard() {
return mMode == MODE_NUMBER;
}
@Override
public boolean equals(Object other) {
return other instanceof KeyboardId && equals((KeyboardId) other);

View file

@ -263,20 +263,6 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
return mKeyTimerHandler;
}
@Override
public void setKeyPreviewPopupEnabled(boolean previewEnabled, int delay) {
final Keyboard keyboard = getKeyboard();
if (keyboard instanceof LatinKeyboard) {
final LatinKeyboard latinKeyboard = (LatinKeyboard)keyboard;
if (latinKeyboard.isPhoneKeyboard() || latinKeyboard.isNumberKeyboard()) {
// Phone and number keyboard never shows popup preview.
super.setKeyPreviewPopupEnabled(false, delay);
return;
}
}
super.setKeyPreviewPopupEnabled(previewEnabled, delay);
}
/**
* Attaches a keyboard to this view. The keyboard can be switched at any time and the
* view will re-layout itself to accommodate the keyboard.

View file

@ -343,7 +343,7 @@ public class PointerTracker {
private void setPressedKeyGraphics(int keyIndex) {
final Key key = getKey(keyIndex);
if (key != null && key.isEnabled()) {
if (isKeyPreviewRequired(key)) {
if (!key.noKeyPreview()) {
mDrawingProxy.showKeyPreview(keyIndex, this);
}
key.onPressed();
@ -351,18 +351,6 @@ public class PointerTracker {
}
}
// The modifier key, such as shift key, should not show its key preview.
private static boolean isKeyPreviewRequired(Key key) {
final int code = key.mCode;
// TODO: Stop hard-coding these key codes here, and add a new key attribute of a key.
if (code == Keyboard.CODE_SPACE || code == Keyboard.CODE_ENTER
|| code == Keyboard.CODE_DELETE || isModifierCode(code)
|| code == Keyboard.CODE_SETTINGS || code == Keyboard.CODE_SHORTCUT) {
return false;
}
return true;
}
public int getLastX() {
return mLastX;
}