Merge "Misc fixes to TTS settings."
diff --git a/res/xml/tts_settings.xml b/res/xml/tts_settings.xml
index 4a24154..e76cdb7 100644
--- a/res/xml/tts_settings.xml
+++ b/res/xml/tts_settings.xml
@@ -20,21 +20,17 @@
android:key="tts_settings_screen"
android:title="@string/tts_settings_title">
- <PreferenceCategory android:key="tts_engine_section">
+ <com.android.settings.widget.GearPreference
+ android:key="tts_engine_preference"
+ android:title="@string/tts_engine_preference_title"
+ android:fragment="com.android.settings.tts.TtsEnginePreferenceFragment"
+ settings:searchable="false"/>
- <com.android.settings.widget.GearPreference
- android:key="tts_engine_preference"
- android:title="@string/tts_engine_preference_title"
- android:fragment="com.android.settings.tts.TtsEnginePreferenceFragment"
- settings:searchable="false"/>
-
- <ListPreference
- android:key="tts_default_lang"
- android:title="@string/tts_default_lang_title"
- android:summary="@string/tts_default_lang_summary"
- android:persistent="false" />
-
- </PreferenceCategory>
+ <ListPreference
+ android:key="tts_default_lang"
+ android:title="@string/tts_default_lang_title"
+ android:summary="@string/tts_default_lang_summary"
+ android:persistent="false" />
<PreferenceCategory android:key="tts_general_section">
diff --git a/src/com/android/settings/tts/TextToSpeechSettings.java b/src/com/android/settings/tts/TextToSpeechSettings.java
index 0f10d28..866e5a8 100644
--- a/src/com/android/settings/tts/TextToSpeechSettings.java
+++ b/src/com/android/settings/tts/TextToSpeechSettings.java
@@ -147,12 +147,7 @@
* screen for the first time (as opposed to when a user changes his choice
* of engine).
*/
- private final TextToSpeech.OnInitListener mInitListener = new TextToSpeech.OnInitListener() {
- @Override
- public void onInit(int status) {
- onInitEngine(status);
- }
- };
+ private final TextToSpeech.OnInitListener mInitListener = this::onInitEngine;
@Override
public int getMetricsCategory() {
@@ -215,6 +210,11 @@
@Override
public void onResume() {
super.onResume();
+ // We tend to change the summary contents of our widgets, which at higher text sizes causes
+ // them to resize, which results in the recyclerview smoothly animating them at inopportune
+ // times. Disable the animation so widgets snap to their positions rather than sliding
+ // around while the user is interacting with it.
+ getListView().getItemAnimator().setMoveDuration(0);
if (mTts == null || mCurrentDefaultLocale == null) {
return;
@@ -323,7 +323,6 @@
if (mCurrentEngine != null) {
EngineInfo info = mEnginesHelper.getEngineInfo(mCurrentEngine);
-
Preference mEnginePreference = findPreference(KEY_TTS_ENGINE_PREFERENCE);
((GearPreference) mEnginePreference).setOnGearClickListener(this);
mEnginePreference.setSummary(info.label);
@@ -365,14 +364,7 @@
if (status == TextToSpeech.SUCCESS) {
if (DBG) Log.d(TAG, "TTS engine for settings screen initialized.");
checkDefaultLocale();
- getActivity()
- .runOnUiThread(
- new Runnable() {
- @Override
- public void run() {
- mLocalePreference.setEnabled(true);
- }
- });
+ getActivity().runOnUiThread(() -> mLocalePreference.setEnabled(true));
} else {
if (DBG) {
Log.d(TAG,
@@ -516,14 +508,7 @@
}
// Sort it
- Collections.sort(
- entryPairs,
- new Comparator<Pair<String, Locale>>() {
- @Override
- public int compare(Pair<String, Locale> lhs, Pair<String, Locale> rhs) {
- return lhs.first.compareToIgnoreCase(rhs.first);
- }
- });
+ Collections.sort(entryPairs, (lhs, rhs) -> lhs.first.compareToIgnoreCase(rhs.first));
// Get two arrays out of one of pairs
mSelectedLocaleIndex = 0; // Will point to the R.string.tts_lang_use_system value