Remove multi-tap feature

Change-Id: Ife44b3f9d420d77d2cfb51044a8356f02ed63e8b
main
Tadashi G. Takaoka 2010-12-20 20:30:26 +09:00
parent 8aa3f5a3ad
commit c4f71668d7
26 changed files with 267 additions and 413 deletions

View File

@ -12,4 +12,5 @@
void setDatabaseMax(int);
void setDatabaseDelete(int);
void waitUntilUpdateDBDone();
void waitForDictionaryLoading();
}

View File

@ -94,8 +94,8 @@
</declare-styleable>
<declare-styleable name="Keyboard_Key">
<!-- The unicode value or comma-separated values that this key outputs. -->
<attr name="codes" format="integer|string" />
<!-- The unicode value that this key outputs. -->
<attr name="code" format="integer" />
<!-- The characters to display in the popup keyboard. -->
<attr name="popupCharacters" format="string" />
<!-- Maximum column of popup keyboard -->

View File

@ -41,7 +41,6 @@
<integer name="config_keyboard_grid_height">16</integer>
<integer name="config_long_press_key_timeout">400</integer>
<integer name="config_long_press_shift_key_timeout">1200</integer>
<integer name="config_multi_tap_key_timeout">800</integer>
<string name="config_text_size_of_language_on_spacebar">small</string>
<integer name="config_max_popup_keyboard_column">9</integer>
<!-- Whether or not auto-correction should be enabled by default -->

View File

@ -31,7 +31,7 @@
latin:isModifier="true" />
<key-style
latin:styleName="shiftKeyStyle"
latin:codes="@integer/key_shift"
latin:code="@integer/key_shift"
latin:keyIcon="@drawable/sym_keyboard_shift_holo"
latin:shiftedIcon="@drawable/sym_keyboard_shift_locked_holo"
latin:iconPreview="@drawable/sym_keyboard_feedback_shift"
@ -39,25 +39,25 @@
latin:isSticky="true" />
<key-style
latin:styleName="deleteKeyStyle"
latin:codes="@integer/key_delete"
latin:code="@integer/key_delete"
latin:keyIcon="@drawable/sym_keyboard_delete_holo"
latin:iconPreview="@drawable/sym_keyboard_feedback_delete"
latin:parentStyle="functionalKeyStyle"
latin:isRepeatable="true" />
<key-style
latin:styleName="returnKeyStyle"
latin:codes="@integer/key_return"
latin:code="@integer/key_return"
latin:keyIcon="@drawable/sym_keyboard_return_holo"
latin:iconPreview="@drawable/sym_keyboard_feedback_return"
latin:parentStyle="functionalKeyStyle" />
<key-style
latin:styleName="spaceKeyStyle"
latin:codes="@integer/key_space"
latin:code="@integer/key_space"
latin:keyIcon="@drawable/sym_keyboard_space_holo"
latin:iconPreview="@drawable/sym_keyboard_feedback_space" />
<key-style
latin:styleName="nonSpecialBackgroundSpaceKeyStyle"
latin:codes="@integer/key_space"
latin:code="@integer/key_space"
latin:keyIcon="@drawable/sym_keyboard_space_holo"
latin:iconPreview="@drawable/sym_keyboard_feedback_space" />
<key-style
@ -69,7 +69,7 @@
latin:maxPopupKeyboardColumn="5" />
<key-style
latin:styleName="micKeyStyle"
latin:codes="@integer/key_voice"
latin:code="@integer/key_voice"
latin:keyIcon="@drawable/sym_keyboard_mic"
latin:iconPreview="@drawable/sym_keyboard_feedback_mic"
latin:parentStyle="functionalKeyStyle" />
@ -81,7 +81,7 @@
latin:styleName="functionalKeyStyle" />
<key-style
latin:styleName="shiftKeyStyle"
latin:codes="@integer/key_shift"
latin:code="@integer/key_shift"
latin:keyIcon="@drawable/sym_bkeyboard_shift"
latin:shiftedIcon="@drawable/sym_bkeyboard_shift_locked"
latin:iconPreview="@drawable/sym_keyboard_feedback_shift"
@ -89,25 +89,25 @@
latin:isSticky="true" />
<key-style
latin:styleName="deleteKeyStyle"
latin:codes="@integer/key_delete"
latin:code="@integer/key_delete"
latin:keyIcon="@drawable/sym_bkeyboard_delete"
latin:iconPreview="@drawable/sym_keyboard_feedback_delete"
latin:parentStyle="functionalKeyStyle"
latin:isRepeatable="true" />
<key-style
latin:styleName="returnKeyStyle"
latin:codes="@integer/key_return"
latin:code="@integer/key_return"
latin:keyIcon="@drawable/sym_bkeyboard_return"
latin:iconPreview="@drawable/sym_keyboard_feedback_return"
latin:parentStyle="functionalKeyStyle" />
<key-style
latin:styleName="spaceKeyStyle"
latin:codes="@integer/key_space"
latin:code="@integer/key_space"
latin:keyIcon="@drawable/sym_bkeyboard_space"
latin:iconPreview="@drawable/sym_keyboard_feedback_space" />
<key-style
latin:styleName="nonSpecialBackgroundSpaceKeyStyle"
latin:codes="@integer/key_space"
latin:code="@integer/key_space"
latin:keyIcon="@drawable/sym_bkeyboard_space"
latin:iconPreview="@drawable/sym_keyboard_feedback_space" />
<key-style
@ -119,7 +119,7 @@
latin:maxPopupKeyboardColumn="5" />
<key-style
latin:styleName="micKeyStyle"
latin:codes="@integer/key_voice"
latin:code="@integer/key_voice"
latin:keyIcon="@drawable/sym_bkeyboard_mic"
latin:iconPreview="@drawable/sym_keyboard_feedback_mic"
latin:parentStyle="functionalKeyStyle" />
@ -127,25 +127,25 @@
</switch>
<key-style
latin:styleName="tabKeyStyle"
latin:codes="@integer/key_tab"
latin:code="@integer/key_tab"
latin:keyLabel="@string/label_tab_key"
latin:keyLabelOption="fontNormal"
latin:parentStyle="functionalKeyStyle" />
<key-style
latin:styleName="toSymbolKeyStyle"
latin:codes="@integer/key_switch_alpha_symbol"
latin:code="@integer/key_switch_alpha_symbol"
latin:keyLabel="@string/label_to_symbol_key"
latin:keyLabelOption="fontNormal"
latin:parentStyle="functionalKeyStyle" />
<key-style
latin:styleName="toAlphaKeyStyle"
latin:codes="@integer/key_switch_alpha_symbol"
latin:code="@integer/key_switch_alpha_symbol"
latin:keyLabel="@string/label_to_alpha_key"
latin:keyLabelOption="fontNormal"
latin:parentStyle="functionalKeyStyle" />
<key-style
latin:styleName="moreKeyStyle"
latin:codes="@integer/key_shift"
latin:code="@integer/key_shift"
latin:keyLabel="@string/label_more_key"
latin:keyLabelOption="fontNormal"
latin:parentStyle="functionalKeyStyle"

View File

@ -27,60 +27,60 @@
>
<key-style
latin:styleName="num0KeyStyle"
latin:codes="48"
latin:code="48"
latin:keyIcon="@drawable/sym_keyboard_num0_holo" />
<key-style
latin:styleName="num1KeyStyle"
latin:codes="49"
latin:code="49"
latin:keyIcon="@drawable/sym_keyboard_num1_holo" />
<key-style
latin:styleName="num2KeyStyle"
latin:codes="50"
latin:code="50"
latin:keyIcon="@drawable/sym_keyboard_num2_holo" />
<key-style
latin:styleName="num3KeyStyle"
latin:codes="51"
latin:code="51"
latin:keyIcon="@drawable/sym_keyboard_num3_holo" />
<key-style
latin:styleName="num4KeyStyle"
latin:codes="52"
latin:code="52"
latin:keyIcon="@drawable/sym_keyboard_num4_holo" />
<key-style
latin:styleName="num5KeyStyle"
latin:codes="53"
latin:code="53"
latin:keyIcon="@drawable/sym_keyboard_num5_holo" />
<key-style
latin:styleName="num6KeyStyle"
latin:codes="54"
latin:code="54"
latin:keyIcon="@drawable/sym_keyboard_num6_holo" />
<key-style
latin:styleName="num7KeyStyle"
latin:codes="55"
latin:code="55"
latin:keyIcon="@drawable/sym_keyboard_num7_holo" />
<key-style
latin:styleName="num8KeyStyle"
latin:codes="56"
latin:code="56"
latin:keyIcon="@drawable/sym_keyboard_num8_holo" />
<key-style
latin:styleName="num9KeyStyle"
latin:codes="57"
latin:code="57"
latin:keyIcon="@drawable/sym_keyboard_num9_holo" />
<key-style
latin:styleName="numStarKeyStyle"
latin:codes="42"
latin:code="42"
latin:keyIcon="@drawable/sym_keyboard_numbstar_holo" />
<key-style
latin:styleName="numPoundKeyStyle"
latin:codes="35"
latin:code="35"
latin:keyIcon="@drawable/sym_keyboard_numbpound_holo" />
<key-style
latin:styleName="numAltKeyStyle"
latin:codes="@integer/key_switch_alpha_symbol"
latin:code="@integer/key_switch_alpha_symbol"
latin:keyIcon="@drawable/sym_keyboard_numalt"
latin:iconPreview="@drawable/sym_keyboard_feedback_numalt" />
<key-style
latin:styleName="numSpaceKeyStyle"
latin:codes="@integer/key_space"
latin:code="@integer/key_space"
latin:keyIcon="@drawable/sym_keyboard_space_holo"
latin:iconPreview="@drawable/sym_keyboard_feedback_space" />
</case>
@ -89,60 +89,60 @@
>
<key-style
latin:styleName="num0KeyStyle"
latin:codes="48"
latin:code="48"
latin:keyIcon="@drawable/sym_bkeyboard_num0" />
<key-style
latin:styleName="num1KeyStyle"
latin:codes="49"
latin:code="49"
latin:keyIcon="@drawable/sym_bkeyboard_num1" />
<key-style
latin:styleName="num2KeyStyle"
latin:codes="50"
latin:code="50"
latin:keyIcon="@drawable/sym_bkeyboard_num2" />
<key-style
latin:styleName="num3KeyStyle"
latin:codes="51"
latin:code="51"
latin:keyIcon="@drawable/sym_bkeyboard_num3" />
<key-style
latin:styleName="num4KeyStyle"
latin:codes="52"
latin:code="52"
latin:keyIcon="@drawable/sym_bkeyboard_num4" />
<key-style
latin:styleName="num5KeyStyle"
latin:codes="53"
latin:code="53"
latin:keyIcon="@drawable/sym_bkeyboard_num5" />
<key-style
latin:styleName="num6KeyStyle"
latin:codes="54"
latin:code="54"
latin:keyIcon="@drawable/sym_bkeyboard_num6" />
<key-style
latin:styleName="num7KeyStyle"
latin:codes="55"
latin:code="55"
latin:keyIcon="@drawable/sym_bkeyboard_num7" />
<key-style
latin:styleName="num8KeyStyle"
latin:codes="56"
latin:code="56"
latin:keyIcon="@drawable/sym_bkeyboard_num8" />
<key-style
latin:styleName="num9KeyStyle"
latin:codes="57"
latin:code="57"
latin:keyIcon="@drawable/sym_bkeyboard_num9" />
<key-style
latin:styleName="numStarKeyStyle"
latin:codes="42"
latin:code="42"
latin:keyIcon="@drawable/sym_bkeyboard_numstar" />
<key-style
latin:styleName="numPoundKeyStyle"
latin:codes="35"
latin:code="35"
latin:keyIcon="@drawable/sym_bkeyboard_numpound" />
<key-style
latin:styleName="numAltKeyStyle"
latin:codes="@integer/key_switch_alpha_symbol"
latin:code="@integer/key_switch_alpha_symbol"
latin:keyIcon="@drawable/sym_bkeyboard_numalt"
latin:iconPreview="@drawable/sym_keyboard_feedback_numalt" />
<key-style
latin:styleName="numSpaceKeyStyle"
latin:codes="@integer/key_space"
latin:code="@integer/key_space"
latin:keyIcon="@drawable/sym_bkeyboard_space"
latin:iconPreview="@drawable/sym_keyboard_feedback_space" />
</case>

View File

@ -44,11 +44,11 @@
<Spacer
latin:horizontalGap="8.470%p" />
<Key
latin:codes="45"
latin:code="45"
latin:keyLabel=" - "
latin:keyWidth="8.042%p" />
<Key
latin:codes="43"
latin:code="43"
latin:keyLabel=" + "
latin:keyWidth="8.042%p" />
<Spacer
@ -75,11 +75,11 @@
<Spacer
latin:horizontalGap="8.470%p" />
<Key
latin:codes="44"
latin:code="44"
latin:keyLabel=" , "
latin:keyWidth="8.042%p" />
<Key
latin:codes="46"
latin:code="46"
latin:keyLabel=" . "
latin:keyWidth="8.042%p" />
<Spacer
@ -105,11 +105,11 @@
<Spacer
latin:horizontalGap="20.427%p" />
<Key
latin:codes="40"
latin:code="40"
latin:keyLabel=" ( "
latin:keyWidth="8.042%p" />
<Key
latin:codes="41"
latin:code="41"
latin:keyLabel=" ) "
latin:keyWidth="8.042%p" />
<Spacer

View File

@ -42,15 +42,15 @@
<Spacer
latin:horizontalGap="4.458%p" />
<Key
latin:codes="45"
latin:code="45"
latin:keyLabel=" - "
latin:keyWidth="8.042%p" />
<Key
latin:codes="43"
latin:code="43"
latin:keyLabel=" + "
latin:keyWidth="8.042%p" />
<Key
latin:codes="44"
latin:code="44"
latin:keyLabel="@string/label_pause_key"
latin:keyWidth="8.042%p" />
<!-- To match one character label size with "Tab" and "Pause, I placed spaces around the
@ -77,15 +77,15 @@
<Spacer
latin:horizontalGap="4.458%p" />
<Key
latin:codes="44"
latin:code="44"
latin:keyLabel=" , "
latin:keyWidth="8.042%p" />
<Key
latin:codes="46"
latin:code="46"
latin:keyLabel=" . "
latin:keyWidth="8.042%p" />
<Key
latin:codes="59"
latin:code="59"
latin:keyLabel="@string/label_wait_key"
latin:keyWidth="8.042%p" />
<!-- To match one character label size with "More" and "Wait", I placed spaces around the
@ -113,15 +113,15 @@
<Spacer
latin:horizontalGap="16.406%p" />
<Key
latin:codes="40"
latin:code="40"
latin:keyLabel=" ( "
latin:keyWidth="8.042%p" />
<Key
latin:codes="41"
latin:code="41"
latin:keyLabel=" ) "
latin:keyWidth="8.042%p" />
<Key
latin:codes="78"
latin:code="78"
latin:keyLabel=" N "
latin:keyWidth="8.042%p" />
<Spacer

View File

@ -31,7 +31,7 @@
latin:isModifier="true" />
<key-style
latin:styleName="shiftKeyStyle"
latin:codes="@integer/key_shift"
latin:code="@integer/key_shift"
latin:keyIcon="@drawable/sym_keyboard_shift"
latin:shiftedIcon="@drawable/sym_keyboard_shift_locked"
latin:iconPreview="@drawable/sym_keyboard_feedback_shift"
@ -39,7 +39,7 @@
latin:isSticky="true" />
<key-style
latin:styleName="deleteKeyStyle"
latin:codes="@integer/key_delete"
latin:code="@integer/key_delete"
latin:keyIcon="@drawable/sym_keyboard_delete"
latin:iconPreview="@drawable/sym_keyboard_feedback_delete"
latin:parentStyle="functionalKeyStyle"
@ -54,7 +54,7 @@
>
<key-style
latin:styleName="toSymbolKeyStyle"
latin:codes="@integer/key_switch_alpha_symbol"
latin:code="@integer/key_switch_alpha_symbol"
latin:keyIcon="@drawable/sym_keyboard_123_mic"
latin:iconPreview="@drawable/sym_keyboard_feedback_123_mic"
latin:parentStyle="functionalKeyStyle" />
@ -62,32 +62,32 @@
<default>
<key-style
latin:styleName="toSymbolKeyStyle"
latin:codes="@integer/key_switch_alpha_symbol"
latin:code="@integer/key_switch_alpha_symbol"
latin:keyLabel="@string/label_to_symbol_key"
latin:parentStyle="functionalKeyStyle" />
</default>
</switch>
<key-style
latin:styleName="settingsKeyStyle"
latin:codes="@integer/key_settings"
latin:code="@integer/key_settings"
latin:keyIcon="@drawable/sym_keyboard_settings"
latin:iconPreview="@drawable/sym_keyboard_feedback_settings"
latin:parentStyle="functionalKeyStyle" />
<key-style
latin:styleName="spaceKeyStyle"
latin:codes="@integer/key_space"
latin:code="@integer/key_space"
latin:keyIcon="@drawable/sym_keyboard_space"
latin:iconPreview="@drawable/sym_keyboard_feedback_space"
latin:parentStyle="functionalKeyStyle" />
<key-style
latin:styleName="tabKeyStyle"
latin:codes="@integer/key_tab"
latin:code="@integer/key_tab"
latin:keyIcon="@drawable/sym_keyboard_tab"
latin:iconPreview="@drawable/sym_keyboard_feedback_tab"
latin:parentStyle="functionalKeyStyle" />
<key-style
latin:styleName="micKeyStyle"
latin:codes="@integer/key_voice"
latin:code="@integer/key_voice"
latin:keyIcon="@drawable/sym_keyboard_mic"
latin:iconPreview="@drawable/sym_keyboard_feedback_mic"
latin:keyHintIcon="@drawable/hint_popup"
@ -97,7 +97,7 @@
which is laid out as normal letter key. -->
<key-style
latin:styleName="nonSpecialBackgroundTabKeyStyle"
latin:codes="@integer/key_tab"
latin:code="@integer/key_tab"
latin:keyIcon="@drawable/sym_keyboard_tab"
latin:iconPreview="@drawable/sym_keyboard_feedback_tab" />
</case>
@ -108,7 +108,7 @@
latin:styleName="functionalKeyStyle" />
<key-style
latin:styleName="shiftKeyStyle"
latin:codes="@integer/key_shift"
latin:code="@integer/key_shift"
latin:keyIcon="@drawable/sym_bkeyboard_shift"
latin:shiftedIcon="@drawable/sym_bkeyboard_shift_locked"
latin:iconPreview="@drawable/sym_keyboard_feedback_shift"
@ -116,7 +116,7 @@
latin:isSticky="true" />
<key-style
latin:styleName="deleteKeyStyle"
latin:codes="@integer/key_delete"
latin:code="@integer/key_delete"
latin:keyIcon="@drawable/sym_bkeyboard_delete"
latin:iconPreview="@drawable/sym_keyboard_feedback_delete"
latin:parentStyle="functionalKeyStyle"
@ -131,7 +131,7 @@
>
<key-style
latin:styleName="toSymbolKeyStyle"
latin:codes="@integer/key_switch_alpha_symbol"
latin:code="@integer/key_switch_alpha_symbol"
latin:keyIcon="@drawable/sym_bkeyboard_123_mic"
latin:iconPreview="@drawable/sym_keyboard_feedback_123_mic"
latin:parentStyle="functionalKeyStyle" />
@ -139,32 +139,32 @@
<default>
<key-style
latin:styleName="toSymbolKeyStyle"
latin:codes="@integer/key_switch_alpha_symbol"
latin:code="@integer/key_switch_alpha_symbol"
latin:keyLabel="@string/label_to_symbol_key"
latin:parentStyle="functionalKeyStyle" />
</default>
</switch>
<key-style
latin:styleName="settingsKeyStyle"
latin:codes="@integer/key_settings"
latin:code="@integer/key_settings"
latin:keyIcon="@drawable/sym_bkeyboard_settings"
latin:iconPreview="@drawable/sym_keyboard_feedback_settings"
latin:parentStyle="functionalKeyStyle" />
<key-style
latin:styleName="spaceKeyStyle"
latin:codes="@integer/key_space"
latin:code="@integer/key_space"
latin:keyIcon="@drawable/sym_bkeyboard_space"
latin:iconPreview="@drawable/sym_keyboard_feedback_space"
latin:parentStyle="functionalKeyStyle" />
<key-style
latin:styleName="tabKeyStyle"
latin:codes="@integer/key_tab"
latin:code="@integer/key_tab"
latin:keyIcon="@drawable/sym_bkeyboard_tab"
latin:iconPreview="@drawable/sym_keyboard_feedback_tab"
latin:parentStyle="functionalKeyStyle" />
<key-style
latin:styleName="micKeyStyle"
latin:codes="@integer/key_voice"
latin:code="@integer/key_voice"
latin:keyIcon="@drawable/sym_bkeyboard_mic"
latin:iconPreview="@drawable/sym_keyboard_feedback_mic"
latin:keyHintIcon="@drawable/hint_popup"
@ -174,7 +174,7 @@
which is laid out as normal letter key. -->
<key-style
latin:styleName="nonSpecialBackgroundTabKeyStyle"
latin:codes="@integer/key_tab"
latin:code="@integer/key_tab"
latin:keyIcon="@drawable/sym_bkeyboard_tab"
latin:iconPreview="@drawable/sym_keyboard_feedback_tab" />
</case>
@ -186,7 +186,7 @@
>
<key-style
latin:styleName="returnKeyStyle"
latin:codes="@integer/key_return"
latin:code="@integer/key_return"
latin:keyLabel="@string/label_go_key"
latin:parentStyle="functionalKeyStyle" />
</case>
@ -195,7 +195,7 @@
>
<key-style
latin:styleName="returnKeyStyle"
latin:codes="@integer/key_return"
latin:code="@integer/key_return"
latin:keyLabel="@string/label_next_key"
latin:parentStyle="functionalKeyStyle" />
</case>
@ -204,7 +204,7 @@
>
<key-style
latin:styleName="returnKeyStyle"
latin:codes="@integer/key_return"
latin:code="@integer/key_return"
latin:keyLabel="@string/label_done_key"
latin:parentStyle="functionalKeyStyle" />
</case>
@ -213,7 +213,7 @@
>
<key-style
latin:styleName="returnKeyStyle"
latin:codes="@integer/key_return"
latin:code="@integer/key_return"
latin:keyLabel="@string/label_send_key"
latin:parentStyle="functionalKeyStyle" />
</case>
@ -226,7 +226,7 @@
>
<key-style
latin:styleName="returnKeyStyle"
latin:codes="@integer/key_return"
latin:code="@integer/key_return"
latin:keyIcon="@drawable/sym_keyboard_search"
latin:iconPreview="@drawable/sym_keyboard_feedback_search"
latin:parentStyle="functionalKeyStyle" />
@ -236,7 +236,7 @@
>
<key-style
latin:styleName="returnKeyStyle"
latin:codes="@integer/key_return"
latin:code="@integer/key_return"
latin:keyIcon="@drawable/sym_bkeyboard_search"
latin:iconPreview="@drawable/sym_keyboard_feedback_search"
latin:parentStyle="functionalKeyStyle" />
@ -250,7 +250,7 @@
>
<key-style
latin:styleName="returnKeyStyle"
latin:codes="@integer/key_return"
latin:code="@integer/key_return"
latin:keyIcon="@drawable/sym_keyboard_return"
latin:iconPreview="@drawable/sym_keyboard_feedback_return"
latin:parentStyle="functionalKeyStyle" />
@ -260,7 +260,7 @@
>
<key-style
latin:styleName="returnKeyStyle"
latin:codes="@integer/key_return"
latin:code="@integer/key_return"
latin:keyIcon="@drawable/sym_bkeyboard_return"
latin:iconPreview="@drawable/sym_keyboard_feedback_return"
latin:parentStyle="functionalKeyStyle" />
@ -270,12 +270,12 @@
</switch>
<key-style
latin:styleName="toAlphaKeyStyle"
latin:codes="@integer/key_switch_alpha_symbol"
latin:code="@integer/key_switch_alpha_symbol"
latin:keyLabel="@string/label_to_alpha_key"
latin:parentStyle="functionalKeyStyle" />
<key-style
latin:styleName="altKeyStyle"
latin:codes="@integer/key_shift"
latin:code="@integer/key_shift"
latin:keyLabel="@string/label_alt_key"
latin:parentStyle="functionalKeyStyle"
latin:isSticky="true" />

View File

@ -37,7 +37,7 @@
>
<key-style
latin:styleName="numSpaceKeyStyle"
latin:codes="@integer/key_space"
latin:code="@integer/key_space"
latin:keyIcon="@drawable/sym_keyboard_space"
latin:iconPreview="@drawable/sym_keyboard_feedback_space" />
</case>
@ -46,7 +46,7 @@
>
<key-style
latin:styleName="numSpaceKeyStyle"
latin:codes="@integer/key_space"
latin:code="@integer/key_space"
latin:keyIcon="@drawable/sym_bkeyboard_space"
latin:iconPreview="@drawable/sym_keyboard_feedback_space" />
</case>

View File

@ -27,60 +27,60 @@
>
<key-style
latin:styleName="num0KeyStyle"
latin:codes="48"
latin:code="48"
latin:keyIcon="@drawable/sym_keyboard_num0" />
<key-style
latin:styleName="num1KeyStyle"
latin:codes="49"
latin:code="49"
latin:keyIcon="@drawable/sym_keyboard_num1" />
<key-style
latin:styleName="num2KeyStyle"
latin:codes="50"
latin:code="50"
latin:keyIcon="@drawable/sym_keyboard_num2" />
<key-style
latin:styleName="num3KeyStyle"
latin:codes="51"
latin:code="51"
latin:keyIcon="@drawable/sym_keyboard_num3" />
<key-style
latin:styleName="num4KeyStyle"
latin:codes="52"
latin:code="52"
latin:keyIcon="@drawable/sym_keyboard_num4" />
<key-style
latin:styleName="num5KeyStyle"
latin:codes="53"
latin:code="53"
latin:keyIcon="@drawable/sym_keyboard_num5" />
<key-style
latin:styleName="num6KeyStyle"
latin:codes="54"
latin:code="54"
latin:keyIcon="@drawable/sym_keyboard_num6" />
<key-style
latin:styleName="num7KeyStyle"
latin:codes="55"
latin:code="55"
latin:keyIcon="@drawable/sym_keyboard_num7" />
<key-style
latin:styleName="num8KeyStyle"
latin:codes="56"
latin:code="56"
latin:keyIcon="@drawable/sym_keyboard_num8" />
<key-style
latin:styleName="num9KeyStyle"
latin:codes="57"
latin:code="57"
latin:keyIcon="@drawable/sym_keyboard_num9" />
<key-style
latin:styleName="numStarKeyStyle"
latin:codes="42"
latin:code="42"
latin:keyIcon="@drawable/sym_keyboard_numstar" />
<key-style
latin:styleName="numPoundKeyStyle"
latin:codes="35"
latin:code="35"
latin:keyIcon="@drawable/sym_keyboard_numpound" />
<key-style
latin:styleName="numAltKeyStyle"
latin:codes="@integer/key_switch_alpha_symbol"
latin:code="@integer/key_switch_alpha_symbol"
latin:keyIcon="@drawable/sym_keyboard_numalt"
latin:iconPreview="@drawable/sym_keyboard_feedback_numalt" />
<key-style
latin:styleName="numSpaceKeyStyle"
latin:codes="@integer/key_space"
latin:code="@integer/key_space"
latin:keyIcon="@drawable/sym_keyboard_space"
latin:iconPreview="@drawable/sym_keyboard_feedback_space" />
</case>
@ -89,60 +89,60 @@
>
<key-style
latin:styleName="num0KeyStyle"
latin:codes="48"
latin:code="48"
latin:keyIcon="@drawable/sym_bkeyboard_num0" />
<key-style
latin:styleName="num1KeyStyle"
latin:codes="49"
latin:code="49"
latin:keyIcon="@drawable/sym_bkeyboard_num1" />
<key-style
latin:styleName="num2KeyStyle"
latin:codes="50"
latin:code="50"
latin:keyIcon="@drawable/sym_bkeyboard_num2" />
<key-style
latin:styleName="num3KeyStyle"
latin:codes="51"
latin:code="51"
latin:keyIcon="@drawable/sym_bkeyboard_num3" />
<key-style
latin:styleName="num4KeyStyle"
latin:codes="52"
latin:code="52"
latin:keyIcon="@drawable/sym_bkeyboard_num4" />
<key-style
latin:styleName="num5KeyStyle"
latin:codes="53"
latin:code="53"
latin:keyIcon="@drawable/sym_bkeyboard_num5" />
<key-style
latin:styleName="num6KeyStyle"
latin:codes="54"
latin:code="54"
latin:keyIcon="@drawable/sym_bkeyboard_num6" />
<key-style
latin:styleName="num7KeyStyle"
latin:codes="55"
latin:code="55"
latin:keyIcon="@drawable/sym_bkeyboard_num7" />
<key-style
latin:styleName="num8KeyStyle"
latin:codes="56"
latin:code="56"
latin:keyIcon="@drawable/sym_bkeyboard_num8" />
<key-style
latin:styleName="num9KeyStyle"
latin:codes="57"
latin:code="57"
latin:keyIcon="@drawable/sym_bkeyboard_num9" />
<key-style
latin:styleName="numStarKeyStyle"
latin:codes="42"
latin:code="42"
latin:keyIcon="@drawable/sym_bkeyboard_numstar" />
<key-style
latin:styleName="numPoundKeyStyle"
latin:codes="35"
latin:code="35"
latin:keyIcon="@drawable/sym_bkeyboard_numpound" />
<key-style
latin:styleName="numAltKeyStyle"
latin:codes="@integer/key_switch_alpha_symbol"
latin:code="@integer/key_switch_alpha_symbol"
latin:keyIcon="@drawable/sym_bkeyboard_numalt"
latin:iconPreview="@drawable/sym_keyboard_feedback_numalt" />
<key-style
latin:styleName="numSpaceKeyStyle"
latin:codes="@integer/key_space"
latin:code="@integer/key_space"
latin:keyIcon="@drawable/sym_bkeyboard_space"
latin:iconPreview="@drawable/sym_keyboard_feedback_space" />
</case>

View File

@ -56,7 +56,7 @@
<!-- Pause is a comma. Check PhoneNumberUtils.java to see if this
has changed. -->
<Key
latin:codes="44"
latin:code="44"
latin:keyLabel="Pause" />
<Key
latin:keyLabel="," />
@ -72,7 +72,7 @@
latin:keyEdgeFlags="left" />
<!-- Wait is a semicolon. -->
<Key
latin:codes="59"
latin:code="59"
latin:keyLabel="Wait" />
<Key
latin:keyStyle="numPoundKeyStyle" />
@ -85,7 +85,7 @@
latin:rowEdgeFlags="bottom"
>
<Key
latin:codes="@integer/key_switch_alpha_symbol"
latin:code="@integer/key_switch_alpha_symbol"
latin:keyLabel="@string/label_to_numeric_key"
latin:keyEdgeFlags="left" />
<Key

View File

@ -34,7 +34,7 @@
latin:hasVoiceKey="false"
>
<Key
latin:codes="@integer/key_switch_alpha_symbol"
latin:code="@integer/key_switch_alpha_symbol"
latin:keyIcon="@drawable/sym_bkeyboard_123_mic"
latin:iconPreview="@drawable/sym_keyboard_feedback_123_mic"
latin:keyWidth="20%p"
@ -43,7 +43,7 @@
</case>
<default>
<Key
latin:codes="@integer/key_switch_alpha_symbol"
latin:code="@integer/key_switch_alpha_symbol"
latin:keyLabel="@string/label_to_symbol_key"
latin:keyWidth="20%p"
latin:isModifier="true"
@ -63,7 +63,7 @@
latin:hasVoiceKey="false"
>
<Key
latin:codes="@integer/key_switch_alpha_symbol"
latin:code="@integer/key_switch_alpha_symbol"
latin:keyIcon="@drawable/sym_bkeyboard_123_mic"
latin:iconPreview="@drawable/sym_keyboard_feedback_123_mic"
latin:keyWidth="15%p"
@ -72,7 +72,7 @@
</case>
<default>
<Key
latin:codes="@integer/key_switch_alpha_symbol"
latin:code="@integer/key_switch_alpha_symbol"
latin:keyLabel="@string/label_to_symbol_key"
latin:keyWidth="15%p"
latin:isModifier="true"

View File

@ -32,10 +32,9 @@ import android.util.Xml;
*/
public class Key {
/**
* All the key codes (unicode or custom code) that this key could generate, zero'th
* being the most important.
* The key code (unicode or custom code) that this key generates.
*/
public final int[] mCodes;
public final int mCode;
/** The unicode that this key generates in manual temporary upper case mode. */
public final int mManualTemporaryUpperCaseCode;
@ -133,8 +132,6 @@ public class Key {
android.R.attr.state_pressed
};
private static final int[] DUMMY_CODES = { 0 };
/**
* Create an empty key with no attributes.
* This constructor is being used only for key in mini popup keyboard.
@ -157,7 +154,7 @@ public class Key {
final String popupSpecification = popupCharacter.toString();
mLabel = PopupCharactersParser.getLabel(popupSpecification);
mOutputText = PopupCharactersParser.getOutputText(popupSpecification);
mCodes = PopupCharactersParser.getCodes(res, popupSpecification);
mCode = PopupCharactersParser.getCode(res, popupSpecification);
mIcon = PopupCharactersParser.getIcon(res, popupSpecification);
// Horizontal gap is divided equally to both sides of the key.
mX = x + mGap / 2;
@ -240,13 +237,14 @@ public class Key {
mOutputText = style.getText(keyAttr, R.styleable.Keyboard_Key_keyOutputText);
// Choose the first letter of the label as primary code if not
// specified.
final int[] codes = style.getIntArray(keyAttr, R.styleable.Keyboard_Key_codes);
if (codes == null && !TextUtils.isEmpty(mLabel)) {
mCodes = new int[] { mLabel.charAt(0) };
} else if (codes != null) {
mCodes = codes;
final int code = style.getInt(keyAttr, R.styleable.Keyboard_Key_code,
Keyboard.CODE_UNSPECIFIED);
if (code == Keyboard.CODE_UNSPECIFIED && !TextUtils.isEmpty(mLabel)) {
mCode = mLabel.charAt(0);
} else if (code != Keyboard.CODE_UNSPECIFIED) {
mCode = code;
} else {
mCodes = DUMMY_CODES;
mCode = Keyboard.CODE_DUMMY;
}
final Drawable shiftedIcon = style.getDrawable(keyAttr,

View File

@ -23,11 +23,9 @@ import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.graphics.drawable.Drawable;
import android.util.Log;
import android.util.TypedValue;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.StringTokenizer;
public class KeyStyles {
private static final String TAG = "KeyStyles";
@ -38,7 +36,6 @@ public class KeyStyles {
private static final KeyStyle EMPTY_KEY_STYLE = new EmptyKeyStyle();
public interface KeyStyle {
public int[] getIntArray(TypedArray a, int index);
public CharSequence[] getTextArray(TypedArray a, int index);
public Drawable getDrawable(TypedArray a, int index);
public CharSequence getText(TypedArray a, int index);
@ -52,11 +49,6 @@ public class KeyStyles {
// Nothing to do.
}
@Override
public int[] getIntArray(TypedArray a, int index) {
return parseIntArray(a, index);
}
@Override
public CharSequence[] getTextArray(TypedArray a, int index) {
return parseTextArray(a, index);
@ -136,49 +128,11 @@ public class KeyStyles {
return list.toArray(new CharSequence[list.size()]);
}
}
protected static int[] parseIntArray(TypedArray a, int index) {
if (!a.hasValue(index))
return null;
TypedValue v = new TypedValue();
a.getValue(index, v);
if (v.type == TypedValue.TYPE_INT_DEC || v.type == TypedValue.TYPE_INT_HEX) {
return new int[] { v.data };
} else if (v.type == TypedValue.TYPE_STRING) {
return parseCsvInt(v.string.toString());
} else {
return null;
}
}
/* package */ static int[] parseCsvInt(String value) {
int count = 0;
int lastIndex = 0;
if (value.length() > 0) {
count++;
while ((lastIndex = value.indexOf(",", lastIndex + 1)) > 0) {
count++;
}
}
int[] values = new int[count];
count = 0;
StringTokenizer st = new StringTokenizer(value, ",");
while (st.hasMoreTokens()) {
values[count++] = Integer.parseInt(st.nextToken());
}
return values;
}
}
private static class DeclaredKeyStyle extends EmptyKeyStyle {
private final HashMap<Integer, Object> mAttributes = new HashMap<Integer, Object>();
@Override
public int[] getIntArray(TypedArray a, int index) {
return a.hasValue(index)
? super.getIntArray(a, index) : (int[])mAttributes.get(index);
}
@Override
public CharSequence[] getTextArray(TypedArray a, int index) {
return a.hasValue(index)
@ -221,7 +175,7 @@ public class KeyStyles {
private void parseKeyStyleAttributes(TypedArray keyAttr) {
// TODO: Currently not all Key attributes can be declared as style.
readIntArray(keyAttr, R.styleable.Keyboard_Key_codes);
readInt(keyAttr, R.styleable.Keyboard_Key_code);
readText(keyAttr, R.styleable.Keyboard_Key_keyLabel);
readFlag(keyAttr, R.styleable.Keyboard_Key_keyLabelOption);
readTextArray(keyAttr, R.styleable.Keyboard_Key_popupCharacters);
@ -262,12 +216,6 @@ public class KeyStyles {
mAttributes.put(index, a.getBoolean(index, false));
}
private void readIntArray(TypedArray a, int index) {
final int[] value = parseIntArray(a, index);
if (value != null)
mAttributes.put(index, value);
}
private void readTextArray(TypedArray a, int index) {
final CharSequence[] value = parseTextArray(a, index);
if (value != null)

View File

@ -65,12 +65,15 @@ public class Keyboard {
public static final int CODE_PERIOD = '.';
/** Special keys code. These should be aligned with values/keycodes.xml */
public static final int CODE_DUMMY = 0;
public static final int CODE_SHIFT = -1;
public static final int CODE_SWITCH_ALPHA_SYMBOL = -2;
public static final int CODE_CANCEL = -3;
public static final int CODE_DONE = -4;
public static final int CODE_DELETE = -5;
public static final int CODE_ALT = -6;
// Code value representing the code is not specified.
public static final int CODE_UNSPECIFIED = -99;
public static final int CODE_SETTINGS = -100;
public static final int CODE_SETTINGS_LONGPRESS = -101;
// TODO: remove this once LatinIME stops referring to this.

View File

@ -279,14 +279,14 @@ public class KeyboardParser {
checkEndTag(TAG_KEY, parser);
} else {
Key key = new Key(mResources, row, mCurrentX, mCurrentY, parser, mKeyStyles);
if (DEBUG) Log.d(TAG, String.format("<%s keyLabel=%s codes=%s popupCharacters=%s />",
TAG_KEY, key.mLabel, Arrays.toString(key.mCodes),
if (DEBUG) Log.d(TAG, String.format("<%s keyLabel=%s code=%d popupCharacters=%s />",
TAG_KEY, key.mLabel, key.mCode,
Arrays.toString(key.mPopupCharacters)));
checkEndTag(TAG_KEY, parser);
keys.add(key);
if (key.mCodes[0] == Keyboard.CODE_SHIFT)
if (key.mCode == Keyboard.CODE_SHIFT)
mKeyboard.getShiftKeys().add(key);
if (key.mCodes[0] == Keyboard.CODE_SPACE)
if (key.mCode == Keyboard.CODE_SPACE)
mKeyboard.setSpaceKey(key);
endKey(key);
}

View File

@ -834,7 +834,7 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
// For characters, use large font. For labels like "Done", use small font.
final int labelSize;
final Typeface labelStyle;
if (label.length() > 1 && key.mCodes.length < 2) {
if (label.length() > 1) {
labelSize = mLabelTextSize;
if ((key.mLabelOption & KEY_LABEL_OPTION_FONT_NORMAL) != 0) {
labelStyle = Typeface.DEFAULT;
@ -943,7 +943,7 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
// TODO Should take care of temporaryShiftLabel here.
mPreviewText.setCompoundDrawables(null, null, null, null);
mPreviewText.setText(adjustCase(tracker.getPreviewText(key)));
if (key.mLabel.length() > 1 && key.mCodes.length < 2) {
if (key.mLabel.length() > 1) {
mPreviewText.setTextSize(TypedValue.COMPLEX_UNIT_PX, mKeyLetterSize);
mPreviewText.setTypeface(Typeface.DEFAULT_BOLD);
} else {

View File

@ -294,7 +294,7 @@ public class LatinKeyboard extends Keyboard {
public boolean isInside(Key key, int pointX, int pointY) {
int x = pointX;
int y = pointY;
final int code = key.mCodes[0];
final int code = key.mCode;
if (code == CODE_SHIFT || code == CODE_DELETE) {
y -= key.mHeight / 10;
if (code == CODE_SHIFT) x += key.mWidth / 6;
@ -348,11 +348,11 @@ public class LatinKeyboard extends Keyboard {
mPrefLetterY = y;
for (int i = 0; i < nearby.length; i++) {
Key k = nearbyKeys.get(nearby[i]);
if (k != key && inPrefList(k.mCodes[0], pref)) {
if (k != key && inPrefList(k.mCode, pref)) {
final int dist = distanceFrom(k, x, y);
if (dist < (int) (k.mWidth * OVERLAP_PERCENTAGE_LOW_PROB) &&
(pref[k.mCodes[0]] > pref[mPrefLetter] * 3)) {
mPrefLetter = k.mCodes[0];
(pref[k.mCode] > pref[mPrefLetter] * 3)) {
mPrefLetter = k.mCode;
mPrefDistance = dist;
if (DEBUG_PREFERRED_LETTER) {
Log.d(TAG, "CORRECTED ALTHOUGH PREFERRED !!!!!!");
@ -376,11 +376,11 @@ public class LatinKeyboard extends Keyboard {
for (int i = 0; i < nearby.length; i++) {
Key k = nearbyKeys.get(nearby[i]);
if (inPrefList(k.mCodes[0], pref)) {
if (inPrefList(k.mCode, pref)) {
final int dist = distanceFrom(k, x, y);
if (dist < (int) (k.mWidth * OVERLAP_PERCENTAGE_HIGH_PROB)
&& dist < mPrefDistance) {
mPrefLetter = k.mCodes[0];
mPrefLetter = k.mCode;
mPrefLetterX = x;
mPrefLetterY = y;
mPrefDistance = dist;
@ -430,7 +430,7 @@ public class LatinKeyboard extends Keyboard {
List<Key> keys = getKeys();
int count = keys.size();
for (int i = 0; i < count; i++) {
if (keys.get(i).mCodes[0] == code) return i;
if (keys.get(i).mCode == code) return i;
}
return -1;
}

View File

@ -82,7 +82,7 @@ public class LatinKeyboardView extends KeyboardView {
@Override
protected boolean onLongPress(Key key) {
int primaryCode = key.mCodes[0];
int primaryCode = key.mCode;
if (primaryCode == Keyboard.CODE_SETTINGS) {
return invokeOnKey(Keyboard.CODE_SETTINGS_LONGPRESS);
} else if (primaryCode == '0' && getLatinKeyboard().isPhoneKeyboard()) {

View File

@ -52,7 +52,7 @@ public class MiniKeyboardKeyDetector extends KeyDetector {
}
if (allKeys != null && closestKeyIndex != NOT_A_KEY)
allKeys[0] = keys[closestKeyIndex].mCodes[0];
allKeys[0] = keys[closestKeyIndex].mCode;
return closestKeyIndex;
}
}

View File

@ -43,7 +43,6 @@ public class PointerTracker {
private final int mDelayBeforeKeyRepeatStart;
private final int mLongPressKeyTimeout;
private final int mLongPressShiftKeyTimeout;
private final int mMultiTapKeyTimeout;
// Miscellaneous constants
private static final int NOT_A_KEY = KeyDetector.NOT_A_KEY;
@ -75,13 +74,6 @@ public class PointerTracker {
// true if sliding key is allowed.
private boolean mIsAllowedSlidingKeyInput;
// For multi-tap
private int mLastSentIndex;
private int mTapCount;
private long mLastTapTime;
private boolean mInMultiTap;
private final StringBuilder mPreviewLabel = new StringBuilder(1);
// pressed key
private int mPreviousKey = NOT_A_KEY;
@ -116,8 +108,6 @@ public class PointerTracker {
mDelayBeforeKeyRepeatStart = res.getInteger(R.integer.config_delay_before_key_repeat_start);
mLongPressKeyTimeout = res.getInteger(R.integer.config_long_press_key_timeout);
mLongPressShiftKeyTimeout = res.getInteger(R.integer.config_long_press_shift_key_timeout);
mMultiTapKeyTimeout = res.getInteger(R.integer.config_multi_tap_key_timeout);
resetMultiTap();
}
public void setOnKeyboardActionListener(KeyboardActionListener listener) {
@ -184,7 +174,7 @@ public class PointerTracker {
private boolean isModifierInternal(int keyIndex) {
final Key key = getKey(keyIndex);
return key == null ? false : isModifierCode(key.mCodes[0]);
return key == null ? false : isModifierCode(key.mCode);
}
public boolean isModifier() {
@ -197,12 +187,12 @@ public class PointerTracker {
public boolean isOnShiftKey(int x, int y) {
final Key key = getKey(mKeyDetector.getKeyIndexAndNearbyCodes(x, y, null));
return key != null && key.mCodes[0] == Keyboard.CODE_SHIFT;
return key != null && key.mCode == Keyboard.CODE_SHIFT;
}
public boolean isSpaceKey(int keyIndex) {
Key key = getKey(keyIndex);
return key != null && key.mCodes[0] == Keyboard.CODE_SPACE;
return key != null && key.mCode == Keyboard.CODE_SPACE;
}
public void releaseKey() {
@ -260,9 +250,8 @@ public class PointerTracker {
mKeyAlreadyProcessed = false;
mIsRepeatableKey = false;
mIsInSlidingKeyInput = false;
checkMultiTap(eventTime, keyIndex);
if (isValidKeyIndex(keyIndex)) {
callListenerOnPress(mKeys[keyIndex].mCodes[0]);
callListenerOnPress(mKeys[keyIndex].mCode);
// This onPress call may have changed keyboard layout and have updated mKeyIndex.
// If that's the case, mKeyIndex has been updated in setKeyboard().
keyIndex = mKeyState.getKeyIndex();
@ -290,7 +279,7 @@ public class PointerTracker {
if (oldKey == null) {
// The pointer has been slid in to the new key, but the finger was not on any keys.
// In this case, we must call onPress() to notify that the new key is being pressed.
callListenerOnPress(getKey(keyIndex).mCodes[0]);
callListenerOnPress(getKey(keyIndex).mCode);
keyState.onMoveToNewKey(keyIndex, x, y);
startLongPressTimer(keyIndex);
} else if (!isMinorMoveBounce(x, y, keyIndex)) {
@ -298,11 +287,10 @@ public class PointerTracker {
// onRelease() first to notify that the previous key has been released, then call
// onPress() to notify that the new key is being pressed.
mIsInSlidingKeyInput = true;
callListenerOnRelease(oldKey.mCodes[0]);
callListenerOnRelease(oldKey.mCode);
mHandler.cancelLongPressTimers();
if (mIsAllowedSlidingKeyInput) {
resetMultiTap();
callListenerOnPress(getKey(keyIndex).mCodes[0]);
callListenerOnPress(getKey(keyIndex).mCode);
keyState.onMoveToNewKey(keyIndex, x, y);
startLongPressTimer(keyIndex);
} else {
@ -316,10 +304,9 @@ public class PointerTracker {
// The pointer has been slid out from the previous key, we must call onRelease() to
// notify that the previous key has been released.
mIsInSlidingKeyInput = true;
callListenerOnRelease(oldKey.mCodes[0]);
callListenerOnRelease(oldKey.mCode);
mHandler.cancelLongPressTimers();
if (mIsAllowedSlidingKeyInput) {
resetMultiTap();
keyState.onMoveToNewKey(keyIndex, x ,y);
} else {
setAlreadyProcessed();
@ -351,7 +338,7 @@ public class PointerTracker {
y = keyState.getKeyY();
}
if (!mIsRepeatableKey) {
detectAndSendKey(keyIndex, x, y, eventTime);
detectAndSendKey(keyIndex, x, y);
}
if (isValidKeyIndex(keyIndex))
@ -373,9 +360,7 @@ public class PointerTracker {
public void repeatKey(int keyIndex) {
Key key = getKey(keyIndex);
if (key != null) {
// While key is repeating, because there is no need to handle multi-tap key, we can
// pass -1 as eventTime argument.
detectAndSendKey(keyIndex, key.mX, key.mY, -1);
detectAndSendKey(keyIndex, key.mX, key.mY);
}
}
@ -427,7 +412,7 @@ public class PointerTracker {
private void startLongPressTimer(int keyIndex) {
Key key = getKey(keyIndex);
if (key.mCodes[0] == Keyboard.CODE_SHIFT) {
if (key.mCode == Keyboard.CODE_SHIFT) {
mHandler.startLongPressShiftTimer(mLongPressShiftKeyTimeout, keyIndex, this);
} else if (mKeyboardSwitcher.isInMomentaryAutoModeSwitchState()) {
// We use longer timeout for sliding finger input started from the symbols mode key.
@ -437,7 +422,7 @@ public class PointerTracker {
}
}
private void detectAndSendKey(int index, int x, int y, long eventTime) {
private void detectAndSendKey(int index, int x, int y) {
final Key key = getKey(index);
if (key == null) {
callListenerOnCancelInput();
@ -445,20 +430,11 @@ public class PointerTracker {
}
if (key.mOutputText != null) {
callListenerOnTextInput(key.mOutputText);
callListenerOnRelease(key.mCodes[0]);
callListenerOnRelease(key.mCode);
} else {
int code = key.mCodes[0];
int code = key.mCode;
final int[] codes = mKeyDetector.newCodeArray();
mKeyDetector.getKeyIndexAndNearbyCodes(x, y, codes);
// Multi-tap
if (mInMultiTap) {
if (mTapCount != -1) {
callListenerOnCodeInput(Keyboard.CODE_DELETE, KEY_DELETE, x, y);
} else {
mTapCount = 0;
}
code = key.mCodes[mTapCount];
}
// If keyboard is in manual temporary upper case state and key has manual temporary
// shift code, alternate character code should be sent.
@ -477,51 +453,10 @@ public class PointerTracker {
callListenerOnCodeInput(code, codes, x, y);
callListenerOnRelease(code);
}
mLastSentIndex = index;
mLastTapTime = eventTime;
}
/**
* Handle multi-tap keys by producing the key label for the current multi-tap state.
*/
public CharSequence getPreviewText(Key key) {
if (mInMultiTap) {
// Multi-tap
mPreviewLabel.setLength(0);
mPreviewLabel.append((char) key.mCodes[mTapCount < 0 ? 0 : mTapCount]);
return mPreviewLabel;
} else {
return key.mLabel;
}
}
private void resetMultiTap() {
mLastSentIndex = NOT_A_KEY;
mTapCount = 0;
mLastTapTime = -1;
mInMultiTap = false;
}
private void checkMultiTap(long eventTime, int keyIndex) {
Key key = getKey(keyIndex);
if (key == null)
return;
final boolean isMultiTap =
(eventTime < mLastTapTime + mMultiTapKeyTimeout && keyIndex == mLastSentIndex);
if (key.mCodes.length > 1) {
mInMultiTap = true;
if (isMultiTap) {
mTapCount = (mTapCount + 1) % key.mCodes.length;
return;
} else {
mTapCount = -1;
return;
}
}
if (!isMultiTap) {
resetMultiTap();
}
return key.mLabel;
}
private long mPreviousEventTime;
@ -529,7 +464,7 @@ public class PointerTracker {
private void printTouchEvent(String title, int x, int y, long eventTime) {
final int keyIndex = mKeyDetector.getKeyIndexAndNearbyCodes(x, y, null);
final Key key = getKey(keyIndex);
final String code = (key == null) ? "----" : keyCodePrintable(key.mCodes[0]);
final String code = (key == null) ? "----" : keyCodePrintable(key.mCode);
final long delta = eventTime - mPreviousEventTime;
Log.d(TAG, String.format("%s%s[%d] %4d %4d %5d %3d(%s)", title,
(mKeyAlreadyProcessed ? "-" : " "), mPointerId, x, y, delta, keyIndex, code));

View File

@ -39,7 +39,6 @@ public class PopupCharactersParser {
private static final String PREFIX_AT = "@";
private static final String PREFIX_ICON = PREFIX_AT + "drawable/";
private static final String PREFIX_CODE = PREFIX_AT + "integer/";
private static final int[] DUMMY_CODES = { 0 };
private PopupCharactersParser() {
// Intentional empty constructor for utility class.
@ -126,13 +125,13 @@ public class PopupCharactersParser {
final String label = getLabel(popupSpec);
if (label == null)
throw new PopupCharactersParserError("Empty label: " + popupSpec);
// Code is automatically generated for one letter label. See getCode().
// Code is automatically generated for one letter label. See {@link getCode()}.
if (label.length() == 1)
return null;
return label;
}
public static int[] getCodes(Resources res, String popupSpec) {
public static int getCode(Resources res, String popupSpec) {
if (hasCode(popupSpec)) {
final int end = indexOfLabelEnd(popupSpec, 0);
if (indexOfLabelEnd(popupSpec, end + 1) >= 0)
@ -140,15 +139,15 @@ public class PopupCharactersParser {
final int resId = getResourceId(res,
popupSpec.substring(end + LABEL_END.length() + PREFIX_AT.length()));
final int code = res.getInteger(resId);
return new int[] { code };
return code;
}
if (indexOfLabelEnd(popupSpec, 0) > 0)
return DUMMY_CODES;
return Keyboard.CODE_DUMMY;
final String label = getLabel(popupSpec);
// Code is automatically generated for one letter label.
if (label != null && label.length() == 1)
return new int[] { label.charAt(0) };
return DUMMY_CODES;
return label.charAt(0);
return Keyboard.CODE_DUMMY;
}
public static Drawable getIcon(Resources res, String popupSpec) {

View File

@ -46,17 +46,16 @@ public class ProximityKeyDetector extends KeyDetector {
final int dist = key.squaredDistanceToEdge(touchX, touchY);
if (isInside || (mProximityCorrectOn && dist < mProximityThresholdSquare)) {
if (allKeys == null) continue;
final int nCodes = key.mCodes.length;
// Find insertion point
for (int j = 0; j < distances.length; j++) {
if (distances[j] > dist) {
// Make space for nCodes codes
System.arraycopy(distances, j, distances, j + nCodes,
distances.length - (j + nCodes));
System.arraycopy(allKeys, j, allKeys, j + nCodes,
allKeys.length - (j + nCodes));
System.arraycopy(key.mCodes, 0, allKeys, j, nCodes);
Arrays.fill(distances, j, j + nCodes, dist);
final int nextPos = j + 1;
System.arraycopy(distances, j, distances, nextPos,
distances.length - nextPos);
System.arraycopy(allKeys, j, allKeys, nextPos,
allKeys.length - nextPos);
distances[j] = dist;
allKeys[j] = key.mCode;
break;
}
}

View File

@ -263,9 +263,9 @@ public class TextEntryState {
}
public static void keyPressedAt(Key key, int x, int y) {
if (LOGGING && sKeyLocationFile != null && key.mCodes[0] >= 32) {
if (LOGGING && sKeyLocationFile != null && key.mCode >= 32) {
String out =
"KEY: " + (char) key.mCodes[0]
"KEY: " + (char) key.mCode
+ " X: " + x
+ " Y: " + y
+ " MX: " + (key.mX + key.mWidth / 2)

View File

@ -22,23 +22,6 @@ import android.test.AndroidTestCase;
import android.text.TextUtils;
public class KeyStylesTests extends AndroidTestCase {
private static void assertNumberFormatException(String message, String value) {
try {
EmptyKeyStyle.parseCsvInt(value);
fail(message);
} catch (NumberFormatException nfe) {
// success.
}
}
private static void assertIntArray(String message, String value, Integer ... expected) {
final int actual[] = EmptyKeyStyle.parseCsvInt(value);
assertSame(message + ": result length", expected.length, actual.length);
for (int i = 0; i < actual.length; i++) {
assertEquals(message + ": result at " + i + ":", (int)expected[i], actual[i]);
}
}
private static String format(String message, Object expected, Object actual) {
return message + " expected:<" + expected + "> but was:<" + actual + ">";
}
@ -57,19 +40,6 @@ public class KeyStylesTests extends AndroidTestCase {
}
}
public void testParseCsvInt() {
assertIntArray("Empty string", "");
assertNumberFormatException("Spaces", " ");
assertNumberFormatException("Non-decimal number", "abc");
assertIntArray("Single number", "123", 123);
assertIntArray("Negative number", "-123", -123);
assertNumberFormatException("Hexadecimal number", "1b2b");
assertIntArray("Multiple numbers", "123,456", 123, 456);
assertNumberFormatException("Non-decimal numbers", "123,abc");
assertNumberFormatException("Escaped comma", "123\\,456");
assertNumberFormatException("Escaped escape", "123\\\\,456");
}
public void testParseCsvTextZero() {
assertTextArray("Empty string", "");
}

View File

@ -32,8 +32,6 @@ public class PopupCharactersParserTests extends AndroidTestCase {
private int mCodeSettings;
private Drawable mIconSettings;
private static final Integer[] DUMMY_CODES = { 0 };
@Override
protected void setUp() {
Resources res = getContext().getResources();
@ -47,7 +45,7 @@ public class PopupCharactersParserTests extends AndroidTestCase {
}
private void assertParser(String message, String popupSpec, String expectedLabel,
String expectedOutputText, Drawable expectedIcon, Integer ... expectedCodes) {
String expectedOutputText, Drawable expectedIcon, int expectedCode) {
String actualLabel = PopupCharactersParser.getLabel(popupSpec);
assertEquals(message + ": label:", expectedLabel, actualLabel);
@ -62,28 +60,15 @@ public class PopupCharactersParserTests extends AndroidTestCase {
assertNotNull(message + ": icon non-null:", actualIcon);
}
int[] actualCodes = PopupCharactersParser.getCodes(mRes, popupSpec);
if (expectedCodes == null) {
assertNull(message + ": codes null:", actualCodes);
return;
}
assertSame(message + ": codes length:", expectedCodes.length, actualCodes.length);
for (int i = 0; i < actualCodes.length; i++) {
assertEquals(message + ": codes value at " + i + ":", (int)expectedCodes[i],
actualCodes[i]);
}
int actualCode = PopupCharactersParser.getCode(mRes, popupSpec);
assertEquals(message + ": codes value:", expectedCode, actualCode);
}
private void assertParserError(String message, String popupSpec, String expectedLabel,
String expectedOutputText, Drawable expectedIcon, Integer ... expectedCodes) {
String expectedOutputText, Drawable expectedIcon, int expectedCode) {
try {
if (expectedCodes.length > 0) {
assertParser(message, popupSpec, expectedLabel, expectedOutputText, expectedIcon,
expectedCodes);
} else {
assertParser(message, popupSpec, expectedLabel, expectedOutputText, expectedIcon,
DUMMY_CODES);
}
assertParser(message, popupSpec, expectedLabel, expectedOutputText, expectedIcon,
expectedCode);
fail(message);
} catch (PopupCharactersParser.PopupCharactersParserError pcpe) {
// success.
@ -91,71 +76,83 @@ public class PopupCharactersParserTests extends AndroidTestCase {
}
public void testSingleLetter() {
assertParser("Single letter", "a", "a", null, null, (int)'a');
assertParser("Single escaped bar", "\\|", "|", null, null, (int)'|');
assertParser("Single escaped escape", "\\\\", "\\", null, null, (int)'\\');
assertParser("Single comma", ",", ",", null, null, (int)',');
assertParser("Single escaped comma", "\\,", ",", null, null, (int)',');
assertParser("Single escaped letter", "\\a", "a", null, null, (int)'a');
assertParser("Single at", "@", "@", null, null, (int)'@');
assertParser("Single escaped at", "\\@", "@", null, null, (int)'@');
assertParser("Single letter with outputText", "a|abc", "a", "abc", null, DUMMY_CODES);
assertParser("Single letter", "a", "a", null, null, 'a');
assertParser("Single escaped bar", "\\|", "|", null, null, '|');
assertParser("Single escaped escape", "\\\\", "\\", null, null, '\\');
assertParser("Single comma", ",", ",", null, null, ',');
assertParser("Single escaped comma", "\\,", ",", null, null, ',');
assertParser("Single escaped letter", "\\a", "a", null, null, 'a');
assertParser("Single at", "@", "@", null, null, '@');
assertParser("Single escaped at", "\\@", "@", null, null, '@');
assertParser("Single letter with outputText", "a|abc", "a", "abc", null,
Keyboard.CODE_DUMMY);
assertParser("Single letter with escaped outputText", "a|a\\|c", "a", "a|c", null,
DUMMY_CODES);
assertParser("Single letter with comma outputText", "a|a,b", "a", "a,b", null, DUMMY_CODES);
Keyboard.CODE_DUMMY);
assertParser("Single letter with comma outputText", "a|a,b", "a", "a,b", null,
Keyboard.CODE_DUMMY);
assertParser("Single letter with escaped comma outputText", "a|a\\,b", "a", "a,b", null,
DUMMY_CODES);
Keyboard.CODE_DUMMY);
assertParser("Single letter with outputText starts with at", "a|@bc", "a", "@bc", null,
DUMMY_CODES);
Keyboard.CODE_DUMMY);
assertParser("Single letter with outputText contains at", "a|a@c", "a", "a@c", null,
DUMMY_CODES);
Keyboard.CODE_DUMMY);
assertParser("Single letter with escaped at outputText", "a|\\@bc", "a", "@bc", null,
DUMMY_CODES);
Keyboard.CODE_DUMMY);
assertParser("Single escaped escape with outputText", "\\\\|\\\\", "\\", "\\", null,
DUMMY_CODES);
assertParser("Single escaped bar with outputText", "\\||\\|", "|", "|", null, DUMMY_CODES);
Keyboard.CODE_DUMMY);
assertParser("Single escaped bar with outputText", "\\||\\|", "|", "|", null,
Keyboard.CODE_DUMMY);
assertParser("Single letter with code", "a|" + CODE_SETTINGS, "a", null, null,
mCodeSettings);
}
public void testLabel() {
assertParser("Simple label", "abc", "abc", "abc", null, DUMMY_CODES);
assertParser("Label with escaped bar", "a\\|c", "a|c", "a|c", null, DUMMY_CODES);
assertParser("Label with escaped escape", "a\\\\c", "a\\c", "a\\c", null, DUMMY_CODES);
assertParser("Label with comma", "a,c", "a,c", "a,c", null, DUMMY_CODES);
assertParser("Label with escaped comma", "a\\,c", "a,c", "a,c", null, DUMMY_CODES);
assertParser("Label starts with at", "@bc", "@bc", "@bc", null, DUMMY_CODES);
assertParser("Label contains at", "a@c", "a@c", "a@c", null, DUMMY_CODES);
assertParser("Label with escaped at", "\\@bc", "@bc", "@bc", null, DUMMY_CODES);
assertParser("Label with escaped letter", "\\abc", "abc", "abc", null, DUMMY_CODES);
assertParser("Label with outputText", "abc|def", "abc", "def", null, DUMMY_CODES);
assertParser("Label with comma and outputText", "a,c|def", "a,c", "def", null, DUMMY_CODES);
assertParser("Simple label", "abc", "abc", "abc", null, Keyboard.CODE_DUMMY);
assertParser("Label with escaped bar", "a\\|c", "a|c", "a|c", null,
Keyboard.CODE_DUMMY);
assertParser("Label with escaped escape", "a\\\\c", "a\\c", "a\\c", null,
Keyboard.CODE_DUMMY);
assertParser("Label with comma", "a,c", "a,c", "a,c", null, Keyboard.CODE_DUMMY);
assertParser("Label with escaped comma", "a\\,c", "a,c", "a,c", null,
Keyboard.CODE_DUMMY);
assertParser("Label starts with at", "@bc", "@bc", "@bc", null, Keyboard.CODE_DUMMY);
assertParser("Label contains at", "a@c", "a@c", "a@c", null, Keyboard.CODE_DUMMY);
assertParser("Label with escaped at", "\\@bc", "@bc", "@bc", null,
Keyboard.CODE_DUMMY);
assertParser("Label with escaped letter", "\\abc", "abc", "abc", null,
Keyboard.CODE_DUMMY);
assertParser("Label with outputText", "abc|def", "abc", "def", null,
Keyboard.CODE_DUMMY);
assertParser("Label with comma and outputText", "a,c|def", "a,c", "def", null,
Keyboard.CODE_DUMMY);
assertParser("Escaped comma label with outputText", "a\\,c|def", "a,c", "def", null,
DUMMY_CODES);
assertParser("Escaped label with outputText", "a\\|c|def", "a|c", "def", null, DUMMY_CODES);
Keyboard.CODE_DUMMY);
assertParser("Escaped label with outputText", "a\\|c|def", "a|c", "def", null,
Keyboard.CODE_DUMMY);
assertParser("Label with escaped bar outputText", "abc|d\\|f", "abc", "d|f", null,
DUMMY_CODES);
Keyboard.CODE_DUMMY);
assertParser("Escaped escape label with outputText", "a\\\\|def", "a\\", "def", null,
DUMMY_CODES);
Keyboard.CODE_DUMMY);
assertParser("Label starts with at and outputText", "@bc|def", "@bc", "def", null,
DUMMY_CODES);
Keyboard.CODE_DUMMY);
assertParser("Label contains at label and outputText", "a@c|def", "a@c", "def", null,
DUMMY_CODES);
Keyboard.CODE_DUMMY);
assertParser("Escaped at label with outputText", "\\@bc|def", "@bc", "def", null,
DUMMY_CODES);
assertParser("Label with comma outputText", "abc|a,b", "abc", "a,b", null, DUMMY_CODES);
Keyboard.CODE_DUMMY);
assertParser("Label with comma outputText", "abc|a,b", "abc", "a,b", null,
Keyboard.CODE_DUMMY);
assertParser("Label with escaped comma outputText", "abc|a\\,b", "abc", "a,b", null,
DUMMY_CODES);
Keyboard.CODE_DUMMY);
assertParser("Label with outputText starts with at", "abc|@bc", "abc", "@bc", null,
DUMMY_CODES);
Keyboard.CODE_DUMMY);
assertParser("Label with outputText contains at", "abc|a@c", "abc", "a@c", null,
DUMMY_CODES);
Keyboard.CODE_DUMMY);
assertParser("Label with escaped at outputText", "abc|\\@bc", "abc", "@bc", null,
DUMMY_CODES);
Keyboard.CODE_DUMMY);
assertParser("Label with escaped bar outputText", "abc|d\\|f", "abc", "d|f",
null, DUMMY_CODES);
null, Keyboard.CODE_DUMMY);
assertParser("Escaped bar label with escaped bar outputText", "a\\|c|d\\|f", "a|c", "d|f",
null, DUMMY_CODES);
null, Keyboard.CODE_DUMMY);
assertParser("Label with code", "abc|" + CODE_SETTINGS, "abc", null, null, mCodeSettings);
assertParser("Escaped label with code", "a\\|c|" + CODE_SETTINGS, "a|c", null, null,
mCodeSettings);
@ -163,13 +160,13 @@ public class PopupCharactersParserTests extends AndroidTestCase {
public void testIconAndCode() {
assertParser("Icon with outputText", ICON_SETTINGS + "|abc", null, "abc", mIconSettings,
DUMMY_CODES);
Keyboard.CODE_DUMMY);
assertParser("Icon with outputText starts with at", ICON_SETTINGS + "|@bc", null, "@bc",
mIconSettings, DUMMY_CODES);
mIconSettings, Keyboard.CODE_DUMMY);
assertParser("Icon with outputText contains at", ICON_SETTINGS + "|a@c", null, "a@c",
mIconSettings, DUMMY_CODES);
mIconSettings, Keyboard.CODE_DUMMY);
assertParser("Icon with escaped at outputText", ICON_SETTINGS + "|\\@bc", null, "@bc",
mIconSettings, DUMMY_CODES);
mIconSettings, Keyboard.CODE_DUMMY);
assertParser("Label starts with at and code", "@bc|" + CODE_SETTINGS, "@bc", null, null,
mCodeSettings);
assertParser("Label contains at and code", "a@c|" + CODE_SETTINGS, "a@c", null, null,
@ -181,23 +178,28 @@ public class PopupCharactersParserTests extends AndroidTestCase {
}
public void testFormatError() {
assertParserError("Empty spec", "", null, null, null);
assertParserError("Empty label with outputText", "|a", null, "a", null);
assertParserError("Empty spec", "", null, null, null, Keyboard.CODE_UNSPECIFIED);
assertParserError("Empty label with outputText", "|a", null, "a", null,
Keyboard.CODE_DUMMY);
assertParserError("Empty label with code", "|" + CODE_SETTINGS, null, null, null,
mCodeSettings);
assertParserError("Empty outputText with label", "a|", "a", null, null);
assertParserError("Empty outputText with label", "a|", "a", null, null,
Keyboard.CODE_UNSPECIFIED);
assertParserError("Empty outputText with icon", ICON_SETTINGS + "|", null, null,
mIconSettings);
assertParserError("Empty icon and code", "|", null, null, null);
assertParserError("Icon without code", ICON_SETTINGS, null, null, mIconSettings);
assertParserError("Non existing icon", ICON_NON_EXISTING + "|abc", null, "abc", null);
assertParserError("Non existing code", "abc|" + CODE_NON_EXISTING, "abc", null, null);
assertParserError("Third bar at end", "a|b|", "a", null, null);
assertParserError("Multiple bar", "a|b|c", "a", null, null);
mIconSettings, Keyboard.CODE_UNSPECIFIED);
assertParserError("Empty icon and code", "|", null, null, null, Keyboard.CODE_UNSPECIFIED);
assertParserError("Icon without code", ICON_SETTINGS, null, null, mIconSettings,
Keyboard.CODE_DUMMY);
assertParserError("Non existing icon", ICON_NON_EXISTING + "|abc", null, "abc", null,
Keyboard.CODE_DUMMY);
assertParserError("Non existing code", "abc|" + CODE_NON_EXISTING, "abc", null, null,
Keyboard.CODE_UNSPECIFIED);
assertParserError("Third bar at end", "a|b|", "a", null, null, Keyboard.CODE_UNSPECIFIED);
assertParserError("Multiple bar", "a|b|c", "a", null, null, Keyboard.CODE_UNSPECIFIED);
assertParserError("Multiple bar with label and code", "a|" + CODE_SETTINGS + "|c", "a",
null, null, mCodeSettings);
assertParserError("Multiple bar with icon and outputText", ICON_SETTINGS + "|b|c", null,
null, mIconSettings);
null, mIconSettings, Keyboard.CODE_UNSPECIFIED);
assertParserError("Multiple bar with icon and code",
ICON_SETTINGS + "|" + CODE_SETTINGS + "|c", null, null, mIconSettings,
mCodeSettings);