diff options
Diffstat (limited to 'client/Piztor/src/com/macaroon')
27 files changed, 999 insertions, 341 deletions
diff --git a/client/Piztor/src/com/macaroon/piztor/ActMgr.java b/client/Piztor/src/com/macaroon/piztor/ActMgr.java index f5ff994..903527e 100644 --- a/client/Piztor/src/com/macaroon/piztor/ActMgr.java +++ b/client/Piztor/src/com/macaroon/piztor/ActMgr.java @@ -25,6 +25,7 @@ public class ActMgr { void trigger(int event) { System.out.println(act.id + " : " + event); if (mp.get(nowStatus).containsKey(event)) { + System.out.println("status + " + event); nowStatus.leave(event); nowStatus = mp.get(nowStatus).get(event); nowStatus.enter(event); diff --git a/client/Piztor/src/com/macaroon/piztor/AlertMaker.java b/client/Piztor/src/com/macaroon/piztor/AlertMaker.java index cc70e62..63382bb 100644 --- a/client/Piztor/src/com/macaroon/piztor/AlertMaker.java +++ b/client/Piztor/src/com/macaroon/piztor/AlertMaker.java @@ -96,7 +96,7 @@ public class AlertMaker { mapMaker.DrawMarker(markerPoint); else { Toast toast = Toast.makeText(context, - "Too early! Give me at least 2 minutes!", Toast.LENGTH_LONG); + "Too early!Give me more time!", Toast.LENGTH_LONG); toast.show(); closeBoard(context); showMarkerAlert(markerPoint); @@ -108,4 +108,25 @@ public class AlertMaker { markerDialog.show(); } + public void showQuitAlert() { + + AlertDialog.Builder quitDialog = new AlertDialog.Builder(context); + closeBoard(context); + quitDialog.setTitle("Quit"); + quitDialog.setMessage("Do you want to logout and quit?"); + quitDialog.setPositiveButton("Quit", + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { + AppMgr.exit(); + } + }); + quitDialog.setNegativeButton("Cancel", + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { + dialog.cancel(); + } + }); + quitDialog.show(); + } + } diff --git a/client/Piztor/src/com/macaroon/piztor/AppMgr.java b/client/Piztor/src/com/macaroon/piztor/AppMgr.java index aed8ca6..790fe4d 100644 --- a/client/Piztor/src/com/macaroon/piztor/AppMgr.java +++ b/client/Piztor/src/com/macaroon/piztor/AppMgr.java @@ -14,10 +14,10 @@ import com.baidu.mapapi.MKGeneralListener; @SuppressLint("UseSparseArrays") public class AppMgr { - + private static final String strKey = "8a0ae50048d103b2b8b12b7066f4ea7d"; - static BMapManager mBMapManager = null; - + static BMapManager mBMapManager = null; + // Status public enum ActivityStatus { create, start, resume, restart, stop, pause, destroy @@ -37,9 +37,9 @@ public class AppMgr { final static int hasToken = 104; final static int toSettings = 105; final static int logout = 106; - + static MapInfo mapInfo; - + static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp; static HashSet<PiztorAct> acts; @@ -76,13 +76,14 @@ public class AppMgr { i.setClass(nowAct, mp.get(nowAct.getClass()).get(event)); if (event == errorToken) Infomation.token = null; - if (event == toSettings) { - if (nowAct.actMgr.nowStatus.getClass() == Main.FetchStatus.class) - i.putExtra("status", true); - else i.putExtra("status", false); + if (event == loginSuccess) { + mBMapManager.start(); + transam.startPush(Infomation.token, Infomation.username); + } + if (event == logout) { + mBMapManager.stop(); + transam.stopPush(); } - if (event == loginSuccess) mBMapManager.start(); - if (event == logout) mBMapManager.stop(); nowAct.startActivity(i); } @@ -115,16 +116,18 @@ public class AppMgr { static void init(Context context) { if (mBMapManager == null) { mBMapManager = new BMapManager(context); - mBMapManager.init(strKey, new MKGeneralListener(){ + mBMapManager.init(strKey, new MKGeneralListener() { + @Override + public void onGetNetworkState(int iError) { + Log.d("Network", "failure"); + System.out.println("network wocao ni ma de !!!!!!!!!"); + } + @Override - public void onGetNetworkState(int iError) { - Log.d("Network","failure"); - } - - @Override - public void onGetPermissionState(int iError) { - Log.d("Permission","wrong key"); - } + public void onGetPermissionState(int iError) { + Log.d("Permission", "wrong key"); + System.out.println("ju ran bu gei wo quan xian !!!!!!!!!!"); + } }); } mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>(); @@ -138,15 +141,15 @@ public class AppMgr { addStatus(Login.class); addStatus(Main.class); addStatus(Settings.class); - addTransition(Main.class, logout, Login.class); addTransition(InitAct.class, noToken, Login.class); - addTransition(Login.class, loginSuccess, Main.class); - addTransition(Main.class, errorToken, Login.class); - addTransition(Settings.class, errorToken, Login.class); addTransition(InitAct.class, hasToken, Main.class); addTransition(InitAct.class, errorToken, Login.class); + addTransition(Main.class, logout, Login.class); addTransition(Main.class, toSettings, Settings.class); + addTransition(Main.class, errorToken, Login.class); + addTransition(Login.class, loginSuccess, Main.class); addTransition(Settings.class, logout, Login.class); + addTransition(Settings.class, errorToken, Login.class); } } diff --git a/client/Piztor/src/com/macaroon/piztor/Infomation.java b/client/Piztor/src/com/macaroon/piztor/Infomation.java index cd0b49e..603819e 100644 --- a/client/Piztor/src/com/macaroon/piztor/Infomation.java +++ b/client/Piztor/src/com/macaroon/piztor/Infomation.java @@ -1,7 +1,8 @@ package com.macaroon.piztor; public class Infomation { - static String ip = "69.85.86.42"; + static String ip = "192.168.1.171"; +// static String ip = "69.85.86.42"; // static String ip = "192.168.1.101"; static int port = 2222; static String token = null; diff --git a/client/Piztor/src/com/macaroon/piztor/InitAct.java b/client/Piztor/src/com/macaroon/piztor/InitAct.java index 8a7ad7a..8145935 100644 --- a/client/Piztor/src/com/macaroon/piztor/InitAct.java +++ b/client/Piztor/src/com/macaroon/piztor/InitAct.java @@ -4,7 +4,7 @@ import android.os.Bundle; import android.view.Menu; public class InitAct extends PiztorAct { - + @Override protected void onCreate(Bundle savedInstanceState) { id = "initAct"; @@ -13,14 +13,18 @@ public class InitAct extends PiztorAct { AppMgr.transam.setTimeOutTime(5000); setContentView(R.layout.activity_init); } - + @Override protected void onStart() { super.onStart(); + } + + @Override + protected void onResume() { + super.onResume(); if (Infomation.token == null) AppMgr.trigger(AppMgr.noToken); else { - //TODO jump to main AppMgr.trigger(AppMgr.hasToken); } } @@ -28,8 +32,6 @@ public class InitAct extends PiztorAct { @Override protected void onDestroy() { super.onDestroy(); - //TODO 减少频率 - } @Override diff --git a/client/Piztor/src/com/macaroon/piztor/Login.java b/client/Piztor/src/com/macaroon/piztor/Login.java index b55cd2e..a1a6d0d 100644 --- a/client/Piztor/src/com/macaroon/piztor/Login.java +++ b/client/Piztor/src/com/macaroon/piztor/Login.java @@ -19,7 +19,7 @@ public class Login extends PiztorAct { int loginButtonClick = 1, retryButtonClick = 2, loginFailed = 3; @SuppressLint("HandlerLeak") - Handler hand = new Handler() { + Handler handler = new Handler() { @Override public void handleMessage(Message m) { System.out.println("receive what : " + m.what); @@ -30,17 +30,20 @@ public class Login extends PiztorAct { } if (m.what == 0) { ResLogin res = (ResLogin) m.obj; - if (res.s == 1) { + if (res.status == 1) { actMgr.trigger(loginFailed); return; } Infomation.token = res.t; Infomation.myInfo.uid = res.uid; Infomation.username = edtUser.getText().toString(); - System.out.println(res.s + " :!!! " + res.t); + System.out.println(res.status + " :!!! " + res.type); actMgr.trigger(AppMgr.loginSuccess); + System.out.println("............"); } else { - actMgr.trigger(loginFailed); + System.out.println("reveive other info ~~~~~~~~~~~~~~" + m.what); +// System.out.println("login de " + m.what); +// actMgr.trigger(loginFailed); } } }; @@ -69,9 +72,13 @@ public class Login extends PiztorAct { @Override void leave(int e) { - Toast toast = Toast.makeText(getApplicationContext(), - "login failed", Toast.LENGTH_LONG); - toast.show(); + if (e == loginFailed) { + Toast toast = Toast.makeText(getApplicationContext(), + "login failed", Toast.LENGTH_LONG); + toast.show(); + } else { + System.out.println("fuck!!!asdfasdfasdf!"); + } } } @@ -81,7 +88,6 @@ public class Login extends PiztorAct { id = "login"; super.onCreate(savedInstanceState); ActStatus[] r = new ActStatus[2]; - AppMgr.transam.setHandler(hand); r[0] = new StartStatus(); r[1] = new LoginStatus(); actMgr = new ActMgr(this, r[0], r); @@ -107,7 +113,7 @@ public class Login extends PiztorAct { @Override protected void onResume() { super.onResume(); - + AppMgr.transam.setHandler(handler); } @Override diff --git a/client/Piztor/src/com/macaroon/piztor/Main.java b/client/Piztor/src/com/macaroon/piztor/Main.java index eeab207..3e8a939 100644 --- a/client/Piztor/src/com/macaroon/piztor/Main.java +++ b/client/Piztor/src/com/macaroon/piztor/Main.java @@ -3,27 +3,21 @@ package com.macaroon.piztor; import java.util.Calendar; import java.util.Timer; import java.util.TimerTask; +import java.util.Vector; import android.annotation.SuppressLint; -import android.app.AlertDialog; -import android.app.TimePickerDialog; import android.content.Context; -import android.content.DialogInterface; -import android.content.Intent; import android.location.LocationManager; import android.os.Bundle; import android.os.Handler; import android.os.Message; -import android.provider.Settings; import android.util.Log; import android.view.KeyEvent; import android.view.Menu; import android.view.View; import android.view.inputmethod.InputMethodManager; -import android.widget.EditText; import android.widget.ImageButton; import android.widget.TextView; -import android.widget.TimePicker; import android.widget.Toast; import com.baidu.location.BDLocation; @@ -35,27 +29,23 @@ import com.baidu.mapapi.map.MKMapTouchListener; import com.baidu.mapapi.map.MapView; import com.baidu.mapapi.map.OverlayItem; import com.baidu.mapapi.map.PopupOverlay; +import com.baidu.mapapi.utils.DistanceUtil; import com.baidu.platform.comapi.basestruct.GeoPoint; public class Main extends PiztorAct { - final static int SearchButtonPress = 1; final static int FocuseButtonPress = 3; final static int SuccessFetch = 4; final static int FailedFetch = 5; - final static int Fetch = 6; final static int mapViewtouched = 7; - + + MapMaker mapMaker = null; MapView mMapView; AlertMaker alertMaker; private Calendar calendar; GeoPoint markerPoint = null; - - // map touch listener - private MKMapTouchListener mapTouchListener; - - boolean isFirstLocation = true; + private MKMapTouchListener mapTouchListener; /** * Locating component @@ -65,21 +55,11 @@ public class Main extends PiztorAct { LocationClient mLocClient; LocationData locData = null; public MyLocationListener myListener = new MyLocationListener(); + boolean isFirstLocation = true; ImageButton btnSearch, btnFetch, btnFocus, btnSettings; - // Timer autodate; MapInfo mapInfo; - /* - * @SuppressLint("HandlerLeak") Handler fromGPS = new Handler() { - * - * @Override public void handleMessage(Message m) { if (m.what != 0) { - * Location l = (Location) m.obj; if (l == null) - * System.out.println("fuck!!!"); else { ReqUpdate r = new - * ReqUpdate(Infomation.token, Infomation.username, l.getLatitude(), - * l.getLongitude(), System.currentTimeMillis(), 1000); - * AppMgr.transam.send(r); } } } }; - */ - + @SuppressLint("HandlerLeak") Handler handler = new Handler() { @Override @@ -87,7 +67,7 @@ public class Main extends PiztorAct { switch (m.what) { case 1:// 上传自己信息成功or失败 ResUpdate update = (ResUpdate) m.obj; - if (update.s == 0) + if (update.status == 0) System.out.println("update success"); else { System.out.println("update failed"); @@ -96,32 +76,36 @@ public class Main extends PiztorAct { break; case 2:// 得到别人的信息 ResLocation location = (ResLocation) m.obj; - if (location.s == 0) { + if (location.status == 0) { mapInfo.clear(); - for (Rlocation i : location.l) { - System.out.println(i.i + " : " + i.lat + " " + i.lot); - UserInfo info = new UserInfo(i.i); - info.setLocation(i.lat, i.lot); + for (RLocation i : location.l) { + System.out.println(i.id + " : " + i.latitude + " " + + i.longitude); + UserInfo info = new UserInfo(i.id); + info.setLocation(i.latitude, i.longitude); mapInfo.addUserInfo(info); } - actMgr.trigger(SuccessFetch); +// actMgr.trigger(SuccessFetch); + flushMap(); } else { System.out.println("resquest for location failed!"); actMgr.trigger(AppMgr.errorToken); } break; case 3:// 得到用户信息 - ResUserinfo r = (ResUserinfo) m.obj; - if (r.s == 0) { + ResUserInfo r = (ResUserInfo) m.obj; + if (r.status == 0) { System.out.println("id : " + r.uid + " sex : " + r.sex - + " group : " + r.gid); + + " group : " + r.section); if (r.uid == Infomation.myInfo.uid) { - Infomation.myInfo.gid = r.gid; + System.out.println("flush myself info!!!"); + Infomation.myInfo.section = r.section; + Infomation.myInfo.company = r.company; Infomation.myInfo.sex = r.sex; } else { UserInfo user = mapInfo.getUserInfo(r.uid); if (user != null) - user.setInfo(r.gid, r.sex); + user.setInfo(r.company, r.section, r.sex); else System.out.println("fuck!!!!"); } @@ -133,7 +117,7 @@ public class Main extends PiztorAct { break; case 4:// 登出 ResLogout logout = (ResLogout) m.obj; - if (logout.s == 0) { + if (logout.status == 0) { actMgr.trigger(AppMgr.logout); } else { Toast toast = Toast.makeText(getApplicationContext(), @@ -141,18 +125,49 @@ public class Main extends PiztorAct { toast.show(); } break; + case Transam.StartPush: + ResStartPush startpush = (ResStartPush) m.obj; + if (startpush.status == 1) { + System.out.println("!!!!!!!!!!!!!jian gui le!!!!!!!!!!!!!"); + } + break; + case Transam.PushMessage: + ResPushMessage pushMessage = (ResPushMessage) m.obj; + receiveMessage(pushMessage.message); + break; + case Transam.SendMessage: + ResSendMessage resMessage = (ResSendMessage) m.obj; + System.out.println("res message " + resMessage.status); + break; + case Transam.PushLocation: + ResPushLocation pushLocation = (ResPushLocation) m.obj; + upDateInfo(pushLocation.l); + break; default: break; } } + + void upDateInfo(Vector<RLocation> l) { + // TODO + for (RLocation i : l) { + UserInfo info = AppMgr.mapInfo.getUserInfo(i.id); + if (info != null) { + info.setLocation(i.latitude, i.longitude); + } else { + info = new UserInfo(i.id); + info.setLocation(i.latitude, i.longitude); + AppMgr.mapInfo.addUserInfo(info); + } + } + flushMap(); + } }; String cause(int t) { switch (t) { case SearchButtonPress: return "Search Button Press"; - case Fetch: - return "Fetch "; case FocuseButtonPress: return "Focuse Button Press"; case SuccessFetch: @@ -172,29 +187,44 @@ public class Main extends PiztorAct { System.out .println("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"); } + + void receiveMessage(String msg) { + System.out.println("receiveed push message!!!!!"); + System.out.println(msg); + Toast toast = Toast.makeText(getApplicationContext(), + msg, Toast.LENGTH_LONG); + toast.show(); + } + public class MyLocationListener implements BDLocationListener { + int cnt = 0; + GeoPoint lastPoint = null; @Override public void onReceiveLocation(BDLocation location) { Log.d("GPS", "Gotten"); + cnt++; if (location == null) { return; } - locData.latitude = location.getLatitude(); locData.longitude = location.getLongitude(); locData.accuracy = location.getRadius(); locData.direction = location.getDerect(); - - System.out.println("LLLLLLLLLLLLLLLLLLLLLLL " + locData.latitude + " " + locData.longitude); - mapMaker.UpdateLocationOverlay(locData, isFirstLocation); - isFirstLocation = false; - if (Infomation.token != null) { - AppMgr.transam.send(new ReqUpdate(Infomation.token, - Infomation.username, locData.latitude, - locData.longitude, System.currentTimeMillis(), 2000)); - Infomation.myInfo.setLocation(locData.latitude, locData.longitude); + + GeoPoint point = new GeoPoint((int)(locData.latitude * 1e6), (int)(locData.longitude * 1e6)); + if (lastPoint == null || cnt > 5 || DistanceUtil.getDistance(point, lastPoint) > 10 ) { + if (Infomation.token != null) { + Infomation.myInfo.setLocation(locData.latitude, + locData.longitude); + AppMgr.transam.send(new ReqUpdate(Infomation.token, + Infomation.username, locData.latitude, + locData.longitude, System.currentTimeMillis(), 2000)); + lastPoint = point; + cnt = 0; + } } + mapMaker.UpdateLocationOverlay(locData, false); } @Override @@ -213,14 +243,9 @@ public class Main extends PiztorAct { if (e == ActMgr.Create) { System.out.println(Infomation.token + " " + Infomation.username + " " + Infomation.myInfo.uid); - AppMgr.transam.send(new ReqUserinfo(Infomation.token, + AppMgr.transam.send(new ReqUserInfo(Infomation.token, Infomation.username, Infomation.myInfo.uid, System .currentTimeMillis(), 5000)); - // TODO flush mapinfo.myinfo - } - - if (e == Fetch) { - requesLocation(Infomation.myInfo.gid); } if (e == SuccessFetch) flushMap(); @@ -233,67 +258,19 @@ public class Main extends PiztorAct { } - class FetchStatus extends ActStatus { - - @Override - void enter(int e) { - System.out.println("enter Fetch status!!!!"); - if (e == Fetch) { - requesLocation(Infomation.myInfo.gid); - } - if (e == SuccessFetch) { - flushMap(); - } - } - @Override - void leave(int e) { - System.out.println("leave fetch status!!!! because" + cause(e)); - } - - } - - class FocusStatus extends ActStatus { - - @Override - void enter(int e) { - // TODO - switch (e) { - case Fetch: - requesLocation(Infomation.myInfo.gid); - break; - case FocuseButtonPress: - mapMaker.UpdateLocationOverlay(locData, true); - break; - case SuccessFetch: - flushMap(); - break; - default: - break; - } - System.out.println("enter focus status!!!!"); - } - - @Override - void leave(int e) { - // TODO leave focus - System.out.println("leave focus status!!!! because" + cause(e)); - } - - } - - void requesLocation(int gid) { + void requesLocation(int company, int section) { ReqLocation r = new ReqLocation(Infomation.token, Infomation.username, - gid, System.currentTimeMillis(), 2000); + company, section, System.currentTimeMillis(), 2000); + AppMgr.transam + .send(new ReqSendMessage(Infomation.token, Infomation.username, + "hahaha", System.currentTimeMillis(), 5000)); System.out.println("get others infomation!!!"); AppMgr.transam.send(r); } - class AutoUpdate extends TimerTask { - @Override - public void run() { - actMgr.trigger(Main.Fetch); - } + void focusOn() { + mapMaker.mMapController.animateTo(Infomation.myInfo.location); } public void InitTouchListenr() { @@ -304,11 +281,6 @@ public class Main extends PiztorAct { public void onMapLongClick(GeoPoint arg0) { closeBoard(Main.this); alertMaker.showMarkerAlert(arg0); - /* - if (mapMaker != null) - mapMaker.DrawMarker(arg0); - Log.d("marker", "draw a new marker"); - */ } @Override @@ -335,24 +307,25 @@ public class Main extends PiztorAct { isGPSEnabled = locationManager.isProviderEnabled(locationManager.GPS_PROVIDER); mapInfo = AppMgr.mapInfo; - ActStatus[] r = new ActStatus[3]; + ActStatus[] r = new ActStatus[1]; ActStatus startStatus = r[0] = new StartStatus(); - ActStatus fetchStatus = r[1] = new FetchStatus(); - ActStatus focusStatus = r[2] = new FocusStatus(); +// ActStatus fetchStatus = r[1] = new FetchStatus(); +// ActStatus focusStatus = r[2] = new FocusStatus(); AppMgr.transam.setHandler(handler); actMgr = new ActMgr(this, startStatus, r); - actMgr.add(startStatus, FocuseButtonPress, focusStatus); - actMgr.add(startStatus, Fetch, fetchStatus); - actMgr.add(startStatus, SuccessFetch, startStatus); - actMgr.add(startStatus, Fetch, startStatus); - actMgr.add(fetchStatus, Fetch, startStatus); - actMgr.add(fetchStatus, FailedFetch, startStatus); - actMgr.add(fetchStatus, SuccessFetch, startStatus); - actMgr.add(focusStatus, FocuseButtonPress, startStatus); - actMgr.add(focusStatus, mapViewtouched, startStatus); - actMgr.add(focusStatus, SuccessFetch, focusStatus); - actMgr.add(focusStatus, Fetch, focusStatus); +// actMgr.add(startStatus, FocuseButtonPress, focusStatus); +// actMgr.add(startStatus, Fetch, fetchStatus); +// actMgr.add(startStatus, SuccessFetch, startStatus); +// actMgr.add(startStatus, Fetch, startStatus); +// actMgr.add(fetchStatus, Fetch, startStatus); +// actMgr.add(fetchStatus, FailedFetch, startStatus); +// actMgr.add(fetchStatus, SuccessFetch, startStatus); +// actMgr.add(focusStatus, FocuseButtonPress, startStatus); +// actMgr.add(focusStatus, mapViewtouched, startStatus); +// actMgr.add(focusStatus, SuccessFetch, focusStatus); +// actMgr.add(focusStatus, Fetch, focusStatus); setContentView(R.layout.activity_main); + mMapView = (MapView) findViewById(R.id.bmapView); mapMaker = new MapMaker(mMapView, getApplicationContext()); alertMaker = new AlertMaker(Main.this, mapMaker); @@ -371,7 +344,7 @@ public class Main extends PiztorAct { mLocClient.start(); mapMaker.UpdateLocationOverlay(locData, false); } - + public static void closeBoard(Context cc) { InputMethodManager imm = (InputMethodManager) cc .getSystemService(Context.INPUT_METHOD_SERVICE); @@ -379,7 +352,11 @@ public class Main extends PiztorAct { imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, InputMethodManager.HIDE_NOT_ALWAYS); } - + + /* + * public boolean onTap(int index) { OverlayItem item = getItem(index); + * mCurItem = item; if () } + */ @Override protected void onStart() { super.onStart(); @@ -390,15 +367,17 @@ public class Main extends PiztorAct { btnFetch.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { - actMgr.trigger(Fetch); + requesLocation(Infomation.myInfo.company, Infomation.myInfo.section); } }); + btnFocus.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - actMgr.trigger(FocuseButtonPress); + focusOn(); } }); + btnSettings.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { @@ -409,10 +388,17 @@ public class Main extends PiztorAct { } @Override + protected void onRestart() { + super.onRestart(); + AppMgr.transam.setHandler(handler); + } + + @Override protected void onResume() { isFirstLocation = true; mapMaker.onResume(); flushMap(); + requesLocation(Infomation.myInfo.company, Infomation.myInfo.section); super.onResume(); } @@ -439,7 +425,7 @@ public class Main extends PiztorAct { @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { - AppMgr.exit(); + alertMaker.showQuitAlert(); return true; } return super.onKeyDown(keyCode, event); @@ -456,7 +442,6 @@ public class Main extends PiztorAct { protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); mMapView.onSaveInstanceState(outState); - } @Override diff --git a/client/Piztor/src/com/macaroon/piztor/MapInfo.java b/client/Piztor/src/com/macaroon/piztor/MapInfo.java index f5840c7..52e168b 100644 --- a/client/Piztor/src/com/macaroon/piztor/MapInfo.java +++ b/client/Piztor/src/com/macaroon/piztor/MapInfo.java @@ -53,7 +53,9 @@ public class MapInfo { } class UserInfo { - int uid, gid, sex; + int uid, sex; + int company; //group id + int section; GeoPoint location; UserInfo(int uid) { @@ -64,8 +66,9 @@ class UserInfo { location = new GeoPoint((int)(lat * 1e6), (int)(lot * 1e6)); } - void setInfo(int gid, int sex) { - this.gid = gid; + void setInfo(int company, int section, int sex) { + this.company = company; + this.section = section; this.sex = sex; } diff --git a/client/Piztor/src/com/macaroon/piztor/MapMaker.java b/client/Piztor/src/com/macaroon/piztor/MapMaker.java index 3987cd6..05cf0b9 100644 --- a/client/Piztor/src/com/macaroon/piztor/MapMaker.java +++ b/client/Piztor/src/com/macaroon/piztor/MapMaker.java @@ -61,7 +61,7 @@ public class MapMaker extends Activity { // MapView controlling component private MapView mMapView = null; - private MapController mMapController = null; + MapController mMapController = null; // Default center private final static GeoPoint sjtuCenter = new GeoPoint((int)(31.032247 * 1E6), (int)(121.445937 * 1E6)); diff --git a/client/Piztor/src/com/macaroon/piztor/PushClient.java b/client/Piztor/src/com/macaroon/piztor/PushClient.java new file mode 100644 index 0000000..ea32ad6 --- /dev/null +++ b/client/Piztor/src/com/macaroon/piztor/PushClient.java @@ -0,0 +1,252 @@ +package com.macaroon.piztor;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.net.Soc |