Bug 1207719 - (Part 1) Convert tabs to spaces. r=sebastian draft
authorMargaret Leibovic <margaret.leibovic@gmail.com>
Fri, 01 Apr 2016 18:23:13 -0400
changeset 347224 bd6ae3033f25cb8df1e1c995f240368b99f1ae7a
parent 347223 d50240348923d829500a0284d832599804987e5c
child 347225 6ada4aeb9ce898057f6d66ac95b63bf8606abb21
push id14517
push usermleibovic@mozilla.com
push dateSun, 03 Apr 2016 21:27:42 +0000
reviewerssebastian
bugs1207719
milestone48.0a1
Bug 1207719 - (Part 1) Convert tabs to spaces. r=sebastian MozReview-Commit-ID: EyzXCnv1Nnk
mobile/android/thirdparty/com/keepsafe/switchboard/AsyncConfigLoader.java
mobile/android/thirdparty/com/keepsafe/switchboard/DeviceUuidFactory.java
mobile/android/thirdparty/com/keepsafe/switchboard/Preferences.java
mobile/android/thirdparty/com/keepsafe/switchboard/Switch.java
mobile/android/thirdparty/com/keepsafe/switchboard/SwitchBoard.java
--- a/mobile/android/thirdparty/com/keepsafe/switchboard/AsyncConfigLoader.java
+++ b/mobile/android/thirdparty/com/keepsafe/switchboard/AsyncConfigLoader.java
@@ -27,58 +27,58 @@ import android.util.Log;
  * To use your custom UUID call <code>AsyncConfigLoader.execute(uuid)</code> with uuid being your unique user id
  * as a String 
  *
  * @author Philipp Berner
  *
  */
 public class AsyncConfigLoader extends AsyncTask<Void, Void, Void> {
 
-	private String TAG = "AsyncConfigLoader";
-	
-	public static final int UPDATE_SERVER = 1;
-	public static final int CONFIG_SERVER = 2;
-	
-	private Context context;
-	private int configToLoad;
-	private String uuid;
-	
-	/**
-	 * Sets the params for async loading either SwitchBoard.updateConfigServerUrl()
-	 * or SwitchBoard.loadConfig.
-	 * @param c Application context
-	 * @param configType Either UPDATE_SERVER or CONFIG_SERVER
-	 */
-	public AsyncConfigLoader(Context c, int configType) {
-		this(c, configType, null);
-	}
-	
-	/**
-	 * Sets the params for async loading either SwitchBoard.updateConfigServerUrl()
-	 * or SwitchBoard.loadConfig.
-	 * Loads config with a custom UUID
-	 * @param c Application context
-	 * @param configType Either UPDATE_SERVER or CONFIG_SERVER
-	 * @param uuid Custom UUID
-	 */
-	public AsyncConfigLoader(Context c, int configType, String uuid) {
-		this.context = c;
-		this.configToLoad = configType;
-		this.uuid = uuid;
-	}
-	
-	@Override
-	protected Void doInBackground(Void... params) {
-		
-		if(configToLoad == UPDATE_SERVER) {
-			SwitchBoard.updateConfigServerUrl(context);
-		}
-		else {
-			if(uuid == null)
-				SwitchBoard.loadConfig(context);
-			else
-				SwitchBoard.loadConfig(context, uuid);
-		}
-			
-		return null;
-	}
-	
+    private String TAG = "AsyncConfigLoader";
+
+    public static final int UPDATE_SERVER = 1;
+    public static final int CONFIG_SERVER = 2;
+
+    private Context context;
+    private int configToLoad;
+    private String uuid;
+
+    /**
+     * Sets the params for async loading either SwitchBoard.updateConfigServerUrl()
+     * or SwitchBoard.loadConfig.
+     * @param c Application context
+     * @param configType Either UPDATE_SERVER or CONFIG_SERVER
+     */
+    public AsyncConfigLoader(Context c, int configType) {
+        this(c, configType, null);
+    }
+
+    /**
+     * Sets the params for async loading either SwitchBoard.updateConfigServerUrl()
+     * or SwitchBoard.loadConfig.
+     * Loads config with a custom UUID
+     * @param c Application context
+     * @param configType Either UPDATE_SERVER or CONFIG_SERVER
+     * @param uuid Custom UUID
+     */
+    public AsyncConfigLoader(Context c, int configType, String uuid) {
+        this.context = c;
+        this.configToLoad = configType;
+        this.uuid = uuid;
+    }
+
+    @Override
+    protected Void doInBackground(Void... params) {
+
+        if(configToLoad == UPDATE_SERVER) {
+            SwitchBoard.updateConfigServerUrl(context);
+        }
+        else {
+            if(uuid == null)
+                SwitchBoard.loadConfig(context);
+            else
+                SwitchBoard.loadConfig(context, uuid);
+        }
+
+        return null;
+    }
+
 }
\ No newline at end of file
--- a/mobile/android/thirdparty/com/keepsafe/switchboard/DeviceUuidFactory.java
+++ b/mobile/android/thirdparty/com/keepsafe/switchboard/DeviceUuidFactory.java
@@ -23,58 +23,58 @@ import android.preference.Preference;
 
 
 /**
  * Generates a UUID and stores is persistent as in the apps shared preferences.
  * 
  * @author Philipp Berner
  */
 public class DeviceUuidFactory {
-	protected static final String PREFS_FILE = "com.keepsafe.switchboard.uuid";
-	protected static final String PREFS_DEVICE_ID = "device_id";
+    protected static final String PREFS_FILE = "com.keepsafe.switchboard.uuid";
+    protected static final String PREFS_DEVICE_ID = "device_id";
 
-	private static UUID uuid = null;
+    private static UUID uuid = null;
 
-	public DeviceUuidFactory(Context context) {
+    public DeviceUuidFactory(Context context) {
 
-		if (uuid == null) {
-			synchronized (DeviceUuidFactory.class) {
-				if (uuid == null) {
-					final SharedPreferences prefs = context
-							.getSharedPreferences(PREFS_FILE, Context.MODE_PRIVATE);
-					final String id = prefs.getString(PREFS_DEVICE_ID, null);
+        if (uuid == null) {
+            synchronized (DeviceUuidFactory.class) {
+                if (uuid == null) {
+                    final SharedPreferences prefs = context
+                            .getSharedPreferences(PREFS_FILE, Context.MODE_PRIVATE);
+                    final String id = prefs.getString(PREFS_DEVICE_ID, null);
 
-					if (id != null) {
-						// Use the ids previously computed and stored in the
-						// prefs file
-						uuid = UUID.fromString(id);
+                    if (id != null) {
+                        // Use the ids previously computed and stored in the
+                        // prefs file
+                        uuid = UUID.fromString(id);
 
-					} else {
+                    } else {
+
+                        UUID newId = UUID.randomUUID();
+                        uuid = newId;
 
-						UUID newId = UUID.randomUUID();
-						uuid = newId;
-						
-						// Write the value out to the prefs file
-						prefs.edit()
-								.putString(PREFS_DEVICE_ID, newId.toString())
-								.commit();
+                        // Write the value out to the prefs file
+                        prefs.edit()
+                                .putString(PREFS_DEVICE_ID, newId.toString())
+                                .commit();
 
-					}
-				}
-			}
-		}
-	}
+                    }
+                }
+            }
+        }
+    }
 
-	/**
-	 * Returns a unique UUID for the current android device. As with all UUIDs,
-	 * this unique ID is "very highly likely" to be unique across all Android
-	 * devices. Much more so than ANDROID_ID is.
-	 * 
-	 * The UUID is generated with <code>UUID.randomUUID()</code>.
-	 * 
-	 * @return a UUID that may be used to uniquely identify your device for most
-	 *         purposes.
-	 */
-	public UUID getDeviceUuid() {
-		return uuid;
-	}
-	
+    /**
+     * Returns a unique UUID for the current android device. As with all UUIDs,
+     * this unique ID is "very highly likely" to be unique across all Android
+     * devices. Much more so than ANDROID_ID is.
+     *
+     * The UUID is generated with <code>UUID.randomUUID()</code>.
+     *
+     * @return a UUID that may be used to uniquely identify your device for most
+     *         purposes.
+     */
+    public UUID getDeviceUuid() {
+        return uuid;
+    }
+
 }
\ No newline at end of file
--- a/mobile/android/thirdparty/com/keepsafe/switchboard/Preferences.java
+++ b/mobile/android/thirdparty/com/keepsafe/switchboard/Preferences.java
@@ -21,96 +21,96 @@ import android.content.SharedPreferences
 import android.content.SharedPreferences.Editor;
 
 /**
  * Application preferences for SwitchBoard.
  * @author Philipp Berner
  *
  */
 public class Preferences {
-	private static final String TAG = "Preferences";
-	
-	private static final String switchBoardSettings = "com.keepsafe.switchboard.settings";
-	
-	//dynamic config
-	private static final String kDynamicConfigServerUrl = "dynamic-config-server-url";
-	private static final String kDynamicConfigServerUpdateUrl = "dynamic-config-server-update-url";
-	private static final String kDynamicConfig = "dynamic-config";
-	
-	
+    private static final String TAG = "Preferences";
+
+    private static final String switchBoardSettings = "com.keepsafe.switchboard.settings";
+
+    //dynamic config
+    private static final String kDynamicConfigServerUrl = "dynamic-config-server-url";
+    private static final String kDynamicConfigServerUpdateUrl = "dynamic-config-server-update-url";
+    private static final String kDynamicConfig = "dynamic-config";
+
+
 
-	//dynamic config
-	/** TODO check this!!!
-	 * Returns a JSON string array with <br />
-	 * position 0 = updateserverUrl <br />
-	 * Fields a null if not existent.
-	 * @param c
-	 * @return
-	 */
-	public static String getDynamicUpdateServerUrl(Context c) {
-		SharedPreferences settings = (SharedPreferences) Preferences.getPreferenceObject(c, false);
-		return settings.getString(kDynamicConfigServerUpdateUrl, null);
-	}
-	
-	/**
-	 * Returns a JSON string array with <br />
-	 * postiion 1 = configServerUrl <br />
-	 * Fields a null if not existent.
-	 * @param c
-	 * @return
-	 */
-	public static String getDynamicConfigServerUrl(Context c) {
-		SharedPreferences settings = (SharedPreferences) Preferences.getPreferenceObject(c, false);
-		return settings.getString(kDynamicConfigServerUrl, null);
-	}
+    //dynamic config
+    /** TODO check this!!!
+     * Returns a JSON string array with <br />
+     * position 0 = updateserverUrl <br />
+     * Fields a null if not existent.
+     * @param c
+     * @return
+     */
+    public static String getDynamicUpdateServerUrl(Context c) {
+        SharedPreferences settings = (SharedPreferences) Preferences.getPreferenceObject(c, false);
+        return settings.getString(kDynamicConfigServerUpdateUrl, null);
+    }
+
+    /**
+     * Returns a JSON string array with <br />
+     * postiion 1 = configServerUrl <br />
+     * Fields a null if not existent.
+     * @param c
+     * @return
+     */
+    public static String getDynamicConfigServerUrl(Context c) {
+        SharedPreferences settings = (SharedPreferences) Preferences.getPreferenceObject(c, false);
+        return settings.getString(kDynamicConfigServerUrl, null);
+    }
 
-	/**
-	 * Stores the config servers URL. 
-	 * @param c
-	 * @param updateServerUrl Url end point to get the current config server location
-	 * @param configServerUrl UR: end point to get the current endpoint for the apps config file
-	 * @return true if saved successful
-	 */
-	public static boolean setDynamicConfigServerUrl(Context c, String updateServerUrl, String configServerUrl) {
-	
-		SharedPreferences.Editor settings = (Editor) Preferences.getPreferenceObject(c, true);
-		settings.putString(kDynamicConfigServerUpdateUrl, updateServerUrl);
-		settings.putString(kDynamicConfigServerUrl, configServerUrl);
-		return settings.commit();
-	}
-	
-	/**
-	 * Gets the user config as a JSON string.
-	 * @param c
-	 * @return
-	 */
-	public static String getDynamicConfigJson(Context c) {
-		SharedPreferences settings = (SharedPreferences) Preferences.getPreferenceObject(c, false);
-		return settings.getString(kDynamicConfig, null);
-	}
+    /**
+     * Stores the config servers URL.
+     * @param c
+     * @param updateServerUrl Url end point to get the current config server location
+     * @param configServerUrl UR: end point to get the current endpoint for the apps config file
+     * @return true if saved successful
+     */
+    public static boolean setDynamicConfigServerUrl(Context c, String updateServerUrl, String configServerUrl) {
+
+        SharedPreferences.Editor settings = (Editor) Preferences.getPreferenceObject(c, true);
+        settings.putString(kDynamicConfigServerUpdateUrl, updateServerUrl);
+        settings.putString(kDynamicConfigServerUrl, configServerUrl);
+        return settings.commit();
+    }
+
+    /**
+     * Gets the user config as a JSON string.
+     * @param c
+     * @return
+     */
+    public static String getDynamicConfigJson(Context c) {
+        SharedPreferences settings = (SharedPreferences) Preferences.getPreferenceObject(c, false);
+        return settings.getString(kDynamicConfig, null);
+    }
 
-	/**
-	 * Saves the user config as a JSON sting.
-	 * @param c
-	 * @param configJson
-	 * @return
-	 */
-	public static boolean setDynamicConfigJson(Context c, String configJson) {
-		SharedPreferences.Editor settings = (Editor) Preferences.getPreferenceObject(c, true);
-		settings.putString(kDynamicConfig, configJson);
-		return settings.commit();
-	}
+    /**
+     * Saves the user config as a JSON sting.
+     * @param c
+     * @param configJson
+     * @return
+     */
+    public static boolean setDynamicConfigJson(Context c, String configJson) {
+        SharedPreferences.Editor settings = (Editor) Preferences.getPreferenceObject(c, true);
+        settings.putString(kDynamicConfig, configJson);
+        return settings.commit();
+    }
+
+    static private Object getPreferenceObject(Context ctx, boolean writeable) {
 
-	static private Object getPreferenceObject(Context ctx, boolean writeable) {
-		
-		Object returnValue = null;
-		
-		Context sharedDelegate = ctx.getApplicationContext();
-		
-		if(!writeable) {
-			returnValue = sharedDelegate.getSharedPreferences(switchBoardSettings, Context.MODE_PRIVATE);
-		} else {
-			returnValue = sharedDelegate.getSharedPreferences(switchBoardSettings, Context.MODE_PRIVATE).edit();
-		}
-		
-		return returnValue;
-	}
+        Object returnValue = null;
+
+        Context sharedDelegate = ctx.getApplicationContext();
+
+        if(!writeable) {
+            returnValue = sharedDelegate.getSharedPreferences(switchBoardSettings, Context.MODE_PRIVATE);
+        } else {
+            returnValue = sharedDelegate.getSharedPreferences(switchBoardSettings, Context.MODE_PRIVATE).edit();
+        }
+
+        return returnValue;
+    }
 }
--- a/mobile/android/thirdparty/com/keepsafe/switchboard/Switch.java
+++ b/mobile/android/thirdparty/com/keepsafe/switchboard/Switch.java
@@ -22,61 +22,61 @@ import android.content.Context;
 /**
  * Single instance of an existing experiment for easier and cleaner code.
  * 
  * @author Philipp Berner
  *
  */
 public class Switch {
 
-	private Context context;
-	private String experimentName;
-	
-	/**
-	 * Creates an instance of a single experiment to give more convenient access to its values.
-	 * When the given experiment does not exist, it will give back default valued that can be found 
-	 * in <code>Switchboard</code>. Developer has to know that experiment exists when using it.
-	 * @param c Application context
-	 * @param experimentName Name of the experiment as defined on the server
-	 */
-	public Switch(Context c, String experimentName) {
-		this.context = c;
-		this.experimentName = experimentName;
-	}
-	
-	/**
-	 * Returns true if the experiment is active for this particular user.
-	 * @return Status of the experiment and false when experiment does not exist.
-	 */
-	public boolean isActive() {
-		return SwitchBoard.isInExperiment(context, experimentName);
-	}
-	
-	/** 
-	 * Returns the status of the experiment or the given default value when experiment
-	 * does not exist.
-	 * @param defaultValue Value to return when experiment does not exist.
-	 * @return Experiment status
-	 */
-	public boolean isActive(boolean defaultValue) {
-		return SwitchBoard.isInExperiment(context, experimentName, defaultValue);
-	}
-	
-	/**
-	 * Returns true if the experiment has aditional values.
-	 * @return true when values exist
-	 */
-	public boolean hasValues() {
-		return SwitchBoard.hasExperimentValues(context, experimentName);
-	}
-	
-	/**
-	 * Gives back all the experiment values in a JSONObject. This function checks if
-	 * values exists. If no values exist, it returns null.
-	 * @return Values in JSONObject or null if non
-	 */
-	public JSONObject getValues() {
-		if(hasValues())
-			return SwitchBoard.getExperimentValueFromJson(context, experimentName);
-		else
-			return null;
-	}
+    private Context context;
+    private String experimentName;
+
+    /**
+     * Creates an instance of a single experiment to give more convenient access to its values.
+     * When the given experiment does not exist, it will give back default valued that can be found
+     * in <code>Switchboard</code>. Developer has to know that experiment exists when using it.
+     * @param c Application context
+     * @param experimentName Name of the experiment as defined on the server
+     */
+    public Switch(Context c, String experimentName) {
+        this.context = c;
+        this.experimentName = experimentName;
+    }
+
+    /**
+     * Returns true if the experiment is active for this particular user.
+     * @return Status of the experiment and false when experiment does not exist.
+     */
+    public boolean isActive() {
+        return SwitchBoard.isInExperiment(context, experimentName);
+    }
+
+    /**
+     * Returns the status of the experiment or the given default value when experiment
+     * does not exist.
+     * @param defaultValue Value to return when experiment does not exist.
+     * @return Experiment status
+     */
+    public boolean isActive(boolean defaultValue) {
+        return SwitchBoard.isInExperiment(context, experimentName, defaultValue);
+    }
+
+    /**
+     * Returns true if the experiment has aditional values.
+     * @return true when values exist
+     */
+    public boolean hasValues() {
+        return SwitchBoard.hasExperimentValues(context, experimentName);
+    }
+
+    /**
+     * Gives back all the experiment values in a JSONObject. This function checks if
+     * values exists. If no values exist, it returns null.
+     * @return Values in JSONObject or null if non
+     */
+    public JSONObject getValues() {
+        if(hasValues())
+            return SwitchBoard.getExperimentValueFromJson(context, experimentName);
+        else
+            return null;
+    }
 }
--- a/mobile/android/thirdparty/com/keepsafe/switchboard/SwitchBoard.java
+++ b/mobile/android/thirdparty/com/keepsafe/switchboard/SwitchBoard.java
@@ -52,402 +52,402 @@ import android.util.Log;
  * setup on the server.
  * All functions are design to be safe for programming mistakes and network connection issues. If the 
  * experiment does not exists it will return false and pretend the user is not part of it.
  * 
  * @author Philipp Berner
  *
  */
 public class SwitchBoard {
-	
-	private static final String TAG = "SwitchBoard";
-	
-	/** Set if the application is run in debug mode. DynamicConfig runs against staging server when in debug and production when not */
-	public static boolean DEBUG = true;
-	
-	/** Production server to update the remote server URLs. http://staging.domain/path_to/SwitchboardURLs.php */
-	private static String DYNAMIC_CONFIG_SERVER_URL_UPDATE;
-	
-	/** Production server for getting the actual config file. http://staging.domain/path_to/SwitchboardDriver.php */
-	private static String DYNAMIC_CONFIG_SERVER_DEFAULT_URL;
-	
-	public static final String ACTION_CONFIG_FETCHED = ".SwitchBoard.CONFIG_FETCHED";
+
+    private static final String TAG = "SwitchBoard";
+
+    /** Set if the application is run in debug mode. DynamicConfig runs against staging server when in debug and production when not */
+    public static boolean DEBUG = true;
+
+    /** Production server to update the remote server URLs. http://staging.domain/path_to/SwitchboardURLs.php */
+    private static String DYNAMIC_CONFIG_SERVER_URL_UPDATE;
+
+    /** Production server for getting the actual config file. http://staging.domain/path_to/SwitchboardDriver.php */
+    private static String DYNAMIC_CONFIG_SERVER_DEFAULT_URL;
+
+    public static final String ACTION_CONFIG_FETCHED = ".SwitchBoard.CONFIG_FETCHED";
+
+    private static final String kUpdateServerUrl = "updateServerUrl";
+    private static final String kConfigServerUrl = "configServerUrl";
+
+    private static final String IS_EXPERIMENT_ACTIVE = "isActive";
+    private static final String EXPERIMENT_VALUES = "values";
+
+    private static String uuidExtra = null;
+
+
+    /**
+     * Basic initialization with one server.
+     * @param configServerUpdateUrl Url to: http://staging.domain/path_to/SwitchboardURLs.php
+     * @param configServerUrl Url to: http://staging.domain/path_to/SwitchboardDriver.php - the acutall config
+     * @param isDebug Is the application running in debug mode. This will add log messages.
+     */
+    public static void initDefaultServerUrls(String configServerUpdateUrl, String configServerUrl,
+            boolean isDebug) {
+
+        DYNAMIC_CONFIG_SERVER_URL_UPDATE = configServerUpdateUrl;
+        DYNAMIC_CONFIG_SERVER_DEFAULT_URL = configServerUrl;
+        DEBUG = isDebug;
+    }
 
-	private static final String kUpdateServerUrl = "updateServerUrl";
-	private static final String kConfigServerUrl = "configServerUrl";
-	
-	private static final String IS_EXPERIMENT_ACTIVE = "isActive";
-	private static final String EXPERIMENT_VALUES = "values";
+    public static void setUUIDFromExtra(String uuid) {
+        uuidExtra = uuid;
+    }
+    /**
+     * Advanced initialization that supports a production and staging environment without changing the server URLs manually.
+     * SwitchBoard will connect to the staging environment in debug mode. This makes it very simple to test new experiements
+     * during development.
+     * @param configServerUpdateUrlStaging Url to http://staging.domain/path_to/SwitchboardURLs.php in staging environment
+     * @param configServerUrlStaging Url to: http://staging.domain/path_to/SwitchboardDriver.php in production - the acutall config
+     * @param configServerUpdateUrl Url to http://staging.domain/path_to/SwitchboardURLs.php in production environment
+     * @param configServerUrl Url to: http://staging.domain/path_to/SwitchboardDriver.php in production - the acutall config
+     * @param isDebug Defines if the app runs in debug.
+     */
+    public static void initDefaultServerUrls(String configServerUpdateUrlStaging, String configServerUrlStaging,
+            String configServerUpdateUrl, String configServerUrl,
+            boolean isDebug) {
+
+        if(isDebug) {
+            DYNAMIC_CONFIG_SERVER_URL_UPDATE = configServerUpdateUrlStaging;
+            DYNAMIC_CONFIG_SERVER_DEFAULT_URL = configServerUrlStaging;
+        } else {
+            DYNAMIC_CONFIG_SERVER_URL_UPDATE = configServerUpdateUrl;
+            DYNAMIC_CONFIG_SERVER_DEFAULT_URL = configServerUrl;
+        }
+
+        DEBUG = isDebug;
+    }
+
+    /**
+     * Updates the server URLs from remote and stores it locally in the app. This allows to move the server side
+     * whith users already using Switchboard.
+     * When there is no internet connection it will continue to use the URLs from the last time or
+     * default URLS that have been set with <code>initDefaultServerUrls</code>.
+     *
+     * This methode should always be executed in a background thread to not block the UI.
+     *
+     * @param c Application context
+     */
+    public static void updateConfigServerUrl(Context c) {
+        if(DEBUG) Log.d(TAG, "start initConfigServerUrl");
+
+        if(DEBUG) {
+            //set default value that is set in code for debug mode.
+            Preferences.setDynamicConfigServerUrl(c, DYNAMIC_CONFIG_SERVER_URL_UPDATE, DYNAMIC_CONFIG_SERVER_DEFAULT_URL);
+            return;
+        }
+
+        //lookup new config server url from the one that is in shared prefs
+        String updateServerUrl = Preferences.getDynamicUpdateServerUrl(c);
+
+        //set to default when not set in preferences
+        if(updateServerUrl == null)
+            updateServerUrl = DYNAMIC_CONFIG_SERVER_URL_UPDATE;
+
+        try {
+            String result = readFromUrlGET(updateServerUrl, "");
+            if(DEBUG) Log.d(TAG, "Result String: " + result);
 
-	private static String uuidExtra = null;
-	
-	
-	/**
-	 * Basic initialization with one server. 
-	 * @param configServerUpdateUrl Url to: http://staging.domain/path_to/SwitchboardURLs.php 
-	 * @param configServerUrl Url to: http://staging.domain/path_to/SwitchboardDriver.php - the acutall config
-	 * @param isDebug Is the application running in debug mode. This will add log messages.
-	 */
-	public static void initDefaultServerUrls(String configServerUpdateUrl, String configServerUrl,
-			boolean isDebug) {
-		
-		DYNAMIC_CONFIG_SERVER_URL_UPDATE = configServerUpdateUrl;
-		DYNAMIC_CONFIG_SERVER_DEFAULT_URL = configServerUrl;
-		DEBUG = isDebug;
-	}
-	
-	public static void setUUIDFromExtra(String uuid) {
-		uuidExtra = uuid;
-	}
-	/**
-	 * Advanced initialization that supports a production and staging environment without changing the server URLs manually.
-	 * SwitchBoard will connect to the staging environment in debug mode. This makes it very simple to test new experiements
-	 * during development.
-	 * @param configServerUpdateUrlStaging Url to http://staging.domain/path_to/SwitchboardURLs.php in staging environment
-	 * @param configServerUrlStaging Url to: http://staging.domain/path_to/SwitchboardDriver.php in production - the acutall config
-	 * @param configServerUpdateUrl Url to http://staging.domain/path_to/SwitchboardURLs.php in production environment
-	 * @param configServerUrl Url to: http://staging.domain/path_to/SwitchboardDriver.php in production - the acutall config
-	 * @param isDebug Defines if the app runs in debug.
-	 */
-	public static void initDefaultServerUrls(String configServerUpdateUrlStaging, String configServerUrlStaging, 
-			String configServerUpdateUrl, String configServerUrl,
-			boolean isDebug) {
-		
-		if(isDebug) {
-			DYNAMIC_CONFIG_SERVER_URL_UPDATE = configServerUpdateUrlStaging;
-			DYNAMIC_CONFIG_SERVER_DEFAULT_URL = configServerUrlStaging;
-		} else {
-			DYNAMIC_CONFIG_SERVER_URL_UPDATE = configServerUpdateUrl;
-			DYNAMIC_CONFIG_SERVER_DEFAULT_URL = configServerUrl;	
-		}
-		
-		DEBUG = isDebug;
-	}
-	
-	/**
-	 * Updates the server URLs from remote and stores it locally in the app. This allows to move the server side
-	 * whith users already using Switchboard. 
-	 * When there is no internet connection it will continue to use the URLs from the last time or 
-	 * default URLS that have been set with <code>initDefaultServerUrls</code>.
-	 * 
-	 * This methode should always be executed in a background thread to not block the UI.
-	 * 
-	 * @param c Application context
-	 */
-	public static void updateConfigServerUrl(Context c) {
-		if(DEBUG) Log.d(TAG, "start initConfigServerUrl");
-		
-		if(DEBUG) {
-			//set default value that is set in code for debug mode.
-			Preferences.setDynamicConfigServerUrl(c, DYNAMIC_CONFIG_SERVER_URL_UPDATE, DYNAMIC_CONFIG_SERVER_DEFAULT_URL);
-			return;
-		}
-		
-		//lookup new config server url from the one that is in shared prefs
-		String updateServerUrl = Preferences.getDynamicUpdateServerUrl(c);
-		
-		//set to default when not set in preferences
-		if(updateServerUrl == null) 
-			updateServerUrl = DYNAMIC_CONFIG_SERVER_URL_UPDATE;
-		
-		try {
-			String result = readFromUrlGET(updateServerUrl, "");
-			if(DEBUG) Log.d(TAG, "Result String: " + result);
-			
-			if(result != null){
-				JSONObject a = new JSONObject(result);
-				
-				Preferences.setDynamicConfigServerUrl(c, (String)a.get(kUpdateServerUrl), (String)a.get(kConfigServerUrl));
-				
-				if(DEBUG) Log.d(TAG, "Update Server Url: " + (String)a.get(kUpdateServerUrl));
-				if(DEBUG) Log.d(TAG, "Config Server Url: " + (String)a.get(kConfigServerUrl));
-			} else {
-				storeDefaultUrlsInPreferences(c);
-			}
-			
-		} catch (JSONException e) {
-			e.printStackTrace();
-		}
-		
-		if(DEBUG) Log.d(TAG, "end initConfigServerUrl");
-	}
-	
-	/**
-	 * Loads a new config file for the specific user from current config server. Uses internal unique user ID.
-	 * Use this method only in background thread as network connections are involved that block UI thread.
-	 * Use AsyncConfigLoader() for easy background threading.
-	 * @param c ApplicationContext
-	 */
-	public static void loadConfig(Context c) {
-		loadConfig(c, null);
-	}
+            if(result != null){
+                JSONObject a = new JSONObject(result);
+
+                Preferences.setDynamicConfigServerUrl(c, (String)a.get(kUpdateServerUrl), (String)a.get(kConfigServerUrl));
+
+                if(DEBUG) Log.d(TAG, "Update Server Url: " + (String)a.get(kUpdateServerUrl));
+                if(DEBUG) Log.d(TAG, "Config Server Url: " + (String)a.get(kConfigServerUrl));
+            } else {
+                storeDefaultUrlsInPreferences(c);
+            }
+
+        } catch (JSONException e) {
+            e.printStackTrace();
+        }
+
+        if(DEBUG) Log.d(TAG, "end initConfigServerUrl");
+    }
+
+    /**
+     * Loads a new config file for the specific user from current config server. Uses internal unique user ID.
+     * Use this method only in background thread as network connections are involved that block UI thread.
+     * Use AsyncConfigLoader() for easy background threading.
+     * @param c ApplicationContext
+     */
+    public static void loadConfig(Context c) {
+        loadConfig(c, null);
+    }
+
+    /**
+     * Loads a new config for a user. This method allows you to pass your own unique user ID instead of using
+     * the SwitchBoard internal user ID.
+     * Don't call method direct for background threading reasons.
+     * @param c ApplicationContext
+     * @param uuid Custom unique user ID
+     */
+    public static void loadConfig(Context c, String uuid) {
+
+        try {
+
+            //get uuid
+            if(uuid == null) {
+                DeviceUuidFactory df = new DeviceUuidFactory(c);
+                uuid = df.getDeviceUuid().toString();
+            }
 
-	/**
-	 * Loads a new config for a user. This method allows you to pass your own unique user ID instead of using 
-	 * the SwitchBoard internal user ID.
-	 * Don't call method direct for background threading reasons. 
-	 * @param c ApplicationContext
-	 * @param uuid Custom unique user ID
-	 */
-	public static void loadConfig(Context c, String uuid) {
-		
-		try {
-			
-			//get uuid
-			if(uuid == null) {
-				DeviceUuidFactory df = new DeviceUuidFactory(c);
-				uuid = df.getDeviceUuid().toString();
-			}
-			
-			String device = Build.DEVICE;
-			String manufacturer = Build.MANUFACTURER;
-			String lang = "unknown";
-			try {
-				lang = Locale.getDefault().getISO3Language();
-			} catch (MissingResourceException e) {
-				e.printStackTrace();
-			}
-			String country = "unknown";
-			try {
-				country = Locale.getDefault().getISO3Country();
-			} catch (MissingResourceException e) {
-				e.printStackTrace();
-			}
-			String packageName = c.getPackageName();
-			String versionName = "none";
-			try {
-				versionName = c.getPackageManager().getPackageInfo(c.getPackageName(), 0).versionName;
-			} catch (NameNotFoundException e) {
-				e.printStackTrace();
-			}
-			
-			//load config, includes all experiments
-			String serverUrl = Preferences.getDynamicConfigServerUrl(c);
-			
-			if(serverUrl != null) {
-				String params = "uuid="+uuid+"&device="+device+"&lang="+lang+"&country="+country
-						+"&manufacturer="+manufacturer+"&appId="+packageName+"&version="+versionName;
-				if(DEBUG) Log.d(TAG, "Read from server URL: " + serverUrl + "?" + params);
-				String serverConfig = readFromUrlGET(serverUrl, params);
-				
-				if(DEBUG) Log.d(TAG, serverConfig);
-				
-				//store experiments in shared prefs (one variable)
-				if(serverConfig != null)
-					Preferences.setDynamicConfigJson(c, serverConfig);
-			}
-			
-		} catch (NullPointerException e) {
-			e.printStackTrace();
-		}
+            String device = Build.DEVICE;
+            String manufacturer = Build.MANUFACTURER;
+            String lang = "unknown";
+            try {
+                lang = Locale.getDefault().getISO3Language();
+            } catch (MissingResourceException e) {
+                e.printStackTrace();
+            }
+            String country = "unknown";
+            try {
+                country = Locale.getDefault().getISO3Country();
+            } catch (MissingResourceException e) {
+                e.printStackTrace();
+            }
+            String packageName = c.getPackageName();
+            String versionName = "none";
+            try {
+                versionName = c.getPackageManager().getPackageInfo(c.getPackageName(), 0).versionName;
+            } catch (NameNotFoundException e) {
+                e.printStackTrace();
+            }
+
+            //load config, includes all experiments
+            String serverUrl = Preferences.getDynamicConfigServerUrl(c);
 
-		//notify listeners that the config fetch has completed
-		Intent i = new Intent(ACTION_CONFIG_FETCHED);
-		LocalBroadcastManager.getInstance(c).sendBroadcast(i);
-	}
+            if(serverUrl != null) {
+                String params = "uuid="+uuid+"&device="+device+"&lang="+lang+"&country="+country
+                        +"&manufacturer="+manufacturer+"&appId="+packageName+"&version="+versionName;
+                if(DEBUG) Log.d(TAG, "Read from server URL: " + serverUrl + "?" + params);
+                String serverConfig = readFromUrlGET(serverUrl, params);
+
+                if(DEBUG) Log.d(TAG, serverConfig);
+
+                //store experiments in shared prefs (one variable)
+                if(serverConfig != null)
+                    Preferences.setDynamicConfigJson(c, serverConfig);
+            }
 
-	public static boolean isInBucket(Context c, int low, int high) {
-		int userBucket = getUserBucket(c);
-		if (userBucket >= low && userBucket < high)
-			return true;
-		else
-			return false;
-	}
+        } catch (NullPointerException e) {
+            e.printStackTrace();
+        }
+
+        //notify listeners that the config fetch has completed
+        Intent i = new Intent(ACTION_CONFIG_FETCHED);
+        LocalBroadcastManager.getInstance(c).sendBroadcast(i);
+    }
+
+    public static boolean isInBucket(Context c, int low, int high) {
+        int userBucket = getUserBucket(c);
+        if (userBucket >= low && userBucket < high)
+            return true;
+        else
+            return false;
+    }
 
-	/**
-	 * Looks up in config if user is in certain experiment. Returns false as a default value when experiment
-	 * does not exist.
-	 * Experiment names are defined server side as Key in array for return values.
-	 * @param experimentName Name of the experiment to lookup
-	 * @return returns value for experiment or false if experiment does not exist.
-	 */
-	public static boolean isInExperiment(Context c, String experimentName) {
-		return isInExperiment(c, experimentName, false);
-	}
-	
-	/**
-	 * Looks up in config if user is in certain experiment.
-	 * Experiment names are defined server side as Key in array for return values.
-	 * @param experimentName Name of the experiment to lookup
-	 * @param defaultReturnVal The return value that should be return when experiment does not exist
-	 * @return returns value for experiment or defaultReturnVal if experiment does not exist.
-	 */
-	public static boolean isInExperiment(Context c, String experimentName, boolean defaultReturnVal) {
-		//lookup experiment in config
-		String config = Preferences.getDynamicConfigJson(c);
-		
-		//if it does not exist
-		if(config == null)
-			return false;
-		else {
-			
-			try {
-				JSONObject experiment = (JSONObject) new JSONObject(config).get(experimentName);
-				if(DEBUG) Log.d(TAG, "experiment " + experimentName + " JSON object: " + experiment.toString());
-				if(experiment == null)
-					return defaultReturnVal;
-				
-				boolean returnValue = defaultReturnVal;
-				returnValue = experiment.getBoolean(IS_EXPERIMENT_ACTIVE);
-				
-				return returnValue;
-			} catch (JSONException e) {
-				Log.e(TAG, "Config: " + config);
-				e.printStackTrace();
-				
-			}
-		
-			//return false when JSON fails
-			return defaultReturnVal;
-		}
-		
-	}
-	
-	/**
-	 * @returns a list of all active experiments.
-	 */
-	public static List<String> getActiveExperiments(Context c) {
-		ArrayList<String> returnList = new ArrayList<String>();
+    /**
+     * Looks up in config if user is in certain experiment. Returns false as a default value when experiment
+     * does not exist.
+     * Experiment names are defined server side as Key in array for return values.
+     * @param experimentName Name of the experiment to lookup
+     * @return returns value for experiment or false if experiment does not exist.
+     */
+    public static boolean isInExperiment(Context c, String experimentName) {
+        return isInExperiment(c, experimentName, false);
+    }
+
+    /**
+     * Looks up in config if user is in certain experiment.
+     * Experiment names are defined server side as Key in array for return values.
+     * @param experimentName Name of the experiment to lookup
+     * @param defaultReturnVal The return value that should be return when experiment does not exist
+     * @return returns value for experiment or defaultReturnVal if experiment does not exist.
+     */
+    public static boolean isInExperiment(Context c, String experimentName, boolean defaultReturnVal) {
+        //lookup experiment in config
+        String config = Preferences.getDynamicConfigJson(c);
+
+        //if it does not exist
+        if(config == null)
+            return false;
+        else {
+
+            try {
+                JSONObject experiment = (JSONObject) new JSONObject(config).get(experimentName);
+                if(DEBUG) Log.d(TAG, "experiment " + experimentName + " JSON object: " + experiment.toString());
+                if(experiment == null)
+                    return defaultReturnVal;
+
+                boolean returnValue = defaultReturnVal;
+                returnValue = experiment.getBoolean(IS_EXPERIMENT_ACTIVE);
+
+                return returnValue;
+            } catch (JSONException e) {
+                Log.e(TAG, "Config: " + config);
+                e.printStackTrace();
+
+            }
 
-		// lookup experiment in config
-		String config = Preferences.getDynamicConfigJson(c);
+            //return false when JSON fails
+            return defaultReturnVal;
+        }
+
+    }
 
-		// if it does not exist
-		if (config == null) {
-			return returnList;
-		}
+    /**
+     * @returns a list of all active experiments.
+     */
+    public static List<String> getActiveExperiments(Context c) {
+        ArrayList<String> returnList = new ArrayList<String>();
+
+        // lookup experiment in config
+        String config = Preferences.getDynamicConfigJson(c);
+
+        // if it does not exist
+        if (config == null) {
+            return returnList;
+        }
 
-		try {
-			JSONObject experiments = new JSONObject(config);
-			Iterator<?> iter = experiments.keys();
-			while (iter.hasNext()) {
-				String key = (String)iter.next();
-				JSONObject experiment = experiments.getJSONObject(key);
-				if (experiment.getBoolean(IS_EXPERIMENT_ACTIVE)) {
-					returnList.add(key);
-				}
-			}
-		} catch (JSONException e) {
-			// Something went wrong!
-		}
+        try {
+            JSONObject experiments = new JSONObject(config);
+            Iterator<?> iter = experiments.keys();
+            while (iter.hasNext()) {
+                String key = (String)iter.next();
+                JSONObject experiment = experiments.getJSONObject(key);
+                if (experiment.getBoolean(IS_EXPERIMENT_ACTIVE)) {
+                    returnList.add(key);
+                }
+            }
+        } catch (JSONException e) {
+            // Something went wrong!
+        }
 
-		return returnList;
-	}
+        return returnList;
+    }
+
+    /**
+     * Checks if a certain experiment exists.
+     * @param c ApplicationContext
+     * @param experimentName Name of the experiment
+     * @return true when experiment exists
+     */
+    public static boolean hasExperimentValues(Context c, String experimentName) {
+        if(getExperimentValueFromJson(c, experimentName) == null)
+            return false;
+        else
+            return true;
+    }
 
-	/**
-	 * Checks if a certain experiment exists. 
-	 * @param c ApplicationContext
-	 * @param experimentName Name of the experiment
-	 * @return true when experiment exists
-	 */
-	public static boolean hasExperimentValues(Context c, String experimentName) {
-		if(getExperimentValueFromJson(c, experimentName) == null)
-			return false;
-		else
-			return true;
-	}
-	
-	/**
-	 * Returns the experiment value as a JSONObject. Depending on what experiment is has to be converted to the right type.
-	 * Typcasting is by convention. You have to know what it's in there. Use <code>hasExperiment()</code>
-	 * before this to avoid NullPointerExceptions. 
-	 * @param experimentName Name of the experiment to lookup
-	 * @return Experiment value as String, null if experiment does not exist.
-	 */
-	public static JSONObject getExperimentValueFromJson(Context c, String experimentName) {
-		String config = Preferences.getDynamicConfigJson(c);
-		
-		if(config == null)
-			return null;
-		
-		try {
-			JSONObject experiment = (JSONObject) new JSONObject(config).get(experimentName);
-			JSONObject values = experiment.getJSONObject(EXPERIMENT_VALUES);
-			
-			return values;
-			
-		} catch (JSONException e) {
-			Log.e(TAG, "Config: " + config);
-			e.printStackTrace();
-			Log.e(TAG, "Could not create JSON object from config string", e);
-		}
-		
-		return null;
-	}
-	
-	/**
-	 * Sets config server URLs in shared prefs to defaul when not set already. It keeps
-	 * URLs when already set in shared preferences.
-	 * @param c
-	 */
-	private static void storeDefaultUrlsInPreferences(Context c) {
-		String configUrl = Preferences.getDynamicConfigServerUrl(c);
-		String updateUrl = Preferences.getDynamicUpdateServerUrl(c);
-			
-		if(configUrl == null)
-			configUrl = DYNAMIC_CONFIG_SERVER_DEFAULT_URL;
-		
-		if(updateUrl == null)
-			updateUrl = DYNAMIC_CONFIG_SERVER_URL_UPDATE;
-		
-		Preferences.setDynamicConfigServerUrl(c, updateUrl, configUrl);
-	}
-	
-	/**
-	 * Returns a String containing the server response from a GET request
-	 * @param address Valid http addess.
-	 * @param params String of params. Multiple params seperated with &. No leading ? in string
-	 * @return Returns String from server or null when failed.
-	 */
-	private static String readFromUrlGET(String address, String params) {
-		if(address == null || params == null)
-			return null;
-		
-		String completeUrl = address + "?" + params;
-		if(DEBUG) Log.d(TAG, "readFromUrl(): " + completeUrl);
-		
-		try {
-			URL url = new URL(completeUrl);
-			HttpURLConnection connection = (HttpURLConnection) url.openConnection();
-			connection.setRequestMethod("GET");
-			connection.setUseCaches(false);
+    /**
+     * Returns the experiment value as a JSONObject. Depending on what experiment is has to be converted to the right type.
+     * Typcasting is by convention. You have to know what it's in there. Use <code>hasExperiment()</code>
+     * before this to avoid NullPointerExceptions.
+     * @param experimentName Name of the experiment to lookup
+     * @return Experiment value as String, null if experiment does not exist.
+     */
+    public static JSONObject getExperimentValueFromJson(Context c, String experimentName) {
+        String config = Preferences.getDynamicConfigJson(c);
+
+        if(config == null)
+            return null;
+
+        try {
+            JSONObject experiment = (JSONObject) new JSONObject(config).get(experimentName);
+            JSONObject values = experiment.getJSONObject(EXPERIMENT_VALUES);
+
+            return values;
+
+        } catch (JSONException e) {
+            Log.e(TAG, "Config: " + config);
+            e.printStackTrace();
+            Log.e(TAG, "Could not create JSON object from config string", e);
+        }
+
+        return null;
+    }
+
+    /**
+     * Sets config server URLs in shared prefs to defaul when not set already. It keeps
+     * URLs when already set in shared preferences.
+     * @param c
+     */
+    private static void storeDefaultUrlsInPreferences(Context c) {
+        String configUrl = Preferences.getDynamicConfigServerUrl(c);
+        String updateUrl = Preferences.getDynamicUpdateServerUrl(c);
+
+        if(configUrl == null)
+            configUrl = DYNAMIC_CONFIG_SERVER_DEFAULT_URL;
+
+        if(updateUrl == null)
+            updateUrl = DYNAMIC_CONFIG_SERVER_URL_UPDATE;
+
+        Preferences.setDynamicConfigServerUrl(c, updateUrl, configUrl);
+    }
 
-			// get response
-			InputStream is = connection.getInputStream();
-			InputStreamReader inputStreamReader = new InputStreamReader(is);
-			BufferedReader bufferReader = new BufferedReader(inputStreamReader, 8192);
-			String line = "";
-			StringBuffer resultContent = new StringBuffer();
-			while ((line = bufferReader.readLine()) != null) {
-				if(DEBUG) Log.d(TAG, line);
-				resultContent.append(line);
-			}
-			bufferReader.close();
-			
-			if(DEBUG) Log.d(TAG, "readFromUrl() result: " + resultContent.toString());
-			
-			return resultContent.toString();
-		} catch (ProtocolException e) {
-			e.printStackTrace();
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
+    /**
+     * Returns a String containing the server response from a GET request
+     * @param address Valid http addess.
+     * @param params String of params. Multiple params seperated with &. No leading ? in string
+     * @return Returns String from server or null when failed.
+     */
+    private static String readFromUrlGET(String address, String params) {
+        if(address == null || params == null)
+            return null;
+
+        String completeUrl = address + "?" + params;
+        if(DEBUG) Log.d(TAG, "readFromUrl(): " + completeUrl);
+
+        try {
+            URL url = new URL(completeUrl);
+            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+            connection.setRequestMethod("GET");
+            connection.setUseCaches(false);
 
-		return null;
-	}
+            // get response
+            InputStream is = connection.getInputStream();
+            InputStreamReader inputStreamReader = new InputStreamReader(is);
+            BufferedReader bufferReader = new BufferedReader(inputStreamReader, 8192);
+            String line = "";
+            StringBuffer resultContent = new StringBuffer();
+            while ((line = bufferReader.readLine()) != null) {
+                if(DEBUG) Log.d(TAG, line);
+                resultContent.append(line);
+            }
+            bufferReader.close();
+
+            if(DEBUG) Log.d(TAG, "readFromUrl() result: " + resultContent.toString());
+
+            return resultContent.toString();
+        } catch (ProtocolException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
 
-	/**
-	 * Return the bucket number of the user. There are 100 possible buckets.
-	 */
-	private static int getUserBucket(Context c) {
-		//get uuid
-		String uuid = uuidExtra;
-		if (uuid == null) {
-			DeviceUuidFactory df = new DeviceUuidFactory(c);
-			uuid = df.getDeviceUuid().toString();
-		}
+        return null;
+    }
 
-		CRC32 crc = new CRC32();
-		crc.update(uuid.getBytes());
-		long checksum = crc.getValue();
-		return (int)(checksum % 100L);
-	}
+    /**
+     * Return the bucket number of the user. There are 100 possible buckets.
+     */
+    private static int getUserBucket(Context c) {
+        //get uuid
+        String uuid = uuidExtra;
+        if (uuid == null) {
+            DeviceUuidFactory df = new DeviceUuidFactory(c);
+            uuid = df.getDeviceUuid().toString();
+        }
+
+        CRC32 crc = new CRC32();
+        crc.update(uuid.getBytes());
+        long checksum = crc.getValue();
+        return (int)(checksum % 100L);
+    }
 }