@Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.battery_light_settings);

    PreferenceScreen prefSet = getPreferenceScreen();

    mLightEnabledPref = (SwitchPreference) prefSet.findPreference(LIGHT_ENABLED_PREF);
    mPulseEnabledPref = (SwitchPreference) prefSet.findPreference(PULSE_ENABLED_PREF);

    // Does the Device support changing battery LED colors?
    if (getResources().getBoolean(com.android.internal.R.bool.config_multiColorBatteryLed)) {
      setHasOptionsMenu(true);

      // Low, Medium and full color preferences
      mLowColorPref = (ApplicationLightPreference) prefSet.findPreference(LOW_COLOR_PREF);
      mLowColorPref.setOnPreferenceChangeListener(this);

      mMediumColorPref = (ApplicationLightPreference) prefSet.findPreference(MEDIUM_COLOR_PREF);
      mMediumColorPref.setOnPreferenceChangeListener(this);

      mFullColorPref = (ApplicationLightPreference) prefSet.findPreference(FULL_COLOR_PREF);
      mFullColorPref.setOnPreferenceChangeListener(this);
    } else {
      prefSet.removePreference(prefSet.findPreference("colors_list"));
      resetColors();
    }
  }
  private void refreshDefault() {
    ContentResolver resolver = getContentResolver();
    Resources res = getResources();

    if (mLowColorPref != null) {
      int lowColor =
          Settings.System.getInt(
              resolver,
              Settings.System.BATTERY_LIGHT_LOW_COLOR,
              res.getInteger(com.android.internal.R.integer.config_notificationsBatteryLowARGB));
      mLowColorPref.setAllValues(lowColor, 0, 0, false);
    }

    if (mMediumColorPref != null) {
      int mediumColor =
          Settings.System.getInt(
              resolver,
              Settings.System.BATTERY_LIGHT_MEDIUM_COLOR,
              res.getInteger(com.android.internal.R.integer.config_notificationsBatteryMediumARGB));
      mMediumColorPref.setAllValues(mediumColor, 0, 0, false);
    }

    if (mFullColorPref != null) {
      int fullColor =
          Settings.System.getInt(
              resolver,
              Settings.System.BATTERY_LIGHT_FULL_COLOR,
              res.getInteger(com.android.internal.R.integer.config_notificationsBatteryFullARGB));
      mFullColorPref.setAllValues(fullColor, 0, 0, false);
    }
  }
  @Override
  public boolean onPreferenceChange(Preference preference, Object objValue) {
    ApplicationLightPreference lightPref = (ApplicationLightPreference) preference;
    updateValues(lightPref.getKey(), lightPref.getColor());

    return true;
  }