Move Voice input/output settings to Language & keyboard
Bug: 3267042 Change-Id: I127a2e9d11fb70283812e68979bdde3976e32cf9
This commit is contained in:
@@ -301,6 +301,7 @@
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<action android:name="android.settings.INPUT_METHOD_SETTINGS" />
|
||||
<action android:name="com.android.settings.VOICE_INPUT_OUTPUT_SETTINGS" />
|
||||
<category android:name="android.intent.category.VOICE_LAUNCH" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="com.android.settings.SHORTCUT" />
|
||||
@@ -631,21 +632,6 @@
|
||||
android:resource="@id/accessibility_settings" />
|
||||
</activity>
|
||||
|
||||
<activity android:name="Settings$VoiceInputOutputSettingsActivity"
|
||||
android:theme="@android:style/Theme.Holo"
|
||||
android:label="@string/voice_input_output_settings"
|
||||
android:targetActivity="Settings">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<action android:name="com.android.settings.VOICE_INPUT_OUTPUT_SETTINGS" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||
android:value="com.android.settings.VoiceInputOutputSettings" />
|
||||
<meta-data android:name="com.android.settings.TOP_LEVEL_HEADER_ID"
|
||||
android:resource="@id/voice_input_output_settings" />
|
||||
</activity>
|
||||
|
||||
<activity android:name="TextToSpeechSettings" android:label="@string/tts_settings">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
@@ -2181,7 +2181,7 @@ found in the list of installed applications.</string>
|
||||
|
||||
<!-- Language Settings --> <skip />
|
||||
<!-- Title of setting on main settings screen. This item will take the user to the screen to tweak settings realted to locale and text -->
|
||||
<string name="language_settings">Language & keyboard</string>
|
||||
<string name="language_settings">Language & input</string>
|
||||
<!-- Title of Language and keyboard settings screen -->
|
||||
<string name="language_keyboard_settings_title">Language & keyboard settings</string>
|
||||
<!-- On Language & keyboard settings screen, heading. Inside the "Language & keyboard settings" screen, this is the header for settings that relate to language (select the system language, user dictionary for the language). -->
|
||||
|
@@ -33,6 +33,28 @@
|
||||
android:summary="@string/user_dict_settings_summary">
|
||||
</PreferenceScreen>
|
||||
|
||||
<PreferenceCategory android:key="voice_input_category"
|
||||
android:title="@string/voice_input_category" >
|
||||
|
||||
<!-- entries, entryValues, and defaultValue will be populated programmatically. -->
|
||||
<ListPreference
|
||||
android:key="recognizer"
|
||||
android:title="@string/recognizer_title"
|
||||
android:dialogTitle="@string/recognizer_title" />
|
||||
|
||||
<!-- An intent for this preference will be populated programmatically. -->
|
||||
<PreferenceScreen android:key="recognizer_settings"
|
||||
android:title="@string/recognizer_settings_title" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory android:key="voice_output_category"
|
||||
android:title="@string/voice_output_category" >
|
||||
|
||||
<PreferenceScreen android:key="tts_settings"
|
||||
android:fragment="com.android.settings.TextToSpeechSettings"
|
||||
android:title="@string/tts_settings_title" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory android:key="keyboard_settings_category"
|
||||
android:title="@string/keyboard_settings_category">
|
||||
|
||||
|
@@ -119,14 +119,6 @@
|
||||
android:icon="@drawable/ic_settings_language"
|
||||
android:title="@string/language_settings" />
|
||||
|
||||
<!-- Voice input & output -->
|
||||
|
||||
<header
|
||||
android:id="@+id/voice_input_output_settings"
|
||||
android:fragment="com.android.settings.VoiceInputOutputSettings"
|
||||
android:icon="@drawable/ic_settings_speech"
|
||||
android:title="@string/voice_input_output_settings" />
|
||||
|
||||
<!-- Accessibility feedback -->
|
||||
|
||||
<header
|
||||
|
@@ -1,41 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2010 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:title="@string/voice_input_output_settings_title"
|
||||
android:key="parent">
|
||||
|
||||
<PreferenceCategory android:key="voice_input_category"
|
||||
android:title="@string/voice_input_category" />
|
||||
|
||||
<!-- entries, entryValues, and defaultValue will be populated programmatically. -->
|
||||
<ListPreference
|
||||
android:key="recognizer"
|
||||
android:title="@string/recognizer_title"
|
||||
android:dialogTitle="@string/recognizer_title" />
|
||||
|
||||
<!-- An intent for this preference will be populated programmatically. -->
|
||||
<PreferenceScreen android:key="recognizer_settings"
|
||||
android:title="@string/recognizer_settings_title" />
|
||||
|
||||
<PreferenceCategory android:key="voice_output_category"
|
||||
android:title="@string/voice_output_category" />
|
||||
|
||||
<PreferenceScreen android:key="tts_settings"
|
||||
android:fragment="com.android.settings.TextToSpeechSettings"
|
||||
android:title="@string/tts_settings_title" />
|
||||
|
||||
</PreferenceScreen>
|
@@ -209,7 +209,6 @@ public class Settings extends PreferenceActivity {
|
||||
public static class PrivacySettingsActivity extends Settings { }
|
||||
public static class DockSettingsActivity extends Settings { }
|
||||
public static class RunningServicesActivity extends Settings { }
|
||||
public static class VoiceInputOutputSettingsActivity extends Settings { }
|
||||
public static class ManageAccountsSettingsActivity extends Settings { }
|
||||
public static class PowerUsageSummaryActivity extends Settings { }
|
||||
public static class AccountSyncSettingsActivity extends Settings { }
|
||||
|
@@ -16,9 +16,6 @@
|
||||
|
||||
package com.android.settings;
|
||||
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
@@ -28,7 +25,6 @@ import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
import android.content.res.XmlResourceParser;
|
||||
import android.os.Bundle;
|
||||
import android.preference.ListPreference;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceCategory;
|
||||
@@ -45,15 +41,16 @@ import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* Settings screen for voice input/output.
|
||||
*/
|
||||
public class VoiceInputOutputSettings extends SettingsPreferenceFragment
|
||||
implements OnPreferenceChangeListener {
|
||||
public class VoiceInputOutputSettings implements OnPreferenceChangeListener {
|
||||
|
||||
private static final String TAG = "VoiceInputOutputSettings";
|
||||
|
||||
private static final String KEY_PARENT = "parent";
|
||||
private static final String KEY_VOICE_INPUT_CATEGORY = "voice_input_category";
|
||||
private static final String KEY_RECOGNIZER = "recognizer";
|
||||
private static final String KEY_RECOGNIZER_SETTINGS = "recognizer_settings";
|
||||
@@ -62,20 +59,22 @@ public class VoiceInputOutputSettings extends SettingsPreferenceFragment
|
||||
private PreferenceCategory mVoiceInputCategory;
|
||||
private ListPreference mRecognizerPref;
|
||||
private PreferenceScreen mSettingsPref;
|
||||
private SettingsPreferenceFragment mFragment;
|
||||
|
||||
private HashMap<String, ResolveInfo> mAvailableRecognizersMap;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
public VoiceInputOutputSettings(SettingsPreferenceFragment fragment) {
|
||||
mFragment = fragment;
|
||||
}
|
||||
|
||||
addPreferencesFromResource(R.xml.voice_input_output_settings);
|
||||
public void onCreate() {
|
||||
|
||||
mParent = (PreferenceGroup) findPreference(KEY_PARENT);
|
||||
mParent = (PreferenceGroup) mFragment.getPreferenceScreen();
|
||||
mVoiceInputCategory = (PreferenceCategory) mParent.findPreference(KEY_VOICE_INPUT_CATEGORY);
|
||||
mRecognizerPref = (ListPreference) mParent.findPreference(KEY_RECOGNIZER);
|
||||
mRecognizerPref = (ListPreference) mVoiceInputCategory.findPreference(KEY_RECOGNIZER);
|
||||
mRecognizerPref.setOnPreferenceChangeListener(this);
|
||||
mSettingsPref = (PreferenceScreen) mParent.findPreference(KEY_RECOGNIZER_SETTINGS);
|
||||
mSettingsPref = (PreferenceScreen)
|
||||
mVoiceInputCategory.findPreference(KEY_RECOGNIZER_SETTINGS);
|
||||
|
||||
mAvailableRecognizersMap = new HashMap<String, ResolveInfo>();
|
||||
|
||||
@@ -83,19 +82,18 @@ public class VoiceInputOutputSettings extends SettingsPreferenceFragment
|
||||
}
|
||||
|
||||
private void populateOrRemoveRecognizerPreference() {
|
||||
List<ResolveInfo> availableRecognitionServices = getPackageManager().queryIntentServices(
|
||||
List<ResolveInfo> availableRecognitionServices =
|
||||
mFragment.getPackageManager().queryIntentServices(
|
||||
new Intent(RecognitionService.SERVICE_INTERFACE), PackageManager.GET_META_DATA);
|
||||
int numAvailable = availableRecognitionServices.size();
|
||||
|
||||
if (numAvailable == 0) {
|
||||
// No recognizer available - remove all related preferences.
|
||||
removePreference(mVoiceInputCategory);
|
||||
removePreference(mRecognizerPref);
|
||||
removePreference(mSettingsPref);
|
||||
mFragment.getPreferenceScreen().removePreference(mVoiceInputCategory);
|
||||
} else if (numAvailable == 1) {
|
||||
// Only one recognizer available, so don't show the list of choices, but do
|
||||
// set up the link to settings for the available recognizer.
|
||||
removePreference(mRecognizerPref);
|
||||
mVoiceInputCategory.removePreference(mRecognizerPref);
|
||||
|
||||
// But first set up the available recognizers map with just the one recognizer.
|
||||
ResolveInfo resolveInfo = availableRecognitionServices.get(0);
|
||||
@@ -106,7 +104,7 @@ public class VoiceInputOutputSettings extends SettingsPreferenceFragment
|
||||
mAvailableRecognizersMap.put(recognizerComponent, resolveInfo);
|
||||
|
||||
String currentSetting = Settings.Secure.getString(
|
||||
getContentResolver(), Settings.Secure.VOICE_RECOGNITION_SERVICE);
|
||||
mFragment.getContentResolver(), Settings.Secure.VOICE_RECOGNITION_SERVICE);
|
||||
updateSettingsLink(currentSetting);
|
||||
} else {
|
||||
// Multiple recognizers available, so show the full list of choices.
|
||||
@@ -114,12 +112,6 @@ public class VoiceInputOutputSettings extends SettingsPreferenceFragment
|
||||
}
|
||||
}
|
||||
|
||||
private void removePreference(Preference pref) {
|
||||
if (pref != null) {
|
||||
mParent.removePreference(pref);
|
||||
}
|
||||
}
|
||||
|
||||
private void populateRecognizerPreference(List<ResolveInfo> recognizers) {
|
||||
int size = recognizers.size();
|
||||
CharSequence[] entries = new CharSequence[size];
|
||||
@@ -127,7 +119,7 @@ public class VoiceInputOutputSettings extends SettingsPreferenceFragment
|
||||
|
||||
// Get the current value from the secure setting.
|
||||
String currentSetting = Settings.Secure.getString(
|
||||
getContentResolver(), Settings.Secure.VOICE_RECOGNITION_SERVICE);
|
||||
mFragment.getContentResolver(), Settings.Secure.VOICE_RECOGNITION_SERVICE);
|
||||
|
||||
// Iterate through all the available recognizers and load up their info to show
|
||||
// in the preference. Also build up a map of recognizer component names to their
|
||||
@@ -140,7 +132,7 @@ public class VoiceInputOutputSettings extends SettingsPreferenceFragment
|
||||
|
||||
mAvailableRecognizersMap.put(recognizerComponent, resolveInfo);
|
||||
|
||||
entries[i] = resolveInfo.loadLabel(getPackageManager());
|
||||
entries[i] = resolveInfo.loadLabel(mFragment.getPackageManager());
|
||||
values[i] = recognizerComponent;
|
||||
}
|
||||
|
||||
@@ -159,13 +151,14 @@ public class VoiceInputOutputSettings extends SettingsPreferenceFragment
|
||||
XmlResourceParser parser = null;
|
||||
String settingsActivity = null;
|
||||
try {
|
||||
parser = si.loadXmlMetaData(getPackageManager(), RecognitionService.SERVICE_META_DATA);
|
||||
parser = si.loadXmlMetaData(mFragment.getPackageManager(),
|
||||
RecognitionService.SERVICE_META_DATA);
|
||||
if (parser == null) {
|
||||
throw new XmlPullParserException("No " + RecognitionService.SERVICE_META_DATA +
|
||||
" meta-data for " + si.packageName);
|
||||
}
|
||||
|
||||
Resources res = getPackageManager().getResourcesForApplication(
|
||||
Resources res = mFragment.getPackageManager().getResourcesForApplication(
|
||||
si.applicationInfo);
|
||||
|
||||
AttributeSet attrs = Xml.asAttributeSet(parser);
|
||||
@@ -200,12 +193,12 @@ public class VoiceInputOutputSettings extends SettingsPreferenceFragment
|
||||
// No settings preference available - hide the preference.
|
||||
Log.w(TAG, "no recognizer settings available for " + si.packageName);
|
||||
mSettingsPref.setIntent(null);
|
||||
mParent.removePreference(mSettingsPref);
|
||||
mVoiceInputCategory.removePreference(mSettingsPref);
|
||||
} else {
|
||||
Intent i = new Intent(Intent.ACTION_MAIN);
|
||||
i.setComponent(new ComponentName(si.packageName, settingsActivity));
|
||||
mSettingsPref.setIntent(i);
|
||||
mRecognizerPref.setSummary(currentRecognizer.loadLabel(getPackageManager()));
|
||||
mRecognizerPref.setSummary(currentRecognizer.loadLabel(mFragment.getPackageManager()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,8 +207,7 @@ public class VoiceInputOutputSettings extends SettingsPreferenceFragment
|
||||
String setting = (String) newValue;
|
||||
|
||||
// Put the new value back into secure settings.
|
||||
Settings.Secure.putString(
|
||||
getContentResolver(),
|
||||
Settings.Secure.putString(mFragment.getContentResolver(),
|
||||
Settings.Secure.VOICE_RECOGNITION_SERVICE,
|
||||
setting);
|
||||
|
||||
|
@@ -19,6 +19,7 @@ package com.android.settings.inputmethod;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.VoiceInputOutputSettings;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
@@ -81,6 +82,8 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment {
|
||||
}
|
||||
mCheckboxes = new ArrayList<CheckBoxPreference>();
|
||||
onCreateIMM();
|
||||
|
||||
new VoiceInputOutputSettings(this).onCreate();
|
||||
}
|
||||
|
||||
private boolean isSystemIme(InputMethodInfo property) {
|
||||
|
Reference in New Issue
Block a user