<|start_filename|>src/com/rex/yangtzeu/http/JwcWeb.java<|end_filename|>
package com.rex.yangtzeu.http;

import java.util.HashMap;
import java.util.Map;

import com.rex.yangtzeu.Yangtzeu;
import com.rex.yangtzeu.regex.JwcRegex;
import com.rex.yangtzeu.sqlite.ComDB;
import com.rex.yangtzeu.utils.EncrypAES;

public class JwcWeb {
	public static boolean jwc_login() {
		try {
			String test_response = YuHttp.get("http://jwc.yangtzeu.edu.cn:8080/login.aspx", "gb2312");
			JwcRegex.get_viewstate_keys(test_response);
			
			Map<String,String> data = new HashMap<String,String>();
			data.put("__VIEWSTATE",Yangtzeu.jwc_login_viewstate);
			data.put("__EVENTVALIDATION",Yangtzeu.jwc_login_eventvalidation);
			data.put("txtUid",ComDB.kv_get("student_number"));
			data.put("txtPwd",EncrypAES.decrypt(ComDB.kv_get("student_password")));
			data.put("selKind","1");
			data.put("btLogin", null);
			
			String login_result = YuHttp.post("http://jwc.yangtzeu.edu.cn:8080/login.aspx", data, "gb2312", false);
			
			return JwcRegex.login_success(login_result);
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return false;
		}
	}
}


<|start_filename|>src/com/rex/yangtzeu/ui/Jwc.java<|end_filename|>
/**
 * 长大长新-长江大学校园安卓应用
 *
 * Copyright (C) 2014-2016 <NAME> <<EMAIL>>
 *
 * This program is free and opensource software; 
 * you can redistribute it and/or modify
 * it under the terms of the MIT License
 */
package com.rex.yangtzeu.ui;

import com.rex.yangtzeu.R;
import com.rex.yangtzeu.config.Urls;
import com.rex.yangtzeu.http.YuHttp;
import com.rex.yangtzeu.regex.JwcRegex;

import android.os.AsyncTask;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.LinearLayout;

public class Jwc extends Activity implements android.view.View.OnClickListener {
	private LinearLayout btn1;
	private LinearLayout btn2;
	private LinearLayout btn3;
	private LinearLayout btn4;
	private LinearLayout btn5;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.jwc);
		
		btn1 = (LinearLayout) this.findViewById(R.id.jwc_chafen);
		btn2 = (LinearLayout) this.findViewById(R.id.find_stu);
		btn3 = (LinearLayout) this.findViewById(R.id.ch_cls);
		btn4 = (LinearLayout) this.findViewById(R.id.kebiao_btn);
		btn5 = (LinearLayout) this.findViewById(R.id.cet_btn);
		
		btn1.setOnTouchListener(new OnTouchListener() {
			public boolean onTouch(View v, MotionEvent event) {
				if (event.getAction() == MotionEvent.ACTION_DOWN) {
					// 按下时背景透明
					v.setBackgroundColor(Color.parseColor("#00000000"));
				} else if (event.getAction() == MotionEvent.ACTION_UP) {
					// 抬起时白色
					v.setBackgroundColor(Color.parseColor("#ffffff"));
				}
				return false;
			}
		});
		btn2.setOnTouchListener(new OnTouchListener() {
			public boolean onTouch(View v, MotionEvent event) {
				if (event.getAction() == MotionEvent.ACTION_DOWN) {
					// 按下时背景透明
					v.setBackgroundColor(Color.parseColor("#00000000"));
				} else if (event.getAction() == MotionEvent.ACTION_UP) {
					// 抬起时白色
					v.setBackgroundColor(Color.parseColor("#ffffff"));
				}
				return false;
			}
		});
		btn3.setOnTouchListener(new OnTouchListener() {
			public boolean onTouch(View v, MotionEvent event) {
				if (event.getAction() == MotionEvent.ACTION_DOWN) {
					// 按下时背景透明
					v.setBackgroundColor(Color.parseColor("#00000000"));
				} else if (event.getAction() == MotionEvent.ACTION_UP) {
					// 抬起时白色
					v.setBackgroundColor(Color.parseColor("#ffffff"));
				}
				return false;
			}
		});
		btn4.setOnTouchListener(new OnTouchListener() {
			public boolean onTouch(View v, MotionEvent event) {
				if (event.getAction() == MotionEvent.ACTION_DOWN) {
					// 按下时背景透明
					v.setBackgroundColor(Color.parseColor("#00000000"));
				} else if (event.getAction() == MotionEvent.ACTION_UP) {
					// 抬起时白色
					v.setBackgroundColor(Color.parseColor("#ffffff"));
				}
				return false;
			}
		});
		btn5.setOnTouchListener(new OnTouchListener() {
			public boolean onTouch(View v, MotionEvent event) {
				if (event.getAction() == MotionEvent.ACTION_DOWN) {
					// 按下时背景透明
					v.setBackgroundColor(Color.parseColor("#00000000"));
				} else if (event.getAction() == MotionEvent.ACTION_UP) {
					// 抬起时白色
					v.setBackgroundColor(Color.parseColor("#ffffff"));
				}
				return false;
			}
		});

		btn1.setOnClickListener(this);
		btn2.setOnClickListener(this);
		btn3.setOnClickListener(this);
		btn4.setOnClickListener(this);
		btn5.setOnClickListener(this);
	}


	/**
	 * 按键事件
	 */
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		// 后退动画
		if (keyCode == KeyEvent.KEYCODE_BACK) {
			finish();
			overridePendingTransition(R.anim.back_left_in,
					R.anim.back_right_out);

			return true;
		}
		return super.onKeyDown(keyCode, event);
	}


	@Override
	public void onClick(View arg0) {
		// Auto-generated method stub
		if (arg0 == btn1) {
			// 查分
			new NetTask().execute("load_page");
		}else if (arg0 == btn2){
            redirect_to("cet");
        }
	}
	
	public void redirect_to(String tag){
		if(tag == "jwc"){
			Intent intent = new Intent(this, JwcChafen.class);
			startActivity(intent);
			overridePendingTransition(R.anim.in_from_right, R.anim.out_to_left);
		}else if (tag == "cet"){
            Intent intent = new Intent(this, CetScore.class);
            startActivity(intent);
            overridePendingTransition(R.anim.in_from_right, R.anim.out_to_left);
        }
	}

	// Async load_cfpage_task 
	private class NetTask extends AsyncTask<String, Void,String> {
		String optype;

		protected void onPostExecute(String result) {
			if(this.optype == "load_page"){ // 载入页面
				redirect_to("jwc");
			}
		}
		
		@Override
		protected String doInBackground(String... arg0) {
			this.optype = arg0[0];
			if(arg0[0] == "load_page"){ // 载入页面
				String result = "";
				try {
					result = YuHttp.get(Urls.jwc_cjcx_page, "gb2312");
					JwcRegex.get_viewstate_keys(result);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			return null;
		}
	}
}


<|start_filename|>src/com/rex/yangtzeu/config/Urls.java<|end_filename|>
/**
 * 长大长新-长江大学校园安卓应用
 *
 * Copyright (C) 2014-2016 <NAME> <<EMAIL>>
 *
 * This program is free and opensource software; 
 * you can redistribute it and/or modify
 * it under the terms of the MIT License
 */
package com.rex.yangtzeu.config;

public class Urls {

	// 教务处
	public static String jwc_home = "http://jwc.yangtzeu.edu.cn:8080/";
	public static String jwc_login_page = jwc_home + "login.aspx";
	public static String jwc_login_response = jwc_home + "login.aspx";
	public static String jwc_cjcx_page = jwc_home + "cjcx.aspx";
	public static String jwc_search_student_page = jwc_home + "student.aspx";
	public static String jwc_search_student_response = jwc_home
			+ "student.aspx";
	public static String jwc_search_class_student_page = jwc_home
			+ "student.aspx";
	public static String jwc_search_class_student_response = jwc_home
			+ "student.aspx";

	// 长大首页
	public static String yz_home = "http://www.yangtzeu.edu.cn/";
	public static String yz_news_home = "http://news.yangtzeu.edu.cn/";

	// 长大在线
	public static String yuol_home = "http://online.yangtzeu.edu.cn/";

	// cet 查分API格式如下
	// http://www.chsi.com.cn/cet/query?zkzh=420611122213619&xm=李俊
	public static String cet_score = "http://www.chsi.com.cn/cet/query";

}


<|start_filename|>src/com/rex/yangtzeu/regex/CetRegex.java<|end_filename|>
package com.rex.yangtzeu.regex;

import java.util.Map;

/**
 * 正则表达式 解析CET查分结果
 * Created by rex on 2014/8/2.
 */
public class CetRegex {
    public static boolean get_error(){
        return false;
    }

    public static Map<String,String> get_score(){
        return null;
    }
}


<|start_filename|>src/com/rex/yangtzeu/ui/CetScore.java<|end_filename|>
package com.rex.yangtzeu.ui;

import android.app.Activity;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import com.rex.yangtzeu.R;
import com.rex.yangtzeu.Yangtzeu;
import com.rex.yangtzeu.config.Urls;
import com.rex.yangtzeu.http.YuHttp;
import com.rex.yangtzeu.regex.JwcRegex;

/**
 * Created by rex on 2014/7/30.
 */
public class CetScore extends Activity implements
        android.view.View.OnClickListener{
    private Button get_score_btn;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.cet_score);

        // 标题栏按钮动作
        get_score_btn = (Button) this.findViewById(R.id.get_score_btn);
        get_score_btn.setOnTouchListener(new View.OnTouchListener() {
            public boolean onTouch(View v, MotionEvent event) {
                if (event.getAction() == MotionEvent.ACTION_DOWN) {
                    // 更改为按下时的背景图片
                    v.setBackgroundResource(R.drawable.yangtzeu_main_title);
                } else if (event.getAction() == MotionEvent.ACTION_UP) {
                    // 改为抬起时的图片
                    v.setBackgroundResource(R.drawable.yangtzeu_title_btn_bg);
                }
                return false;
            }
        });

        get_score_btn.setOnClickListener(this);
    }

    /**
     * 按键事件
     */
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        // 后退动画
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            finish();
            overridePendingTransition(R.anim.back_left_in,
                    R.anim.back_right_out);

            return true;
        }
        return super.onKeyDown(keyCode, event);
    }

    @Override
    public void onClick(View view) {
        if (view == get_score_btn) {
            new NetTask().execute("cet");
        }

    }

    // Async 查分
    private class NetTask extends AsyncTask<String, Void,String> {
        String optype;
        String cet_result = "";

        protected void onPostExecute(String result) {
            if(this.optype == "cet"){ // 渲染数据
                Toast.makeText(Yangtzeu.getInstance(),cet_result,Toast.LENGTH_LONG).show(); // TODO
            }
        }

        @Override
        protected String doInBackground(String... arg0) {
            this.optype = arg0[0];
            if(arg0[0] == "cet"){ // 网络获取数据

                try {
                    YuHttp.referer = "http://www.chsi.com.cn/cet/";
                    cet_result = YuHttp.get("http://www.chsi.com.cn/cet/query?zkzh=123456789012345&xm=%E6%9D%8E%E4%BF%8A", "utf-8"); //TODO
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            return null;
        }
    }
}

<|start_filename|>src/com/rex/yangtzeu/ui/Setting.java<|end_filename|>
/**
 * 长大长新-长江大学校园安卓应用
 *
 * Copyright (C) 2014-2016 <NAME> <<EMAIL>>
 *
 * This program is free and opensource software; 
 * you can redistribute it and/or modify
 * it under the terms of the MIT License
 */
package com.rex.yangtzeu.ui;

import com.rex.yangtzeu.sqlite.ComDB;
import com.rex.yangtzeu.utils.EncrypAES;
import com.rex.yangtzeu.R;
import android.os.Bundle;
import android.app.Activity;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class Setting extends Activity implements
		android.view.View.OnClickListener {
	private Button btn_save;
	private EditText stu_no;
	private EditText stu_mm;
	private EditText jsz_no;
	private EditText jsz_mm;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.setting);

		btn_save = (Button) this.findViewById(R.id.save_btn);

		btn_save.setOnTouchListener(new OnTouchListener() {
			public boolean onTouch(View v, MotionEvent event) {
				if (event.getAction() == MotionEvent.ACTION_DOWN) {
					// 更改为按下时的背景图片
					v.setBackgroundResource(R.drawable.yangtzeu_main_title);
				} else if (event.getAction() == MotionEvent.ACTION_UP) {
					// 改为抬起时的图片
					v.setBackgroundResource(R.drawable.yangtzeu_title_btn_bg);
				}
				return false;
			}
		});

		btn_save.setOnClickListener(this);

		// 数据填充到表单
		stu_no = (EditText) findViewById(R.id.student_no);
		stu_no.setText(ComDB.kv_get("student_number"));

		stu_mm = (EditText) findViewById(R.id.jwc_mima);
		stu_mm.setText(EncrypAES.decrypt(ComDB.kv_get("student_password")));

		jsz_no = (EditText) findViewById(R.id.jsz_no);
		jsz_no.setText(ComDB.kv_get("library_number"));

		jsz_mm = (EditText) findViewById(R.id.jsz_mima);
		jsz_mm.setText(EncrypAES.decrypt(ComDB.kv_get("library_password")));
	}

	@Override
	public void onClick(View arg0) {
		if (arg0 == btn_save) {
			// 保存表单信息
			String text_stu_no = stu_no.getText().toString();
			String text_stu_mm = stu_mm.getText().toString();
			String text_jsz_no = jsz_no.getText().toString();
			String text_jsz_mm = jsz_mm.getText().toString();

			if (!text_stu_no.equals("") && !text_stu_mm.equals("")) {
				ComDB.kv_set("student_number", text_stu_no);
				ComDB.kv_set("student_password", EncrypAES.encrypt(text_stu_mm));
			}
			if (!text_jsz_no.equals("") && !text_jsz_mm.equals("")) {
				ComDB.kv_set("library_number", text_jsz_no);
				ComDB.kv_set("library_password", EncrypAES.encrypt(text_jsz_mm));
			}
			Toast.makeText(getApplicationContext(), "已保存", Toast.LENGTH_SHORT)
					.show();
		}
	}

	/**
	 * 按键事件
	 */
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		// 后退动画
		if (keyCode == KeyEvent.KEYCODE_BACK) {
			finish();
			overridePendingTransition(R.anim.back_left_in,
					R.anim.back_right_out);

			return true;
		}
		return super.onKeyDown(keyCode, event);
	}
}
