Merge "Index TTS-Settings and dedupe TTS-engine in search result."
diff --git a/res/xml/tts_engine_picker.xml b/res/xml/tts_engine_picker.xml
index d7a76d4..c0a464c 100644
--- a/res/xml/tts_engine_picker.xml
+++ b/res/xml/tts_engine_picker.xml
@@ -15,7 +15,7 @@
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- android:title="@string/tts_settings_title">
+ android:title="@string/tts_engine_preference_title">
<PreferenceCategory android:key="tts_engine_preference_category"/>
diff --git a/src/com/android/settings/accessibility/AccessibilitySettings.java b/src/com/android/settings/accessibility/AccessibilitySettings.java
index 51b676d..a335c83 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettings.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettings.java
@@ -107,6 +107,8 @@
"magnification_preference_screen";
private static final String FONT_SIZE_PREFERENCE_SCREEN =
"font_size_preference_screen";
+ private static final String TTS_SETTINGS_PREFERENCE =
+ "tts_settings_preference";
private static final String AUTOCLICK_PREFERENCE_SCREEN =
"autoclick_preference_screen";
private static final String DISPLAY_DALTONIZER_PREFERENCE_SCREEN =
@@ -743,6 +745,9 @@
keys.add(FONT_SIZE_PREFERENCE_SCREEN);
keys.add(DisplaySettings.KEY_DISPLAY_SIZE);
+ // Duplicates in Language & Input
+ keys.add(TTS_SETTINGS_PREFERENCE);
+
return keys;
}
};
diff --git a/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java b/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
index c0ce3b9..b0abec4 100644
--- a/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
+++ b/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
@@ -249,6 +249,10 @@
final String uri = tile.metaData.getString(META_DATA_PREFERENCE_ICON_URI);
final Pair<String, Integer> iconInfo = TileUtils.getIconFromUri(
mContext, packageName, uri, providerMap);
+ if (iconInfo == null) {
+ Log.w(TAG, "Failed to get icon from uri " + uri);
+ return;
+ }
tile.icon = Icon.createWithResource(iconInfo.first, iconInfo.second);
ThreadUtils.postOnMainThread(() ->
preference.setIcon(tile.icon.loadDrawable(preference.getContext()))
diff --git a/src/com/android/settings/search/SearchIndexableResources.java b/src/com/android/settings/search/SearchIndexableResources.java
index c20d2a0..d67e8eb 100644
--- a/src/com/android/settings/search/SearchIndexableResources.java
+++ b/src/com/android/settings/search/SearchIndexableResources.java
@@ -81,6 +81,7 @@
import com.android.settings.support.SupportDashboardActivity;
import com.android.settings.system.ResetDashboardFragment;
import com.android.settings.system.SystemDashboardFragment;
+import com.android.settings.tts.TextToSpeechSettings;
import com.android.settings.tts.TtsEnginePreferenceFragment;
import com.android.settings.users.UserSettings;
import com.android.settings.wallpaper.WallpaperTypeSettings;
@@ -199,6 +200,7 @@
R.drawable.ic_devices_other);
addIndex(EnterprisePrivacySettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_about);
addIndex(PaymentSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_nfc_payment);
+ addIndex(TextToSpeechSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_accessibility);
addIndex(
TtsEnginePreferenceFragment.class, NO_DATA_RES_ID, R.drawable.ic_settings_language);
addIndex(LockscreenDashboardFragment.class, R.xml.security_lockscreen_settings,
diff --git a/src/com/android/settings/tts/TextToSpeechSettings.java b/src/com/android/settings/tts/TextToSpeechSettings.java
index 4ea422b..9092c0d 100644
--- a/src/com/android/settings/tts/TextToSpeechSettings.java
+++ b/src/com/android/settings/tts/TextToSpeechSettings.java
@@ -23,8 +23,10 @@
import android.app.AlertDialog;
import android.content.ActivityNotFoundException;
import android.content.ContentResolver;
+import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
+import android.provider.SearchIndexableResource;
import android.speech.tts.TextToSpeech;
import android.speech.tts.TextToSpeech.EngineInfo;
import android.speech.tts.TtsEngines;
@@ -39,11 +41,14 @@
import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settings.search.Indexable;
import com.android.settings.widget.ActionButtonPreference;
import com.android.settings.widget.GearPreference;
import com.android.settings.widget.SeekBarPreference;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
@@ -55,7 +60,7 @@
public class TextToSpeechSettings extends SettingsPreferenceFragment
implements Preference.OnPreferenceChangeListener,
- GearPreference.OnGearClickListener {
+ GearPreference.OnGearClickListener, Indexable {
private static final String STATE_KEY_LOCALE_ENTRIES = "locale_entries";
private static final String STATE_KEY_LOCALE_ENTRY_VALUES = "locale_entry_values";
@@ -225,7 +230,8 @@
// Do set pitch correctly after it may have changed, and unlike speed, it doesn't change
// immediately.
final ContentResolver resolver = getContentResolver();
- mTts.setPitch(android.provider.Settings.Secure.getInt(resolver, TTS_DEFAULT_PITCH, TextToSpeech.Engine.DEFAULT_PITCH)/100.0f);
+ mTts.setPitch(android.provider.Settings.Secure.getInt(resolver, TTS_DEFAULT_PITCH,
+ TextToSpeech.Engine.DEFAULT_PITCH) / 100.0f);
}
Locale ttsDefaultLocale = mTts.getDefaultLanguage();
@@ -241,10 +247,12 @@
}
mTts.setOnUtteranceProgressListener(new UtteranceProgressListener() {
@Override
- public void onStart(String utteranceId) {}
+ public void onStart(String utteranceId) {
+ }
@Override
- public void onDone(String utteranceId) {}
+ public void onDone(String utteranceId) {
+ }
@Override
public void onError(String utteranceId) {
@@ -313,7 +321,6 @@
EngineInfo info = mEnginesHelper.getEngineInfo(mCurrentEngine);
-
Preference mEnginePreference = findPreference(KEY_TTS_ENGINE_PREFERENCE);
((GearPreference) mEnginePreference).setOnGearClickListener(this);
mEnginePreference.setSummary(info.label);
@@ -364,7 +371,10 @@
}
});
} else {
- if (DBG) Log.d(TAG, "TTS engine for settings screen failed to initialize successfully.");
+ if (DBG) {
+ Log.d(TAG,
+ "TTS engine for settings screen failed to initialize successfully.");
+ }
updateWidgetState(false);
}
}
@@ -411,8 +421,8 @@
for (String loc : mAvailableStrLocals) {
if (loc.equalsIgnoreCase(defaultLocaleStr)) {
- notInAvailableLangauges = false;
- break;
+ notInAvailableLangauges = false;
+ break;
}
}
} catch (MissingResourceException e) {
@@ -572,7 +582,7 @@
private boolean isNetworkRequiredForSynthesis() {
Set<String> features = mTts.getFeatures(mCurrentDefaultLocale);
if (features == null) {
- return false;
+ return false;
}
return features.contains(TextToSpeech.Engine.KEY_FEATURE_NETWORK_SYNTHESIS) &&
!features.contains(TextToSpeech.Engine.KEY_FEATURE_EMBEDDED_SYNTHESIS);
@@ -735,7 +745,7 @@
return;
}
- if (data == null){
+ if (data == null) {
Log.e(TAG, "Engine failed voice data integrity check (null return)" +
mTts.getCurrentEngine());
return;
@@ -744,7 +754,7 @@
android.provider.Settings.Secure.putString(getContentResolver(), TTS_DEFAULT_SYNTH, engine);
mAvailableStrLocals = data.getStringArrayListExtra(
- TextToSpeech.Engine.EXTRA_AVAILABLE_VOICES);
+ TextToSpeech.Engine.EXTRA_AVAILABLE_VOICES);
if (mAvailableStrLocals == null) {
Log.e(TAG, "Voice data check complete, but no available voices found");
// Set mAvailableStrLocals to empty list
@@ -764,4 +774,22 @@
}
}
+ public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+ new BaseSearchIndexProvider() {
+ @Override
+ public List<SearchIndexableResource> getXmlResourcesToIndex(
+ Context context, boolean enabled) {
+ final SearchIndexableResource sir = new SearchIndexableResource(context);
+ sir.xmlResId = R.xml.tts_settings;
+ return Arrays.asList(sir);
+ }
+
+ @Override
+ public List<String> getNonIndexableKeys(Context context) {
+ final List<String> keys = super.getNonIndexableKeys(context);
+ keys.add("tts_engine_preference");
+ return keys;
+ }
+ };
+
}
diff --git a/src/com/android/settings/tts/TtsEnginePreferenceFragment.java b/src/com/android/settings/tts/TtsEnginePreferenceFragment.java
index e0ed8b7..8e6cfec 100644
--- a/src/com/android/settings/tts/TtsEnginePreferenceFragment.java
+++ b/src/com/android/settings/tts/TtsEnginePreferenceFragment.java
@@ -23,7 +23,7 @@
public class TtsEnginePreferenceFragment extends SettingsPreferenceFragment //implements
implements RadioButtonGroupState, Indexable {
- private static final String TAG = "TtsEnginePreferenceFragment";
+ private static final String TAG = "TtsEnginePrefFragment";
private static final int VOICE_DATA_INTEGRITY_CHECK = 1977;
@@ -185,7 +185,6 @@
@Override
public List<SearchIndexableResource> getXmlResourcesToIndex(
Context context, boolean enabled) {
- Log.i(TAG, "Indexing");
final SearchIndexableResource sir = new SearchIndexableResource(context);
sir.xmlResId = R.xml.tts_engine_picker;
return Arrays.asList(sir);
diff --git a/tests/robotests/assets/grandfather_not_implementing_indexable b/tests/robotests/assets/grandfather_not_implementing_indexable
index be5a99b..695342e 100644
--- a/tests/robotests/assets/grandfather_not_implementing_indexable
+++ b/tests/robotests/assets/grandfather_not_implementing_indexable
@@ -36,7 +36,6 @@
com.android.settings.applications.AppLaunchSettings
com.android.settings.fuelgauge.BatterySaverSettings
com.android.settings.location.ScanningSettings
-com.android.settings.tts.TextToSpeechSettings
com.android.settings.applications.ProcessStatsUi
com.android.settings.notification.ZenModeScheduleRuleSettings
com.android.settings.datausage.BillingCycleSettings