Migrate voice features into the open-source LatinIME. This includes
the change to logging to remove any private dependencies and use
broadcast intents to VoiceSearch instead.
I have audited this code and it appears good to go for open-source,
but would appreciate a second pair of eyes.
Still to do after submitting this CL:
* Reintroduce Amith's memory leak fix (37557) which was the only CL
added to LatinIME since the last merge over to the private copy.
* Make some changes to allow LatinIME to work without voice search
installed. Currently I believe it will show the mic but fail if
you press it. We need to base the visibility on the mic on the
availability of the service.
* Fix this code to use the new Gservices framework, it's still trying
to use the old one.
diff --git a/res/xml/kbd_qwerty.xml b/res/xml/kbd_qwerty.xml
index d914f46..552e7e5 100755
--- a/res/xml/kbd_qwerty.xml
+++ b/res/xml/kbd_qwerty.xml
@@ -46,7 +46,7 @@
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="@string/alternates_for_u"
/>
- <Key android:keyLabel="@string/key_i"
+ <Key android:codes="105" android:keyLabel="i"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="@string/alternates_for_i"
/>
@@ -70,14 +70,11 @@
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="@string/alternates_for_d"/>
<Key android:codes="102" android:keyLabel="f"/>
- <Key android:codes="103" android:keyLabel="g"
- android:popupKeyboard="@xml/kbd_popup_template"
- android:popupCharacters="@string/alternates_for_g"/>
- />
+ <Key android:codes="103" android:keyLabel="g"/>
<Key android:codes="104" android:keyLabel="h"/>
<Key android:codes="106" android:keyLabel="j"/>
<Key android:codes="107" android:keyLabel="k"/>
- <Key android:codes="108" android:keyLabel="l"
+ <Key android:codes="108" android:keyLabel="l"
android:popupKeyboard="@xml/kbd_popup_template"
android:popupCharacters="@string/alternates_for_l"
android:keyEdgeFlags="right"/>
@@ -126,6 +123,24 @@
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"/>
+ <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">
<Key android:codes="-2" android:keyLabel="@string/label_symbol_key"
android:popupKeyboard="@xml/kbd_popup_template"
@@ -148,6 +163,26 @@
android:keyWidth="20%p" android:keyEdgeFlags="right"/>
</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="@string/popular_domain_0"
+ android:keyOutputText="@string/popular_domain_0"
+ android:popupKeyboard="@xml/popup_domains"
+ android:keyWidth="15%p"/>
+ <Key android:keyLabel="/" android:keyWidth="15%p"/>
+ <Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
+ android:iconPreview="@drawable/sym_keyboard_feedback_space"
+ android:keyWidth="15%p" android:isRepeatable="true"/>
+ <Key android:keyLabel="." android:popupKeyboard="@xml/popup_punctuation"
+ android:keyWidth="15%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">
<Key android:codes="-2" android:keyLabel="@string/label_symbol_key"
android:popupKeyboard="@xml/kbd_popup_template"
@@ -170,6 +205,26 @@
android:keyWidth="20%p" android:keyEdgeFlags="right"/>
</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="15%p"/>
+ <Key android:keyLabel="@string/popular_domain_0"
+ android:keyOutputText="@string/popular_domain_0"
+ android:popupKeyboard="@xml/popup_domains"
+ android:keyWidth="15%p"/>
+ <Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
+ android:iconPreview="@drawable/sym_keyboard_feedback_space"
+ android:keyWidth="15%p" android:isRepeatable="true"/>
+ <Key android:keyLabel="." android:popupKeyboard="@xml/popup_punctuation"
+ android:keyWidth="15%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_im" android:rowEdgeFlags="bottom">
<Key android:codes="-2" android:keyLabel="@string/label_symbol_key"
android:popupKeyboard="@xml/kbd_popup_template"
@@ -186,5 +241,23 @@
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: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>
</Keyboard>
diff --git a/res/xml/method.xml b/res/xml/method.xml
index e5654e9..4a80794 100644
--- a/res/xml/method.xml
+++ b/res/xml/method.xml
@@ -21,6 +21,6 @@
<!-- for the Input Method Manager. -->
<input-method xmlns:android="http://schemas.android.com/apk/res/android"
- android:settingsActivity="com.android.inputmethod.latin.LatinIMESettings"
- android:isDefault="@bool/im_is_default"
+ android:settingsActivity="com.google.android.voicesearch.LatinIMEWithVoiceSettings"
+ android:isDefault="true"
/>
diff --git a/res/xml/prefs.xml b/res/xml/prefs.xml
index d5075c5..74a2bcb 100644
--- a/res/xml/prefs.xml
+++ b/res/xml/prefs.xml
@@ -37,6 +37,12 @@
android:defaultValue="true"
/>
+ <CheckBoxPreference
+ android:key="enable_voice_input"
+ android:title="@string/enable_voice"
+ android:persistent="false"
+ android:defaultValue="@bool/voice_input_default"
+ />
<PreferenceScreen
android:title="@string/language_selection_title">
<intent