diff options
author | Shuhrat Dehkanov <uzbmaster@gmail.com> | 2012-10-03 12:24:07 +0900 |
---|---|---|
committer | Shuhrat Dehkanov <uzbmaster@gmail.com> | 2012-11-28 23:45:35 +0900 |
commit | 96577681a298b44be2e1133b10bc637623be3b87 (patch) | |
tree | ba5a0df757ed5a0170c83625a32810639db09389 | |
parent | 19f09fb127cd193023fe518f4fe3ae890c1b52d4 (diff) | |
download | packages_apps_Settings-96577681a298b44be2e1133b10bc637623be3b87.zip packages_apps_Settings-96577681a298b44be2e1133b10bc637623be3b87.tar.gz packages_apps_Settings-96577681a298b44be2e1133b10bc637623be3b87.tar.bz2 |
Grey out settings icon when it is in disabled state
If engine is not active, its settings icon is disabled in
Settings > Language & input > Text-to-speech output screen.
Currently, settings icons for all TTS engines are shown at
the same opacity. This fix dims settings icons of not-selected
engines.
Make sure that more than one TTS engine are installed on the
target, for e.g., Google Text-to-speech Engine and Classic
Text To Speech Engine (SVOX Classic TTS).
Additionally, since setAlpha() is used in multiple places within
Settings package, moved DISABLED_ALPHA declaration to Utils.java
in order to have single point of reference.
Change-Id: Ifa7de79814a2f4a4aa021cd8621cbfab41655680
Signed-off-by: Shuhrat Dehkanov <uzbmaster@gmail.com>
6 files changed, 23 insertions, 9 deletions
diff --git a/src/com/android/settings/DreamSettings.java b/src/com/android/settings/DreamSettings.java index 32328d9..23285c0 100644 --- a/src/com/android/settings/DreamSettings.java +++ b/src/com/android/settings/DreamSettings.java @@ -316,7 +316,7 @@ public class DreamSettings extends SettingsPreferenceFragment { ImageView settingsButton = (ImageView) row.findViewById(android.R.id.button2); settingsButton.setVisibility(showSettings ? View.VISIBLE : View.INVISIBLE); - settingsButton.setAlpha(dreamInfo.isActive ? 1f : 0.33f); + settingsButton.setAlpha(dreamInfo.isActive ? 1f : Utils.DISABLED_ALPHA); settingsButton.setEnabled(dreamInfo.isActive); settingsButton.setOnClickListener(new OnClickListener(){ @Override diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java index 6d76bed..4b0a753 100644 --- a/src/com/android/settings/Utils.java +++ b/src/com/android/settings/Utils.java @@ -80,6 +80,11 @@ public class Utils { public static final int UPDATE_PREFERENCE_FLAG_SET_TITLE_TO_MATCHING_ACTIVITY = 1; /** + * The opacity level of a disabled icon. + */ + public static final float DISABLED_ALPHA = 0.4f; + + /** * Name of the meta-data item that should be set in the AndroidManifest.xml * to specify the icon that should be displayed for the preference. */ diff --git a/src/com/android/settings/inputmethod/CheckBoxAndSettingsPreference.java b/src/com/android/settings/inputmethod/CheckBoxAndSettingsPreference.java index 28b8616..f440bc8 100644 --- a/src/com/android/settings/inputmethod/CheckBoxAndSettingsPreference.java +++ b/src/com/android/settings/inputmethod/CheckBoxAndSettingsPreference.java @@ -18,6 +18,7 @@ package com.android.settings.inputmethod; import com.android.settings.R; import com.android.settings.SettingsPreferenceFragment; +import com.android.settings.Utils; import android.content.Context; import android.content.Intent; @@ -29,7 +30,6 @@ import android.widget.ImageView; import android.widget.TextView; public class CheckBoxAndSettingsPreference extends CheckBoxPreference { - private static final float DISABLED_ALPHA = 0.4f; private SettingsPreferenceFragment mFragment; private TextView mTitleText; @@ -103,7 +103,7 @@ public class CheckBoxAndSettingsPreference extends CheckBoxPreference { mSettingsButton.setClickable(checked); mSettingsButton.setFocusable(checked); if (!checked) { - mSettingsButton.setAlpha(DISABLED_ALPHA); + mSettingsButton.setAlpha(Utils.DISABLED_ALPHA); } } } diff --git a/src/com/android/settings/inputmethod/InputMethodPreference.java b/src/com/android/settings/inputmethod/InputMethodPreference.java index 103481e..f064c08 100644 --- a/src/com/android/settings/inputmethod/InputMethodPreference.java +++ b/src/com/android/settings/inputmethod/InputMethodPreference.java @@ -18,6 +18,7 @@ package com.android.settings.inputmethod; import com.android.settings.R; import com.android.settings.SettingsPreferenceFragment; +import com.android.settings.Utils; import android.app.AlertDialog; import android.app.Fragment; @@ -47,7 +48,6 @@ import java.util.List; public class InputMethodPreference extends CheckBoxPreference implements Comparator<InputMethodPreference> { private static final String TAG = InputMethodPreference.class.getSimpleName(); - private static final float DISABLED_ALPHA = 0.4f; private final SettingsPreferenceFragment mFragment; private final InputMethodInfo mImi; private final InputMethodManager mImm; @@ -172,7 +172,7 @@ public class InputMethodPreference extends CheckBoxPreference mInputMethodSettingsButton.setClickable(checked); mInputMethodSettingsButton.setFocusable(checked); if (!checked) { - mInputMethodSettingsButton.setAlpha(DISABLED_ALPHA); + mInputMethodSettingsButton.setAlpha(Utils.DISABLED_ALPHA); } } if (mTitleText != null) { diff --git a/src/com/android/settings/inputmethod/SingleSpellCheckerPreference.java b/src/com/android/settings/inputmethod/SingleSpellCheckerPreference.java index 5b28142..5ea8bd7 100644 --- a/src/com/android/settings/inputmethod/SingleSpellCheckerPreference.java +++ b/src/com/android/settings/inputmethod/SingleSpellCheckerPreference.java @@ -17,6 +17,7 @@ package com.android.settings.inputmethod; import com.android.settings.R; +import com.android.settings.Utils; import android.app.AlertDialog; import android.content.ActivityNotFoundException; @@ -37,7 +38,6 @@ import android.widget.TextView; import android.widget.Toast; public class SingleSpellCheckerPreference extends Preference { - private static final float DISABLED_ALPHA = 0.4f; private static final String TAG = SingleSpellCheckerPreference.class.getSimpleName(); private static final boolean DBG = false; @@ -198,7 +198,7 @@ public class SingleSpellCheckerPreference extends Preference { mSettingsButton.setClickable(enabled); mSettingsButton.setFocusable(enabled); if (!enabled) { - mSettingsButton.setAlpha(DISABLED_ALPHA); + mSettingsButton.setAlpha(Utils.DISABLED_ALPHA); } } } @@ -210,7 +210,7 @@ public class SingleSpellCheckerPreference extends Preference { mSubtypeButton.setClickable(enabled); mSubtypeButton.setFocusable(enabled); if (!enabled) { - mSubtypeButton.setAlpha(DISABLED_ALPHA); + mSubtypeButton.setAlpha(Utils.DISABLED_ALPHA); } } } diff --git a/src/com/android/settings/tts/TtsEnginePreference.java b/src/com/android/settings/tts/TtsEnginePreference.java index 3d612f0..21ef81d 100644 --- a/src/com/android/settings/tts/TtsEnginePreference.java +++ b/src/com/android/settings/tts/TtsEnginePreference.java @@ -30,6 +30,7 @@ import android.widget.RadioButton; import com.android.settings.R; +import com.android.settings.Utils; public class TtsEnginePreference extends Preference { @@ -136,6 +137,9 @@ public class TtsEnginePreference extends Preference { // Will be enabled only the engine has passed the voice check, and // is currently enabled. mSettingsIcon.setEnabled(isChecked && mVoiceCheckData != null); + if (!isChecked) { + mSettingsIcon.setAlpha(Utils.DISABLED_ALPHA); + } mSettingsIcon.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -169,7 +173,12 @@ public class TtsEnginePreference extends Preference { // case mSettingsIcon && mRadioButton will be null. In this case // getView will set the right values. if (mSettingsIcon != null && mRadioButton != null) { - mSettingsIcon.setEnabled(mRadioButton.isChecked()); + if (mRadioButton.isChecked()) { + mSettingsIcon.setEnabled(true); + } else { + mSettingsIcon.setEnabled(false); + mSettingsIcon.setAlpha(Utils.DISABLED_ALPHA); + } } } |