// Path: secu3droid/src/org/secu3/android/api/io/Secu3Logger.java
// public abstract class Secu3Logger {
// 	private static final String LOG_TAG = "Secu3Logger";
// 
// 	private GregorianCalendar time = null;
// 	private BufferedWriter logWriter = null;	
// 	private boolean started = false;
// 	private String path = null;
// 	int protocol_version;
// 	
// 	void log (String log) {
// 		try {
// 			logWriter.write(log);
// 			logWriter.flush();
// 		} catch (IOException e) {
// 			Log.e(LOG_TAG,e.getMessage());
// 		}		
// 	}
// 		
// 	Secu3Logger() {
// 		time = new GregorianCalendar();
// 	}
// 	protected abstract String getFileName();
// 	
// 	public void beginLogging (int protocol_version) {
// 		this.protocol_version = protocol_version;
// 		if (!isStarted()) try {
// 			logWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(path+File.separator+getFileName()),"ISO-8859-1"));
// 			started = true;
// 		} catch (IOException e) {
// 			e.printStackTrace();
// 		}
// 	}
// 	
// 	public void endLogging() {
// 		if (isStarted()) try {
// 			logWriter.flush();
// 			logWriter.close();
// 			started = false;
// 		} catch (IOException e) {
// 			e.printStackTrace();
// 		}
// 	}
// 
// 	public String getPath() {
// 		return path;
// 	}
// 
// 	public void setPath(String path) {
// 		if ((path == null) || (path.length() == 0)) path = Secu3Logger.getDefaultPath();
// 		this.path = path;
// 	}
// 	
// 	public static String getDefaultPath() {
// 		return Environment.getExternalStorageDirectory().getPath();
// 	}
// 
// 	boolean isStarted() {
// 		return started;
// 	}
// 
// 	GregorianCalendar getTime() {
// 		return time;
// 	}
// 
// 	public void setTime(GregorianCalendar time) {
// 		this.time = time;
// 	}
// }


import android.app.AlertDialog;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.content.pm.PackageInfo;
import android.os.Build;
import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceManager;
import android.text.method.LinkMovementMethod;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
import java.util.HashSet;
import java.util.Set;
import org.secu3.android.api.io.Secu3Logger;
		} catch (NullPointerException e) {
			e.printStackTrace();
		}
		return ";";
	}
	
	public static boolean isKeepScreenAliveActive (Context ctx) {
		SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(ctx);
		return sharedPreferences.getBoolean(ctx.getString(R.string.pref_keep_screen_key), false);
	}
	
	public static boolean isWakeLockEnabled (Context ctx) {
		SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(ctx);
		return sharedPreferences.getBoolean(ctx.getString(R.string.pref_wakelock_key), false);
	}
	
	@SuppressWarnings("deprecation")
	private void updatePreferenceSummary(){
		String deviceName = "";
        ListPreference prefDevices = (ListPreference)findPreference(getString(R.string.pref_bluetooth_device_key));
        String deviceAddress = sharedPref.getString(getString(R.string.pref_bluetooth_device_key), null);
        if (BluetoothAdapter.checkBluetoothAddress(deviceAddress)){
        	deviceName = bluetoothAdapter.getRemoteDevice(deviceAddress).getName();
        }
        prefDevices.setSummary(getString(R.string.pref_bluetooth_device_summary, deviceName));
        
        String protocolVersion = versions[getProtocolVersion(this)-1];
        ListPreference prefVersions = (ListPreference)findPreference(getString(R.string.pref_protocol_version_key));        
        prefVersions.setSummary(protocolVersion);
        
// Path: secu3droid/src/org/secu3/android/api/io/Secu3Logger.java
// public abstract class Secu3Logger {
// 	private static final String LOG_TAG = "Secu3Logger";
// 
// 	private GregorianCalendar time = null;
// 	private BufferedWriter logWriter = null;	
// 	private boolean started = false;
// 	private String path = null;
// 	int protocol_version;
// 	
// 	void log (String log) {
// 		try {
// 			logWriter.write(log);
// 			logWriter.flush();
// 		} catch (IOException e) {
// 			Log.e(LOG_TAG,e.getMessage());
// 		}		
// 	}
// 		
// 	Secu3Logger() {
// 		time = new GregorianCalendar();
// 	}
// 	protected abstract String getFileName();
// 	
// 	public void beginLogging (int protocol_version) {
// 		this.protocol_version = protocol_version;
// 		if (!isStarted()) try {
// 			logWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(path+File.separator+getFileName()),"ISO-8859-1"));
// 			started = true;
// 		} catch (IOException e) {
// 			e.printStackTrace();
// 		}
// 	}
// 	
// 	public void endLogging() {
// 		if (isStarted()) try {
// 			logWriter.flush();
// 			logWriter.close();
// 			started = false;
// 		} catch (IOException e) {
// 			e.printStackTrace();
// 		}
// 	}
// 
// 	public String getPath() {
// 		return path;
// 	}
// 
// 	public void setPath(String path) {
// 		if ((path == null) || (path.length() == 0)) path = Secu3Logger.getDefaultPath();
// 		this.path = path;
// 	}
// 	
// 	public static String getDefaultPath() {
// 		return Environment.getExternalStorageDirectory().getPath();
// 	}
// 
// 	boolean isStarted() {
// 		return started;
// 	}
// 
// 	GregorianCalendar getTime() {
// 		return time;
// 	}
// 
// 	public void setTime(GregorianCalendar time) {
// 		this.time = time;
// 	}
// }


// Path: secu3droid/src/org/secu3/android/SettingsActivity.java
import android.app.AlertDialog;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.content.pm.PackageInfo;
import android.os.Build;
import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceManager;
import android.text.method.LinkMovementMethod;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
import java.util.HashSet;
import java.util.Set;
import org.secu3.android.api.io.Secu3Logger;

		} catch (NullPointerException e) {
			e.printStackTrace();
		}
		return ";";
	}
	
	public static boolean isKeepScreenAliveActive (Context ctx) {
		SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(ctx);
		return sharedPreferences.getBoolean(ctx.getString(R.string.pref_keep_screen_key), false);
	}
	
	public static boolean isWakeLockEnabled (Context ctx) {
		SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(ctx);
		return sharedPreferences.getBoolean(ctx.getString(R.string.pref_wakelock_key), false);
	}
	
	@SuppressWarnings("deprecation")
	private void updatePreferenceSummary(){
		String deviceName = "";
        ListPreference prefDevices = (ListPreference)findPreference(getString(R.string.pref_bluetooth_device_key));
        String deviceAddress = sharedPref.getString(getString(R.string.pref_bluetooth_device_key), null);
        if (BluetoothAdapter.checkBluetoothAddress(deviceAddress)){
        	deviceName = bluetoothAdapter.getRemoteDevice(deviceAddress).getName();
        }
        prefDevices.setSummary(getString(R.string.pref_bluetooth_device_summary, deviceName));
        
        String protocolVersion = versions[getProtocolVersion(this)-1];
        ListPreference prefVersions = (ListPreference)findPreference(getString(R.string.pref_protocol_version_key));        
        prefVersions.setSummary(protocolVersion);
        
		findPreference(getString(R.string.pref_write_log_path)).setSummary(String.format(getString(R.string.pref_write_log_path_summary), Secu3Logger.getDefaultPath()));