Merge "Clean up tts preference layout." into qt-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
963ebf576a
@@ -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>
|
@@ -18,7 +18,6 @@ package com.android.settings.tts;
|
||||
|
||||
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.Preference;
|
||||
import androidx.preference.PreferenceViewHolder;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
|
||||
|
||||
public class TtsEnginePreference extends Preference {
|
||||
@@ -54,21 +52,20 @@ public class TtsEnginePreference extends Preference {
|
||||
*/
|
||||
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 @@ public class TtsEnginePreference extends Preference {
|
||||
"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 @@ public class TtsEnginePreference extends Preference {
|
||||
mPreventRadioButtonCallbacks = true;
|
||||
rb.setChecked(isChecked);
|
||||
mPreventRadioButtonCallbacks = false;
|
||||
|
||||
mRadioButton = rb;
|
||||
}
|
||||
|
||||
public void setVoiceDataDetails(Intent data) {
|
||||
mVoiceCheckData = data;
|
||||
}
|
||||
|
||||
private boolean shouldDisplayDataAlert() {
|
||||
@@ -145,7 +135,7 @@ public class TtsEnginePreference extends Preference {
|
||||
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 class TtsEnginePreference extends Preference {
|
||||
*/
|
||||
public interface RadioButtonGroupState {
|
||||
String getCurrentKey();
|
||||
|
||||
Checkable getCurrentChecked();
|
||||
|
||||
void setCurrentKey(String key);
|
||||
|
||||
void setCurrentChecked(Checkable current);
|
||||
}
|
||||
|
||||
|
@@ -15,7 +15,6 @@ import android.widget.Checkable;
|
||||
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 @@ public class TtsEnginePreferenceFragment extends SettingsPreferenceFragment
|
||||
|
||||
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 class TtsEnginePreferenceFragment extends SettingsPreferenceFragment
|
||||
public void onUpdateEngine(int status) {
|
||||
if (status == TextToSpeech.SUCCESS) {
|
||||
Log.d(
|
||||
|
||||
TAG,
|
||||
"Updating engine: Successfully bound to the engine: "
|
||||
+ mTts.getCurrentEngine());
|
||||
|
Reference in New Issue
Block a user