package com.mlab.roadrecorder.settings;

import org.apache.log4j.Logger;

import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.PreferenceFragment;

import com.mlab.roadrecorder.alvac.R;

public class SettingsFragment extends PreferenceFragment {
	private final Logger LOG = Logger.getLogger(SettingsFragment.class);
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		addPreferencesFromResource(R.xml.prefs);
		ListPreference listpref = (ListPreference) findPreference("videoresolution");
		
		listpref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
			@Override
			public boolean onPreferenceChange(Preference preference, Object newValue) {
				LOG.debug("onPreferenceChange() " + newValue);
				return true;
			}
		});
	}
	
}

@@ -93,16 +93,62 @@
 Bundle;%0A
+import android.preference.EditTextPreference;%0A
 import a
@@ -331,16 +331,50 @@
 gment;%0A%0A
+import com.mlab.roadrecorder.App;%0A
 import c
@@ -761,19 +761,16 @@
 tion%22);%0A
-%09%09%0A
 %09%09listpr
@@ -988,35 +988,704 @@
 %09%09%09%09
-return true;%0A%09%09%09%7D%0A%09%09%7D);%0A%09%7D%0A%09
+setSummary(preference, newValue.toString());%0A%09%09%09%09return true;%0A%09%09%09%7D%0A%09%09%7D);%0A%09%09setSummary(listpref, App.getVideoResolution());%0A%09%09%0A%09%09EditTextPreference edit = (EditTextPreference) findPreference(%22mindiskspace%22);%0A%09%09edit.setSummary(%22M%C3%ADnimo espacio en disco para empezar a grabar %22 + App.getMinDiskSpaceToSave() + %22 Mb%22);%0A%09%09%0A%09%7D%0A%09private void setSummary(Preference preference, String summary) %7B%0A%09%09if(summary.equals(%22480%22)) %7B%0A%09%09%09preference.setSummary(%22720x480 px%22);%09%09%09%09%09%09%09%09%09%0A%09%09%7D else if(summary.equals(%22720%22)) %7B%0A%09%09%09preference.setSummary(%221280x720 px%22);%09%09%09%09%09%09%09%09%09%0A%09%09%7D else if(summary.equals(%221080%22)) %7B%0A%09%09%09preference.setSummary(%221920x1080 px%22);%09%09%09%09%09%09%09%09%09%0A%09%09%7D else %7B%0A%09%09%09preference.setSummary(%22%22);%09%09%09%09%09%09%09%09%09%0A%09%09%7D%0A%09%7D
 %0A%7D%0A

Add summaries to ListPreference and MinDiskSpace preference