// Path: ASA/src/com/thesis/asa/Data.java
// public class Data {
// 	private static SparseArray<List<String>> permissions;
// 	
// 	public enum SecurityMode {
// 		PERMISSIVE, SECURE, PARANOID;
// 
// 		public static int toInteger(SecurityMode mode) {
// 			switch(mode) {
// 	        case PERMISSIVE:
// 	            return 0;
// 	        case SECURE:
// 	            return 1;
// 	        case PARANOID:
// 	            return 2;
// 	        }
// 			Log.d(Utilities.ERROR, "No int found for security mode: "+mode);
// 	        return -1;
// 		}
// 		
// 		public static SecurityMode fromInteger(int mode) {
// 			switch(mode) {
// 	        case 0:
// 	            return PERMISSIVE;
// 	        case 1:
// 	            return SECURE;
// 	        case 2:
// 	            return PARANOID;
// 	        }
// 			
// 			Log.d(Utilities.ERROR, "No security mode found for int: "+mode);
// 	        return PARANOID;
// 		}
// 
// 	}
// 	
//     static
//     {
//     	permissions = new SparseArray< List<String> >();
//     	permissions.put(0, Arrays.asList(Manifest.permission.READ_CONTACTS));
//     	permissions.put(1, Arrays.asList(Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION));
//     	permissions.put(2, Arrays.asList(Manifest.permission.READ_PHONE_STATE));
//     	permissions.put(3, Arrays.asList(Manifest.permission.ACCESS_WIFI_STATE));
//     	permissions.put(4, Arrays.asList(Manifest.permission.INTERNET));
//     }
//     
//     public static List<String> permissionsForPage(Integer page) {
//     	return permissions.get(page);
//     }
// 	
//     private static SparseArray<String> titles;
// 	static
//     {
// 		titles = new SparseArray<String>();
// 		titles.put(0, "Contacts");
// 		titles.put(1, "Location");
// 		titles.put(2, "Device data");
// 		titles.put(3, "Wifi info");
// 		titles.put(4, "Internet access");
//     }
// 	
// 	public static String titleForPage(Integer page) {
// 		return titles.get(page);
// 	}
// 	
// 	private static Map<Integer, String> resourceClasses;
// 	
// 	static
//     {
// 		resourceClasses = new HashMap<Integer, String>();
// 		resourceClasses.put(0, "com.thesis.asa.contacts.ContactsSettings");
// 		resourceClasses.put(1, "com.thesis.asa.location.LocationSettings");
// 		resourceClasses.put(2, "com.thesis.asa.devicedata.DeviceDataSettings");
// 		resourceClasses.put(3, "com.thesis.asa.wifi.WifiSettings"); 
// 		resourceClasses.put(4, "com.thesis.asa.internet.InternetSettings");
//     }
// 	
// 	public static String getResourceFor(Integer page) {
// 		return resourceClasses.get(page);
// 	}
// 	
// 	public static Collection<String> resources() {
// 		return resourceClasses.values();
// 	}
// }
// 
// Path: ASA/src/com/thesis/asa/resourcemvc/DefaultResourceActivity.java
// public class DefaultResourceActivity extends ResourceActivity
// 	{
// 		protected void loadSettings() {
// 			loadDefaultSettings();
// 		}
// 		
// 		@Override
// 		public String getSelectedApplication() throws Exception {
// 			throw new Exception("The activity has no reference to the package Name");
// 		}
// 				
// 		protected void loadIntent(Bundle extras) {
// 			isSystem = extras.getInt(AdvancedSettingsActivity.SYSTEM, -1);
// 		}
// 
// 		@Override
// 		protected OnClickListener getController() {
// 			return new DefaultResourceController(view,resource);
// 		}
// 		
// 	}


import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.Preference.OnPreferenceClickListener;
import com.thesis.asa.Data;
import com.thesis.asa.resourcemvc.DefaultResourceActivity;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
/*******************************************************************************
 * Copyright (c) 2014 CodingBad.
 * All rights reserved.  This file is part of ASA.
 * 
 * ASA is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * ASA is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with ASA.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * Contributors:
 * Ayelén Chavez - ashy.on.line@gmail.com
 * Joaquín Rinaudo - jmrinaudo@gmail.com
 ******************************************************************************/
 
 
package com.thesis.asa.mainui;



public class AdvancedSettingsController implements OnPreferenceChangeListener, OnPreferenceClickListener {

	private AdvancedSettingsActivity activity;

	public AdvancedSettingsController(AdvancedSettingsActivity a) {
		activity = a;
	}

	@Override
	public boolean onPreferenceChange(Preference preference, Object newValue) {
		boolean checked = Boolean.valueOf(newValue.toString());
		SlidePageFragment.ADVANCED_DISPLAYED = checked;

		return true;
	}

	@Override
	public boolean onPreferenceClick(Preference preference) {
		if (preference.getKey().equals("system_key"))
			openActivity(preference.getContext(), 1);
		else if (preference.getKey().equals("third_key")) {
			openActivity(preference.getContext(), 0);
		}
		return true;
	}

	private void openActivity(Context context, int isSystem) {

		Intent intent = new Intent(context,
				DefaultResourceActivity.class);

		Bundle extras = new Bundle();
		extras.putInt(AdvancedSettingsActivity.SYSTEM, isSystem);
		extras.putString(SlidePageFragment.RESOURCE,
// Path: ASA/src/com/thesis/asa/Data.java
// public class Data {
// 	private static SparseArray<List<String>> permissions;
// 	
// 	public enum SecurityMode {
// 		PERMISSIVE, SECURE, PARANOID;
// 
// 		public static int toInteger(SecurityMode mode) {
// 			switch(mode) {
// 	        case PERMISSIVE:
// 	            return 0;
// 	        case SECURE:
// 	            return 1;
// 	        case PARANOID:
// 	            return 2;
// 	        }
// 			Log.d(Utilities.ERROR, "No int found for security mode: "+mode);
// 	        return -1;
// 		}
// 		
// 		public static SecurityMode fromInteger(int mode) {
// 			switch(mode) {
// 	        case 0:
// 	            return PERMISSIVE;
// 	        case 1:
// 	            return SECURE;
// 	        case 2:
// 	            return PARANOID;
// 	        }
// 			
// 			Log.d(Utilities.ERROR, "No security mode found for int: "+mode);
// 	        return PARANOID;
// 		}
// 
// 	}
// 	
//     static
//     {
//     	permissions = new SparseArray< List<String> >();
//     	permissions.put(0, Arrays.asList(Manifest.permission.READ_CONTACTS));
//     	permissions.put(1, Arrays.asList(Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION));
//     	permissions.put(2, Arrays.asList(Manifest.permission.READ_PHONE_STATE));
//     	permissions.put(3, Arrays.asList(Manifest.permission.ACCESS_WIFI_STATE));
//     	permissions.put(4, Arrays.asList(Manifest.permission.INTERNET));
//     }
//     
//     public static List<String> permissionsForPage(Integer page) {
//     	return permissions.get(page);
//     }
// 	
//     private static SparseArray<String> titles;
// 	static
//     {
// 		titles = new SparseArray<String>();
// 		titles.put(0, "Contacts");
// 		titles.put(1, "Location");
// 		titles.put(2, "Device data");
// 		titles.put(3, "Wifi info");
// 		titles.put(4, "Internet access");
//     }
// 	
// 	public static String titleForPage(Integer page) {
// 		return titles.get(page);
// 	}
// 	
// 	private static Map<Integer, String> resourceClasses;
// 	
// 	static
//     {
// 		resourceClasses = new HashMap<Integer, String>();
// 		resourceClasses.put(0, "com.thesis.asa.contacts.ContactsSettings");
// 		resourceClasses.put(1, "com.thesis.asa.location.LocationSettings");
// 		resourceClasses.put(2, "com.thesis.asa.devicedata.DeviceDataSettings");
// 		resourceClasses.put(3, "com.thesis.asa.wifi.WifiSettings"); 
// 		resourceClasses.put(4, "com.thesis.asa.internet.InternetSettings");
//     }
// 	
// 	public static String getResourceFor(Integer page) {
// 		return resourceClasses.get(page);
// 	}
// 	
// 	public static Collection<String> resources() {
// 		return resourceClasses.values();
// 	}
// }
// 
// Path: ASA/src/com/thesis/asa/resourcemvc/DefaultResourceActivity.java
// public class DefaultResourceActivity extends ResourceActivity
// 	{
// 		protected void loadSettings() {
// 			loadDefaultSettings();
// 		}
// 		
// 		@Override
// 		public String getSelectedApplication() throws Exception {
// 			throw new Exception("The activity has no reference to the package Name");
// 		}
// 				
// 		protected void loadIntent(Bundle extras) {
// 			isSystem = extras.getInt(AdvancedSettingsActivity.SYSTEM, -1);
// 		}
// 
// 		@Override
// 		protected OnClickListener getController() {
// 			return new DefaultResourceController(view,resource);
// 		}
// 		
// 	}


// Path: ASA/src/com/thesis/asa/mainui/AdvancedSettingsController.java
import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.Preference.OnPreferenceClickListener;
import com.thesis.asa.Data;
import com.thesis.asa.resourcemvc.DefaultResourceActivity;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

/*******************************************************************************
 * Copyright (c) 2014 CodingBad.
 * All rights reserved.  This file is part of ASA.
 * 
 * ASA is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * ASA is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with ASA.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * Contributors:
 * Ayelén Chavez - ashy.on.line@gmail.com
 * Joaquín Rinaudo - jmrinaudo@gmail.com
 ******************************************************************************/
 
 
package com.thesis.asa.mainui;



public class AdvancedSettingsController implements OnPreferenceChangeListener, OnPreferenceClickListener {

	private AdvancedSettingsActivity activity;

	public AdvancedSettingsController(AdvancedSettingsActivity a) {
		activity = a;
	}

	@Override
	public boolean onPreferenceChange(Preference preference, Object newValue) {
		boolean checked = Boolean.valueOf(newValue.toString());
		SlidePageFragment.ADVANCED_DISPLAYED = checked;

		return true;
	}

	@Override
	public boolean onPreferenceClick(Preference preference) {
		if (preference.getKey().equals("system_key"))
			openActivity(preference.getContext(), 1);
		else if (preference.getKey().equals("third_key")) {
			openActivity(preference.getContext(), 0);
		}
		return true;
	}

	private void openActivity(Context context, int isSystem) {

		Intent intent = new Intent(context,
				DefaultResourceActivity.class);

		Bundle extras = new Bundle();
		extras.putInt(AdvancedSettingsActivity.SYSTEM, isSystem);
		extras.putString(SlidePageFragment.RESOURCE,
				Data.getResourceFor(activity.getPageNumber()));