diff options
4 files changed, 20 insertions, 13 deletions
diff --git a/src/com/android/settings/notificationlight/ApplicationLightPreference.java b/src/com/android/settings/notificationlight/ApplicationLightPreference.java index a12f45b..405c826 100644 --- a/src/com/android/settings/notificationlight/ApplicationLightPreference.java +++ b/src/com/android/settings/notificationlight/ApplicationLightPreference.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.Context; import android.content.DialogInterface; import android.content.res.Resources; @@ -55,11 +56,11 @@ public class ApplicationLightPreference extends DialogPreference { */ public ApplicationLightPreference(Context context, AttributeSet attrs) { super(context, attrs); + NotificationManager nm = context.getSystemService(NotificationManager.class); mColorValue = DEFAULT_COLOR; mOnValue = DEFAULT_TIME; mOffValue = DEFAULT_TIME; - mOnOffChangeable = context.getResources().getBoolean( - com.android.internal.R.bool.config_ledCanPulse); + mOnOffChangeable = nm.deviceLightsCan(NotificationManager.LIGHTS_LED_PULSE); init(); } @@ -71,11 +72,11 @@ public class ApplicationLightPreference extends DialogPreference { */ public ApplicationLightPreference(Context context, int color, int onValue, int offValue) { super(context, null); + NotificationManager nm = context.getSystemService(NotificationManager.class); mColorValue = color; mOnValue = onValue; mOffValue = offValue; - mOnOffChangeable = context.getResources().getBoolean( - com.android.internal.R.bool.config_ledCanPulse); + mOnOffChangeable = nm.deviceLightsCan(NotificationManager.LIGHTS_LED_PULSE); init(); } @@ -117,6 +118,8 @@ public class ApplicationLightPreference extends DialogPreference { protected void onBindView(View view) { super.onBindView(view); + NotificationManager nm = getContext().getSystemService(NotificationManager.class); + mLightColorView = (ImageView) view.findViewById(R.id.light_color); mOnValueView = (TextView) view.findViewById(R.id.textViewTimeOnValue); mOffValueView = (TextView) view.findViewById(R.id.textViewTimeOffValue); @@ -126,7 +129,7 @@ public class ApplicationLightPreference extends DialogPreference { TextView tView = (TextView) view.findViewById(android.R.id.summary); tView.setVisibility(View.GONE); - if (!mResources.getBoolean(com.android.internal.R.bool.config_multiColorNotificationLed)) { + if (!nm.deviceLightsCan(NotificationManager.LIGHTS_RGB_NOTIFICATION)) { mLightColorView.setVisibility(View.GONE); } diff --git a/src/com/android/settings/notificationlight/BatteryLightSettings.java b/src/com/android/settings/notificationlight/BatteryLightSettings.java index 2ee884e..9efabc3 100644 --- a/src/com/android/settings/notificationlight/BatteryLightSettings.java +++ b/src/com/android/settings/notificationlight/BatteryLightSettings.java @@ -16,6 +16,7 @@ package com.android.settings.notificationlight; +import android.app.NotificationManager; import android.content.ContentResolver; import android.content.res.Resources; import android.os.Bundle; @@ -64,6 +65,8 @@ public class BatteryLightSettings extends SettingsPreferenceFragment implements super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.battery_light_settings); + final NotificationManager nm = getContext().getSystemService(NotificationManager.class); + PreferenceScreen prefSet = getPreferenceScreen(); PreferenceGroup mGeneralPrefs = (PreferenceGroup) prefSet.findPreference("general_section"); @@ -71,13 +74,13 @@ public class BatteryLightSettings extends SettingsPreferenceFragment implements mLightEnabledPref = (CMSystemSettingSwitchPreference) prefSet.findPreference(LIGHT_ENABLED_PREF); mPulseEnabledPref = (CMSystemSettingSwitchPreference) prefSet.findPreference(PULSE_ENABLED_PREF); - if (!getResources().getBoolean(com.android.internal.R.bool.config_ledCanPulse) || - getResources().getBoolean(org.cyanogenmod.platform.internal.R.bool.config_useSegmentedBatteryLed)) { + if (!nm.deviceLightsCan(NotificationManager.LIGHTS_LED_PULSE) || + nm.deviceLightsCan(NotificationManager.LIGHTS_SEGMENTED_BATTERY_LIGHTS) ) { mGeneralPrefs.removePreference(mPulseEnabledPref); } // Does the Device support changing battery LED colors? - if (getResources().getBoolean(com.android.internal.R.bool.config_multiColorBatteryLed)) { + if (nm.deviceLightsCan(NotificationManager.LIGHTS_RGB_BATTERY)) { setHasOptionsMenu(true); // Low, Medium and full color preferences diff --git a/src/com/android/settings/notificationlight/LightSettingsDialog.java b/src/com/android/settings/notificationlight/LightSettingsDialog.java index d2d4e84..79b23e0 100644 --- a/src/com/android/settings/notificationlight/LightSettingsDialog.java +++ b/src/com/android/settings/notificationlight/LightSettingsDialog.java @@ -170,8 +170,7 @@ public class LightSettingsDialog extends AlertDialog implements setView(layout); setTitle(R.string.edit_light_settings); - if (!getContext().getResources().getBoolean( - com.android.internal.R.bool.config_multiColorNotificationLed)) { + if (!mNotificationManager.deviceLightsCan(NotificationManager.LIGHTS_RGB_NOTIFICATION)) { mColorPicker.setVisibility(View.GONE); mColorPanel.setVisibility(View.GONE); mLightsDialogDivider.setVisibility(View.GONE); diff --git a/src/com/android/settings/notificationlight/NotificationLightSettings.java b/src/com/android/settings/notificationlight/NotificationLightSettings.java index b17918a..1c3601c 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; @@ -97,6 +98,8 @@ 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"); // Get the system defined default notification color @@ -135,8 +138,7 @@ public class NotificationLightSettings extends SettingsPreferenceFragment implem } 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); @@ -164,7 +166,7 @@ public class NotificationLightSettings extends SettingsPreferenceFragment implem mPackages = new HashMap<String, Package>(); setHasOptionsMenu(true); - mMultiColorLed = resources.getBoolean(com.android.internal.R.bool.config_multiColorNotificationLed); + mMultiColorLed = nm.deviceLightsCan(NotificationManager.LIGHTS_RGB_NOTIFICATION); if (!mMultiColorLed) { resetColors(); PreferenceGroup mGeneralPrefs = (PreferenceGroup) prefSet.findPreference("general_section"); |