// Path: app/src/main/java/com/ubiqlog/vis/common/Settings.java
// public class Settings {
// 
// 	public static final String googleMapKey = "0U0FROSv7CVVKcfYcZY_7wDf4OBYAgX9HsueySA";
// 	public static final String PREF_FILE_NAME = "UbiqlogVisPrefFile";
// 	public static final String LOG_FOLDER = Setting.LOG_FOLDER;
// 	public static final String SensorLocation = "Location";
// 	public static final String SensorApplication = "Application";
// 	public static final String SensorCall = "Call";
// 	public static final String SensorSms = "SMS";
// 	public static final int application_timeinterval = 11000;
// 
// 	public static int location_timeFrame = 5000;
// 	public static int call_timeFrame = 5000;
// 	public static int sms_timeFrame = 5000;
// 
// 	// Initialize preferences (from pref file or default)
// 	public static void initialise(Context context) {
// 		SharedPreferences settings = context.getSharedPreferences(
// 				PREF_FILE_NAME, 0);
// 		location_timeFrame = settings.getInt("location_timeFrame",
// 				location_timeFrame);
// 		call_timeFrame = settings.getInt("call_timeFrame", call_timeFrame);
// 		sms_timeFrame = settings.getInt("sms_timeFrame", sms_timeFrame);
// 	}
// 
// 	// save preferences in pref file
// 	public static void savePreferences(Context context,
// 			int _location_timeFrame, int _call_timeFrame, int _sms_timeFrame) {
// 		SharedPreferences settings = context.getSharedPreferences(
// 				PREF_FILE_NAME, 0);
// 		SharedPreferences.Editor editor = settings.edit();
// 
// 		location_timeFrame = _location_timeFrame;
// 		call_timeFrame = _call_timeFrame;
// 		sms_timeFrame = _sms_timeFrame;
// 
// 		editor.putInt("location_timeFrame", _location_timeFrame);
// 		editor.putInt("call_timeFrame", _call_timeFrame);
// 		editor.putInt("sms_timeFrame", _sms_timeFrame);
// 
// 		// Commit the edits!
// 		editor.commit();
// 
// 	}
// 
// }
// 
// Path: app/src/main/java/com/ubiqlog/vis/utils/UserFriendlyException.java
// public class UserFriendlyException extends Exception {
// 
// 	private static final long serialVersionUID = 1L;
// 
// 	public UserFriendlyException(String message) {
// 		super(message);
// 	}
// 
// }


import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import android.content.Context;
import com.ubiqlog.ui.R;
import com.ubiqlog.vis.common.Settings;
import com.ubiqlog.vis.utils.UserFriendlyException;
package com.ubiqlog.vis.extras.search;




/**
 * @author Soheil KHOSRAVIPOUR
 * @modified by Victor Gugonatu
 * @modified on 12.2010
 * @date 07.2010
 * @version 1.0
 */
public class Searcher {

	// This function receives sensor, and address of the file and returns the
	// search results in an array list
	public ArrayList<String> searchFile(String sensor, String fileAddress) {
		FileInputStream in;
		ArrayList<String> result = new ArrayList<String>(); // The Result array list

		try {
			in = new FileInputStream(new File(fileAddress));
		} catch (FileNotFoundException e) {
			// file not found -> ignore
			return new ArrayList<String>();
		}

		InputStreamReader inputreader = new InputStreamReader(in);
		BufferedReader buffreader = new BufferedReader(inputreader);

		String line;

		// read every line of the file into the line-variable, one line at the
		// time
		try {
			while ((line = buffreader.readLine()) != null) {
				if (line.startsWith("{\"" + sensor) || line.startsWith("\"" + sensor)) {
					// Found a record
					result.add(line);
				}

			}
		} catch (IOException e) {
			// ignore
		}

		return result;
	}

	// This function receives a sensor, dates and creates address of the files
	// and returns the search results using searchFile
	public ArrayList<String> searchFolder(String sensor, String date1,String date2, Context _context) 
		throws UserFriendlyException {
		ArrayList<String> result = new ArrayList<String>();

// Path: app/src/main/java/com/ubiqlog/vis/common/Settings.java
// public class Settings {
// 
// 	public static final String googleMapKey = "0U0FROSv7CVVKcfYcZY_7wDf4OBYAgX9HsueySA";
// 	public static final String PREF_FILE_NAME = "UbiqlogVisPrefFile";
// 	public static final String LOG_FOLDER = Setting.LOG_FOLDER;
// 	public static final String SensorLocation = "Location";
// 	public static final String SensorApplication = "Application";
// 	public static final String SensorCall = "Call";
// 	public static final String SensorSms = "SMS";
// 	public static final int application_timeinterval = 11000;
// 
// 	public static int location_timeFrame = 5000;
// 	public static int call_timeFrame = 5000;
// 	public static int sms_timeFrame = 5000;
// 
// 	// Initialize preferences (from pref file or default)
// 	public static void initialise(Context context) {
// 		SharedPreferences settings = context.getSharedPreferences(
// 				PREF_FILE_NAME, 0);
// 		location_timeFrame = settings.getInt("location_timeFrame",
// 				location_timeFrame);
// 		call_timeFrame = settings.getInt("call_timeFrame", call_timeFrame);
// 		sms_timeFrame = settings.getInt("sms_timeFrame", sms_timeFrame);
// 	}
// 
// 	// save preferences in pref file
// 	public static void savePreferences(Context context,
// 			int _location_timeFrame, int _call_timeFrame, int _sms_timeFrame) {
// 		SharedPreferences settings = context.getSharedPreferences(
// 				PREF_FILE_NAME, 0);
// 		SharedPreferences.Editor editor = settings.edit();
// 
// 		location_timeFrame = _location_timeFrame;
// 		call_timeFrame = _call_timeFrame;
// 		sms_timeFrame = _sms_timeFrame;
// 
// 		editor.putInt("location_timeFrame", _location_timeFrame);
// 		editor.putInt("call_timeFrame", _call_timeFrame);
// 		editor.putInt("sms_timeFrame", _sms_timeFrame);
// 
// 		// Commit the edits!
// 		editor.commit();
// 
// 	}
// 
// }
// 
// Path: app/src/main/java/com/ubiqlog/vis/utils/UserFriendlyException.java
// public class UserFriendlyException extends Exception {
// 
// 	private static final long serialVersionUID = 1L;
// 
// 	public UserFriendlyException(String message) {
// 		super(message);
// 	}
// 
// }


// Path: app/src/main/java/com/ubiqlog/vis/extras/search/Searcher.java
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import android.content.Context;
import com.ubiqlog.ui.R;
import com.ubiqlog.vis.common.Settings;
import com.ubiqlog.vis.utils.UserFriendlyException;

package com.ubiqlog.vis.extras.search;




/**
 * @author Soheil KHOSRAVIPOUR
 * @modified by Victor Gugonatu
 * @modified on 12.2010
 * @date 07.2010
 * @version 1.0
 */
public class Searcher {

	// This function receives sensor, and address of the file and returns the
	// search results in an array list
	public ArrayList<String> searchFile(String sensor, String fileAddress) {
		FileInputStream in;
		ArrayList<String> result = new ArrayList<String>(); // The Result array list

		try {
			in = new FileInputStream(new File(fileAddress));
		} catch (FileNotFoundException e) {
			// file not found -> ignore
			return new ArrayList<String>();
		}

		InputStreamReader inputreader = new InputStreamReader(in);
		BufferedReader buffreader = new BufferedReader(inputreader);

		String line;

		// read every line of the file into the line-variable, one line at the
		// time
		try {
			while ((line = buffreader.readLine()) != null) {
				if (line.startsWith("{\"" + sensor) || line.startsWith("\"" + sensor)) {
					// Found a record
					result.add(line);
				}

			}
		} catch (IOException e) {
			// ignore
		}

		return result;
	}

	// This function receives a sensor, dates and creates address of the files
	// and returns the search results using searchFile
	public ArrayList<String> searchFolder(String sensor, String date1,String date2, Context _context) 
		throws UserFriendlyException {
		ArrayList<String> result = new ArrayList<String>();

		String folderAddress = Settings.LOG_FOLDER + "/";