Program: 13594
Project: 13594
Buggy source:
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  ((WordPress)getActivity().getApplication()).component().inject(this);
  setRetainInstance(true);
  addPreferencesFromResource(R.xml.app_settings);
  mLanguagePreference=(DetailListPreference)findPreference(getString(R.string.pref_key_language));
  mLanguagePreference.setOnPreferenceChangeListener(this);
  findPreference(getString(R.string.pref_key_language)).setOnPreferenceClickListener(this);
  findPreference(getString(R.string.pref_key_device_settings)).setOnPreferenceClickListener(this);
  findPreference(getString(R.string.pref_key_app_about)).setOnPreferenceClickListener(this);
  findPreference(getString(R.string.pref_key_oss_licenses)).setOnPreferenceClickListener(this);
  mOptimizedImage=(WPSwitchPreference)WPPrefUtils.getPrefAndSetChangeListener(this,R.string.pref_key_optimize_image,this);
  mImageMaxSizePref=(DetailListPreference)WPPrefUtils.getPrefAndSetChangeListener(this,R.string.pref_key_site_image_width,this);
  mImageQualityPref=(DetailListPreference)WPPrefUtils.getPrefAndSetChangeListener(this,R.string.pref_key_site_image_quality,this);
  mOptimizedVideo=(WPSwitchPreference)WPPrefUtils.getPrefAndSetChangeListener(this,R.string.pref_key_optimize_video,this);
  mVideoWidthPref=(DetailListPreference)WPPrefUtils.getPrefAndSetChangeListener(this,R.string.pref_key_site_video_width,this);
  mVideoEncorderBitratePref=(DetailListPreference)WPPrefUtils.getPrefAndSetChangeListener(this,R.string.pref_key_site_video_encoder_bitrate,this);
  mOptimizedImage.setChecked(AppPrefs.isImageOptimize());
  setDetailListPreferenceValue(mImageMaxSizePref,String.valueOf(AppPrefs.getImageOptimizeMaxSize()),getLabelForImageMaxSizeValue(AppPrefs.getImageOptimizeMaxSize()));
  setDetailListPreferenceValue(mImageQualityPref,String.valueOf(AppPrefs.getImageOptimizeQuality()),getLabelForImageQualityValue(AppPrefs.getImageOptimizeQuality()));
  mOptimizedVideo.setChecked(AppPrefs.isVideoOptimize());
  setDetailListPreferenceValue(mVideoWidthPref,String.valueOf(AppPrefs.getVideoOptimizeWidth()),getLabelForVideoMaxWidthValue(AppPrefs.getVideoOptimizeWidth()));
  setDetailListPreferenceValue(mVideoEncorderBitratePref,String.valueOf(AppPrefs.getVideoOptimizeQuality()),getLabelForVideoEncoderBitrateValue(AppPrefs.getVideoOptimizeQuality()));
  if (!WPMediaUtils.isVideoOptimizationAvailable()) {
    WPPrefUtils.removePreference(this,R.string.pref_key_optimize_media,R.string.pref_key_optimize_video);
    WPPrefUtils.removePreference(this,R.string.pref_key_optimize_media,R.string.pref_key_site_video_width);
    WPPrefUtils.removePreference(this,R.string.pref_key_optimize_media,R.string.pref_key_site_video_encoder_bitrate);
  }
  mSettings=PreferenceManager.getDefaultSharedPreferences(getActivity());
  updateEditorSettings();
}

Fixed version (ground truth):
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  ((WordPress)getActivity().getApplication()).component().inject(this);
  setRetainInstance(true);
  addPreferencesFromResource(R.xml.app_settings);
  findPreference(getString(R.string.pref_key_send_usage)).setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener(){
    @Override public boolean onPreferenceChange(    Preference preference,    Object newValue){
      if (newValue == null)       return false;
      AnalyticsTracker.flush();
      AnalyticsTracker.setHasUserOptedOut(!(boolean)newValue);
      return true;
    }
  }
);
  mLanguagePreference=(DetailListPreference)findPreference(getString(R.string.pref_key_language));
  mLanguagePreference.setOnPreferenceChangeListener(this);
  findPreference(getString(R.string.pref_key_language)).setOnPreferenceClickListener(this);
  findPreference(getString(R.string.pref_key_device_settings)).setOnPreferenceClickListener(this);
  findPreference(getString(R.string.pref_key_app_about)).setOnPreferenceClickListener(this);
  findPreference(getString(R.string.pref_key_oss_licenses)).setOnPreferenceClickListener(this);
  mOptimizedImage=(WPSwitchPreference)WPPrefUtils.getPrefAndSetChangeListener(this,R.string.pref_key_optimize_image,this);
  mImageMaxSizePref=(DetailListPreference)WPPrefUtils.getPrefAndSetChangeListener(this,R.string.pref_key_site_image_width,this);
  mImageQualityPref=(DetailListPreference)WPPrefUtils.getPrefAndSetChangeListener(this,R.string.pref_key_site_image_quality,this);
  mOptimizedVideo=(WPSwitchPreference)WPPrefUtils.getPrefAndSetChangeListener(this,R.string.pref_key_optimize_video,this);
  mVideoWidthPref=(DetailListPreference)WPPrefUtils.getPrefAndSetChangeListener(this,R.string.pref_key_site_video_width,this);
  mVideoEncorderBitratePref=(DetailListPreference)WPPrefUtils.getPrefAndSetChangeListener(this,R.string.pref_key_site_video_encoder_bitrate,this);
  mOptimizedImage.setChecked(AppPrefs.isImageOptimize());
  setDetailListPreferenceValue(mImageMaxSizePref,String.valueOf(AppPrefs.getImageOptimizeMaxSize()),getLabelForImageMaxSizeValue(AppPrefs.getImageOptimizeMaxSize()));
  setDetailListPreferenceValue(mImageQualityPref,String.valueOf(AppPrefs.getImageOptimizeQuality()),getLabelForImageQualityValue(AppPrefs.getImageOptimizeQuality()));
  mOptimizedVideo.setChecked(AppPrefs.isVideoOptimize());
  setDetailListPreferenceValue(mVideoWidthPref,String.valueOf(AppPrefs.getVideoOptimizeWidth()),getLabelForVideoMaxWidthValue(AppPrefs.getVideoOptimizeWidth()));
  setDetailListPreferenceValue(mVideoEncorderBitratePref,String.valueOf(AppPrefs.getVideoOptimizeQuality()),getLabelForVideoEncoderBitrateValue(AppPrefs.getVideoOptimizeQuality()));
  if (!WPMediaUtils.isVideoOptimizationAvailable()) {
    WPPrefUtils.removePreference(this,R.string.pref_key_optimize_media,R.string.pref_key_optimize_video);
    WPPrefUtils.removePreference(this,R.string.pref_key_optimize_media,R.string.pref_key_site_video_width);
    WPPrefUtils.removePreference(this,R.string.pref_key_optimize_media,R.string.pref_key_site_video_encoder_bitrate);
  }
  mSettings=PreferenceManager.getDefaultSharedPreferences(getActivity());
  updateEditorSettings();
}