Merge "Clean up tts preference layout." into qt-dev
diff --git a/res/layout/preference_tts_engine.xml b/res/layout/preference_tts_engine.xml
deleted file mode 100644
index 19401f0..0000000
--- a/res/layout/preference_tts_engine.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 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.
--->
-
-<LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="?android:attr/listPreferredItemHeight"
- android:paddingStart="@dimen/preference_no_icon_padding_start"
- android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
- android:layout_gravity="center_vertical">
-
- <RadioButton
- android:id="@+id/tts_engine_radiobutton"
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:clickable="true"
- android:layout_weight="1"
- android:maxLines="2"
- android:textAppearance="?android:attr/textAppearanceListItem"
- android:ellipsize="marquee"/>
-</LinearLayout>
diff --git a/src/com/android/settings/tts/TtsEnginePreference.java b/src/com/android/settings/tts/TtsEnginePreference.java
index 7dc00fe..6ea414d 100644
--- a/src/com/android/settings/tts/TtsEnginePreference.java
+++ b/src/com/android/settings/tts/TtsEnginePreference.java
@@ -18,7 +18,6 @@
import android.content.Context;
import android.content.DialogInterface;
-import android.content.Intent;
import android.speech.tts.TextToSpeech.EngineInfo;
import android.util.Log;
import android.widget.Checkable;
@@ -30,7 +29,6 @@
import androidx.preference.PreferenceViewHolder;
import com.android.settings.R;
-import com.android.settings.SettingsActivity;
public class TtsEnginePreference extends Preference {
@@ -54,21 +52,20 @@
*/
private volatile boolean mPreventRadioButtonCallbacks;
- private RadioButton mRadioButton;
- private Intent mVoiceCheckData;
-
private final CompoundButton.OnCheckedChangeListener mRadioChangeListener =
- new CompoundButton.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- onRadioButtonClicked(buttonView, isChecked);
- }
- };
+ new CompoundButton.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ onRadioButtonClicked(buttonView, isChecked);
+ }
+ };
- public TtsEnginePreference(Context context, EngineInfo info, RadioButtonGroupState state,
- SettingsActivity prefActivity) {
+ public TtsEnginePreference(Context context, EngineInfo info, RadioButtonGroupState state) {
super(context);
- setLayoutResource(R.layout.preference_tts_engine);
+
+ setWidgetLayoutResource(R.layout.preference_widget_radiobutton);
+ setLayoutResource(R.layout.preference_radio);
+ setIconSpaceReserved(false);
mSharedState = state;
mEngineInfo = info;
@@ -87,9 +84,8 @@
"setSharedState()");
}
- final RadioButton rb = (RadioButton) view.findViewById(R.id.tts_engine_radiobutton);
+ final RadioButton rb = view.itemView.findViewById(android.R.id.checkbox);
rb.setOnCheckedChangeListener(mRadioChangeListener);
- rb.setText(mEngineInfo.label);
boolean isChecked = getKey().equals(mSharedState.getCurrentKey());
if (isChecked) {
@@ -99,12 +95,6 @@
mPreventRadioButtonCallbacks = true;
rb.setChecked(isChecked);
mPreventRadioButtonCallbacks = false;
-
- mRadioButton = rb;
- }
-
- public void setVoiceDataDetails(Intent data) {
- mVoiceCheckData = data;
}
private boolean shouldDisplayDataAlert() {
@@ -145,7 +135,7 @@
public void onClick(DialogInterface dialog, int which) {
makeCurrentEngine(buttonView);
}
- },new DialogInterface.OnClickListener() {
+ }, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// Undo the click.
@@ -176,9 +166,11 @@
*/
public interface RadioButtonGroupState {
String getCurrentKey();
+
Checkable getCurrentChecked();
void setCurrentKey(String key);
+
void setCurrentChecked(Checkable current);
}
diff --git a/src/com/android/settings/tts/TtsEnginePreferenceFragment.java b/src/com/android/settings/tts/TtsEnginePreferenceFragment.java
index 43bb459..244e5b1 100644
--- a/src/com/android/settings/tts/TtsEnginePreferenceFragment.java
+++ b/src/com/android/settings/tts/TtsEnginePreferenceFragment.java
@@ -15,7 +15,6 @@
import androidx.preference.PreferenceCategory;
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;
@@ -87,12 +86,10 @@
mEnginePreferenceCategory.removeAll();
- SettingsActivity activity = (SettingsActivity) getActivity();
-
List<EngineInfo> engines = mEnginesHelper.getEngines();
for (EngineInfo engine : engines) {
TtsEnginePreference enginePref =
- new TtsEnginePreference(getPrefContext(), engine, this, activity);
+ new TtsEnginePreference(getPrefContext(), engine, this);
mEnginePreferenceCategory.addPreference(enginePref);
}
}
@@ -161,6 +158,7 @@
public void onUpdateEngine(int status) {
if (status == TextToSpeech.SUCCESS) {
Log.d(
+
TAG,
"Updating engine: Successfully bound to the engine: "
+ mTts.getCurrentEngine());