@Override
  public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
    if (preference == mEnableNavigationBar) {

      Settings.System.putInt(
          mContentRes,
          Settings.System.NAVIGATION_BAR_SHOW,
          ((CheckBoxPreference) preference).isChecked() ? 1 : 0);
      Helpers.restartSystemUI();
      return true;
    } else if (preference == mColorizeAllIcons) {
      Settings.System.putBoolean(
          mContentRes,
          Settings.System.NAVIGATION_BAR_ALLCOLOR,
          ((CheckBoxPreference) preference).isChecked() ? true : false);
      return true;
    } else if (preference == mNavBarHideEnable) {
      Settings.System.putBoolean(
          mContentRes,
          Settings.System.NAV_HIDE_ENABLE,
          ((CheckBoxPreference) preference).isChecked());
      mDragHandleOpacity.setInitValue(
          Settings.System.getInt(
              getActivity().getContentResolver(), Settings.System.DRAG_HANDLE_OPACITY, 50));
      mDragHandleWidth.setInitValue(
          Settings.System.getInt(
              getActivity().getContentResolver(), Settings.System.DRAG_HANDLE_WEIGHT, 5));
      mNavBarHideTimeout.setValue(
          Settings.System.getInt(
                  getActivity().getContentResolver(), Settings.System.NAV_HIDE_TIMEOUT, 3000)
              + "");
      refreshSettings();
      return true;
    } else if (preference == mConfigureWidgets) {
      FragmentTransaction ft = getFragmentManager().beginTransaction();
      WidgetConfigurationFragment fragment = new WidgetConfigurationFragment();
      ft.addToBackStack("config_widgets");
      ft.replace(this.getId(), fragment);
      ft.commit();
      return true;
    } else if (preference == mMenuArrowKeysCheckBox) {
      Settings.System.putBoolean(
          mContentRes,
          Settings.System.NAVIGATION_BAR_MENU_ARROW_KEYS,
          ((CheckBoxPreference) preference).isChecked());
      return true;
    }
    return super.onPreferenceTreeClick(preferenceScreen, preference);
  }
  @Override
  public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
    if (preference == mEnableSPen) {

      Settings.System.putBoolean(
          getActivity().getContentResolver(),
          Settings.System.ENABLE_SPEN_ACTIONS,
          ((CheckBoxPreference) preference).isChecked());
      return true;
    }
    return super.onPreferenceTreeClick(preferenceScreen, preference);
  }
  @Override
  public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
    boolean value;

    if (preference == mShowScreenShot) {
      Settings.System.putBoolean(
          mContentRes,
          Settings.System.POWER_DIALOG_SHOW_SCREENSHOT,
          ((CheckBoxPreference) preference).isChecked());
      return true;
    } else if (preference == mExpandedDesktopNoNavbarPref) {
      value = mExpandedDesktopNoNavbarPref.isChecked();
      updateExpandedDesktop(value ? 2 : 0);
      /*
      } else if (preference == mShowPowerSaver) {
          Settings.System.putInt(mContentRes,
                  Settings.System.POWER_DIALOG_SHOW_POWER_SAVER,
                  ((CheckBoxPreference)preference).isChecked() ? 1 : 0);
          return true; */
    } else if (preference == mShowTorchToggle) {
      Settings.System.putBoolean(
          mContentRes,
          Settings.System.POWER_DIALOG_SHOW_TORCH_TOGGLE,
          ((CheckBoxPreference) preference).isChecked());
      return true;
    } else if (preference == mShowAirplaneToggle) {
      Settings.System.putBoolean(
          mContentRes,
          Settings.System.POWER_DIALOG_SHOW_AIRPLANE_TOGGLE,
          ((CheckBoxPreference) preference).isChecked());
      return true;
    } else if (preference == mShowNavBarHide) {
      Settings.System.putBoolean(
          mContentRes,
          Settings.System.POWER_DIALOG_SHOW_NAVBAR_HIDE,
          ((CheckBoxPreference) preference).isChecked());
      return true;
    } else if (preference == mShowVolumeStateToggle) {
      Settings.System.putBoolean(
          mContentRes,
          Settings.System.POWER_DIALOG_SHOW_VOLUME_STATE_TOGGLE,
          ((CheckBoxPreference) preference).isChecked());
      return true;
    } else if (preference == mShowRebootKeyguard) {
      Settings.System.putBoolean(
          mContentRes,
          Settings.System.POWER_DIALOG_SHOW_REBOOT_KEYGUARD,
          ((CheckBoxPreference) preference).isChecked());
      return true;
    }

    return super.onPreferenceTreeClick(preferenceScreen, preference);
  }