diff options
Diffstat (limited to 'src/com/android/settings/notificationlight/NotificationLightSettings.java')
-rw-r--r-- | src/com/android/settings/notificationlight/NotificationLightSettings.java | 51 |
1 files changed, 40 insertions, 11 deletions
diff --git a/src/com/android/settings/notificationlight/NotificationLightSettings.java b/src/com/android/settings/notificationlight/NotificationLightSettings.java index 95a354d..3b02d36 100644 --- a/src/com/android/settings/notificationlight/NotificationLightSettings.java +++ b/src/com/android/settings/notificationlight/NotificationLightSettings.java @@ -18,6 +18,7 @@ package com.android.settings.notificationlight; import android.app.AlertDialog; import android.app.Dialog; +import android.app.NotificationManager; import android.content.ContentResolver; import android.content.Context; import android.content.DialogInterface; @@ -88,6 +89,7 @@ public class NotificationLightSettings extends SettingsPreferenceFragment implem private String mPackageList; private Map<String, Package> mPackages; private boolean mMultiColorLed; + private boolean mLedCanPulse; @Override public void onCreate(Bundle savedInstanceState) { @@ -97,7 +99,10 @@ public class NotificationLightSettings extends SettingsPreferenceFragment implem PreferenceScreen prefSet = getPreferenceScreen(); Resources resources = getResources(); + final NotificationManager nm = getContext().getSystemService(NotificationManager.class); + PreferenceGroup mAdvancedPrefs = (PreferenceGroup) prefSet.findPreference("advanced_section"); + PreferenceGroup mGeneralPrefs = (PreferenceGroup) prefSet.findPreference("general_section"); // Get the system defined default notification color mDefaultColor = @@ -108,12 +113,14 @@ public class NotificationLightSettings extends SettingsPreferenceFragment implem mDefaultLedOff = resources.getInteger( com.android.internal.R.integer.config_defaultNotificationLedOff); + mLedCanPulse = nm.deviceLightsCan(NotificationManager.LIGHTS_LED_PULSE); + mMultiColorLed = nm.deviceLightsCan(NotificationManager.LIGHTS_RGB_NOTIFICATION); + mEnabledPref = (SystemSettingSwitchPreference) findPreference(Settings.System.NOTIFICATION_LIGHT_PULSE); mEnabledPref.setOnPreferenceChangeListener(this); mDefaultPref = (ApplicationLightPreference) findPreference(DEFAULT_PREF); - mDefaultPref.setOnPreferenceChangeListener(this); mAutoGenerateColors = (CMSystemSettingSwitchPreference) findPreference(CMSettings.System.NOTIFICATION_LIGHT_COLOR_AUTO); @@ -128,23 +135,29 @@ public class NotificationLightSettings extends SettingsPreferenceFragment implem mScreenOnLightsPref.setOnPreferenceChangeListener(this); mCustomEnabledPref = (CMSystemSettingSwitchPreference) findPreference(CMSettings.System.NOTIFICATION_LIGHT_PULSE_CUSTOM_ENABLE); - mCustomEnabledPref.setOnPreferenceChangeListener(this); if (!resources.getBoolean( org.cyanogenmod.platform.internal.R.bool.config_adjustableNotificationLedBrightness)) { mAdvancedPrefs.removePreference(mNotificationLedBrightnessPref); } else { mNotificationLedBrightnessPref.setOnPreferenceChangeListener(this); } - if (!resources.getBoolean( - org.cyanogenmod.platform.internal.R.bool.config_multipleNotificationLeds)) { + if (!nm.deviceLightsCan(NotificationManager.LIGHTS_MULTIPLE_LED)) { mAdvancedPrefs.removePreference(mMultipleLedsEnabledPref); } else { mMultipleLedsEnabledPref.setOnPreferenceChangeListener(this); } + if (!mLedCanPulse && !mMultiColorLed) { + mGeneralPrefs.removePreference(mDefaultPref); + mAdvancedPrefs.removePreference(mCustomEnabledPref); + } else { + mCustomEnabledPref.setOnPreferenceChangeListener(this); + mDefaultPref.setOnPreferenceChangeListener(this); + } // Missed call and Voicemail preferences should only show on devices with a voice capabilities TelephonyManager tm = (TelephonyManager) getActivity().getSystemService(Context.TELEPHONY_SERVICE); - if (tm.getPhoneType() == TelephonyManager.PHONE_TYPE_NONE) { + if (tm.getPhoneType() == TelephonyManager.PHONE_TYPE_NONE + || (!mLedCanPulse && !mMultiColorLed)) { removePreference("phone_list"); } else { mCallPref = (ApplicationLightPreference) findPreference(MISSED_CALL_PREF); @@ -154,8 +167,12 @@ public class NotificationLightSettings extends SettingsPreferenceFragment implem mVoicemailPref.setOnPreferenceChangeListener(this); } - mApplicationPrefList = (PreferenceGroup) findPreference("applications_list"); - mApplicationPrefList.setOrderingAsAdded(false); + if (!mLedCanPulse && !mMultiColorLed) { + removePreference("applications_list"); + } else { + mApplicationPrefList = (PreferenceGroup) findPreference("applications_list"); + mApplicationPrefList.setOrderingAsAdded(false); + } // Get launch-able applications mPackageManager = getPackageManager(); @@ -164,10 +181,8 @@ public class NotificationLightSettings extends SettingsPreferenceFragment implem mPackages = new HashMap<String, Package>(); setHasOptionsMenu(true); - mMultiColorLed = resources.getBoolean(com.android.internal.R.bool.config_multiColorNotificationLed); if (!mMultiColorLed) { resetColors(); - PreferenceGroup mGeneralPrefs = (PreferenceGroup) prefSet.findPreference("general_section"); mGeneralPrefs.removePreference(mAutoGenerateColors); } else { mAutoGenerateColors.setOnPreferenceChangeListener(this); @@ -251,8 +266,10 @@ public class NotificationLightSettings extends SettingsPreferenceFragment implem mVoicemailPref.setAllValues(vmailColor, vmailTimeOn, vmailTimeOff); } - mApplicationPrefList = (PreferenceGroup) findPreference("applications_list"); - mApplicationPrefList.setOrderingAsAdded(false); + if (mLedCanPulse || mMultiColorLed) { + mApplicationPrefList = (PreferenceGroup) findPreference("applications_list"); + mApplicationPrefList.setOrderingAsAdded(false); + } } private void refreshCustomApplicationPrefs() { @@ -284,6 +301,18 @@ public class NotificationLightSettings extends SettingsPreferenceFragment implem // Do nothing } } + + /* Display a pref explaining how to add apps */ + if (mApplicationPrefList.getPreferenceCount() == 0) { + String summary = getResources().getString( + R.string.notification_light_no_apps_summary); + String useCustom = getResources().getString( + R.string.notification_light_use_custom); + Preference pref = new Preference(context); + pref.setSummary(String.format(summary, useCustom)); + pref.setEnabled(false); + mApplicationPrefList.addPreference(pref); + } } } |