Misc fixes to TTS settings.
1. Remove an extra PreferenceGroup that was causing some spacing issues. 2. Remove the animations when elements resize because this causes items to slide around unnecessarily. 3. While we're in the file, lambda-ify some of the older code. Bug: 77981482 Bug: 79897262 Test: Manually verified. Change-Id: I9c79beea3a231ba62aeef3543802faebd775e128
This commit is contained in:
@@ -20,8 +20,6 @@
|
|||||||
android:key="tts_settings_screen"
|
android:key="tts_settings_screen"
|
||||||
android:title="@string/tts_settings_title">
|
android:title="@string/tts_settings_title">
|
||||||
|
|
||||||
<PreferenceCategory android:key="tts_engine_section">
|
|
||||||
|
|
||||||
<com.android.settings.widget.GearPreference
|
<com.android.settings.widget.GearPreference
|
||||||
android:key="tts_engine_preference"
|
android:key="tts_engine_preference"
|
||||||
android:title="@string/tts_engine_preference_title"
|
android:title="@string/tts_engine_preference_title"
|
||||||
@@ -34,8 +32,6 @@
|
|||||||
android:summary="@string/tts_default_lang_summary"
|
android:summary="@string/tts_default_lang_summary"
|
||||||
android:persistent="false" />
|
android:persistent="false" />
|
||||||
|
|
||||||
</PreferenceCategory>
|
|
||||||
|
|
||||||
<PreferenceCategory android:key="tts_general_section">
|
<PreferenceCategory android:key="tts_general_section">
|
||||||
|
|
||||||
<!-- The max value for seek bars here should be kept in sync
|
<!-- The max value for seek bars here should be kept in sync
|
||||||
|
@@ -147,12 +147,7 @@ public class TextToSpeechSettings extends SettingsPreferenceFragment
|
|||||||
* screen for the first time (as opposed to when a user changes his choice
|
* screen for the first time (as opposed to when a user changes his choice
|
||||||
* of engine).
|
* of engine).
|
||||||
*/
|
*/
|
||||||
private final TextToSpeech.OnInitListener mInitListener = new TextToSpeech.OnInitListener() {
|
private final TextToSpeech.OnInitListener mInitListener = this::onInitEngine;
|
||||||
@Override
|
|
||||||
public void onInit(int status) {
|
|
||||||
onInitEngine(status);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMetricsCategory() {
|
public int getMetricsCategory() {
|
||||||
@@ -215,6 +210,11 @@ public class TextToSpeechSettings extends SettingsPreferenceFragment
|
|||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.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) {
|
if (mTts == null || mCurrentDefaultLocale == null) {
|
||||||
return;
|
return;
|
||||||
@@ -323,7 +323,6 @@ public class TextToSpeechSettings extends SettingsPreferenceFragment
|
|||||||
if (mCurrentEngine != null) {
|
if (mCurrentEngine != null) {
|
||||||
EngineInfo info = mEnginesHelper.getEngineInfo(mCurrentEngine);
|
EngineInfo info = mEnginesHelper.getEngineInfo(mCurrentEngine);
|
||||||
|
|
||||||
|
|
||||||
Preference mEnginePreference = findPreference(KEY_TTS_ENGINE_PREFERENCE);
|
Preference mEnginePreference = findPreference(KEY_TTS_ENGINE_PREFERENCE);
|
||||||
((GearPreference) mEnginePreference).setOnGearClickListener(this);
|
((GearPreference) mEnginePreference).setOnGearClickListener(this);
|
||||||
mEnginePreference.setSummary(info.label);
|
mEnginePreference.setSummary(info.label);
|
||||||
@@ -365,14 +364,7 @@ public class TextToSpeechSettings extends SettingsPreferenceFragment
|
|||||||
if (status == TextToSpeech.SUCCESS) {
|
if (status == TextToSpeech.SUCCESS) {
|
||||||
if (DBG) Log.d(TAG, "TTS engine for settings screen initialized.");
|
if (DBG) Log.d(TAG, "TTS engine for settings screen initialized.");
|
||||||
checkDefaultLocale();
|
checkDefaultLocale();
|
||||||
getActivity()
|
getActivity().runOnUiThread(() -> mLocalePreference.setEnabled(true));
|
||||||
.runOnUiThread(
|
|
||||||
new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
mLocalePreference.setEnabled(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
if (DBG) {
|
if (DBG) {
|
||||||
Log.d(TAG,
|
Log.d(TAG,
|
||||||
@@ -516,14 +508,7 @@ public class TextToSpeechSettings extends SettingsPreferenceFragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Sort it
|
// Sort it
|
||||||
Collections.sort(
|
Collections.sort(entryPairs, (lhs, rhs) -> lhs.first.compareToIgnoreCase(rhs.first));
|
||||||
entryPairs,
|
|
||||||
new Comparator<Pair<String, Locale>>() {
|
|
||||||
@Override
|
|
||||||
public int compare(Pair<String, Locale> lhs, Pair<String, Locale> rhs) {
|
|
||||||
return lhs.first.compareToIgnoreCase(rhs.first);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Get two arrays out of one of pairs
|
// Get two arrays out of one of pairs
|
||||||
mSelectedLocaleIndex = 0; // Will point to the R.string.tts_lang_use_system value
|
mSelectedLocaleIndex = 0; // Will point to the R.string.tts_lang_use_system value
|
||||||
|
Reference in New Issue
Block a user