Change the voice checkboxes into a 3-state list.
Also add a language-switch hint
This commit is contained in:
parent
1b62ff1a3d
commit
457fdffce4
4 changed files with 76 additions and 60 deletions
|
@ -250,13 +250,34 @@
|
||||||
<string name="ok">OK</string>
|
<string name="ok">OK</string>
|
||||||
|
|
||||||
<!-- Preferences item for enabling speech input -->
|
<!-- Preferences item for enabling speech input -->
|
||||||
<string name="enable_voice">Voice input</string>
|
<string name="voice_input">Voice input</string>
|
||||||
|
|
||||||
<!-- Preferences item for speech icon on primary keyboard -->
|
<!-- Array of Voice Input modes -->
|
||||||
<string name="voice_on_primary">Mic on primary</string>
|
<string-array name="voice_input_modes">
|
||||||
|
<item>On main keyboard</item>
|
||||||
|
<item>On symbols keyboard</item>
|
||||||
|
<item>Off</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
<!-- Preferences item summary for speech icon on primary keyboard -->
|
<!-- Don't translate -->
|
||||||
<string name="voice_on_primary_summary">Show the microphone on the primary keyboard</string>
|
<string name="voice_mode_main" translatable="false">0</string>
|
||||||
|
<!-- Don't translate -->
|
||||||
|
<string name="voice_mode_symbols" translatable="false">1</string>
|
||||||
|
<!-- Don't translate -->
|
||||||
|
<string name="voice_mode_off" translatable="false">2</string>
|
||||||
|
|
||||||
|
<string-array name="voice_input_modes_values" translatable="false">
|
||||||
|
<item>@string/voice_mode_main</item>
|
||||||
|
<item>@string/voice_mode_symbols</item>
|
||||||
|
<item>@string/voice_mode_off</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<!-- Array of Voice Input modes summary -->
|
||||||
|
<string-array name="voice_input_modes_summary">
|
||||||
|
<item>Mic on main keyboard</item>
|
||||||
|
<item>Mic on symbols keyboard</item>
|
||||||
|
<item>Voice input is disabled</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
<!-- 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>
|
||||||
|
@ -293,4 +314,6 @@
|
||||||
|
|
||||||
<!-- Title for input language selection screen -->
|
<!-- Title for input language selection screen -->
|
||||||
<string name="language_selection_title">Select input languages</string>
|
<string name="language_selection_title">Select input languages</string>
|
||||||
|
<!-- Title summary for input language selection screen -->
|
||||||
|
<string name="language_selection_summary">Slide your finger across the spacebar to switch</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -37,24 +37,18 @@
|
||||||
android:defaultValue="true"
|
android:defaultValue="true"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<CheckBoxPreference
|
<ListPreference
|
||||||
android:key="enable_voice_input"
|
android:key="voice_mode"
|
||||||
android:title="@string/enable_voice"
|
android:title="@string/voice_input"
|
||||||
android:persistent="false"
|
|
||||||
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:persistent="true"
|
||||||
android:dependency="enable_voice_input"
|
android:entryValues="@array/voice_input_modes_values"
|
||||||
android:defaultValue="@bool/voice_input_default"
|
android:entries="@array/voice_input_modes"
|
||||||
|
android:defaultValue="@string/voice_mode_main"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
android:title="@string/language_selection_title">
|
android:title="@string/language_selection_title"
|
||||||
|
android:summary="@string/language_selection_summary">
|
||||||
<intent
|
<intent
|
||||||
android:action="android.intent.action.MAIN"
|
android:action="android.intent.action.MAIN"
|
||||||
android:targetPackage="com.android.inputmethod.latin"
|
android:targetPackage="com.android.inputmethod.latin"
|
||||||
|
|
|
@ -90,9 +90,8 @@ public class LatinIME extends InputMethodService
|
||||||
private static final String PREF_QUICK_FIXES = "quick_fixes";
|
private static final String PREF_QUICK_FIXES = "quick_fixes";
|
||||||
private static final String PREF_SHOW_SUGGESTIONS = "show_suggestions";
|
private static final String PREF_SHOW_SUGGESTIONS = "show_suggestions";
|
||||||
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_VOICE_MODE = "voice_mode";
|
||||||
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).
|
||||||
|
@ -1771,8 +1770,9 @@ public class LatinIME extends InputMethodService
|
||||||
mShowSuggestions = sp.getBoolean(PREF_SHOW_SUGGESTIONS, true) & mQuickFixes;
|
mShowSuggestions = sp.getBoolean(PREF_SHOW_SUGGESTIONS, true) & mQuickFixes;
|
||||||
|
|
||||||
if (VOICE_INSTALLED) {
|
if (VOICE_INSTALLED) {
|
||||||
boolean enableVoice = sp.getBoolean(PREF_ENABLE_VOICE, true);
|
final String voiceMode = sp.getString(PREF_VOICE_MODE, "");
|
||||||
boolean voiceOnPrimary = sp.getBoolean(PREF_VOICE_MAIN, true);
|
boolean enableVoice = !voiceMode.equals(getString(R.string.voice_mode_off));
|
||||||
|
boolean voiceOnPrimary = voiceMode.equals(getString(R.string.voice_mode_main));
|
||||||
if (mKeyboardSwitcher != null &&
|
if (mKeyboardSwitcher != null &&
|
||||||
(enableVoice != mEnableVoice || voiceOnPrimary != mVoiceOnPrimary)) {
|
(enableVoice != mEnableVoice || voiceOnPrimary != mVoiceOnPrimary)) {
|
||||||
mKeyboardSwitcher.setVoiceMode(enableVoice, voiceOnPrimary);
|
mKeyboardSwitcher.setVoiceMode(enableVoice, voiceOnPrimary);
|
||||||
|
|
|
@ -16,6 +16,9 @@
|
||||||
|
|
||||||
package com.android.inputmethod.latin;
|
package com.android.inputmethod.latin;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.backup.BackupManager;
|
import android.backup.BackupManager;
|
||||||
|
@ -23,6 +26,7 @@ import android.content.DialogInterface;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.CheckBoxPreference;
|
import android.preference.CheckBoxPreference;
|
||||||
|
import android.preference.ListPreference;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.PreferenceActivity;
|
import android.preference.PreferenceActivity;
|
||||||
import android.preference.PreferenceGroup;
|
import android.preference.PreferenceGroup;
|
||||||
|
@ -31,23 +35,18 @@ import android.speech.RecognitionManager;
|
||||||
import android.text.AutoText;
|
import android.text.AutoText;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.google.android.collect.Lists;
|
|
||||||
|
|
||||||
import com.android.inputmethod.voice.SettingsUtil;
|
import com.android.inputmethod.voice.SettingsUtil;
|
||||||
import com.android.inputmethod.voice.VoiceInputLogger;
|
import com.android.inputmethod.voice.VoiceInputLogger;
|
||||||
|
import com.google.android.collect.Lists;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
public class LatinIMESettings extends PreferenceActivity
|
public class LatinIMESettings extends PreferenceActivity
|
||||||
implements SharedPreferences.OnSharedPreferenceChangeListener,
|
implements SharedPreferences.OnSharedPreferenceChangeListener,
|
||||||
OnPreferenceClickListener,
|
|
||||||
DialogInterface.OnDismissListener {
|
DialogInterface.OnDismissListener {
|
||||||
|
|
||||||
private static final String QUICK_FIXES_KEY = "quick_fixes";
|
private static final String QUICK_FIXES_KEY = "quick_fixes";
|
||||||
private static final String SHOW_SUGGESTIONS_KEY = "show_suggestions";
|
private static final String SHOW_SUGGESTIONS_KEY = "show_suggestions";
|
||||||
private static final String PREDICTION_SETTINGS_KEY = "prediction_settings";
|
private static final String PREDICTION_SETTINGS_KEY = "prediction_settings";
|
||||||
private static final String VOICE_SETTINGS_KEY = "enable_voice_input";
|
private static final String VOICE_SETTINGS_KEY = "voice_mode";
|
||||||
private static final String VOICE_ON_PRIMARY_KEY = "voice_on_main";
|
private static final String VOICE_ON_PRIMARY_KEY = "voice_on_main";
|
||||||
private static final String VOICE_SERVER_KEY = "voice_server_url";
|
private static final String VOICE_SERVER_KEY = "voice_server_url";
|
||||||
|
|
||||||
|
@ -58,12 +57,13 @@ public class LatinIMESettings extends PreferenceActivity
|
||||||
|
|
||||||
private CheckBoxPreference mQuickFixes;
|
private CheckBoxPreference mQuickFixes;
|
||||||
private CheckBoxPreference mShowSuggestions;
|
private CheckBoxPreference mShowSuggestions;
|
||||||
private CheckBoxPreference mVoicePreference;
|
private ListPreference mVoicePreference;
|
||||||
private CheckBoxPreference mVoiceOnPrimary;
|
private boolean mVoiceOn;
|
||||||
|
|
||||||
private VoiceInputLogger mLogger;
|
private VoiceInputLogger mLogger;
|
||||||
|
|
||||||
private boolean mOkClicked = false;
|
private boolean mOkClicked = false;
|
||||||
|
private String mVoiceModeOff;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle icicle) {
|
protected void onCreate(Bundle icicle) {
|
||||||
|
@ -71,15 +71,12 @@ public class LatinIMESettings extends PreferenceActivity
|
||||||
addPreferencesFromResource(R.xml.prefs);
|
addPreferencesFromResource(R.xml.prefs);
|
||||||
mQuickFixes = (CheckBoxPreference) findPreference(QUICK_FIXES_KEY);
|
mQuickFixes = (CheckBoxPreference) findPreference(QUICK_FIXES_KEY);
|
||||||
mShowSuggestions = (CheckBoxPreference) findPreference(SHOW_SUGGESTIONS_KEY);
|
mShowSuggestions = (CheckBoxPreference) findPreference(SHOW_SUGGESTIONS_KEY);
|
||||||
mVoicePreference = (CheckBoxPreference) findPreference(VOICE_SETTINGS_KEY);
|
mVoicePreference = (ListPreference) findPreference(VOICE_SETTINGS_KEY);
|
||||||
mVoiceOnPrimary = (CheckBoxPreference) findPreference(VOICE_ON_PRIMARY_KEY);
|
|
||||||
SharedPreferences prefs = getPreferenceManager().getSharedPreferences();
|
SharedPreferences prefs = getPreferenceManager().getSharedPreferences();
|
||||||
prefs.registerOnSharedPreferenceChangeListener(this);
|
prefs.registerOnSharedPreferenceChangeListener(this);
|
||||||
|
|
||||||
mVoicePreference.setOnPreferenceClickListener(this);
|
mVoiceModeOff = getString(R.string.voice_mode_off);
|
||||||
mVoicePreference.setChecked(prefs.getBoolean(
|
mVoiceOn = !(prefs.getString(VOICE_SETTINGS_KEY, mVoiceModeOff).equals(mVoiceModeOff));
|
||||||
VOICE_SETTINGS_KEY, getResources().getBoolean(R.bool.voice_input_default)));
|
|
||||||
|
|
||||||
mLogger = VoiceInputLogger.getLogger(this);
|
mLogger = VoiceInputLogger.getLogger(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,12 +92,10 @@ public class LatinIMESettings extends PreferenceActivity
|
||||||
}
|
}
|
||||||
if (!LatinIME.VOICE_INSTALLED
|
if (!LatinIME.VOICE_INSTALLED
|
||||||
|| !RecognitionManager.isRecognitionAvailable(this)) {
|
|| !RecognitionManager.isRecognitionAvailable(this)) {
|
||||||
getPreferenceScreen().removePreference(mVoiceOnPrimary);
|
|
||||||
getPreferenceScreen().removePreference(mVoicePreference);
|
getPreferenceScreen().removePreference(mVoicePreference);
|
||||||
|
} else {
|
||||||
|
updateVoiceModeSummary();
|
||||||
}
|
}
|
||||||
|
|
||||||
mVoicePreference.setChecked(
|
|
||||||
getPreferenceManager().getSharedPreferences().getBoolean(VOICE_SETTINGS_KEY, true));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -110,21 +105,28 @@ public class LatinIMESettings extends PreferenceActivity
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
|
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
|
||||||
String key) {
|
|
||||||
(new BackupManager(this)).dataChanged();
|
(new BackupManager(this)).dataChanged();
|
||||||
|
// If turning on voice input, show dialog
|
||||||
|
if (key.equals(VOICE_SETTINGS_KEY) && !mVoiceOn) {
|
||||||
|
if (! prefs.getString(VOICE_SETTINGS_KEY, mVoiceModeOff)
|
||||||
|
.equals(mVoiceModeOff)) {
|
||||||
|
showVoiceConfirmation();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mVoiceOn = !(prefs.getString(VOICE_SETTINGS_KEY, mVoiceModeOff).equals(mVoiceModeOff));
|
||||||
|
updateVoiceModeSummary();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
private void showVoiceConfirmation() {
|
||||||
if (preference == mVoicePreference) {
|
|
||||||
if (mVoicePreference.isChecked()) {
|
|
||||||
mOkClicked = false;
|
mOkClicked = false;
|
||||||
showDialog(VOICE_INPUT_CONFIRM_DIALOG);
|
showDialog(VOICE_INPUT_CONFIRM_DIALOG);
|
||||||
} else {
|
|
||||||
updateVoicePreference();
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return false;
|
private void updateVoiceModeSummary() {
|
||||||
|
mVoicePreference.setSummary(
|
||||||
|
getResources().getStringArray(R.array.voice_input_modes_summary)
|
||||||
|
[mVoicePreference.findIndexOfValue(mVoicePreference.getValue())]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -134,7 +136,7 @@ public class LatinIMESettings extends PreferenceActivity
|
||||||
DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
|
DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int whichButton) {
|
public void onClick(DialogInterface dialog, int whichButton) {
|
||||||
if (whichButton == DialogInterface.BUTTON_NEGATIVE) {
|
if (whichButton == DialogInterface.BUTTON_NEGATIVE) {
|
||||||
mVoicePreference.setChecked(false);
|
mVoicePreference.setValue(mVoiceModeOff);
|
||||||
mLogger.settingsWarningDialogCancel();
|
mLogger.settingsWarningDialogCancel();
|
||||||
} else if (whichButton == DialogInterface.BUTTON_POSITIVE) {
|
} else if (whichButton == DialogInterface.BUTTON_POSITIVE) {
|
||||||
mOkClicked = true;
|
mOkClicked = true;
|
||||||
|
@ -186,19 +188,16 @@ public class LatinIMESettings extends PreferenceActivity
|
||||||
if (!mOkClicked) {
|
if (!mOkClicked) {
|
||||||
// This assumes that onPreferenceClick gets called first, and this if the user
|
// This assumes that onPreferenceClick gets called first, and this if the user
|
||||||
// agreed after the warning, we set the mOkClicked value to true.
|
// agreed after the warning, we set the mOkClicked value to true.
|
||||||
mVoicePreference.setChecked(false);
|
mVoicePreference.setValue(mVoiceModeOff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateVoicePreference() {
|
private void updateVoicePreference() {
|
||||||
SharedPreferences.Editor editor = getPreferenceManager().getSharedPreferences().edit();
|
boolean isChecked = !mVoicePreference.getValue().equals(mVoiceModeOff);
|
||||||
boolean isChecked = mVoicePreference.isChecked();
|
|
||||||
if (isChecked) {
|
if (isChecked) {
|
||||||
mLogger.voiceInputSettingEnabled();
|
mLogger.voiceInputSettingEnabled();
|
||||||
} else {
|
} else {
|
||||||
mLogger.voiceInputSettingDisabled();
|
mLogger.voiceInputSettingDisabled();
|
||||||
}
|
}
|
||||||
editor.putBoolean(VOICE_SETTINGS_KEY, isChecked);
|
|
||||||
editor.commit();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue