// Path: src/interdroid/swan/swansong/ExpressionFactory.java
// public class ExpressionFactory {
// 
// 	public static Expression parse(String parseString)
// 			throws ExpressionParseException {
// 		return SwanExpressionParser.parseExpression(parseString);
// 	}
// 
// }
// 
// Path: src/interdroid/swan/swansong/SensorValueExpression.java
// public class SensorValueExpression implements ValueExpression {
// 
// 	private String mLocation;
// 	private String mEntity;
// 	private String mValuePath;
// 	private Bundle mConfig;
// 	private HistoryReductionMode mMode;
// 	private long mHistoryLength;
// 
// 	public SensorValueExpression(String location, String entity,
// 			String valuePath, Bundle config, HistoryReductionMode mode,
// 			long historyLength) {
// 		mLocation = location;
// 		mEntity = entity;
// 		mValuePath = valuePath;
// 		mConfig = config;
// 		if (mConfig == null) {
// 			mConfig = new Bundle();
// 		}
// 		mMode = mode;
// 		mHistoryLength = historyLength;
// 	}
// 
// 	@Override
// 	public HistoryReductionMode getHistoryReductionMode() {
// 		return mMode;
// 	}
// 
// 	public long getHistoryLength() {
// 		return mHistoryLength;
// 	}
// 
// 	@Override
// 	public String toParseString() {
// 		String result = mLocation + "@" + mEntity + ":" + mValuePath;
// 		if (mConfig != null && mConfig.size() > 0) {
// 			boolean first = true;
// 			for (String key : mConfig.keySet()) {
// 				String value = "" + mConfig.get(key);
// 				if (mConfig.get(key) instanceof String) {
// 					value = "'" + value + "'";
// 				}
// 				result += (first ? "?" : "&") + key + "=" + value;
// 				first = false;
// 			}
// 		}
// 		result += "{" + mMode.toParseString() + "," + mHistoryLength + "}";
// 		return result;
// 	}
// 
// 	public String getEntity() {
// 		return mEntity;
// 	}
// 
// 	@Override
// 	public void setInferredLocation(String location) {
// 		throw new RuntimeException(
// 				"Please don't use this method. For internal use only.");
// 	}
// 
// 	public String getValuePath() {
// 		return mValuePath;
// 	}
// 
// 	public String getLocation() {
// 		return mLocation;
// 	}
// 
// 	public Bundle getConfiguration() {
// 		return mConfig;
// 	}
// 
// }


import interdroid.swan.swansong.ExpressionFactory;
import interdroid.swan.swansong.ExpressionParseException;
import interdroid.swan.swansong.HistoryReductionMode;
import interdroid.swan.swansong.SensorValueExpression;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.preference.EditTextPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.PreferenceActivity;
import android.preference.PreferenceGroup;
import android.preference.PreferenceManager;
import android.util.Log;
package interdroid.swan.sensors;




/**
 * Base for ConfigurationActivities for configuring sensors.
 * 
 * @author nick &lt;palmer@cs.vu.nl&gt;
 * 
 */
public abstract class AbstractConfigurationActivity extends PreferenceActivity
		implements OnPreferenceChangeListener {
	private static final String TAG = AbstractConfigurationActivity.class
			.getSimpleName();

	private static final long SECOND = 1000;
	private static final long MINUTE = 60 * SECOND;
	private static final long HOUR = 60 * MINUTE;

	/**
	 * Returns the id for the sensors preferences XML setup.
	 * 
	 * @return the id for the preferences XML
	 */
	public abstract int getPreferencesXML();

	private List<String> keys = new ArrayList<String>();

	private BroadcastReceiver mNameReceiver = new BroadcastReceiver() {

		@SuppressWarnings("deprecation")
		@Override
		public void onReceive(Context context, Intent intent) {
			List<String> names = intent.getStringArrayListExtra("names");
			names.add(0, "self");
			((ListPreference) findPreference("swan_location")).setEntries(names
					.toArray(new String[names.size()]));
			((ListPreference) findPreference("swan_location"))
					.setEntryValues(names.toArray(new String[names.size()]));
			intentToPrefs();
		}

	};

	@Override
	protected void onCreate(final Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	}

	private void intentToPrefs() {
		if (getIntent().hasExtra("expression")) {
			try {
// Path: src/interdroid/swan/swansong/ExpressionFactory.java
// public class ExpressionFactory {
// 
// 	public static Expression parse(String parseString)
// 			throws ExpressionParseException {
// 		return SwanExpressionParser.parseExpression(parseString);
// 	}
// 
// }
// 
// Path: src/interdroid/swan/swansong/SensorValueExpression.java
// public class SensorValueExpression implements ValueExpression {
// 
// 	private String mLocation;
// 	private String mEntity;
// 	private String mValuePath;
// 	private Bundle mConfig;
// 	private HistoryReductionMode mMode;
// 	private long mHistoryLength;
// 
// 	public SensorValueExpression(String location, String entity,
// 			String valuePath, Bundle config, HistoryReductionMode mode,
// 			long historyLength) {
// 		mLocation = location;
// 		mEntity = entity;
// 		mValuePath = valuePath;
// 		mConfig = config;
// 		if (mConfig == null) {
// 			mConfig = new Bundle();
// 		}
// 		mMode = mode;
// 		mHistoryLength = historyLength;
// 	}
// 
// 	@Override
// 	public HistoryReductionMode getHistoryReductionMode() {
// 		return mMode;
// 	}
// 
// 	public long getHistoryLength() {
// 		return mHistoryLength;
// 	}
// 
// 	@Override
// 	public String toParseString() {
// 		String result = mLocation + "@" + mEntity + ":" + mValuePath;
// 		if (mConfig != null && mConfig.size() > 0) {
// 			boolean first = true;
// 			for (String key : mConfig.keySet()) {
// 				String value = "" + mConfig.get(key);
// 				if (mConfig.get(key) instanceof String) {
// 					value = "'" + value + "'";
// 				}
// 				result += (first ? "?" : "&") + key + "=" + value;
// 				first = false;
// 			}
// 		}
// 		result += "{" + mMode.toParseString() + "," + mHistoryLength + "}";
// 		return result;
// 	}
// 
// 	public String getEntity() {
// 		return mEntity;
// 	}
// 
// 	@Override
// 	public void setInferredLocation(String location) {
// 		throw new RuntimeException(
// 				"Please don't use this method. For internal use only.");
// 	}
// 
// 	public String getValuePath() {
// 		return mValuePath;
// 	}
// 
// 	public String getLocation() {
// 		return mLocation;
// 	}
// 
// 	public Bundle getConfiguration() {
// 		return mConfig;
// 	}
// 
// }


// Path: src/interdroid/swan/sensors/AbstractConfigurationActivity.java
import interdroid.swan.swansong.ExpressionFactory;
import interdroid.swan.swansong.ExpressionParseException;
import interdroid.swan.swansong.HistoryReductionMode;
import interdroid.swan.swansong.SensorValueExpression;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.preference.EditTextPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.PreferenceActivity;
import android.preference.PreferenceGroup;
import android.preference.PreferenceManager;
import android.util.Log;

package interdroid.swan.sensors;




/**
 * Base for ConfigurationActivities for configuring sensors.
 * 
 * @author nick &lt;palmer@cs.vu.nl&gt;
 * 
 */
public abstract class AbstractConfigurationActivity extends PreferenceActivity
		implements OnPreferenceChangeListener {
	private static final String TAG = AbstractConfigurationActivity.class
			.getSimpleName();

	private static final long SECOND = 1000;
	private static final long MINUTE = 60 * SECOND;
	private static final long HOUR = 60 * MINUTE;

	/**
	 * Returns the id for the sensors preferences XML setup.
	 * 
	 * @return the id for the preferences XML
	 */
	public abstract int getPreferencesXML();

	private List<String> keys = new ArrayList<String>();

	private BroadcastReceiver mNameReceiver = new BroadcastReceiver() {

		@SuppressWarnings("deprecation")
		@Override
		public void onReceive(Context context, Intent intent) {
			List<String> names = intent.getStringArrayListExtra("names");
			names.add(0, "self");
			((ListPreference) findPreference("swan_location")).setEntries(names
					.toArray(new String[names.size()]));
			((ListPreference) findPreference("swan_location"))
					.setEntryValues(names.toArray(new String[names.size()]));
			intentToPrefs();
		}

	};

	@Override
	protected void onCreate(final Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	}

	private void intentToPrefs() {
		if (getIntent().hasExtra("expression")) {
			try {
				SensorValueExpression sensor = (SensorValueExpression) ExpressionFactory