Relocate Speech entry point
Bug: 383051970 Flag: android.provider.system_regional_preferences_api_enabled Test: check hsv Change-Id: Id5cbeef4263d94a9c9ebef7ede291b277a740871
This commit is contained in:
@@ -4865,6 +4865,10 @@
|
|||||||
|
|
||||||
<!-- Title for the 'Speech' preference category. [CHAR LIMIT=45] -->
|
<!-- Title for the 'Speech' preference category. [CHAR LIMIT=45] -->
|
||||||
<string name="speech_category_title">Speech</string>
|
<string name="speech_category_title">Speech</string>
|
||||||
|
<!-- Title for the 'Speech' preference. [CHAR LIMIT=45] -->
|
||||||
|
<string name="speech_preference_title">Speech</string>
|
||||||
|
<!-- Summary text for the 'Speech' preference. [CHAR LIMIT=45] -->
|
||||||
|
<string name="speech_preference_summary">Control speech recognition and output</string>
|
||||||
|
|
||||||
<!-- On Languages & input settings screen, setting summary. Setting for mouse pointer speed. [CHAR LIMIT=35] -->
|
<!-- On Languages & input settings screen, setting summary. Setting for mouse pointer speed. [CHAR LIMIT=35] -->
|
||||||
<string name="pointer_speed">Pointer speed</string>
|
<string name="pointer_speed">Pointer speed</string>
|
||||||
|
@@ -44,6 +44,13 @@
|
|||||||
android:name="classname"
|
android:name="classname"
|
||||||
android:value="com.android.settings.applications.appinfo.AppLocaleDetails" />
|
android:value="com.android.settings.applications.appinfo.AppLocaleDetails" />
|
||||||
</Preference>
|
</Preference>
|
||||||
|
|
||||||
|
<Preference
|
||||||
|
android:key="speech_preference"
|
||||||
|
android:title="@string/speech_preference_title"
|
||||||
|
android:summary="@string/speech_preference_summary"
|
||||||
|
android:fragment="com.android.settings.language.SpeechSettings"/>
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="terms_of_address_in_more_language_settings"
|
android:key="terms_of_address_in_more_language_settings"
|
||||||
android:title="@string/terms_of_address_title"
|
android:title="@string/terms_of_address_title"
|
||||||
@@ -109,28 +116,6 @@
|
|||||||
</Preference>
|
</Preference>
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory
|
|
||||||
android:key="speech_category"
|
|
||||||
android:title="@string/speech_category_title">
|
|
||||||
<com.android.settings.widget.GearPreference
|
|
||||||
android:key="voice_input_settings"
|
|
||||||
android:title="@string/voice_input_settings_title"
|
|
||||||
android:fragment="com.android.settings.language.DefaultVoiceInputPicker" />
|
|
||||||
|
|
||||||
<Preference
|
|
||||||
android:key="on_device_recognition_settings"
|
|
||||||
android:title="@string/on_device_recognition_settings_title"
|
|
||||||
android:summary="@string/on_device_recognition_settings_summary"
|
|
||||||
settings:controller=
|
|
||||||
"com.android.settings.language.OnDeviceRecognitionPreferenceController" />
|
|
||||||
|
|
||||||
<Preference
|
|
||||||
android:key="tts_settings_summary"
|
|
||||||
android:title="@string/tts_settings_title"
|
|
||||||
android:fragment="com.android.settings.tts.TextToSpeechSettings"
|
|
||||||
settings:searchable="false"/>
|
|
||||||
</PreferenceCategory>
|
|
||||||
|
|
||||||
<com.android.settingslib.widget.FooterPreference
|
<com.android.settingslib.widget.FooterPreference
|
||||||
android:key="new_regional_pref_footer"
|
android:key="new_regional_pref_footer"
|
||||||
android:title="@string/title_regional_pref_footer"
|
android:title="@string/title_regional_pref_footer"
|
||||||
|
49
res/xml/speech_settings.xml
Normal file
49
res/xml/speech_settings.xml
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
Copyright (C) 2024 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"
|
||||||
|
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:title="@string/speech_preference_title"
|
||||||
|
android:key="speech_settings">
|
||||||
|
|
||||||
|
<com.android.settingslib.widget.TopIntroPreference
|
||||||
|
android:key="speech_settings_intro"
|
||||||
|
android:title="@string/speech_preference_summary"
|
||||||
|
android:persistent="false" />
|
||||||
|
|
||||||
|
<PreferenceCategory
|
||||||
|
android:key="speech_category">
|
||||||
|
<com.android.settings.widget.GearPreference
|
||||||
|
android:key="voice_input_settings"
|
||||||
|
android:title="@string/voice_input_settings_title"
|
||||||
|
android:fragment="com.android.settings.language.DefaultVoiceInputPicker" />
|
||||||
|
|
||||||
|
<Preference
|
||||||
|
android:key="on_device_recognition_settings"
|
||||||
|
android:title="@string/on_device_recognition_settings_title"
|
||||||
|
android:summary="@string/on_device_recognition_settings_summary"
|
||||||
|
settings:controller=
|
||||||
|
"com.android.settings.language.OnDeviceRecognitionPreferenceController" />
|
||||||
|
|
||||||
|
<Preference
|
||||||
|
android:key="tts_settings_summary"
|
||||||
|
android:title="@string/tts_settings_title"
|
||||||
|
android:fragment="com.android.settings.tts.TextToSpeechSettings"
|
||||||
|
settings:searchable="false"/>
|
||||||
|
</PreferenceCategory>
|
||||||
|
</PreferenceScreen>
|
106
src/com/android/settings/language/SpeechSettings.java
Normal file
106
src/com/android/settings/language/SpeechSettings.java
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2024 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.settings.language;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.dashboard.DashboardFragment;
|
||||||
|
import com.android.settings.flags.Flags;
|
||||||
|
import com.android.settings.search.BaseSearchIndexProvider;
|
||||||
|
import com.android.settings.widget.PreferenceCategoryController;
|
||||||
|
import com.android.settingslib.core.AbstractPreferenceController;
|
||||||
|
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class SpeechSettings extends DashboardFragment {
|
||||||
|
|
||||||
|
private static final String TAG = "SpeechSettings";
|
||||||
|
private static final String KEY_SPEECH_CATEGORY = "speech_category";
|
||||||
|
private static final String KEY_ON_DEVICE_RECOGNITION = "on_device_recognition_settings";
|
||||||
|
private static final String KEY_TEXT_TO_SPEECH = "tts_settings_summary";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getPreferenceScreenResId() {
|
||||||
|
return R.xml.speech_settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getLogTag() {
|
||||||
|
return TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMetricsCategory() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
|
||||||
|
return buildPreferenceControllers(context, getSettingsLifecycle());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<AbstractPreferenceController> buildPreferenceControllers(
|
||||||
|
@NonNull Context context, @Nullable Lifecycle lifecycle) {
|
||||||
|
final List<AbstractPreferenceController> controllers = new ArrayList<>();
|
||||||
|
|
||||||
|
final DefaultVoiceInputPreferenceController defaultVoiceInputPreferenceController =
|
||||||
|
new DefaultVoiceInputPreferenceController(context, lifecycle);
|
||||||
|
final TtsPreferenceController ttsPreferenceController =
|
||||||
|
new TtsPreferenceController(context, KEY_TEXT_TO_SPEECH);
|
||||||
|
final OnDeviceRecognitionPreferenceController onDeviceRecognitionPreferenceController =
|
||||||
|
new OnDeviceRecognitionPreferenceController(context, KEY_ON_DEVICE_RECOGNITION);
|
||||||
|
|
||||||
|
controllers.add(defaultVoiceInputPreferenceController);
|
||||||
|
controllers.add(ttsPreferenceController);
|
||||||
|
List<AbstractPreferenceController> speechCategoryChildren = new ArrayList<>(
|
||||||
|
List.of(defaultVoiceInputPreferenceController, ttsPreferenceController));
|
||||||
|
|
||||||
|
if (onDeviceRecognitionPreferenceController.isAvailable()) {
|
||||||
|
controllers.add(onDeviceRecognitionPreferenceController);
|
||||||
|
speechCategoryChildren.add(onDeviceRecognitionPreferenceController);
|
||||||
|
}
|
||||||
|
|
||||||
|
controllers.add(new PreferenceCategoryController(context, KEY_SPEECH_CATEGORY)
|
||||||
|
.setChildren(speechCategoryChildren));
|
||||||
|
|
||||||
|
return controllers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||||
|
new BaseSearchIndexProvider(R.xml.language_and_region_settings) {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NonNull
|
||||||
|
public List<AbstractPreferenceController> createPreferenceControllers(
|
||||||
|
@NonNull Context context) {
|
||||||
|
return buildPreferenceControllers(context, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isPageSearchEnabled(Context context) {
|
||||||
|
if (Flags.regionalPreferencesApiEnabled()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
Reference in New Issue
Block a user