Commits

Shuhrat Dehkanov  committed 9657768

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>

  • Participants
  • Parent commits 19f09fb

Comments (0)

Files changed (6)

File src/com/android/settings/DreamSettings.java

 
             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

File src/com/android/settings/Utils.java

     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.
      */

File src/com/android/settings/inputmethod/CheckBoxAndSettingsPreference.java

 
 import com.android.settings.R;
 import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.Utils;
 
 import android.content.Context;
 import android.content.Intent;
 import android.widget.TextView;
 
 public class CheckBoxAndSettingsPreference extends CheckBoxPreference {
-    private static final float DISABLED_ALPHA = 0.4f;
 
     private SettingsPreferenceFragment mFragment;
     private TextView mTitleText;
                 mSettingsButton.setClickable(checked);
                 mSettingsButton.setFocusable(checked);
                 if (!checked) {
-                    mSettingsButton.setAlpha(DISABLED_ALPHA);
+                    mSettingsButton.setAlpha(Utils.DISABLED_ALPHA);
                 }
             }
         }

File src/com/android/settings/inputmethod/InputMethodPreference.java

 
 import com.android.settings.R;
 import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.Utils;
 
 import android.app.AlertDialog;
 import android.app.Fragment;
 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;
             mInputMethodSettingsButton.setClickable(checked);
             mInputMethodSettingsButton.setFocusable(checked);
             if (!checked) {
-                mInputMethodSettingsButton.setAlpha(DISABLED_ALPHA);
+                mInputMethodSettingsButton.setAlpha(Utils.DISABLED_ALPHA);
             }
         }
         if (mTitleText != null) {

File src/com/android/settings/inputmethod/SingleSpellCheckerPreference.java

 package com.android.settings.inputmethod;
 
 import com.android.settings.R;
+import com.android.settings.Utils;
 
 import android.app.AlertDialog;
 import android.content.ActivityNotFoundException;
 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;
 
                 mSettingsButton.setClickable(enabled);
                 mSettingsButton.setFocusable(enabled);
                 if (!enabled) {
-                    mSettingsButton.setAlpha(DISABLED_ALPHA);
+                    mSettingsButton.setAlpha(Utils.DISABLED_ALPHA);
                 }
             }
         }
                 mSubtypeButton.setClickable(enabled);
                 mSubtypeButton.setFocusable(enabled);
                 if (!enabled) {
-                    mSubtypeButton.setAlpha(DISABLED_ALPHA);
+                    mSubtypeButton.setAlpha(Utils.DISABLED_ALPHA);
                 }
             }
         }

File src/com/android/settings/tts/TtsEnginePreference.java

 
 
 import com.android.settings.R;
+import com.android.settings.Utils;
 
 
 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) {
         // 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);
+            }
         }
     }