// Path: src/com/wifiafterconnect/Constants.java
// public interface Constants {
// 
// 	public static final String TAG = "WifiAfterConnect";
// 	
// 	public static final String URL_KERNEL_ORG_HTTPS = "https://mirrors.kernel.org/debian/pool/";
// 	public static final String URL_KERNEL_ORG_HTTP = "http://mirrors.kernel.org/debian/pool/";
// 	public static final String URL_GOOGLE_HTTP = "http://www.google.com";
// 	public static final String URL_GOOGLE_HTTPS = "https://www.google.com";
// 	
// 	// Google page is rather large, so let's try and pull a smaller page
// 	// kernel.org should be sufficiently fast and stable for our purposes
// 	public static final String URL_TO_CHECK_HTTP = URL_KERNEL_ORG_HTTP;
// 	public static final String URL_TO_CHECK_HTTPS = URL_KERNEL_ORG_HTTPS;
// 	
// 	public static final int SOCKET_CONNECT_TIMEOUT_MS = 0; //Use TCP timeout
// 	public static final int SOCKET_READ_TIMEOUT_MS = 220000; // this could be really slow in some cases
// 	
// 	
// 	public static final String [] PROTOCOLS = {"http","https"};
// 
// 	public static final int MAX_AUTOMATED_REQUESTS = 10;
// 
// 	// MAX timeout while handling <meta http-equiv="refresh" content="timeout; url=url">
// 	public static final int MAX_REFRESH_TIMEOUT = 15;
// 
// 
// }
// 
// Path: src/com/wifiafterconnect/WifiAuthParams.java
// public class WifiAuthParams {
// 	// Some standard input names used almost universally:
// 	public static final String PASSWORD = "password";
// 	public static final String USERNAME = "username";
// 	public static final String EMAIL = "email";
// 	
// 	
// 	public AuthAction authAction = AuthAction.DEFAULT;
// 	public WifiTools.Action wifiAction = WifiTools.Action.DEFAULT;
// 	
// 	boolean savePassword = false;
// 	
// 	protected HashMap<String,HtmlInput> fields = new HashMap<String,HtmlInput>();
// 	
// 	public Collection<HtmlInput> getFields() {
// 		return fields.values();
// 	}
// 
// 	public void add (HtmlInput i) {
// 		Log.d(Constants.TAG, "Adding param ["+i.getName() + "], type = [" + i.getType()+"]");
// 		if (i.isValid() && !i.isHidden() && isSupportedParamType(i)){
// 			Log.d(Constants.TAG, "Added");
// 			fields.put(i.getName(), i);
// 		}
// 		else
// 			Log.d(Constants.TAG, "Not Added");
// 	}
// 	
// 	public boolean hasParam (final String name) {
// 		HtmlInput i = fields.get (name);
// 		return (i != null && !i.getValue().isEmpty());
// 	}
// 	
// 	public static boolean isSupportedParamType (HtmlInput input) {
// 		return (input.getAndroidInputType() != 0);
// 		
// 	}
// 
// 	public HtmlInput getField(String tag) {
// 		return fields.get(tag);
// 	}
// 
// 	public HtmlInput getFieldByType(String type) {
//   	   	for (HtmlInput i : fields.values()) {
//    			if (i.matchType(HtmlInput.TYPE_PASSWORD))
//    					return i;
//   	   	}
//   	   	return null;
// 	}
// 
// 	@Override
// 	public String toString() {
// 		String s = "<WifiAuthParams authAction=\"" + authAction + 
// 				"\" wifiAction=\"" + wifiAction + 
// 				"\" savePassword=\"" + savePassword +
// 				"\">";
// 		for (HtmlInput i : fields.values())
// 			s += i;
// 		s += "</WifiAuthParams>";
// 		return s;
// 	}
// 	
// 	public static String toString (WifiAuthParams params) {
// 		return params == null ? "(null)": params.toString();
// 	}
// }


import java.util.Map;
import org.jsoup.nodes.Element;
import android.util.Log;
import com.wifiafterconnect.BuildConfig;
import com.wifiafterconnect.Constants;
import com.wifiafterconnect.WifiAuthParams;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Locale;
		
		for (HtmlInput i :inputsList) {
			if (!i.isHidden() && !params.hasParam(i.getName())) {
				HtmlInput param = new HtmlInput (i);
				params.add(param);
			}
		}		
		return params;
	}
	
	public boolean isParamMissing (WifiAuthParams params, final String paramName) {
		return (hasVisibleInput(paramName) && (params == null || !params.hasParam (paramName)));
	}

	public void fillInputs (WifiAuthParams params) {
		if (params != null) {
			for (HtmlInput f :params.getFields()) {
				String value = f.getValue();
				HtmlInput i = inputs.get(f.getName());
				if (i!=null)
					i.setValue(value);
			}
		}
	}

	public boolean isSubmittable() {
		boolean missingValues = false;
		boolean hasSubmit = false;
		for (HtmlInput i :inputs.values()) {
			if (!i.isHidden() && i.getValue().isEmpty()
// Path: src/com/wifiafterconnect/Constants.java
// public interface Constants {
// 
// 	public static final String TAG = "WifiAfterConnect";
// 	
// 	public static final String URL_KERNEL_ORG_HTTPS = "https://mirrors.kernel.org/debian/pool/";
// 	public static final String URL_KERNEL_ORG_HTTP = "http://mirrors.kernel.org/debian/pool/";
// 	public static final String URL_GOOGLE_HTTP = "http://www.google.com";
// 	public static final String URL_GOOGLE_HTTPS = "https://www.google.com";
// 	
// 	// Google page is rather large, so let's try and pull a smaller page
// 	// kernel.org should be sufficiently fast and stable for our purposes
// 	public static final String URL_TO_CHECK_HTTP = URL_KERNEL_ORG_HTTP;
// 	public static final String URL_TO_CHECK_HTTPS = URL_KERNEL_ORG_HTTPS;
// 	
// 	public static final int SOCKET_CONNECT_TIMEOUT_MS = 0; //Use TCP timeout
// 	public static final int SOCKET_READ_TIMEOUT_MS = 220000; // this could be really slow in some cases
// 	
// 	
// 	public static final String [] PROTOCOLS = {"http","https"};
// 
// 	public static final int MAX_AUTOMATED_REQUESTS = 10;
// 
// 	// MAX timeout while handling <meta http-equiv="refresh" content="timeout; url=url">
// 	public static final int MAX_REFRESH_TIMEOUT = 15;
// 
// 
// }
// 
// Path: src/com/wifiafterconnect/WifiAuthParams.java
// public class WifiAuthParams {
// 	// Some standard input names used almost universally:
// 	public static final String PASSWORD = "password";
// 	public static final String USERNAME = "username";
// 	public static final String EMAIL = "email";
// 	
// 	
// 	public AuthAction authAction = AuthAction.DEFAULT;
// 	public WifiTools.Action wifiAction = WifiTools.Action.DEFAULT;
// 	
// 	boolean savePassword = false;
// 	
// 	protected HashMap<String,HtmlInput> fields = new HashMap<String,HtmlInput>();
// 	
// 	public Collection<HtmlInput> getFields() {
// 		return fields.values();
// 	}
// 
// 	public void add (HtmlInput i) {
// 		Log.d(Constants.TAG, "Adding param ["+i.getName() + "], type = [" + i.getType()+"]");
// 		if (i.isValid() && !i.isHidden() && isSupportedParamType(i)){
// 			Log.d(Constants.TAG, "Added");
// 			fields.put(i.getName(), i);
// 		}
// 		else
// 			Log.d(Constants.TAG, "Not Added");
// 	}
// 	
// 	public boolean hasParam (final String name) {
// 		HtmlInput i = fields.get (name);
// 		return (i != null && !i.getValue().isEmpty());
// 	}
// 	
// 	public static boolean isSupportedParamType (HtmlInput input) {
// 		return (input.getAndroidInputType() != 0);
// 		
// 	}
// 
// 	public HtmlInput getField(String tag) {
// 		return fields.get(tag);
// 	}
// 
// 	public HtmlInput getFieldByType(String type) {
//   	   	for (HtmlInput i : fields.values()) {
//    			if (i.matchType(HtmlInput.TYPE_PASSWORD))
//    					return i;
//   	   	}
//   	   	return null;
// 	}
// 
// 	@Override
// 	public String toString() {
// 		String s = "<WifiAuthParams authAction=\"" + authAction + 
// 				"\" wifiAction=\"" + wifiAction + 
// 				"\" savePassword=\"" + savePassword +
// 				"\">";
// 		for (HtmlInput i : fields.values())
// 			s += i;
// 		s += "</WifiAuthParams>";
// 		return s;
// 	}
// 	
// 	public static String toString (WifiAuthParams params) {
// 		return params == null ? "(null)": params.toString();
// 	}
// }


// Path: src/com/wifiafterconnect/html/HtmlForm.java
import java.util.Map;
import org.jsoup.nodes.Element;
import android.util.Log;
import com.wifiafterconnect.BuildConfig;
import com.wifiafterconnect.Constants;
import com.wifiafterconnect.WifiAuthParams;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Locale;

		
		for (HtmlInput i :inputsList) {
			if (!i.isHidden() && !params.hasParam(i.getName())) {
				HtmlInput param = new HtmlInput (i);
				params.add(param);
			}
		}		
		return params;
	}
	
	public boolean isParamMissing (WifiAuthParams params, final String paramName) {
		return (hasVisibleInput(paramName) && (params == null || !params.hasParam (paramName)));
	}

	public void fillInputs (WifiAuthParams params) {
		if (params != null) {
			for (HtmlInput f :params.getFields()) {
				String value = f.getValue();
				HtmlInput i = inputs.get(f.getName());
				if (i!=null)
					i.setValue(value);
			}
		}
	}

	public boolean isSubmittable() {
		boolean missingValues = false;
		boolean hasSubmit = false;
		for (HtmlInput i :inputs.values()) {
			if (!i.isHidden() && i.getValue().isEmpty()
					&& (WifiAuthParams.isSupportedParamType(i) || i.matchType(HtmlInput.TYPE_CHECKBOX)))