Commits

nattster committed 423b7d2

add new file

Comments (0)

Files changed (6)

AndroidManifest.xml

 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
       package="net.siamdev.nattster.WifiTest"
-      android:versionCode="4"
-      android:versionName="1.3">
+      android:versionCode="5"
+      android:versionName="1.4">
     <application android:icon="@drawable/icon" android:label="Nontri AutoLogin">
         <activity android:name=".WifiTest" android:label="AutoLogin">
             <intent-filter>

default.properties

-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-# 
-# This file must be checked in Version Control Systems.
-# 
-# To customize properties used by the Ant build system use,
-# "build.properties", and override values to adapt the script to your
-# project structure.
-
 # Project target.
 target=android-10
Added
New image

project.properties

+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system edit
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+#
+# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
+#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
+
+# Project target.
+target=android-10

src/net/siamdev/nattster/WifiTest/NontriLogin.java

 import org.apache.http.client.entity.UrlEncodedFormEntity;
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.client.methods.HttpPost;
+import org.apache.http.impl.client.DefaultHttpClient;
 import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.params.HttpParams;
 
 import android.content.Context;
 import android.util.Log;
 		Random r = new Random();
 		Integer id = r.nextInt(10)+1;
 		
-		HttpClient client = new SafeHttpClient(context);
+		HttpClient client = new DefaultHttpClient();
+		HttpParams params = client.getParams();
+		params.setBooleanParameter("http.protocol.handle-redirects", false);    // don't automatically follow Location: header
+        params.setBooleanParameter("http.protocol.expect-continue", false);
+        
 		String url = "https://login"+id.toString()+".ku.ac.th/index.php";
 		String content_type = "application/x-www-form-urlencoded";
 		

src/net/siamdev/nattster/WifiTest/WifiTest.java

     		zoneSpinner.setSelection(pref.getInt("zone", 0));
 	}
 	
-    @Override
 	public void onClick(View v) {
 		switch(v.getId())
 		{
 			}
 			break;
 		case R.id.btnTestLogin:
-			dialog = ProgressDialog.show(this, "", "Logging in...");
-			new TestLoginTask().execute(this);
+			if(txtUsername.getText().length() > 0 && txtPassword.getText().length() > 0)
+			{
+				SharedPreferences.Editor editor = pref.edit();
+				editor.putString("user", txtUsername.getText().toString());
+				editor.putString("pass", txtPassword.getText().toString());
+				editor.putInt("zone", zoneSpinner.getSelectedItemPosition());
+				editor.commit();
+
+				dialog = ProgressDialog.show(this, "", "Logging in...");
+				new TestLoginTask().execute(this);
+			} else {
+				Toast.makeText(getApplicationContext(), "Please enter both Username and Password", Toast.LENGTH_LONG).show();
+			}
+			
 			break;
 		}
 	}