code\Detail.java
code\About2.java code\Detail.java code\ExpressSensor.java code\GlobalInfo.java code\SettingsActivity2.java code\About.java code\LoginActivity2.java code\SettingsActivity.java code\WiFi.java code\WorkStatistics.java
This commit is contained in:
parent
46d10c4f83
commit
b532c6d17c
|
@ -1,11 +1,4 @@
|
|||
/**
|
||||
* Copyright: Moonlight(Eric yue)
|
||||
* Email: hi.moonlight@gmail.com
|
||||
* Website: www.ericyue.info
|
||||
* File name: About.java
|
||||
* Project Name:ExpressSensor
|
||||
* Create Date: 2011-7-17
|
||||
*/
|
||||
|
||||
package info.ericyue.es.activity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
|
@ -0,0 +1,109 @@
|
|||
|
||||
package info.ericyue.es.activity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.SimpleAdapter;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import info.ericyue.es.R;
|
||||
|
||||
public class About extends Activity {
|
||||
private ListView listView;
|
||||
private String[] str=new String[8];
|
||||
public static void launch(Context c,Bundle bundle){
|
||||
Intent intent = new Intent(c, About.class);
|
||||
intent.putExtras(bundle);
|
||||
c.startActivity(intent);
|
||||
}
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
this.setContentView(R.layout.about);
|
||||
listView=(ListView) findViewById(R.id.aboutlist);
|
||||
listView.setCacheColorHint(0);
|
||||
fillItemList();
|
||||
}
|
||||
private void fillItemList(){
|
||||
queryDatabase();
|
||||
ArrayList<HashMap<String, Object>> listItem = new ArrayList<HashMap<String, Object>>();
|
||||
String[] itemStr={"软件简介","软件作者","联系方式","提交BUG","客户端当前版本"};
|
||||
for(int i=0;i<5;i++){
|
||||
HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("ItemTitle", itemStr[i]);
|
||||
map.put("ItemText", str[i]);
|
||||
listItem.add(map);
|
||||
}
|
||||
SimpleAdapter listItemAdapter = new SimpleAdapter(this,listItem,//数据源
|
||||
R.layout.aboutlist,
|
||||
new String[] {"ItemTitle","ItemText"},
|
||||
new int[] {R.id.ItemTitle,R.id.ItemText}
|
||||
);
|
||||
listView.setAdapter(listItemAdapter);
|
||||
listView.setOnItemClickListener(itemListener);
|
||||
}
|
||||
public void queryDatabase(){
|
||||
|
||||
str[0]="Express Sensor是一款基于Android平台的智能物流管理系统.特色在于让用户通过GPS来实时定位自己的包裹.并且采用\"类NFC\"的概念来实现包裹自动感应签收";
|
||||
str[1]="岳斌(Eric Yue@Moonlight)\n河北工业大学,计算机学院 软件091班";
|
||||
str[2]="E-mail:hi.moonlight@gmail.com";
|
||||
str[3]="点击发送邮件提交BUG";
|
||||
str[4]="当前软件版本: ";
|
||||
|
||||
}
|
||||
public String VersionStatus(String version){
|
||||
String[] tmp=version.split("\\.");
|
||||
if(tmp[0].compareTo("3")>=0){
|
||||
return version+=" Release";
|
||||
}
|
||||
else if(tmp[0].compareTo("2")>=0){
|
||||
return version+=" Release Candidate";
|
||||
}
|
||||
else{
|
||||
return version+=" Alpha";
|
||||
}
|
||||
}
|
||||
public void openURL(String url){
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setData(Uri.parse(url));
|
||||
startActivity(intent);
|
||||
}
|
||||
public void mailToEricyue(boolean bug){
|
||||
Uri uri=Uri.parse("mailto:hi.moonlight@gmail.com");
|
||||
Intent mail= new Intent(Intent.ACTION_SENDTO,uri);
|
||||
if(bug)
|
||||
mail.putExtra(Intent.EXTRA_SUBJECT, "[Express Sensor]BUG提交");
|
||||
startActivity(mail);
|
||||
}
|
||||
private OnItemClickListener itemListener = new OnItemClickListener(){
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, int position,
|
||||
long id) {
|
||||
switch(position){
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
|
||||
break;
|
||||
case 2:
|
||||
mailToEricyue(false);
|
||||
break;
|
||||
case 3:
|
||||
mailToEricyue(true);
|
||||
break;
|
||||
case 4:
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}
|
|
@ -0,0 +1,178 @@
|
|||
|
||||
package info.ericyue.es.activity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.ListView;
|
||||
import android.widget.SimpleAdapter;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import info.ericyue.es.R;
|
||||
|
||||
public class Detail extends Activity {
|
||||
private ListView listView;
|
||||
private String[] str=new String[7];
|
||||
private Bundle bundle;
|
||||
private String paytype="";
|
||||
private String number="";
|
||||
private String name="";
|
||||
private String address="";
|
||||
private String postcode="";
|
||||
private String tel="";
|
||||
private String cash="";
|
||||
private String id="";
|
||||
public static void launch(Context c,Bundle bundle){
|
||||
Intent intent = new Intent(c, Detail.class);
|
||||
intent.putExtras(bundle);
|
||||
c.startActivity(intent);
|
||||
}
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
this.setContentView(R.layout.detailinfo);
|
||||
listView=(ListView) findViewById(R.id.detaillist);
|
||||
listView.setCacheColorHint(0);
|
||||
|
||||
bundle=this.getIntent().getExtras();
|
||||
id=bundle.getString("id");
|
||||
number=bundle.getString("detail");
|
||||
Toast.makeText(this, number, Toast.LENGTH_LONG).show();
|
||||
try {
|
||||
QueryDatabase();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
fillItemList();
|
||||
}
|
||||
private String query_detail(String id) throws InterruptedException {
|
||||
Detail.NetThread sockethread = new Detail.NetThread();
|
||||
sockethread.setValue(number);
|
||||
sockethread.start();
|
||||
sockethread.join();
|
||||
return sockethread.result;
|
||||
|
||||
}
|
||||
class NetThread extends Thread
|
||||
{
|
||||
private PrintWriter pw=null;
|
||||
private BufferedReader br=null;
|
||||
private String Number;
|
||||
public String result;
|
||||
public void run(){
|
||||
try {
|
||||
|
||||
pw=LoginActivity.pw;
|
||||
br=LoginActivity.br;
|
||||
pw.println("detail");
|
||||
pw.println(Number);
|
||||
pw.flush();
|
||||
result=br.readLine();
|
||||
}catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public void setValue(String mynumber) {
|
||||
Number = mynumber;
|
||||
}
|
||||
}
|
||||
public void QueryDatabase() throws InterruptedException {
|
||||
|
||||
String tmp = query_detail(id);
|
||||
String[] item=tmp.split("/");
|
||||
/*name = "zai";
|
||||
address = "gfkd";
|
||||
postcode = "13450";
|
||||
tel = "13991111";
|
||||
cash = "128";
|
||||
String s = "2";*/
|
||||
name =item[0];
|
||||
address =item[4];
|
||||
postcode = item[5];
|
||||
tel =item[6];
|
||||
cash =item[8];
|
||||
String s = item[7];
|
||||
|
||||
switch(Integer.parseInt(s)){
|
||||
case 0:
|
||||
paytype="未指定";
|
||||
break;
|
||||
case 1:
|
||||
paytype="网银支付";
|
||||
break;
|
||||
case 2:
|
||||
paytype="货到付款";
|
||||
break;
|
||||
case 3:
|
||||
paytype="支付宝";
|
||||
break;
|
||||
case 4:
|
||||
paytype="财付通";
|
||||
break;
|
||||
case 5:
|
||||
paytype="信用卡";
|
||||
break;
|
||||
case 6:
|
||||
paytype="邮局汇款";
|
||||
break;
|
||||
}
|
||||
str[0]=number;
|
||||
str[1]=name;
|
||||
str[2]=address;
|
||||
str[3]=postcode;
|
||||
str[4]=tel;
|
||||
str[5]=paytype;
|
||||
str[6]=cash;
|
||||
|
||||
}
|
||||
private void fillItemList(){
|
||||
ArrayList<HashMap<String, Object>> listItem = new ArrayList<HashMap<String, Object>>();
|
||||
String[] itemStr={"邮包编号","收件人姓名","收件人地址","收件人邮编","收件人电话","支付类型","应支付金额"};
|
||||
for(int i=0;i<7;i++){
|
||||
HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("ItemTitle", itemStr[i]);
|
||||
map.put("ItemText", str[i]);
|
||||
listItem.add(map);
|
||||
}
|
||||
SimpleAdapter listItemAdapter = new SimpleAdapter(this,listItem,//数据源
|
||||
R.layout.detaillist,
|
||||
new String[] {"ItemTitle","ItemText"},
|
||||
new int[] {R.id.ItemTitle,R.id.ItemText}
|
||||
);
|
||||
listView.setAdapter(listItemAdapter);
|
||||
listView.setOnItemClickListener(itemListener);
|
||||
}
|
||||
private OnItemClickListener itemListener = new OnItemClickListener(){
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, int position,
|
||||
long id) {
|
||||
if(position==4){
|
||||
try{
|
||||
String strInput = bundle.getString("phone");
|
||||
if (strInput.length()==11){
|
||||
Intent myIntentDial = new Intent("android.intent.action.CALL",Uri.parse("tel:"+strInput));
|
||||
startActivity(myIntentDial);
|
||||
}
|
||||
else{
|
||||
Toast.makeText(Detail.this, "电话格式不符", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
}
|
|
@ -0,0 +1,317 @@
|
|||
|
||||
package info.ericyue.es.activity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.SharedPreferences;
|
||||
import android.location.LocationManager;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.ListView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.SimpleAdapter;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import info.ericyue.es.R;
|
||||
import info.ericyue.es.util.TutorialDialog;
|
||||
import info.ericyue.es.zxing.client.android.CaptureActivity;
|
||||
|
||||
public class ExpressSensor extends Activity{
|
||||
private ListView listView;
|
||||
private Bundle bundle;
|
||||
private TextView infoWall;
|
||||
private ProgressBar progressbar;
|
||||
private serviceReceiver receiver;
|
||||
private LocationManager locationManager;
|
||||
//private int id;
|
||||
private String id;
|
||||
private boolean show_tutorial;
|
||||
private long exitTime = 0; //确定是短时间按下了两次返回键
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if(keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN){
|
||||
if((System.currentTimeMillis()-exitTime) > 2000){
|
||||
Toast.makeText(getApplicationContext(), "再按一次退出程序", Toast.LENGTH_SHORT).show();
|
||||
exitTime = System.currentTimeMillis();
|
||||
}
|
||||
else{
|
||||
Intent location = new Intent( ExpressSensor.this, LocationService.class );
|
||||
Intent record = new Intent( ExpressSensor.this, TraceRecordService.class );
|
||||
/* 以stopService方法关闭Intent */
|
||||
stopService(location);
|
||||
stopService(record);
|
||||
finish();
|
||||
System.exit(0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
//不显示标题栏
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
setContentView(R.layout.main);
|
||||
progressbar=(ProgressBar) findViewById(R.id.ProgressBar);
|
||||
infoWall=(TextView) findViewById(R.id.infoWall);
|
||||
show_tutorial = SettingsActivity.getShowTutorial(this);
|
||||
headInfo(true,"欢迎进入Express Sensor(快递版)");
|
||||
listView = (ListView)findViewById(R.id.HomeListView);
|
||||
bundle=this.getIntent().getExtras();
|
||||
id=bundle.getString("username");
|
||||
|
||||
bundle.putString("id",id);
|
||||
|
||||
if(!isClient()){
|
||||
showDialog("账户类型与该版本客户端不匹配");
|
||||
}
|
||||
|
||||
fillItemList();
|
||||
/**
|
||||
* 开启系统服务 监听用户与送货员人的位置直线距离。
|
||||
*/
|
||||
Intent i = new Intent(this, LocationService.class );
|
||||
i.setFlags( Intent.FLAG_ACTIVITY_NEW_TASK );
|
||||
i.putExtras(bundle);
|
||||
startService(i);
|
||||
if(show_tutorial){
|
||||
showTutorial();
|
||||
}
|
||||
/*if(SettingsActivity.getTraceRecord(this)){
|
||||
Intent tr = new Intent(this, TraceRecordService.class );
|
||||
tr.setFlags( Intent.FLAG_ACTIVITY_NEW_TASK );
|
||||
tr.putExtras(bundle);
|
||||
startService(tr);
|
||||
}
|
||||
else{
|
||||
Toast.makeText(this, "轨迹记录服务关闭", Toast.LENGTH_LONG).show();
|
||||
}*/
|
||||
// }
|
||||
}
|
||||
@Override
|
||||
protected void onRestoreInstanceState(Bundle savedInstanceState) {}
|
||||
/**
|
||||
* MenuInflater 用来解析定义在menu目录下的菜单布局文件
|
||||
*/
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.home, menu);
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
/**
|
||||
* 按下菜单后的响应
|
||||
*/
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch(item.getItemId()){
|
||||
case R.id.about_menu_item:
|
||||
About.launch(ExpressSensor.this,bundle);
|
||||
break;
|
||||
case R.id.about_menu_min:
|
||||
Intent i= new Intent(Intent.ACTION_MAIN);
|
||||
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
i.addCategory(Intent.CATEGORY_HOME);
|
||||
startActivity(i);
|
||||
break;
|
||||
case R.id.settings_menu_item:
|
||||
SettingsActivity.launch(ExpressSensor.this,bundle);
|
||||
break;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
private void showDialog(String msg){
|
||||
AlertDialog.Builder builder=new AlertDialog.Builder(this);
|
||||
builder.setTitle("错误").setMessage(msg).setCancelable(false).setPositiveButton("确定", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface arg0, int arg1) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
AlertDialog alert=builder.create();
|
||||
alert.show();
|
||||
}
|
||||
|
||||
|
||||
|
||||
class NetThread extends Thread
|
||||
{
|
||||
private PrintWriter pw=null;
|
||||
private BufferedReader br=null;
|
||||
private String id;
|
||||
private String result;
|
||||
public void run(){
|
||||
try {
|
||||
pw=LoginActivity.pw;
|
||||
br=LoginActivity.br;
|
||||
pw.println("client");
|
||||
pw.println(id);
|
||||
pw.flush();
|
||||
result=br.readLine();
|
||||
}catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public void setId(String myname) {
|
||||
id = myname;
|
||||
}
|
||||
public String getRole() {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
//判断是否为客户端身份
|
||||
public boolean isClient(){
|
||||
return queryRole(id).equals("0");
|
||||
}
|
||||
//查询用户角色
|
||||
public String queryRole(String id) {
|
||||
NetThread sockethread = new ExpressSensor.NetThread();
|
||||
sockethread.setId(id);
|
||||
sockethread.start();
|
||||
try {
|
||||
sockethread.join();
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return sockethread.getRole();
|
||||
}
|
||||
|
||||
final void showTutorial() {
|
||||
boolean showTutorial = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("show_tutorial", true);
|
||||
if (showTutorial) {
|
||||
final TutorialDialog dlg = new TutorialDialog(this);
|
||||
dlg.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
CheckBox cb = (CheckBox) dlg.findViewById(R.id.show_tutorial);
|
||||
if (cb != null && cb.isChecked()) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ExpressSensor.this);
|
||||
prefs.edit().putBoolean("show_tutorial", false).commit();
|
||||
}
|
||||
}
|
||||
});
|
||||
dlg.show();
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
private void fillItemList(){
|
||||
ArrayList<HashMap<String, Object>> listItem = new ArrayList<HashMap<String, Object>>();
|
||||
String[] itemStr={"全局信息","快递投递","工作统计","查看轨迹","二维码识别","关于产品"};
|
||||
Integer[] iconBag={R.drawable.globalinfo,R.drawable.send,R.drawable.workstatistics,R.drawable.trace,R.drawable.qrcode,R.drawable.about};
|
||||
for(int i=0;i<6;i++){
|
||||
HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("ItemImage", iconBag[i]);//图像资源的ID
|
||||
map.put("ItemTitle", itemStr[i]);
|
||||
listItem.add(map);
|
||||
}
|
||||
SimpleAdapter listItemAdapter = new SimpleAdapter(this,listItem,//数据源
|
||||
R.layout.purple_row,
|
||||
//动态数组与ImageItem对应的子项
|
||||
new String[] {"ItemImage","ItemTitle"},
|
||||
//ImageItem的XML文件里面的一个ImageView,两个TextView ID
|
||||
new int[] {R.id.leftHead,R.id.PurpleRowTextView}
|
||||
);
|
||||
listView.setAdapter(listItemAdapter);
|
||||
listView.setOnItemClickListener(itemListener);
|
||||
}
|
||||
|
||||
public void headInfo(boolean run,String msg){
|
||||
if(!run)
|
||||
progressbar.setVisibility(View.GONE);
|
||||
else
|
||||
progressbar.setVisibility(View.VISIBLE);
|
||||
infoWall.setText(msg);
|
||||
}
|
||||
private OnItemClickListener itemListener = new OnItemClickListener(){
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, int position,
|
||||
long id) {
|
||||
switch(position){
|
||||
case 0:
|
||||
GlobalInfo.launch(ExpressSensor.this,bundle);
|
||||
break;
|
||||
case 1:
|
||||
ExpressDelivery.launch(ExpressSensor.this,bundle);
|
||||
break;
|
||||
case 2:
|
||||
WorkStatistics.launch(ExpressSensor.this,bundle);
|
||||
break;
|
||||
case 3:
|
||||
TraceRecord.launch(ExpressSensor.this,bundle);
|
||||
break;
|
||||
case 4:
|
||||
CaptureActivity.launch(ExpressSensor.this,bundle);
|
||||
break;
|
||||
case 5:
|
||||
About.launch(ExpressSensor.this,bundle);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public class serviceReceiver extends BroadcastReceiver{
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
// TODO Auto-generated method stub
|
||||
try{
|
||||
/* 取并来自后台服务所Broadcast的参数 */
|
||||
Bundle b = intent.getExtras();
|
||||
String message = b.getString("MESSAGE");
|
||||
Toast.makeText(ExpressSensor.this, message, Toast.LENGTH_LONG).show();
|
||||
}catch(Exception e){
|
||||
e.getStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
protected void onResume(){
|
||||
// TODO Auto-generated method stub
|
||||
try{
|
||||
/* 前景程序生命周期开始 */
|
||||
IntentFilter filter;
|
||||
/* 自定义要过滤的广播讯息(DavidLanz) */
|
||||
filter = new IntentFilter("SENT");
|
||||
receiver = new serviceReceiver();
|
||||
registerReceiver(receiver, filter);
|
||||
}catch(Exception e){
|
||||
e.getStackTrace();
|
||||
}
|
||||
super.onResume();
|
||||
}
|
||||
@Override
|
||||
protected void onPause(){
|
||||
// TODO Auto-generated method stub
|
||||
/* 前景程序生命周期结束,解除刚守系统注册的Receiver */
|
||||
unregisterReceiver(receiver);
|
||||
super.onPause();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,222 @@
|
|||
|
||||
package info.ericyue.es.activity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.location.Criteria;
|
||||
import android.location.Location;
|
||||
import android.location.LocationListener;
|
||||
import android.location.LocationManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.text.format.DateFormat;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.ListView;
|
||||
import android.widget.SimpleAdapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.baidu.location.BDLocation;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import info.ericyue.es.R;
|
||||
|
||||
public class GlobalInfo extends Activity {
|
||||
/** Called when the activity is first created. */
|
||||
private TextView infoWall;
|
||||
private LocationManager locationManager;
|
||||
private double lat;
|
||||
private double lng;
|
||||
private String id;
|
||||
private int updateSecond=5000;//刷新信息线程的间隔
|
||||
private Bundle bundle;
|
||||
private final static String M24 = "kk:mm";
|
||||
private String timeStr;
|
||||
private ListView listView;
|
||||
private String[] str=new String[7];
|
||||
private Handler objHandler = new Handler();
|
||||
private Runnable updateInfo= new Runnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
if(SettingsActivity.getAutoUpdate(GlobalInfo.this)){
|
||||
try {
|
||||
refreshInfo();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
objHandler.postDelayed(updateInfo, updateSecond);
|
||||
}
|
||||
};
|
||||
public static void launch(Context c,Bundle bundle){
|
||||
Intent intent = new Intent(c, GlobalInfo.class);
|
||||
intent.putExtras(bundle);
|
||||
c.startActivity(intent);
|
||||
}
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState );
|
||||
this.setContentView(R.layout.globalinfo);
|
||||
bundle=this.getIntent().getExtras();
|
||||
listView=(ListView) findViewById(R.id.globalList);
|
||||
listView.setCacheColorHint(0);
|
||||
locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
|
||||
//从XML中读取配置信息
|
||||
updateSecond=Integer.parseInt(SettingsActivity.getUpdateTime(GlobalInfo.this));
|
||||
id=bundle.getString("username");
|
||||
objHandler.postDelayed(updateInfo, updateSecond);
|
||||
timeStr ="最近一次更新数据: "+(String) DateFormat.format(M24,System.currentTimeMillis());
|
||||
infoWall=(TextView) findViewById(R.id.infoWall);
|
||||
locate();
|
||||
|
||||
|
||||
|
||||
try {
|
||||
queryDatabase();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
fillItemList();
|
||||
headInfo(timeStr);
|
||||
}
|
||||
public void headInfo(String msg){
|
||||
infoWall.setText(msg);
|
||||
}
|
||||
private void fillItemList(){
|
||||
ArrayList<HashMap<String, Object>> listItem = new ArrayList<HashMap<String, Object>>();
|
||||
String[] itemStr={"当前用户","今日总委派数","今日完成派送",
|
||||
"今日拒绝签收","今日投递失败(无人签收)","今日收入总额","当前坐标"};
|
||||
|
||||
for(int i=0;i<7;i++){
|
||||
HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("ItemTitle", itemStr[i]);
|
||||
map.put("ItemText", str[i]);
|
||||
listItem.add(map);
|
||||
}
|
||||
SimpleAdapter listItemAdapter = new SimpleAdapter(this,listItem,//数据源
|
||||
R.layout.globallist,
|
||||
new String[] {"ItemTitle","ItemText"},
|
||||
new int[] {R.id.ItemTitle,R.id.ItemText}
|
||||
);
|
||||
listView.setAdapter(listItemAdapter);
|
||||
listView.setOnItemClickListener(itemListener);
|
||||
}
|
||||
private void queryDatabase() throws InterruptedException {
|
||||
|
||||
String tmp=query_global(id);
|
||||
String[] item=tmp.split("/");
|
||||
str[0]="当前用户:"+id;
|
||||
str[1]="今日总委派数"+item[0];
|
||||
str[2]="今日完成派送"+item[1];
|
||||
str[3]="拒绝签收共 "+item[2]+" 件";
|
||||
str[4]="投递失败共 "+item[3]+" 件";
|
||||
str[5]="今日收入总额 "+item[4]+" 元";
|
||||
|
||||
|
||||
}
|
||||
|
||||
private String query_global(String id) throws InterruptedException {
|
||||
GlobalInfo.NetThread sockethread = new GlobalInfo.NetThread();
|
||||
sockethread.setValue(id);
|
||||
sockethread.start();
|
||||
sockethread.join();
|
||||
return sockethread.result;
|
||||
|
||||
}
|
||||
class NetThread extends Thread
|
||||
{
|
||||
private PrintWriter pw=null;
|
||||
private BufferedReader br=null;
|
||||
private String Id;
|
||||
public String result;
|
||||
public void run(){
|
||||
try {
|
||||
pw=LoginActivity.pw;
|
||||
br=LoginActivity.br;
|
||||
pw.println("globalinfo");
|
||||
pw.println(Id);
|
||||
pw.flush();
|
||||
result=br.readLine();
|
||||
}catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public void setValue(String myid) {
|
||||
Id = myid;
|
||||
}
|
||||
}
|
||||
public void refreshInfo() throws InterruptedException {
|
||||
timeStr = "最近一次更新数据: "+ (String) DateFormat.format(M24,System.currentTimeMillis());
|
||||
headInfo(timeStr);
|
||||
locate();
|
||||
|
||||
queryDatabase();
|
||||
|
||||
fillItemList();
|
||||
}
|
||||
|
||||
private void updateWithNewLocation(Location location) {
|
||||
String latLongString;
|
||||
double lat =TraceRecord.mLatitude ;
|
||||
double lng =TraceRecord.mlongitude;
|
||||
if (lat != 0) {
|
||||
BDLocation bdlocation;
|
||||
latLongString = "纬度:" + lat + "\n经度:" + lng + "\n位置" + TraceRecord.mAddrStr;
|
||||
} else {
|
||||
latLongString = "无法获取地理信息";
|
||||
}
|
||||
|
||||
str[6]=(latLongString);
|
||||
}
|
||||
private final LocationListener locationListener = new LocationListener() {
|
||||
public void onLocationChanged(Location location) {
|
||||
updateWithNewLocation(location);
|
||||
}
|
||||
public void onProviderDisabled(String provider){
|
||||
updateWithNewLocation(null);
|
||||
}
|
||||
public void onProviderEnabled(String provider){ }
|
||||
public void onStatusChanged(String provider, int status,
|
||||
Bundle extras){ }
|
||||
};
|
||||
public void locate(){
|
||||
Criteria criteria = new Criteria();
|
||||
criteria.setAccuracy(Criteria.ACCURACY_FINE);
|
||||
criteria.setAltitudeRequired(false);
|
||||
criteria.setBearingRequired(false);
|
||||
criteria.setCostAllowed(true);
|
||||
criteria.setPowerRequirement(Criteria.POWER_LOW);
|
||||
String provider = locationManager.getBestProvider(criteria, true);
|
||||
|
||||
Location location = locationManager.getLastKnownLocation(provider);
|
||||
updateWithNewLocation(location);
|
||||
locationManager.requestLocationUpdates(provider, 2000, 10,
|
||||
locationListener);
|
||||
|
||||
}
|
||||
|
||||
private OnItemClickListener itemListener = new OnItemClickListener(){
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, int position,
|
||||
long ids) {
|
||||
switch(position){
|
||||
case 1:
|
||||
case 2:
|
||||
TraceRecord.launch(GlobalInfo.this, bundle);
|
||||
break;
|
||||
case 6:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
|
@ -1,11 +1,4 @@
|
|||
/**
|
||||
* Copyright: Moonlight(Eric yue)
|
||||
* Email: hi.moonlight@gmail.com
|
||||
* Website: www.ericyue.info
|
||||
* File name: Welcome.java
|
||||
* Project Name:ExpressSensor
|
||||
* Create Date: 2011-7-17
|
||||
*/
|
||||
|
||||
package info.ericyue.es.activity;
|
||||
|
||||
import android.app.Activity;
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
/**
|
||||
* Copyright: Moonlight(Eric yue)
|
||||
* Email: hi.moonlight@gmail.com
|
||||
* Website: www.ericyue.info
|
||||
* File name: Settings.java
|
||||
* Project Name:ExpressSensor
|
||||
* Create Date: 2011-8-13
|
||||
*/
|
||||
|
||||
package info.ericyue.es.activity;
|
||||
|
||||
import info.ericyue.es.R;
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
/**
|
||||
* Copyright: Moonlight(Eric yue)
|
||||
* Email: hi.moonlight@gmail.com
|
||||
* Website: www.ericyue.info
|
||||
* File name: SettingsActivity.java
|
||||
* Project Name:ExpressSensor
|
||||
* Create Date: 2011-8-13
|
||||
*/
|
||||
package info.ericyue.es.activity;
|
||||
|
||||
import info.ericyue.es.R;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.preference.PreferenceScreen;
|
||||
import android.view.Window;
|
||||
|
||||
public class SettingsActivity extends PreferenceActivity {
|
||||
public static void launch(Context c,Bundle bundle){
|
||||
Intent intent = new Intent(c, SettingsActivity.class);
|
||||
intent.putExtras(bundle);
|
||||
c.startActivity(intent);
|
||||
}
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.preferences);
|
||||
setContentView(R.layout.settings);
|
||||
}
|
||||
@Override
|
||||
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen,
|
||||
Preference preference) {
|
||||
|
||||
return super.onPreferenceTreeClick(preferenceScreen, preference);
|
||||
}
|
||||
public static boolean getShowTutorial(Context context){
|
||||
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean("show_tutorial", true);
|
||||
}
|
||||
|
||||
public static String getUpdateTime(Context context){
|
||||
return PreferenceManager.getDefaultSharedPreferences(context).getString("auto_update","10000");
|
||||
}
|
||||
public static String getTraceTime(Context context){
|
||||
return PreferenceManager.getDefaultSharedPreferences(context).getString("gps_record","10000");
|
||||
}
|
||||
public static boolean getAutoUpdate(Context context){
|
||||
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean("switch_autorefresh",false);
|
||||
}
|
||||
public static boolean setAutoUpdate(Context context,boolean status){
|
||||
return PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean("switch_autorefresh", status).commit();
|
||||
}
|
||||
public static boolean getTraceRecord(Context context){
|
||||
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean("trace_record",false);
|
||||
}
|
||||
public static boolean setTraceRecord(Context context,boolean status){
|
||||
return PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean("trace_record", status).commit();
|
||||
}
|
||||
public static boolean getWIFIReceive(Context context){
|
||||
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean("wifi_receive",false);
|
||||
}
|
||||
}
|
|
@ -1,11 +1,4 @@
|
|||
/**
|
||||
* Copyright: Moonlight(Eric yue)
|
||||
* Email: hi.moonlight@gmail.com
|
||||
* Website: www.ericyue.info
|
||||
* File name: WifiHotSpot.java
|
||||
* Project Name:ExpressSensor
|
||||
* Create Date: 2011-8-13
|
||||
*/
|
||||
|
||||
package info.ericyue.es.activity;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
|
|
@ -0,0 +1,108 @@
|
|||
|
||||
package info.ericyue.es.activity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.widget.ListView;
|
||||
import android.widget.SimpleAdapter;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import info.ericyue.es.R;
|
||||
|
||||
public class WorkStatistics extends Activity {
|
||||
private ListView listView;
|
||||
private String pid;
|
||||
private String[] str=new String[3];
|
||||
private Bundle bundle;
|
||||
// private WebView webview;
|
||||
public static void launch(Context c,Bundle bundle){
|
||||
Intent intent = new Intent(c, WorkStatistics.class);
|
||||
intent.putExtras(bundle);
|
||||
c.startActivity(intent);
|
||||
}
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
this.setContentView(R.layout.workstatistics);
|
||||
bundle=this.getIntent().getExtras();
|
||||
listView=(ListView) findViewById(R.id.statList);
|
||||
listView.setCacheColorHint(0);
|
||||
|
||||
listView.setAlwaysDrawnWithCacheEnabled(true);
|
||||
|
||||
pid = bundle.getString("username");
|
||||
try {
|
||||
queryDatebase();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
fillItemList();
|
||||
|
||||
}
|
||||
public void queryDatebase() throws InterruptedException {
|
||||
|
||||
String tmp = query_work(pid);
|
||||
String[] item=tmp.split("/");
|
||||
str[0]="今日共投递件"+item[0];
|
||||
str[1]="本周共投递件"+item[1];
|
||||
str[2]="本月共投递件"+item[2];
|
||||
|
||||
}
|
||||
private String query_work(String id) throws InterruptedException {
|
||||
WorkStatistics.NetThread sockethread = new WorkStatistics.NetThread();
|
||||
sockethread.setValue(id);
|
||||
sockethread.start();
|
||||
sockethread.join();
|
||||
return sockethread.result;
|
||||
|
||||
}
|
||||
class NetThread extends Thread
|
||||
{
|
||||
private PrintWriter pw=null;
|
||||
private BufferedReader br=null;
|
||||
private String Id;
|
||||
public String result;
|
||||
public void run(){
|
||||
try {
|
||||
|
||||
pw=LoginActivity.pw;
|
||||
br=LoginActivity.br;
|
||||
pw.println("workstatistics");
|
||||
pw.println(Id);
|
||||
pw.flush();
|
||||
result=br.readLine();
|
||||
}catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public void setValue(String myid) {
|
||||
Id = myid;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void fillItemList(){
|
||||
ArrayList<HashMap<String, Object>> listItem = new ArrayList<HashMap<String, Object>>();
|
||||
String[] itemStr={"今日投递总数","本周投递总数","本月投递总数"};
|
||||
for(int i=0;i<3;i++){
|
||||
HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("ItemTitle", itemStr[i]);
|
||||
map.put("ItemText", str[i]);
|
||||
listItem.add(map);
|
||||
}
|
||||
SimpleAdapter listItemAdapter = new SimpleAdapter(this,listItem,//数据源
|
||||
R.layout.worklist,
|
||||
new String[] {"ItemTitle","ItemText"},
|
||||
new int[] {R.id.ItemTitle,R.id.ItemText}
|
||||
);
|
||||
listView.setAdapter(listItemAdapter);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue