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.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
|
||||||
import android.speech.tts.TextToSpeech.EngineInfo;
|
import android.speech.tts.TextToSpeech.EngineInfo;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.widget.Checkable;
|
import android.widget.Checkable;
|
||||||
@@ -30,7 +29,6 @@ import androidx.preference.Preference;
|
|||||||
import androidx.preference.PreferenceViewHolder;
|
import androidx.preference.PreferenceViewHolder;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.SettingsActivity;
|
|
||||||
|
|
||||||
|
|
||||||
public class TtsEnginePreference extends Preference {
|
public class TtsEnginePreference extends Preference {
|
||||||
@@ -54,9 +52,6 @@ public class TtsEnginePreference extends Preference {
|
|||||||
*/
|
*/
|
||||||
private volatile boolean mPreventRadioButtonCallbacks;
|
private volatile boolean mPreventRadioButtonCallbacks;
|
||||||
|
|
||||||
private RadioButton mRadioButton;
|
|
||||||
private Intent mVoiceCheckData;
|
|
||||||
|
|
||||||
private final CompoundButton.OnCheckedChangeListener mRadioChangeListener =
|
private final CompoundButton.OnCheckedChangeListener mRadioChangeListener =
|
||||||
new CompoundButton.OnCheckedChangeListener() {
|
new CompoundButton.OnCheckedChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -65,10 +60,12 @@ public class TtsEnginePreference extends Preference {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public TtsEnginePreference(Context context, EngineInfo info, RadioButtonGroupState state,
|
public TtsEnginePreference(Context context, EngineInfo info, RadioButtonGroupState state) {
|
||||||
SettingsActivity prefActivity) {
|
|
||||||
super(context);
|
super(context);
|
||||||
setLayoutResource(R.layout.preference_tts_engine);
|
|
||||||
|
setWidgetLayoutResource(R.layout.preference_widget_radiobutton);
|
||||||
|
setLayoutResource(R.layout.preference_radio);
|
||||||
|
setIconSpaceReserved(false);
|
||||||
|
|
||||||
mSharedState = state;
|
mSharedState = state;
|
||||||
mEngineInfo = info;
|
mEngineInfo = info;
|
||||||
@@ -87,9 +84,8 @@ public class TtsEnginePreference extends Preference {
|
|||||||
"setSharedState()");
|
"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.setOnCheckedChangeListener(mRadioChangeListener);
|
||||||
rb.setText(mEngineInfo.label);
|
|
||||||
|
|
||||||
boolean isChecked = getKey().equals(mSharedState.getCurrentKey());
|
boolean isChecked = getKey().equals(mSharedState.getCurrentKey());
|
||||||
if (isChecked) {
|
if (isChecked) {
|
||||||
@@ -99,12 +95,6 @@ public class TtsEnginePreference extends Preference {
|
|||||||
mPreventRadioButtonCallbacks = true;
|
mPreventRadioButtonCallbacks = true;
|
||||||
rb.setChecked(isChecked);
|
rb.setChecked(isChecked);
|
||||||
mPreventRadioButtonCallbacks = false;
|
mPreventRadioButtonCallbacks = false;
|
||||||
|
|
||||||
mRadioButton = rb;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setVoiceDataDetails(Intent data) {
|
|
||||||
mVoiceCheckData = data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean shouldDisplayDataAlert() {
|
private boolean shouldDisplayDataAlert() {
|
||||||
@@ -145,7 +135,7 @@ public class TtsEnginePreference extends Preference {
|
|||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
makeCurrentEngine(buttonView);
|
makeCurrentEngine(buttonView);
|
||||||
}
|
}
|
||||||
},new DialogInterface.OnClickListener() {
|
}, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
// Undo the click.
|
// Undo the click.
|
||||||
@@ -176,9 +166,11 @@ public class TtsEnginePreference extends Preference {
|
|||||||
*/
|
*/
|
||||||
public interface RadioButtonGroupState {
|
public interface RadioButtonGroupState {
|
||||||
String getCurrentKey();
|
String getCurrentKey();
|
||||||
|
|
||||||
Checkable getCurrentChecked();
|
Checkable getCurrentChecked();
|
||||||
|
|
||||||
void setCurrentKey(String key);
|
void setCurrentKey(String key);
|
||||||
|
|
||||||
void setCurrentChecked(Checkable current);
|
void setCurrentChecked(Checkable current);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -15,7 +15,6 @@ import android.widget.Checkable;
|
|||||||
import androidx.preference.PreferenceCategory;
|
import androidx.preference.PreferenceCategory;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.SettingsActivity;
|
|
||||||
import com.android.settings.SettingsPreferenceFragment;
|
import com.android.settings.SettingsPreferenceFragment;
|
||||||
import com.android.settings.search.BaseSearchIndexProvider;
|
import com.android.settings.search.BaseSearchIndexProvider;
|
||||||
import com.android.settings.search.Indexable;
|
import com.android.settings.search.Indexable;
|
||||||
@@ -87,12 +86,10 @@ public class TtsEnginePreferenceFragment extends SettingsPreferenceFragment
|
|||||||
|
|
||||||
mEnginePreferenceCategory.removeAll();
|
mEnginePreferenceCategory.removeAll();
|
||||||
|
|
||||||
SettingsActivity activity = (SettingsActivity) getActivity();
|
|
||||||
|
|
||||||
List<EngineInfo> engines = mEnginesHelper.getEngines();
|
List<EngineInfo> engines = mEnginesHelper.getEngines();
|
||||||
for (EngineInfo engine : engines) {
|
for (EngineInfo engine : engines) {
|
||||||
TtsEnginePreference enginePref =
|
TtsEnginePreference enginePref =
|
||||||
new TtsEnginePreference(getPrefContext(), engine, this, activity);
|
new TtsEnginePreference(getPrefContext(), engine, this);
|
||||||
mEnginePreferenceCategory.addPreference(enginePref);
|
mEnginePreferenceCategory.addPreference(enginePref);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -161,6 +158,7 @@ public class TtsEnginePreferenceFragment extends SettingsPreferenceFragment
|
|||||||
public void onUpdateEngine(int status) {
|
public void onUpdateEngine(int status) {
|
||||||
if (status == TextToSpeech.SUCCESS) {
|
if (status == TextToSpeech.SUCCESS) {
|
||||||
Log.d(
|
Log.d(
|
||||||
|
|
||||||
TAG,
|
TAG,
|
||||||
"Updating engine: Successfully bound to the engine: "
|
"Updating engine: Successfully bound to the engine: "
|
||||||
+ mTts.getCurrentEngine());
|
+ mTts.getCurrentEngine());
|
||||||
|
Reference in New Issue
Block a user