Setting to move microphone to secondary keyboard.

Microphone button can be optionally moved to the symbols keyboard
to get your comma back. You can also completely disable voice input.

Now you can get your comma back but still use the swipe gesture to
activate voice input.
main
Amith Yamasani 2010-01-28 07:33:27 -08:00
parent 7a722cbfc8
commit b1cd701602
10 changed files with 107 additions and 466 deletions

View File

@ -252,6 +252,12 @@
<!-- Preferences item for enabling speech input --> <!-- Preferences item for enabling speech input -->
<string name="enable_voice">Voice input</string> <string name="enable_voice">Voice input</string>
<!-- Preferences item for speech icon on primary keyboard -->
<string name="voice_on_primary">Mic on primary</string>
<!-- Preferences item summary for speech icon on primary keyboard -->
<string name="voice_on_primary_summary">Show the microphone on the primary keyboard</string>
<!-- Press the "enter" key after the user speaks. Option on settings.--> <!-- Press the "enter" key after the user speaks. Option on settings.-->
<string name="auto_submit">Auto submit after voice</string> <string name="auto_submit">Auto submit after voice</string>

View File

@ -100,25 +100,7 @@
android:popupKeyboard="@xml/kbd_popup_template" android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="_" android:popupCharacters="_"
android:keyWidth="20%p" android:keyEdgeFlags="left"/> android:keyWidth="20%p" android:keyEdgeFlags="left"/>
<Key android:codes="@integer/key_f1" android:keyIcon="@drawable/sym_keyboard_globe" <Key android:codes="@integer/key_f1"
android:keyWidth="10%p"/>
<Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
android:iconPreview="@drawable/sym_keyboard_feedback_space"
android:keyWidth="40%p" android:isRepeatable="true"/>
<Key android:codes="46" android:keyLabel="." android:popupKeyboard="@xml/popup_punctuation"
android:keyWidth="10%p"/>
<Key android:codes="10" android:keyIcon="@drawable/sym_keyboard_return"
android:iconPreview="@drawable/sym_keyboard_feedback_return"
android:keyWidth="20%p" android:keyEdgeFlags="right"/>
</Row>
<Row android:keyboardMode="@+id/mode_normal_voice" android:rowEdgeFlags="bottom">
<Key android:codes="-2" android:keyLabel="@string/label_symbol_key"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="_"
android:keyWidth="20%p" android:keyEdgeFlags="left"/>
<Key android:codes="-102" android:keyIcon="@drawable/sym_keyboard_mic"
android:iconPreview="@drawable/sym_keyboard_feedback_mic"
android:keyWidth="10%p"/> android:keyWidth="10%p"/>
<Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space" <Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
android:iconPreview="@drawable/sym_keyboard_feedback_space" android:iconPreview="@drawable/sym_keyboard_feedback_space"
@ -150,26 +132,6 @@
android:keyWidth="20%p" android:keyEdgeFlags="right"/> android:keyWidth="20%p" android:keyEdgeFlags="right"/>
</Row> </Row>
<Row android:keyboardMode="@+id/mode_url_voice" android:rowEdgeFlags="bottom">
<Key android:codes="-2" android:keyLabel="@string/label_symbol_key"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="_"
android:keyWidth="20%p" android:keyEdgeFlags="left"/>
<Key android:keyLabel="/" android:keyWidth="10%p"/>
<Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
android:iconPreview="@drawable/sym_keyboard_feedback_space"
android:keyWidth="20%p" android:isRepeatable="true"/>
<Key android:keyLabel="@string/popular_domain_0"
android:keyOutputText="@string/popular_domain_0"
android:popupKeyboard="@xml/popup_domains"
android:keyWidth="20%p"/>
<Key android:keyLabel="." android:popupKeyboard="@xml/popup_punctuation"
android:keyWidth="10%p"/>
<Key android:codes="10" android:keyIcon="@drawable/sym_keyboard_return"
android:iconPreview="@drawable/sym_keyboard_feedback_return"
android:keyWidth="20%p" android:keyEdgeFlags="right"/>
</Row>
<Row android:keyboardMode="@+id/mode_email" android:rowEdgeFlags="bottom"> <Row android:keyboardMode="@+id/mode_email" android:rowEdgeFlags="bottom">
<Key android:codes="-2" android:keyLabel="@string/label_symbol_key" <Key android:codes="-2" android:keyLabel="@string/label_symbol_key"
android:popupKeyboard="@xml/kbd_popup_template" android:popupKeyboard="@xml/kbd_popup_template"
@ -189,25 +151,6 @@
android:keyWidth="20%p" android:keyEdgeFlags="right"/> android:keyWidth="20%p" android:keyEdgeFlags="right"/>
</Row> </Row>
<Row android:keyboardMode="@+id/mode_email_voice" android:rowEdgeFlags="bottom">
<Key android:codes="-2" android:keyLabel="@string/label_symbol_key"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="_"
android:keyWidth="20%p" android:keyEdgeFlags="left"/>
<Key android:keyLabel="\@"/>
<Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
android:iconPreview="@drawable/sym_keyboard_feedback_space"
android:keyWidth="20%p" android:isRepeatable="true"/>
<Key android:keyLabel="@string/popular_domain_0"
android:keyOutputText="@string/popular_domain_0"
android:popupKeyboard="@xml/popup_domains"
android:keyWidth="20%p"/>
<Key android:keyLabel="." android:popupKeyboard="@xml/popup_punctuation"/>
<Key android:codes="10" android:keyIcon="@drawable/sym_keyboard_return"
android:iconPreview="@drawable/sym_keyboard_feedback_return"
android:keyWidth="20%p" android:keyEdgeFlags="right"/>
</Row>
<Row android:keyboardMode="@+id/mode_im" android:rowEdgeFlags="bottom"> <Row android:keyboardMode="@+id/mode_im" android:rowEdgeFlags="bottom">
<Key android:codes="-2" android:keyLabel="@string/label_symbol_key" <Key android:codes="-2" android:keyLabel="@string/label_symbol_key"
android:popupKeyboard="@xml/kbd_popup_template" android:popupKeyboard="@xml/kbd_popup_template"
@ -225,24 +168,6 @@
android:keyWidth="20%p" android:keyEdgeFlags="right"/> android:keyWidth="20%p" android:keyEdgeFlags="right"/>
</Row> </Row>
<Row android:keyboardMode="@+id/mode_im_voice" android:rowEdgeFlags="bottom">
<Key android:codes="-2" android:keyLabel="@string/label_symbol_key"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="_"
android:keyWidth="20%p" android:keyEdgeFlags="left"/>
<Key android:codes="-102" android:keyIcon="@drawable/sym_keyboard_mic"
android:iconPreview="@drawable/sym_keyboard_feedback_mic"
android:keyWidth="10%p"/>
<Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
android:iconPreview="@drawable/sym_keyboard_feedback_space"
android:keyWidth="40%p" android:isRepeatable="true"/>
<Key android:codes="46" android:keyLabel="." android:popupKeyboard="@xml/popup_punctuation"
android:keyWidth="10%p"/>
<Key android:keyLabel=":-)" android:keyOutputText=":-) "
android:popupKeyboard="@xml/popup_smileys"
android:keyWidth="20%p" android:keyEdgeFlags="right"/>
</Row>
<Row android:keyboardMode="@+id/mode_webentry" android:rowEdgeFlags="bottom"> <Row android:keyboardMode="@+id/mode_webentry" android:rowEdgeFlags="bottom">
<Key android:codes="-2" android:keyLabel="@string/label_symbol_key" <Key android:codes="-2" android:keyLabel="@string/label_symbol_key"
android:popupKeyboard="@xml/kbd_popup_template" android:popupKeyboard="@xml/kbd_popup_template"
@ -261,24 +186,4 @@
android:iconPreview="@drawable/sym_keyboard_feedback_return" android:iconPreview="@drawable/sym_keyboard_feedback_return"
android:keyWidth="20%p" android:keyEdgeFlags="right"/> android:keyWidth="20%p" android:keyEdgeFlags="right"/>
</Row> </Row>
<Row android:keyboardMode="@+id/mode_webentry_voice" android:rowEdgeFlags="bottom">
<Key android:codes="-2" android:keyLabel="@string/label_symbol_key"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="_"
android:keyWidth="20%p" android:keyEdgeFlags="left"/>
<Key android:codes="-102" android:keyIcon="@drawable/sym_keyboard_mic"
android:iconPreview="@drawable/sym_keyboard_feedback_mic"
android:keyWidth="10%p"/>
<Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
android:iconPreview="@drawable/sym_keyboard_feedback_space"
android:keyWidth="20%p" android:isRepeatable="true"/>
<Key android:codes="9" android:keyIcon="@drawable/sym_keyboard_tab"
android:iconPreview="@drawable/sym_keyboard_feedback_tab"
android:keyWidth="20%p"/>
<Key android:keyLabel="." android:popupKeyboard="@xml/popup_punctuation"/>
<Key android:codes="10" android:keyIcon="@drawable/sym_keyboard_return"
android:iconPreview="@drawable/sym_keyboard_feedback_return"
android:keyWidth="20%p" android:keyEdgeFlags="right"/>
</Row>
</Keyboard> </Keyboard>

View File

@ -114,24 +114,6 @@
android:keyWidth="20%p" android:keyEdgeFlags="right"/> android:keyWidth="20%p" android:keyEdgeFlags="right"/>
</Row> </Row>
<Row android:keyboardMode="@+id/mode_normal_voice" android:rowEdgeFlags="bottom">
<Key android:codes="-2" android:keyLabel="@string/label_symbol_key"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="_"
android:keyWidth="20%p" android:keyEdgeFlags="left"/>
<Key android:codes="-102" android:keyIcon="@drawable/sym_keyboard_mic"
android:iconPreview="@drawable/sym_keyboard_feedback_mic"
android:keyWidth="10%p"/>
<Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
android:iconPreview="@drawable/sym_keyboard_feedback_space"
android:keyWidth="40%p" android:isRepeatable="true"/>
<Key android:codes="46" android:keyLabel="." android:popupKeyboard="@xml/popup_punctuation"
android:keyWidth="10%p"/>
<Key android:codes="10" android:keyIcon="@drawable/sym_keyboard_return"
android:iconPreview="@drawable/sym_keyboard_feedback_return"
android:keyWidth="20%p" android:keyEdgeFlags="right"/>
</Row>
<Row android:keyboardMode="@+id/mode_url" android:rowEdgeFlags="bottom"> <Row android:keyboardMode="@+id/mode_url" android:rowEdgeFlags="bottom">
<Key android:codes="-2" android:keyLabel="@string/label_symbol_key" <Key android:codes="-2" android:keyLabel="@string/label_symbol_key"
android:popupKeyboard="@xml/kbd_popup_template" android:popupKeyboard="@xml/kbd_popup_template"
@ -152,26 +134,6 @@
android:keyWidth="20%p" android:keyEdgeFlags="right"/> android:keyWidth="20%p" android:keyEdgeFlags="right"/>
</Row> </Row>
<Row android:keyboardMode="@+id/mode_url_voice" android:rowEdgeFlags="bottom">
<Key android:codes="-2" android:keyLabel="@string/label_symbol_key"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="_"
android:keyWidth="20%p" android:keyEdgeFlags="left"/>
<Key android:keyLabel="/" android:keyWidth="10%p"/>
<Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
android:iconPreview="@drawable/sym_keyboard_feedback_space"
android:keyWidth="20%p" android:isRepeatable="true"/>
<Key android:keyLabel="@string/popular_domain_0"
android:keyOutputText="@string/popular_domain_0"
android:popupKeyboard="@xml/popup_domains"
android:keyWidth="20%p"/>
<Key android:keyLabel="." android:popupKeyboard="@xml/popup_punctuation"
android:keyWidth="10%p"/>
<Key android:codes="10" android:keyIcon="@drawable/sym_keyboard_return"
android:iconPreview="@drawable/sym_keyboard_feedback_return"
android:keyWidth="20%p" android:keyEdgeFlags="right"/>
</Row>
<Row android:keyboardMode="@+id/mode_email" android:rowEdgeFlags="bottom"> <Row android:keyboardMode="@+id/mode_email" android:rowEdgeFlags="bottom">
<Key android:codes="-2" android:keyLabel="@string/label_symbol_key" <Key android:codes="-2" android:keyLabel="@string/label_symbol_key"
android:popupKeyboard="@xml/kbd_popup_template" android:popupKeyboard="@xml/kbd_popup_template"
@ -191,25 +153,6 @@
android:keyWidth="20%p" android:keyEdgeFlags="right"/> android:keyWidth="20%p" android:keyEdgeFlags="right"/>
</Row> </Row>
<Row android:keyboardMode="@+id/mode_email_voice" android:rowEdgeFlags="bottom">
<Key android:codes="-2" android:keyLabel="@string/label_symbol_key"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="_"
android:keyWidth="20%p" android:keyEdgeFlags="left"/>
<Key android:keyLabel="\@"/>
<Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
android:iconPreview="@drawable/sym_keyboard_feedback_space"
android:keyWidth="20%p" android:isRepeatable="true"/>
<Key android:keyLabel="@string/popular_domain_0"
android:keyOutputText="@string/popular_domain_0"
android:popupKeyboard="@xml/popup_domains"
android:keyWidth="20%p"/>
<Key android:keyLabel="." android:popupKeyboard="@xml/popup_punctuation"/>
<Key android:codes="10" android:keyIcon="@drawable/sym_keyboard_return"
android:iconPreview="@drawable/sym_keyboard_feedback_return"
android:keyWidth="20%p" android:keyEdgeFlags="right"/>
</Row>
<Row android:keyboardMode="@+id/mode_im" android:rowEdgeFlags="bottom"> <Row android:keyboardMode="@+id/mode_im" android:rowEdgeFlags="bottom">
<Key android:codes="-2" android:keyLabel="@string/label_symbol_key" <Key android:codes="-2" android:keyLabel="@string/label_symbol_key"
android:popupKeyboard="@xml/kbd_popup_template" android:popupKeyboard="@xml/kbd_popup_template"
@ -227,24 +170,6 @@
android:keyWidth="20%p" android:keyEdgeFlags="right"/> android:keyWidth="20%p" android:keyEdgeFlags="right"/>
</Row> </Row>
<Row android:keyboardMode="@+id/mode_im_voice" android:rowEdgeFlags="bottom">
<Key android:codes="-2" android:keyLabel="@string/label_symbol_key"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="_"
android:keyWidth="20%p" android:keyEdgeFlags="left"/>
<Key android:codes="-102" android:keyIcon="@drawable/sym_keyboard_mic"
android:iconPreview="@drawable/sym_keyboard_feedback_mic"
android:keyWidth="10%p"/>
<Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
android:iconPreview="@drawable/sym_keyboard_feedback_space"
android:keyWidth="40%p" android:isRepeatable="true"/>
<Key android:codes="46" android:keyLabel="." android:popupKeyboard="@xml/popup_punctuation"
android:keyWidth="10%p"/>
<Key android:keyLabel=":-)" android:keyOutputText=":-) "
android:popupKeyboard="@xml/popup_smileys"
android:keyWidth="20%p" android:keyEdgeFlags="right"/>
</Row>
<Row android:keyboardMode="@+id/mode_webentry" android:rowEdgeFlags="bottom"> <Row android:keyboardMode="@+id/mode_webentry" android:rowEdgeFlags="bottom">
<Key android:codes="-2" android:keyLabel="@string/label_symbol_key" <Key android:codes="-2" android:keyLabel="@string/label_symbol_key"
android:popupKeyboard="@xml/kbd_popup_template" android:popupKeyboard="@xml/kbd_popup_template"
@ -264,25 +189,5 @@
android:keyWidth="20%p" android:keyEdgeFlags="right"/> android:keyWidth="20%p" android:keyEdgeFlags="right"/>
</Row> </Row>
<Row android:keyboardMode="@+id/mode_webentry_voice" android:rowEdgeFlags="bottom">
<Key android:codes="-2" android:keyLabel="@string/label_symbol_key"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="_"
android:keyWidth="20%p" android:keyEdgeFlags="left"/>
<Key android:codes="-102" android:keyIcon="@drawable/sym_keyboard_mic"
android:iconPreview="@drawable/sym_keyboard_feedback_mic"
android:keyWidth="10%p"/>
<Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
android:iconPreview="@drawable/sym_keyboard_feedback_space"
android:keyWidth="20%p" android:isRepeatable="true"/>
<Key android:codes="9" android:keyIcon="@drawable/sym_keyboard_tab"
android:iconPreview="@drawable/sym_keyboard_feedback_tab"
android:keyWidth="20%p"/>
<Key android:keyLabel="." android:popupKeyboard="@xml/popup_punctuation"/>
<Key android:codes="10" android:keyIcon="@drawable/sym_keyboard_return"
android:iconPreview="@drawable/sym_keyboard_feedback_return"
android:keyWidth="20%p" android:keyEdgeFlags="right"/>
</Row>
</Keyboard> </Keyboard>

View File

@ -96,24 +96,6 @@
android:keyWidth="20%p" android:keyEdgeFlags="right"/> android:keyWidth="20%p" android:keyEdgeFlags="right"/>
</Row> </Row>
<Row android:keyboardMode="@+id/mode_normal_voice" android:rowEdgeFlags="bottom">
<Key android:codes="-2" android:keyLabel="@string/label_symbol_key"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="_"
android:keyWidth="20%p" android:keyEdgeFlags="left"/>
<Key android:codes="-102" android:keyIcon="@drawable/sym_keyboard_mic"
android:iconPreview="@drawable/sym_keyboard_feedback_mic"
android:keyWidth="10%p"/>
<Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
android:iconPreview="@drawable/sym_keyboard_feedback_space"
android:keyWidth="40%p" android:isRepeatable="true"/>
<Key android:codes="46" android:keyLabel="." android:popupKeyboard="@xml/popup_punctuation"
android:keyWidth="10%p"/>
<Key android:codes="10" android:keyIcon="@drawable/sym_keyboard_return"
android:iconPreview="@drawable/sym_keyboard_feedback_return"
android:keyWidth="20%p" android:keyEdgeFlags="right"/>
</Row>
<Row android:keyboardMode="@+id/mode_url" android:rowEdgeFlags="bottom"> <Row android:keyboardMode="@+id/mode_url" android:rowEdgeFlags="bottom">
<Key android:codes="-2" android:keyLabel="@string/label_symbol_key" <Key android:codes="-2" android:keyLabel="@string/label_symbol_key"
android:popupKeyboard="@xml/kbd_popup_template" android:popupKeyboard="@xml/kbd_popup_template"
@ -134,26 +116,6 @@
android:keyWidth="20%p" android:keyEdgeFlags="right"/> android:keyWidth="20%p" android:keyEdgeFlags="right"/>
</Row> </Row>
<Row android:keyboardMode="@+id/mode_url_voice" android:rowEdgeFlags="bottom">
<Key android:codes="-2" android:keyLabel="@string/label_symbol_key"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="_"
android:keyWidth="20%p" android:keyEdgeFlags="left"/>
<Key android:keyLabel="/" android:keyWidth="10%p"/>
<Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
android:iconPreview="@drawable/sym_keyboard_feedback_space"
android:keyWidth="20%p" android:isRepeatable="true"/>
<Key android:keyLabel="@string/popular_domain_0"
android:keyOutputText="@string/popular_domain_0"
android:popupKeyboard="@xml/popup_domains"
android:keyWidth="20%p"/>
<Key android:keyLabel="." android:popupKeyboard="@xml/popup_punctuation"
android:keyWidth="10%p"/>
<Key android:codes="10" android:keyIcon="@drawable/sym_keyboard_return"
android:iconPreview="@drawable/sym_keyboard_feedback_return"
android:keyWidth="20%p" android:keyEdgeFlags="right"/>
</Row>
<Row android:keyboardMode="@+id/mode_email" android:rowEdgeFlags="bottom"> <Row android:keyboardMode="@+id/mode_email" android:rowEdgeFlags="bottom">
<Key android:codes="-2" android:keyLabel="@string/label_symbol_key" <Key android:codes="-2" android:keyLabel="@string/label_symbol_key"
android:popupKeyboard="@xml/kbd_popup_template" android:popupKeyboard="@xml/kbd_popup_template"
@ -173,25 +135,6 @@
android:keyWidth="20%p" android:keyEdgeFlags="right"/> android:keyWidth="20%p" android:keyEdgeFlags="right"/>
</Row> </Row>
<Row android:keyboardMode="@+id/mode_email_voice" android:rowEdgeFlags="bottom">
<Key android:codes="-2" android:keyLabel="@string/label_symbol_key"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="_"
android:keyWidth="20%p" android:keyEdgeFlags="left"/>
<Key android:keyLabel="\@" android:keyWidth="10%p"/>
<Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
android:iconPreview="@drawable/sym_keyboard_feedback_space"
android:keyWidth="20%p" android:isRepeatable="true"/>
<Key android:keyLabel="@string/popular_domain_0"
android:keyOutputText="@string/popular_domain_0"
android:popupKeyboard="@xml/popup_domains"
android:keyWidth="20%p"/>
<Key android:keyLabel="." android:popupKeyboard="@xml/popup_punctuation"/>
<Key android:codes="10" android:keyIcon="@drawable/sym_keyboard_return"
android:iconPreview="@drawable/sym_keyboard_feedback_return"
android:keyWidth="20%p" android:keyEdgeFlags="right"/>
</Row>
<Row android:keyboardMode="@+id/mode_im" android:rowEdgeFlags="bottom"> <Row android:keyboardMode="@+id/mode_im" android:rowEdgeFlags="bottom">
<Key android:codes="-2" android:keyLabel="@string/label_symbol_key" <Key android:codes="-2" android:keyLabel="@string/label_symbol_key"
android:popupKeyboard="@xml/kbd_popup_template" android:popupKeyboard="@xml/kbd_popup_template"
@ -209,24 +152,6 @@
android:keyWidth="20%p" android:keyEdgeFlags="right"/> android:keyWidth="20%p" android:keyEdgeFlags="right"/>
</Row> </Row>
<Row android:keyboardMode="@+id/mode_im_voice" android:rowEdgeFlags="bottom">
<Key android:codes="-2" android:keyLabel="@string/label_symbol_key"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="_"
android:keyWidth="20%p" android:keyEdgeFlags="left"/>
<Key android:codes="-102" android:keyIcon="@drawable/sym_keyboard_mic"
android:iconPreview="@drawable/sym_keyboard_feedback_mic"
android:keyWidth="10%p"/>
<Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
android:iconPreview="@drawable/sym_keyboard_feedback_space"
android:keyWidth="40%p" android:isRepeatable="true"/>
<Key android:codes="46" android:keyLabel="." android:popupKeyboard="@xml/popup_punctuation"
android:keyWidth="10%p"/>
<Key android:keyLabel=":-)" android:keyOutputText=":-) "
android:popupKeyboard="@xml/popup_smileys"
android:keyWidth="20%p" android:keyEdgeFlags="right"/>
</Row>
<Row android:keyboardMode="@+id/mode_webentry" android:rowEdgeFlags="bottom"> <Row android:keyboardMode="@+id/mode_webentry" android:rowEdgeFlags="bottom">
<Key android:codes="-2" android:keyLabel="@string/label_symbol_key" <Key android:codes="-2" android:keyLabel="@string/label_symbol_key"
android:popupKeyboard="@xml/kbd_popup_template" android:popupKeyboard="@xml/kbd_popup_template"
@ -245,26 +170,5 @@
android:iconPreview="@drawable/sym_keyboard_feedback_return" android:iconPreview="@drawable/sym_keyboard_feedback_return"
android:keyWidth="20%p" android:keyEdgeFlags="right"/> android:keyWidth="20%p" android:keyEdgeFlags="right"/>
</Row> </Row>
<Row android:keyboardMode="@+id/mode_webentry_voice" android:rowEdgeFlags="bottom">
<Key android:codes="-2" android:keyLabel="@string/label_symbol_key"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="_"
android:keyWidth="20%p" android:keyEdgeFlags="left"/>
<Key android:codes="-102" android:keyIcon="@drawable/sym_keyboard_mic"
android:iconPreview="@drawable/sym_keyboard_feedback_mic"
android:keyWidth="10%p"/>
<Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
android:iconPreview="@drawable/sym_keyboard_feedback_space"
android:keyWidth="20%p" android:isRepeatable="true"/>
<Key android:codes="9" android:keyIcon="@drawable/sym_keyboard_tab"
android:iconPreview="@drawable/sym_keyboard_feedback_tab"
android:keyWidth="20%p"/>
<Key android:keyLabel="." android:popupKeyboard="@xml/popup_punctuation"/>
<Key android:codes="10" android:keyIcon="@drawable/sym_keyboard_return"
android:iconPreview="@drawable/sym_keyboard_feedback_return"
android:keyWidth="20%p" android:keyEdgeFlags="right"/>
</Row>
</Keyboard> </Keyboard>

View File

@ -111,24 +111,7 @@
android:popupKeyboard="@xml/kbd_popup_template" android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="_" android:popupCharacters="_"
android:keyWidth="20%p" android:keyEdgeFlags="left"/> android:keyWidth="20%p" android:keyEdgeFlags="left"/>
<Key android:codes="@integer/key_f1" android:keyIcon="@drawable/sym_keyboard_globe" <Key android:codes="@integer/key_f1" android:keyIcon="@drawable/sym_keyboard_mic"
android:keyWidth="10%p"/>
<Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
android:iconPreview="@drawable/sym_keyboard_feedback_space"
android:keyWidth="40%p" android:isRepeatable="true"/>
<Key android:codes="46" android:keyLabel="." android:popupKeyboard="@xml/popup_punctuation"
android:keyWidth="10%p"/>
<Key android:codes="10" android:keyIcon="@drawable/sym_keyboard_return"
android:iconPreview="@drawable/sym_keyboard_feedback_return"
android:keyWidth="20%p" android:keyEdgeFlags="right"/>
</Row>
<Row android:keyboardMode="@+id/mode_normal_voice" android:rowEdgeFlags="bottom">
<Key android:codes="-2" android:keyLabel="@string/label_symbol_key"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="_"
android:keyWidth="20%p" android:keyEdgeFlags="left"/>
<Key android:codes="-102" android:keyIcon="@drawable/sym_keyboard_mic"
android:iconPreview="@drawable/sym_keyboard_feedback_mic" android:iconPreview="@drawable/sym_keyboard_feedback_mic"
android:keyWidth="10%p"/> android:keyWidth="10%p"/>
<Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space" <Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
@ -161,26 +144,6 @@
android:keyWidth="20%p" android:keyEdgeFlags="right"/> android:keyWidth="20%p" android:keyEdgeFlags="right"/>
</Row> </Row>
<Row android:keyboardMode="@+id/mode_url_voice" android:rowEdgeFlags="bottom">
<Key android:codes="-2" android:keyLabel="@string/label_symbol_key"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="_"
android:keyWidth="20%p" android:keyEdgeFlags="left"/>
<Key android:keyLabel="/" android:keyWidth="10%p"/>
<Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
android:iconPreview="@drawable/sym_keyboard_feedback_space"
android:keyWidth="20%p" android:isRepeatable="true"/>
<Key android:keyLabel="@string/popular_domain_0"
android:keyOutputText="@string/popular_domain_0"
android:popupKeyboard="@xml/popup_domains"
android:keyWidth="20%p"/>
<Key android:keyLabel="." android:popupKeyboard="@xml/popup_punctuation"
android:keyWidth="10%p"/>
<Key android:codes="10" android:keyIcon="@drawable/sym_keyboard_return"
android:iconPreview="@drawable/sym_keyboard_feedback_return"
android:keyWidth="20%p" android:keyEdgeFlags="right"/>
</Row>
<Row android:keyboardMode="@+id/mode_email" android:rowEdgeFlags="bottom"> <Row android:keyboardMode="@+id/mode_email" android:rowEdgeFlags="bottom">
<Key android:codes="-2" android:keyLabel="@string/label_symbol_key" <Key android:codes="-2" android:keyLabel="@string/label_symbol_key"
android:popupKeyboard="@xml/kbd_popup_template" android:popupKeyboard="@xml/kbd_popup_template"
@ -200,48 +163,12 @@
android:keyWidth="20%p" android:keyEdgeFlags="right"/> android:keyWidth="20%p" android:keyEdgeFlags="right"/>
</Row> </Row>
<Row android:keyboardMode="@+id/mode_email_voice" android:rowEdgeFlags="bottom">
<Key android:codes="-2" android:keyLabel="@string/label_symbol_key"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="_"
android:keyWidth="20%p" android:keyEdgeFlags="left"/>
<Key android:keyLabel="\@"/>
<Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
android:iconPreview="@drawable/sym_keyboard_feedback_space"
android:keyWidth="20%p" android:isRepeatable="true"/>
<Key android:keyLabel="@string/popular_domain_0"
android:keyOutputText="@string/popular_domain_0"
android:popupKeyboard="@xml/popup_domains"
android:keyWidth="20%p"/>
<Key android:keyLabel="." android:popupKeyboard="@xml/popup_punctuation"/>
<Key android:codes="10" android:keyIcon="@drawable/sym_keyboard_return"
android:iconPreview="@drawable/sym_keyboard_feedback_return"
android:keyWidth="20%p" android:keyEdgeFlags="right"/>
</Row>
<Row android:keyboardMode="@+id/mode_im" android:rowEdgeFlags="bottom"> <Row android:keyboardMode="@+id/mode_im" android:rowEdgeFlags="bottom">
<Key android:codes="-2" android:keyLabel="@string/label_symbol_key" <Key android:codes="-2" android:keyLabel="@string/label_symbol_key"
android:popupKeyboard="@xml/kbd_popup_template" android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="_" android:popupCharacters="_"
android:keyWidth="20%p" android:keyEdgeFlags="left"/> android:keyWidth="20%p" android:keyEdgeFlags="left"/>
<Key android:codes="@integer/key_f1" android:keyIcon="@drawable/sym_keyboard_globe" <Key android:codes="@integer/key_f1" android:keyIcon="@drawable/sym_keyboard_mic"
android:keyWidth="10%p"/>
<Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
android:iconPreview="@drawable/sym_keyboard_feedback_space"
android:keyWidth="40%p" android:isRepeatable="true"/>
<Key android:codes="46" android:keyLabel="." android:popupKeyboard="@xml/popup_punctuation"
android:keyWidth="10%p"/>
<Key android:keyLabel=":-)" android:keyOutputText=":-) "
android:popupKeyboard="@xml/popup_smileys"
android:keyWidth="20%p" android:keyEdgeFlags="right"/>
</Row>
<Row android:keyboardMode="@+id/mode_im_voice" android:rowEdgeFlags="bottom">
<Key android:codes="-2" android:keyLabel="@string/label_symbol_key"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="_"
android:keyWidth="20%p" android:keyEdgeFlags="left"/>
<Key android:codes="-102" android:keyIcon="@drawable/sym_keyboard_mic"
android:iconPreview="@drawable/sym_keyboard_feedback_mic" android:iconPreview="@drawable/sym_keyboard_feedback_mic"
android:keyWidth="10%p"/> android:keyWidth="10%p"/>
<Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space" <Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
@ -259,26 +186,7 @@
android:popupKeyboard="@xml/kbd_popup_template" android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="_" android:popupCharacters="_"
android:keyWidth="20%p" android:keyEdgeFlags="left"/> android:keyWidth="20%p" android:keyEdgeFlags="left"/>
<Key android:codes="@integer/key_f1" android:keyIcon="@drawable/sym_keyboard_globe" <Key android:codes="@integer/key_f1" android:keyIcon="@drawable/sym_keyboard_mic"
android:keyWidth="10%p"/>
<Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
android:iconPreview="@drawable/sym_keyboard_feedback_space"
android:keyWidth="20%p" android:isRepeatable="true"/>
<Key android:codes="9" android:keyIcon="@drawable/sym_keyboard_tab"
android:iconPreview="@drawable/sym_keyboard_feedback_tab"
android:keyWidth="20%p"/>
<Key android:keyLabel="." android:popupKeyboard="@xml/popup_punctuation"/>
<Key android:codes="10" android:keyIcon="@drawable/sym_keyboard_return"
android:iconPreview="@drawable/sym_keyboard_feedback_return"
android:keyWidth="20%p" android:keyEdgeFlags="right"/>
</Row>
<Row android:keyboardMode="@+id/mode_webentry_voice" android:rowEdgeFlags="bottom">
<Key android:codes="-2" android:keyLabel="@string/label_symbol_key"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="_"
android:keyWidth="20%p" android:keyEdgeFlags="left"/>
<Key android:codes="-102" android:keyIcon="@drawable/sym_keyboard_mic"
android:iconPreview="@drawable/sym_keyboard_feedback_mic" android:iconPreview="@drawable/sym_keyboard_feedback_mic"
android:keyWidth="10%p"/> android:keyWidth="10%p"/>
<Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space" <Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"

View File

@ -126,10 +126,7 @@
android:popupKeyboard="@xml/kbd_popup_template" android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="_" android:popupCharacters="_"
android:keyWidth="20%p" android:keyEdgeFlags="left"/> android:keyWidth="20%p" android:keyEdgeFlags="left"/>
<Key android:keyLabel="," android:keyWidth="10%p" <Key android:codes="@integer/key_f1" android:keyWidth="10%p"/>
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="‚„"
/>
<Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space" <Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
android:keyWidth="40%p" android:keyWidth="40%p"
android:iconPreview="@drawable/sym_keyboard_feedback_space" android:iconPreview="@drawable/sym_keyboard_feedback_space"

View File

@ -43,6 +43,16 @@
android:persistent="false" android:persistent="false"
android:defaultValue="@bool/voice_input_default" android:defaultValue="@bool/voice_input_default"
/> />
<CheckBoxPreference
android:key="voice_on_main"
android:title="@string/voice_on_primary"
android:summary="@string/voice_on_primary_summary"
android:persistent="true"
android:dependency="enable_voice_input"
android:defaultValue="@bool/voice_input_default"
/>
<PreferenceScreen <PreferenceScreen
android:title="@string/language_selection_title"> android:title="@string/language_selection_title">
<intent <intent

View File

@ -67,16 +67,12 @@ public class KeyboardSwitcher {
private KeyboardId mCurrentId; private KeyboardId mCurrentId;
private Map<KeyboardId, LatinKeyboard> mKeyboards; private Map<KeyboardId, LatinKeyboard> mKeyboards;
/**
* Maps keyboard mode to the equivalent mode with voice.
*/
private Map<Integer, Integer> mModeToVoice;
private int mMode; /** One of the MODE_XXX values */ private int mMode; /** One of the MODE_XXX values */
private int mImeOptions; private int mImeOptions;
private int mTextMode = MODE_TEXT_QWERTY; private int mTextMode = MODE_TEXT_QWERTY;
private boolean mIsSymbols; private boolean mIsSymbols;
private boolean mHasVoice; private boolean mHasVoice;
private boolean mVoiceOnPrimary;
private boolean mPreferSymbols; private boolean mPreferSymbols;
private int mSymbolsModeState = SYMBOLS_MODE_STATE_NONE; private int mSymbolsModeState = SYMBOLS_MODE_STATE_NONE;
@ -87,14 +83,8 @@ public class KeyboardSwitcher {
KeyboardSwitcher(Context context, InputMethodService ims) { KeyboardSwitcher(Context context, InputMethodService ims) {
mContext = context; mContext = context;
mKeyboards = new HashMap<KeyboardId, LatinKeyboard>(); mKeyboards = new HashMap<KeyboardId, LatinKeyboard>();
mSymbolsId = new KeyboardId(R.xml.kbd_symbols); mSymbolsId = new KeyboardId(R.xml.kbd_symbols, false);
mSymbolsShiftedId = new KeyboardId(R.xml.kbd_symbols_shift); mSymbolsShiftedId = new KeyboardId(R.xml.kbd_symbols_shift, false);
mModeToVoice = new HashMap<Integer, Integer>();
mModeToVoice.put(R.id.mode_normal, R.id.mode_normal_voice);
mModeToVoice.put(R.id.mode_url, R.id.mode_url_voice);
mModeToVoice.put(R.id.mode_email, R.id.mode_email_voice);
mModeToVoice.put(R.id.mode_im, R.id.mode_im_voice);
mModeToVoice.put(R.id.mode_webentry, R.id.mode_webentry_voice);
mInputMethodService = ims; mInputMethodService = ims;
} }
@ -122,8 +112,9 @@ public class KeyboardSwitcher {
if (displayWidth == mLastDisplayWidth) return; if (displayWidth == mLastDisplayWidth) return;
mLastDisplayWidth = displayWidth; mLastDisplayWidth = displayWidth;
if (!forceCreate) mKeyboards.clear(); if (!forceCreate) mKeyboards.clear();
mSymbolsId = new KeyboardId(R.xml.kbd_symbols); mSymbolsId = new KeyboardId(R.xml.kbd_symbols, mHasVoice && !mVoiceOnPrimary);
mSymbolsShiftedId = new KeyboardId(R.xml.kbd_symbols_shift); mSymbolsShiftedId = new KeyboardId(R.xml.kbd_symbols_shift,
mHasVoice && !mVoiceOnPrimary);
} }
/** /**
@ -134,15 +125,17 @@ public class KeyboardSwitcher {
public int mXml; public int mXml;
public int mKeyboardMode; /** A KEYBOARDMODE_XXX value */ public int mKeyboardMode; /** A KEYBOARDMODE_XXX value */
public boolean mEnableShiftLock; public boolean mEnableShiftLock;
public boolean mHasVoice;
public KeyboardId(int xml, int mode, boolean enableShiftLock) { public KeyboardId(int xml, int mode, boolean enableShiftLock, boolean hasVoice) {
this.mXml = xml; this.mXml = xml;
this.mKeyboardMode = mode; this.mKeyboardMode = mode;
this.mEnableShiftLock = enableShiftLock; this.mEnableShiftLock = enableShiftLock;
this.mHasVoice = hasVoice;
} }
public KeyboardId(int xml) { public KeyboardId(int xml, boolean hasVoice) {
this(xml, 0, false); this(xml, 0, false, hasVoice);
} }
public boolean equals(Object other) { public boolean equals(Object other) {
@ -152,16 +145,29 @@ public class KeyboardSwitcher {
public boolean equals(KeyboardId other) { public boolean equals(KeyboardId other) {
return other.mXml == this.mXml return other.mXml == this.mXml
&& other.mKeyboardMode == this.mKeyboardMode && other.mKeyboardMode == this.mKeyboardMode
&& other.mEnableShiftLock == this.mEnableShiftLock; && other.mEnableShiftLock == this.mEnableShiftLock
&& other.mHasVoice == this.mHasVoice;
} }
public int hashCode() { public int hashCode() {
return (mXml + 1) * (mKeyboardMode + 1) * (mEnableShiftLock ? 2 : 1); return (mXml + 1) * (mKeyboardMode + 1) * (mEnableShiftLock ? 2 : 1)
* (mHasVoice ? 4 : 8);
} }
} }
void setVoiceMode(boolean enableVoice) { void setVoiceMode(boolean enableVoice, boolean voiceOnPrimary) {
setKeyboardMode(mMode, mImeOptions, enableVoice, mIsSymbols); if (enableVoice != mHasVoice || voiceOnPrimary != mVoiceOnPrimary) {
System.err.println("Clearing keyboards");
mKeyboards.clear();
}
mHasVoice = enableVoice;
mVoiceOnPrimary = voiceOnPrimary;
setKeyboardMode(mMode, mImeOptions, mHasVoice,
mIsSymbols);
}
boolean hasVoiceButton(boolean isSymbols) {
return mHasVoice && (isSymbols != mVoiceOnPrimary);
} }
void setKeyboardMode(int mode, int imeOptions, boolean enableVoice) { void setKeyboardMode(int mode, int imeOptions, boolean enableVoice) {
@ -181,9 +187,6 @@ public class KeyboardSwitcher {
mInputView.setPreviewEnabled(true); mInputView.setPreviewEnabled(true);
KeyboardId id = getKeyboardId(mode, imeOptions, isSymbols); KeyboardId id = getKeyboardId(mode, imeOptions, isSymbols);
if (enableVoice && mModeToVoice.containsKey(id.mKeyboardMode)) {
id.mKeyboardMode = mModeToVoice.get(id.mKeyboardMode);
}
LatinKeyboard keyboard = getKeyboard(id); LatinKeyboard keyboard = getKeyboard(id);
if (mode == MODE_PHONE) { if (mode == MODE_PHONE) {
@ -211,17 +214,12 @@ public class KeyboardSwitcher {
conf.locale = mInputLocale; conf.locale = mInputLocale;
orig.updateConfiguration(conf, null); orig.updateConfiguration(conf, null);
LatinKeyboard keyboard = new LatinKeyboard( LatinKeyboard keyboard = new LatinKeyboard(
mContext, id.mXml, id.mKeyboardMode); mContext, id.mXml, id.mKeyboardMode, id.mHasVoice);
if (id.mKeyboardMode == KEYBOARDMODE_NORMAL if (id.mKeyboardMode == KEYBOARDMODE_NORMAL
|| id.mKeyboardMode == KEYBOARDMODE_URL || id.mKeyboardMode == KEYBOARDMODE_URL
|| id.mKeyboardMode == KEYBOARDMODE_IM || id.mKeyboardMode == KEYBOARDMODE_IM
|| id.mKeyboardMode == KEYBOARDMODE_EMAIL || id.mKeyboardMode == KEYBOARDMODE_EMAIL
|| id.mKeyboardMode == KEYBOARDMODE_WEB || id.mKeyboardMode == KEYBOARDMODE_WEB
|| id.mKeyboardMode == R.id.mode_normal_voice
|| id.mKeyboardMode == R.id.mode_url_voice
|| id.mKeyboardMode == R.id.mode_im_voice
|| id.mKeyboardMode == R.id.mode_email_voice
|| id.mKeyboardMode == R.id.mode_webentry_voice
) { ) {
keyboard.setExtension(R.xml.kbd_extension); keyboard.setExtension(R.xml.kbd_extension);
} }
@ -238,31 +236,32 @@ public class KeyboardSwitcher {
} }
private KeyboardId getKeyboardId(int mode, int imeOptions, boolean isSymbols) { private KeyboardId getKeyboardId(int mode, int imeOptions, boolean isSymbols) {
boolean hasVoice = hasVoiceButton(isSymbols);
if (isSymbols) { if (isSymbols) {
return (mode == MODE_PHONE) return (mode == MODE_PHONE)
? new KeyboardId(R.xml.kbd_phone_symbols) : new KeyboardId(R.xml.kbd_symbols); ? new KeyboardId(R.xml.kbd_phone_symbols, hasVoice)
: new KeyboardId(R.xml.kbd_symbols, hasVoice);
} }
switch (mode) { switch (mode) {
case MODE_TEXT: case MODE_TEXT:
if (mTextMode == MODE_TEXT_QWERTY) { if (mTextMode == MODE_TEXT_QWERTY) {
return new KeyboardId(R.xml.kbd_qwerty, KEYBOARDMODE_NORMAL, true); return new KeyboardId(R.xml.kbd_qwerty, KEYBOARDMODE_NORMAL, true, hasVoice);
} else if (mTextMode == MODE_TEXT_ALPHA) { } else if (mTextMode == MODE_TEXT_ALPHA) {
return new KeyboardId(R.xml.kbd_alpha, KEYBOARDMODE_NORMAL, true); return new KeyboardId(R.xml.kbd_alpha, KEYBOARDMODE_NORMAL, true, hasVoice);
} }
break; break;
case MODE_SYMBOLS: case MODE_SYMBOLS:
return new KeyboardId(R.xml.kbd_symbols); return new KeyboardId(R.xml.kbd_symbols, hasVoice);
case MODE_PHONE: case MODE_PHONE:
return new KeyboardId(R.xml.kbd_phone); return new KeyboardId(R.xml.kbd_phone, hasVoice);
case MODE_URL: case MODE_URL:
return new KeyboardId(R.xml.kbd_qwerty, KEYBOARDMODE_URL, true); return new KeyboardId(R.xml.kbd_qwerty, KEYBOARDMODE_URL, true, hasVoice);
case MODE_EMAIL: case MODE_EMAIL:
return new KeyboardId(R.xml.kbd_qwerty, KEYBOARDMODE_EMAIL, true); return new KeyboardId(R.xml.kbd_qwerty, KEYBOARDMODE_EMAIL, true, hasVoice);
case MODE_IM: case MODE_IM:
return new KeyboardId(R.xml.kbd_qwerty, KEYBOARDMODE_IM, true); return new KeyboardId(R.xml.kbd_qwerty, KEYBOARDMODE_IM, true, hasVoice);
case MODE_WEB: case MODE_WEB:
return new KeyboardId(R.xml.kbd_qwerty, KEYBOARDMODE_WEB, true); return new KeyboardId(R.xml.kbd_qwerty, KEYBOARDMODE_WEB, true, hasVoice);
} }
return null; return null;
} }
@ -295,7 +294,7 @@ public class KeyboardSwitcher {
boolean isAlphabetMode() { boolean isAlphabetMode() {
int currentMode = mCurrentId.mKeyboardMode; int currentMode = mCurrentId.mKeyboardMode;
for (Integer mode : ALPHABET_MODES) { for (Integer mode : ALPHABET_MODES) {
if (currentMode == mode || currentMode == mModeToVoice.get(mode)) { if (currentMode == mode) {
return true; return true;
} }
} }

View File

@ -92,6 +92,7 @@ public class LatinIME extends InputMethodService
private static final String PREF_AUTO_COMPLETE = "auto_complete"; private static final String PREF_AUTO_COMPLETE = "auto_complete";
private static final String PREF_ENABLE_VOICE = "enable_voice_input"; private static final String PREF_ENABLE_VOICE = "enable_voice_input";
private static final String PREF_VOICE_SERVER_URL = "voice_server_url"; private static final String PREF_VOICE_SERVER_URL = "voice_server_url";
private static final String PREF_VOICE_MAIN = "voice_on_main";
// Whether or not the user has used voice input before (and thus, whether to show the // Whether or not the user has used voice input before (and thus, whether to show the
// first-run warning dialog or not). // first-run warning dialog or not).
@ -211,6 +212,7 @@ public class LatinIME extends InputMethodService
private boolean mIsShowingHint; private boolean mIsShowingHint;
private int mCorrectionMode; private int mCorrectionMode;
private boolean mEnableVoice = true; private boolean mEnableVoice = true;
private boolean mVoiceOnPrimary;
private int mOrientation; private int mOrientation;
// Indicates whether the suggestion strip is to be on in landscape // Indicates whether the suggestion strip is to be on in landscape
@ -445,6 +447,7 @@ public class LatinIME extends InputMethodService
} }
mEnableVoiceButton = shouldShowVoiceButton(makeFieldContext(), attribute); mEnableVoiceButton = shouldShowVoiceButton(makeFieldContext(), attribute);
final boolean enableVoiceButton = mEnableVoiceButton && mEnableVoice;
mAfterVoiceInput = false; mAfterVoiceInput = false;
mImmediatelyAfterVoiceInput = false; mImmediatelyAfterVoiceInput = false;
@ -463,15 +466,15 @@ public class LatinIME extends InputMethodService
case EditorInfo.TYPE_CLASS_NUMBER: case EditorInfo.TYPE_CLASS_NUMBER:
case EditorInfo.TYPE_CLASS_DATETIME: case EditorInfo.TYPE_CLASS_DATETIME:
mKeyboardSwitcher.setKeyboardMode(KeyboardSwitcher.MODE_SYMBOLS, mKeyboardSwitcher.setKeyboardMode(KeyboardSwitcher.MODE_SYMBOLS,
attribute.imeOptions, mEnableVoiceButton); attribute.imeOptions, enableVoiceButton);
break; break;
case EditorInfo.TYPE_CLASS_PHONE: case EditorInfo.TYPE_CLASS_PHONE:
mKeyboardSwitcher.setKeyboardMode(KeyboardSwitcher.MODE_PHONE, mKeyboardSwitcher.setKeyboardMode(KeyboardSwitcher.MODE_PHONE,
attribute.imeOptions, mEnableVoiceButton); attribute.imeOptions, enableVoiceButton);
break; break;
case EditorInfo.TYPE_CLASS_TEXT: case EditorInfo.TYPE_CLASS_TEXT:
mKeyboardSwitcher.setKeyboardMode(KeyboardSwitcher.MODE_TEXT, mKeyboardSwitcher.setKeyboardMode(KeyboardSwitcher.MODE_TEXT,
attribute.imeOptions, mEnableVoiceButton); attribute.imeOptions, enableVoiceButton);
//startPrediction(); //startPrediction();
mPredictionOn = true; mPredictionOn = true;
// Make sure that passwords are not displayed in candidate view // Make sure that passwords are not displayed in candidate view
@ -491,19 +494,19 @@ public class LatinIME extends InputMethodService
if (variation == EditorInfo.TYPE_TEXT_VARIATION_EMAIL_ADDRESS) { if (variation == EditorInfo.TYPE_TEXT_VARIATION_EMAIL_ADDRESS) {
mPredictionOn = false; mPredictionOn = false;
mKeyboardSwitcher.setKeyboardMode(KeyboardSwitcher.MODE_EMAIL, mKeyboardSwitcher.setKeyboardMode(KeyboardSwitcher.MODE_EMAIL,
attribute.imeOptions, mEnableVoiceButton); attribute.imeOptions, enableVoiceButton);
} else if (variation == EditorInfo.TYPE_TEXT_VARIATION_URI) { } else if (variation == EditorInfo.TYPE_TEXT_VARIATION_URI) {
mPredictionOn = false; mPredictionOn = false;
mKeyboardSwitcher.setKeyboardMode(KeyboardSwitcher.MODE_URL, mKeyboardSwitcher.setKeyboardMode(KeyboardSwitcher.MODE_URL,
attribute.imeOptions, mEnableVoiceButton); attribute.imeOptions, enableVoiceButton);
} else if (variation == EditorInfo.TYPE_TEXT_VARIATION_SHORT_MESSAGE) { } else if (variation == EditorInfo.TYPE_TEXT_VARIATION_SHORT_MESSAGE) {
mKeyboardSwitcher.setKeyboardMode(KeyboardSwitcher.MODE_IM, mKeyboardSwitcher.setKeyboardMode(KeyboardSwitcher.MODE_IM,
attribute.imeOptions, mEnableVoiceButton); attribute.imeOptions, enableVoiceButton);
} else if (variation == EditorInfo.TYPE_TEXT_VARIATION_FILTER) { } else if (variation == EditorInfo.TYPE_TEXT_VARIATION_FILTER) {
mPredictionOn = false; mPredictionOn = false;
} else if (variation == EditorInfo.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT) { } else if (variation == EditorInfo.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT) {
mKeyboardSwitcher.setKeyboardMode(KeyboardSwitcher.MODE_WEB, mKeyboardSwitcher.setKeyboardMode(KeyboardSwitcher.MODE_WEB,
attribute.imeOptions, mEnableVoiceButton); attribute.imeOptions, enableVoiceButton);
// If it's a browser edit field and auto correct is not ON explicitly, then // If it's a browser edit field and auto correct is not ON explicitly, then
// disable auto correction, but keep suggestions on. // disable auto correction, but keep suggestions on.
if ((attribute.inputType & EditorInfo.TYPE_TEXT_FLAG_AUTO_CORRECT) == 0) { if ((attribute.inputType & EditorInfo.TYPE_TEXT_FLAG_AUTO_CORRECT) == 0) {
@ -529,7 +532,7 @@ public class LatinIME extends InputMethodService
break; break;
default: default:
mKeyboardSwitcher.setKeyboardMode(KeyboardSwitcher.MODE_TEXT, mKeyboardSwitcher.setKeyboardMode(KeyboardSwitcher.MODE_TEXT,
attribute.imeOptions, mEnableVoiceButton); attribute.imeOptions, enableVoiceButton);
updateShiftKeyState(attribute); updateShiftKeyState(attribute);
} }
mInputView.closing(); mInputView.closing();
@ -790,6 +793,7 @@ public class LatinIME extends InputMethodService
} }
mKeyboardSwitcher.setInputLocale(new Locale(mInputLanguage), mKeyboardSwitcher.setInputLocale(new Locale(mInputLanguage),
getSelectedInputLanguages() != null); getSelectedInputLanguages() != null);
mKeyboardSwitcher.setVoiceMode(mEnableVoice, mVoiceOnPrimary);
mKeyboardSwitcher.makeKeyboards(true); mKeyboardSwitcher.makeKeyboards(true);
} }
@ -1504,7 +1508,8 @@ public class LatinIME extends InputMethodService
int currentKeyboardMode = mKeyboardSwitcher.getKeyboardMode(); int currentKeyboardMode = mKeyboardSwitcher.getKeyboardMode();
reloadKeyboards(); reloadKeyboards();
mKeyboardSwitcher.makeKeyboards(true); mKeyboardSwitcher.makeKeyboards(true);
mKeyboardSwitcher.setKeyboardMode(currentKeyboardMode, 0, mEnableVoiceButton); mKeyboardSwitcher.setKeyboardMode(currentKeyboardMode, 0,
mEnableVoiceButton && mEnableVoice);
initSuggest(mInputLanguage); initSuggest(mInputLanguage);
persistInputLanguage(mInputLanguage); persistInputLanguage(mInputLanguage);
updateShiftKeyState(getCurrentInputEditorInfo()); updateShiftKeyState(getCurrentInputEditorInfo());
@ -1555,7 +1560,6 @@ public class LatinIME extends InputMethodService
private boolean shouldShowVoiceButton(FieldContext fieldContext, EditorInfo attribute) { private boolean shouldShowVoiceButton(FieldContext fieldContext, EditorInfo attribute) {
return ENABLE_VOICE_BUTTON return ENABLE_VOICE_BUTTON
&& mEnableVoice
&& fieldCanDoVoice(fieldContext) && fieldCanDoVoice(fieldContext)
&& !(attribute != null && attribute.privateImeOptions != null && !(attribute != null && attribute.privateImeOptions != null
&& attribute.privateImeOptions.equals(IME_OPTION_NO_MICROPHONE)); && attribute.privateImeOptions.equals(IME_OPTION_NO_MICROPHONE));
@ -1719,10 +1723,13 @@ public class LatinIME extends InputMethodService
if (VOICE_INSTALLED) { if (VOICE_INSTALLED) {
boolean enableVoice = sp.getBoolean(PREF_ENABLE_VOICE, true); boolean enableVoice = sp.getBoolean(PREF_ENABLE_VOICE, true);
if (enableVoice != mEnableVoice && mKeyboardSwitcher != null) { boolean voiceOnPrimary = sp.getBoolean(PREF_VOICE_MAIN, true);
mKeyboardSwitcher.setVoiceMode(enableVoice); if (mKeyboardSwitcher != null &&
(enableVoice != mEnableVoice || voiceOnPrimary != mVoiceOnPrimary)) {
mKeyboardSwitcher.setVoiceMode(enableVoice, voiceOnPrimary);
} }
mEnableVoice = enableVoice; mEnableVoice = enableVoice;
mVoiceOnPrimary = voiceOnPrimary;
} }
mAutoCorrectEnabled = sp.getBoolean(PREF_AUTO_COMPLETE, mAutoCorrectEnabled = sp.getBoolean(PREF_AUTO_COMPLETE,
mResources.getBoolean(R.bool.enable_autocorrect)) & mShowSuggestions; mResources.getBoolean(R.bool.enable_autocorrect)) & mShowSuggestions;

View File

@ -38,6 +38,10 @@ public class LatinKeyboard extends Keyboard {
private Drawable mOldShiftIcon; private Drawable mOldShiftIcon;
private Drawable mOldShiftPreviewIcon; private Drawable mOldShiftPreviewIcon;
private Drawable mSpaceIcon; private Drawable mSpaceIcon;
private Drawable mMicIcon;
private Drawable mMicPreviewIcon;
private Drawable m123MicIcon;
private Drawable m123MicPreviewIcon;
private Key mShiftKey; private Key mShiftKey;
private Key mEnterKey; private Key mEnterKey;
private Key mF1Key; private Key mF1Key;
@ -45,6 +49,7 @@ public class LatinKeyboard extends Keyboard {
/* package */ Locale mLocale; /* package */ Locale mLocale;
private Resources mRes; private Resources mRes;
private int mMode; private int mMode;
private boolean mHasVoice;
private int mExtensionResId; private int mExtensionResId;
@ -57,22 +62,26 @@ public class LatinKeyboard extends Keyboard {
static int sSpacebarVerticalCorrection; static int sSpacebarVerticalCorrection;
public LatinKeyboard(Context context, int xmlLayoutResId) { public LatinKeyboard(Context context, int xmlLayoutResId) {
this(context, xmlLayoutResId, 0); this(context, xmlLayoutResId, 0, false);
} }
public LatinKeyboard(Context context, int xmlLayoutResId, int mode) { public LatinKeyboard(Context context, int xmlLayoutResId, int mode, boolean hasVoice) {
super(context, xmlLayoutResId, mode); super(context, xmlLayoutResId, mode);
final Resources res = context.getResources(); final Resources res = context.getResources();
mMode = mode; mMode = mode;
mRes = res; mRes = res;
mHasVoice = hasVoice;
mShiftLockIcon = res.getDrawable(R.drawable.sym_keyboard_shift_locked); mShiftLockIcon = res.getDrawable(R.drawable.sym_keyboard_shift_locked);
mShiftLockPreviewIcon = res.getDrawable(R.drawable.sym_keyboard_feedback_shift_locked); mShiftLockPreviewIcon = res.getDrawable(R.drawable.sym_keyboard_feedback_shift_locked);
mShiftLockPreviewIcon.setBounds(0, 0, mShiftLockPreviewIcon.setBounds(0, 0,
mShiftLockPreviewIcon.getIntrinsicWidth(), mShiftLockPreviewIcon.getIntrinsicWidth(),
mShiftLockPreviewIcon.getIntrinsicHeight()); mShiftLockPreviewIcon.getIntrinsicHeight());
mSpaceIcon = res.getDrawable(R.drawable.sym_keyboard_space); mSpaceIcon = res.getDrawable(R.drawable.sym_keyboard_space);
mMicIcon = res.getDrawable(R.drawable.sym_keyboard_mic);
mMicPreviewIcon = res.getDrawable(R.drawable.sym_keyboard_feedback_mic);
sSpacebarVerticalCorrection = res.getDimensionPixelOffset( sSpacebarVerticalCorrection = res.getDimensionPixelOffset(
R.dimen.spacebar_vertical_correction); R.dimen.spacebar_vertical_correction);
setF1Key();
} }
public LatinKeyboard(Context context, int layoutTemplateResId, public LatinKeyboard(Context context, int layoutTemplateResId,
@ -227,28 +236,19 @@ public class LatinKeyboard extends Keyboard {
} }
private void setF1Key() { private void setF1Key() {
// TODO if (mF1Key == null) return;
// else { System.err.println("Setting F1 key");
// mSpaceKey.icon = mRes.getDrawable(R.drawable.sym_keyboard_space); if (!mHasVoice) {
// switch (mMode) { mF1Key.label = ",";
// case KeyboardSwitcher.KEYBOARDMODE_NORMAL: mF1Key.codes = new int[] { ',' };
// case KeyboardSwitcher.KEYBOARDMODE_IM: mF1Key.icon = null;
// mF1Key.label = ","; mF1Key.iconPreview = null;
// mF1Key.codes = new int[] { ',' }; } else {
// mF1Key.icon = null; mF1Key.codes = new int[] { LatinKeyboardView.KEYCODE_VOICE };
// mF1Key.iconPreview = null; mF1Key.label = null;
// break; mF1Key.icon = mMicIcon;
// case KeyboardSwitcher.KEYBOARDMODE_EMAIL: mF1Key.iconPreview = mMicPreviewIcon;
// case KeyboardSwitcher.KEYBOARDMODE_URL: }
// mF1Key.label = mRes.getString(R.string.popular_domain_0);
// mF1Key.codes = new int[] { '.' };
// mF1Key.text = mF1Key.label;
// mF1Key.icon = null;
// mF1Key.iconPreview = null;
// mF1Key.popupResId = R.xml.popup_domains;
// break;
// }
// }
} }
private void updateSpaceBarForLocale() { private void updateSpaceBarForLocale() {