package com.jaselogic.adamsonelearn;

import java.io.IOException;
import java.util.Map;

import org.jsoup.Jsoup;
import org.jsoup.Connection.Method;
import org.jsoup.Connection.Response;
import org.jsoup.nodes.Document;

import android.os.AsyncTask;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ProgressBar;

public class Main extends Activity {

	private Button btnLogin;
	private EditText txtStudNo;
	private EditText txtPassword;
	private ProgressBar pb1;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		//get views
		btnLogin = (Button) findViewById(R.id.btn_login);
		txtStudNo = (EditText) findViewById(R.id.txt_studno);
		txtPassword = (EditText) findViewById(R.id.txt_password);
		pb1 = (ProgressBar) findViewById(R.id.progressBar1);
		
		btnLogin.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				btnLogin.setVisibility(View.INVISIBLE);
				txtStudNo.setVisibility(View.INVISIBLE);
				txtPassword.setVisibility(View.INVISIBLE);
				
				pb1.setVisibility(View.VISIBLE);
			}
		});
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

	private class DownloadDocumentTask extends AsyncTask<String, Void, Document> {

		@Override
		protected Document doInBackground(String... arg0) {
			// TODO Auto-generated method stub
	        Document doc = null;
	        Response res = null;
	        try {                                              
	            res = Jsoup.connect("http://learn.adamson.edu.ph/V4/")
	            		.data("TXTusername", "201013888", "TXTpassword", "288785", "BTNlogin", "Login")
	            		.method(Method.POST)
	            		.execute();
	            Map<String, String> loginCookies = res.cookies();
	            
	            doc = Jsoup.connect("http://learn.adamson.edu.ph/V4/?page=welcome")
	            		.cookies(loginCookies)
	            		.get();
	        } catch (IOException e) {                          
	            e.printStackTrace();                           
	        }
	        
	        return doc;
		}
		
		protected void onPostExecute(Document result) {

		}
		
	}
	
}

@@ -488,16 +488,45 @@
 ressBar;
+%0Aimport android.widget.Toast;
 %0A%0Apublic
@@ -1202,16 +1202,565 @@
 od stub%0A
+%09%09%09%09String studNo = txtStudNo.getText().toString().trim();%0A%09%09%09%09String password = txtPassword.getText().toString();%0A%09%09%09%09%09%09%0A%09%09%09%09//check if student number edittext is empty%0A%09%09%09%09if(studNo.equals(%22%22)) %7B%0A%09%09%09%09%09Toast.makeText(Main.this, %22Please provide your Adamson University Student Number%22, Toast.LENGTH_SHORT).show();%0A%09%09%09%09%7D else if(password.equals(%22%22)) %7B //else if password is empty%0A%09%09%09%09%09Toast.makeText(Main.this, %22Please provide your E-Learning password%22, Toast.LENGTH_SHORT).show();%0A%09%09%09%09%7D else %7B //ready to send login details%0A%09%09%09%09%09//set visibilities%0A%09
 %09%09%09%09btnL
@@ -1791,24 +1791,25 @@
 INVISIBLE);%0A
+%09
 %09%09%09%09txtStudN
@@ -1845,16 +1845,17 @@
 E);%0A%09%09%09%09
+%09
 txtPassw
@@ -1893,21 +1893,23 @@
 E);%0A%09%09%09%09
+%09
 %0A%09%09%09%09
+%09
 pb1.setV
@@ -1928,24 +1928,31 @@
 ew.VISIBLE);
+%09%0A%09%09%09%09%7D
 %0A%09%09%09%7D%0A%09%09%7D);%0A

Add toast when username/password empty in Main.java