diff options
author | sjtufs <[email protected]> | 2013-09-01 05:57:40 +0800 |
---|---|---|
committer | sjtufs <[email protected]> | 2013-09-01 05:57:40 +0800 |
commit | 49d2e9d74fbf95e5b287dc8e9179e8d3d977a527 (patch) | |
tree | 57c672ed1bb809ed1bea8c852f61f464c5c1b74c /client/Piztor | |
parent | 0410d0b9c6bb502f8467c3f2c62183e9a74e69fc (diff) |
stable version
Diffstat (limited to 'client/Piztor')
33 files changed, 532 insertions, 465 deletions
diff --git a/client/Piztor/AndroidManifest.xml b/client/Piztor/AndroidManifest.xml index f81ece8..8e9973c 100644 --- a/client/Piztor/AndroidManifest.xml +++ b/client/Piztor/AndroidManifest.xml @@ -39,7 +39,7 @@ <uses-permission android:name="android.permission.ACCESS_GPS" /> <application - android:name=".myApp" + android:name="com.macaroon.piztor.myApp" android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" @@ -81,6 +81,11 @@ android:enabled="true" android:process=":remote" > </service> + + <activity + android:name="com.macaroon.piztor.UpdateInfo" + android:label="@string/title_activity_update_info" > + </activity> </application> <supports-screens diff --git a/client/Piztor/project.properties b/client/Piztor/project.properties index b7c2081..ce39f2d 100644 --- a/client/Piztor/project.properties +++ b/client/Piztor/project.properties @@ -11,4 +11,4 @@ #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt # Project target. -target=android-10 +target=android-18 diff --git a/client/Piztor/res/drawable/circle_blue.png b/client/Piztor/res/drawable/circle_blue.png Binary files differindex 09c3658..d174635 100644 --- a/client/Piztor/res/drawable/circle_blue.png +++ b/client/Piztor/res/drawable/circle_blue.png diff --git a/client/Piztor/res/drawable/circle_glass.png b/client/Piztor/res/drawable/circle_glass.png Binary files differindex 826b2b7..d5dbec4 100644 --- a/client/Piztor/res/drawable/circle_glass.png +++ b/client/Piztor/res/drawable/circle_glass.png diff --git a/client/Piztor/res/drawable/circle_green.png b/client/Piztor/res/drawable/circle_green.png Binary files differindex ded6938..3ab51d4 100644 --- a/client/Piztor/res/drawable/circle_green.png +++ b/client/Piztor/res/drawable/circle_green.png diff --git a/client/Piztor/res/drawable/circle_metal.png b/client/Piztor/res/drawable/circle_metal.png Binary files differindex d84e1ad..07c72f0 100644 --- a/client/Piztor/res/drawable/circle_metal.png +++ b/client/Piztor/res/drawable/circle_metal.png diff --git a/client/Piztor/res/drawable/circle_paper.png b/client/Piztor/res/drawable/circle_paper.png Binary files differindex 973787d..b8d7b0d 100644 --- a/client/Piztor/res/drawable/circle_paper.png +++ b/client/Piztor/res/drawable/circle_paper.png diff --git a/client/Piztor/res/drawable/circle_tan.png b/client/Piztor/res/drawable/circle_tan.png Binary files differindex 27d10ad..667cc25 100644 --- a/client/Piztor/res/drawable/circle_tan.png +++ b/client/Piztor/res/drawable/circle_tan.png diff --git a/client/Piztor/res/drawable/circle_wood.png b/client/Piztor/res/drawable/circle_wood.png Binary files differindex ea18f7a..b2752de 100644 --- a/client/Piztor/res/drawable/circle_wood.png +++ b/client/Piztor/res/drawable/circle_wood.png diff --git a/client/Piztor/res/drawable/circle_yellow.png b/client/Piztor/res/drawable/circle_yellow.png Binary files differindex 7c1dfc7..c596806 100644 --- a/client/Piztor/res/drawable/circle_yellow.png +++ b/client/Piztor/res/drawable/circle_yellow.png diff --git a/client/Piztor/res/layout/activity_login.xml b/client/Piztor/res/layout/activity_login.xml index 232f1e7..c408a1d 100644 --- a/client/Piztor/res/layout/activity_login.xml +++ b/client/Piztor/res/layout/activity_login.xml @@ -76,7 +76,7 @@ android:layout_marginLeft="70.0dip" android:layout_marginRight="70.0dip" android:layout_marginTop="12.0dip" - android:text="login" + android:text="@string/login" android:layout_below="@id/user_layout" /> </RelativeLayout>
\ No newline at end of file diff --git a/client/Piztor/res/layout/activity_settings.xml b/client/Piztor/res/layout/activity_settings.xml index 49e8dfe..e1712aa 100644 --- a/client/Piztor/res/layout/activity_settings.xml +++ b/client/Piztor/res/layout/activity_settings.xml @@ -16,14 +16,21 @@ android:layout_height="wrap_content" android:layout_marginTop="10dip" android:orientation="horizontal"> + <LinearLayout + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:layout_centerVertical="true" + android:layout_centerHorizontal="true" + > <TextView android:id="@+id/settings_GPSrefreshrate_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" + android:gravity="center" android:layout_marginTop="10dip" - android:layout_marginLeft="60dip" - android:text="GPS refresh rate" + android:text="@string/GPSrefreshrate" android:textColor="@android:color/white" android:textSize="20dip" /> <TextView @@ -32,12 +39,12 @@ android:layout_height="wrap_content" android:textSize="20dip" android:layout_marginTop="10dip" - android:layout_marginLeft="20dip" + android:layout_marginLeft="10dip" android:layout_gravity="center_vertical" android:textColor="@android:color/white" android:layout_toRightOf="@+id/settings_GPSrefreshrate_text" android:text="30s"/> - + </LinearLayout> </RelativeLayout> <SeekBar diff --git a/client/Piztor/res/layout/activity_updateinfo.xml b/client/Piztor/res/layout/activity_updateinfo.xml index de9ecc6..5d0c66c 100644 --- a/client/Piztor/res/layout/activity_updateinfo.xml +++ b/client/Piztor/res/layout/activity_updateinfo.xml @@ -7,7 +7,7 @@ android:layout_width="fill_parent" android:layout_height="fill_parent" - android:layout_marginTop="20dip" + android:layout_marginTop="20dip" android:orientation="vertical" > <include layout="@layout/settings_headbar"></include> @@ -17,105 +17,105 @@ android:layout_height="wrap_content" android:layout_gravity="center" android:layout_marginTop="10dip" - android:gravity="center" + android:gravity="center" android:textSize="20dip" android:textColor="#FFFFFF" - android:text="haha" - android:id="@+id/username_text" /> + android:id="@+id/username" /> <View - android:layout_width="fill_parent" - android:layout_height="1.0px" - android:layout_marginTop="10dip" - android:layout_marginBottom="20dip" - android:layout_marginLeft="20dip" - android:layout_marginRight="20dip" - android:background="#ffc0c3c4" /> + android:layout_width="fill_parent" + android:layout_height="1.0px" + android:layout_marginTop="10dip" + android:layout_marginBottom="20dip" + android:layout_marginLeft="20dip" + android:layout_marginRight="20dip" + android:background="#ffc0c3c4" /> - <EditText - android:id="@+id/editText1" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginLeft="25dip" - android:layout_marginRight="25dip" - android:hint=" new nickname" - android:ems="10" > - </EditText> - <View - android:layout_width="fill_parent" - android:layout_height="1.0px" - android:layout_marginTop="20dip" - android:layout_marginBottom="20dip" - android:layout_marginLeft="20dip" - android:layout_marginRight="20dip" - android:background="#ffc0c3c4" /> + <TextView + android:id="@+id/nickname" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:gravity="center" + android:layout_marginLeft="25dip" + android:layout_marginRight="25dip" + android:textSize="20dip" + android:ems="10" > + </TextView> + <View + android:layout_width="fill_parent" + android:layout_height="1.0px" + android:layout_marginTop="20dip" + android:layout_marginBottom="20dip" + android:layout_marginLeft="20dip" + android:layout_marginRight="20dip" + android:background="#ffc0c3c4" /> - <EditText - android:id="@+id/editText2" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginLeft="25dip" - android:layout_marginRight="25dip" - android:ems="10" - android:inputType="textPassword" - android:hint=" * old password"/> - <TextView - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginLeft="25dip" - android:layout_marginRight="25dip" - android:layout_marginBottom="10dip" - android:layout_gravity="center" - android:gravity="center" - android:textSize="14dip" - android:text="Must enter your current password" - android:textColor="#808080"/> + <EditText + android:id="@+id/password_old" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginLeft="25dip" + android:layout_marginRight="25dip" + android:ems="10" + android:inputType="textPassword" + android:hint="@string/old_password"/> + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginLeft="25dip" + android:layout_marginRight="25dip" + android:layout_marginBottom="10dip" + android:layout_gravity="center" + android:gravity="center" + android:textSize="14dip" + android:textColor="#808080"/> - <EditText - android:id="@+id/editText3" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginLeft="25dip" - android:layout_marginRight="25dip" - android:ems="10" - android:inputType="textPassword" - android:hint=" new password"/> - <TextView - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginLeft="25dip" - android:layout_marginRight="25dip" - android:layout_gravity="center" - android:gravity="center" - android:textSize="14dip" - android:text="Keep this blank if you don't want to change" - android:textColor="#808080"/> - <View - android:layout_width="fill_parent" - android:layout_height="1.0px" - android:layout_marginTop="20dip" - android:layout_marginBottom="20dip" - android:layout_marginLeft="20dip" - android:layout_marginRight="20dip" - android:background="#ffc0c3c4" /> + <EditText + android:id="@+id/password_new" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginLeft="25dip" + android:layout_marginRight="25dip" + android:ems="10" + android:inputType="textPassword" + android:hint="@string/new_password"/> + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginLeft="25dip" + android:layout_marginRight="25dip" + android:layout_gravity="center" + android:gravity="center" + android:textSize="14dip" + android:textColor="#808080"/> + <View + android:layout_width="fill_parent" + android:layout_height="1.0px" + android:layout_marginTop="20dip" + android:layout_marginBottom="20dip" + android:layout_marginLeft="20dip" + android:layout_marginRight="20dip" + android:background="#ffc0c3c4" /> - <LinearLayout - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="horizontal" - android:layout_gravity="center" - android:gravity="center"> - <Button - android:layout_height="wrap_content" - android:layout_width="wrap_content" - android:paddingLeft="30dip" - android:paddingRight="30dip" - android:paddingTop="4dip" - android:paddingBottom="4dip" - android:background="#0F9D58" - android:textColor="#FFFFFF" - android:textSize="25dip" - android:text="Submit"/> - </LinearLayout> - + <LinearLayout + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:layout_gravity="center" + android:gravity="center"> + <Button + android:id="@+id/btn_submit" + android:layout_height="wrap_content" + android:layout_width="wrap_content" + android:paddingLeft="30dip" + android:paddingRight="30dip" + android:paddingTop="4dip" + android:paddingBottom="4dip" + android:background="#0F9D58" + android:textColor="#FFFFFF" + android:textSize="25dip" + android:text="@string/submit"/> + </LinearLayout> + </LinearLayout> </ScrollView>
\ No newline at end of file diff --git a/client/Piztor/res/layout/checkindialog.xml b/client/Piztor/res/layout/checkindialog.xml index d72f223..b84404b 100644 --- a/client/Piztor/res/layout/checkindialog.xml +++ b/client/Piztor/res/layout/checkindialog.xml @@ -8,7 +8,7 @@ android:layout_height="wrap_content" android:layout_gravity="center" android:gravity="center" - android:text="Checking in..." + android:text="正在签到..." android:id="@+id/checkin_info"/> <ProgressBar diff --git a/client/Piztor/res/layout/subscribe_item.xml b/client/Piztor/res/layout/subscribe_item.xml index 902da5a..2d53865 100644 --- a/client/Piztor/res/layout/subscribe_item.xml +++ b/client/Piztor/res/layout/subscribe_item.xml @@ -4,33 +4,39 @@ android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal"> + <View + android:id="@+id/seperator" + android:layout_width="fill_parent" + android:layout_height="1.0px" + android:layout_alignParentTop="true" + android:layout_marginTop="10dip" + android:layout_marginBottom="10dip" + android:layout_marginLeft="20dip" + android:layout_marginRight="20dip" + android:background="#ffc0c3c4" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/textView1" + android:layout_below="@+id/seperator" android:textSize="20dip" android:layout_marginLeft="10dip" android:layout_alignParentLeft="true" android:text="company section"/> <Button - android:text="remove" + android:text="@string/remove" android:layout_width="100dip" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_marginRight="10dip" + android:paddingTop="3dip" + android:paddingBottom="3dip" + android:layout_below="@+id/seperator" android:textColor="#FFFFFF" android:background="#DB4437" android:id="@+id/button_delete" android:textSize="20dip" /> - <View - android:layout_width="fill_parent" - android:layout_height="1.0px" - android:layout_below="@+id/button_delete" - android:layout_marginTop="20dip" - android:layout_marginBottom="20dip" - android:layout_marginLeft="20dip" - android:layout_marginRight="20dip" - android:background="#ffc0c3c4" /> + </RelativeLayout> diff --git a/client/Piztor/res/layout/subscribe_settings.xml b/client/Piztor/res/layout/subscribe_settings.xml index c27e3c8..1bfd975 100644 --- a/client/Piztor/res/layout/subscribe_settings.xml +++ b/client/Piztor/res/layout/subscribe_settings.xml @@ -4,6 +4,14 @@ android:layout_width="fill_parent" android:layout_height="fill_parent" > + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:id="@+id/textView1" + android:text="TextView" + android:layout_alignParentBottom="true" + android:layout_centerHorizontal="true" + android:layout_marginBottom="10dp"/> <RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" @@ -16,7 +24,7 @@ android:layout_alignParentLeft="true" android:layout_marginLeft="10dip" android:textSize="20dip" - android:hint="company" + android:hint="@string/company" android:phoneNumber="true" android:id="@+id/subscribe_company"/> <EditText @@ -25,7 +33,7 @@ android:layout_marginLeft="10dip" android:layout_toRightOf="@+id/subscribe_company" android:textSize="20dip" - android:hint="section" + android:hint="@string/section" android:phoneNumber="true" android:id="@+id/subscribe_section"/> <Button @@ -33,7 +41,7 @@ android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_marginRight="10dip" - android:text="add" + android:text="@string/add" android:textColor="#FFFFFF" android:background="#0F9D58" android:textSize="20dip" @@ -55,12 +63,4 @@ android:focusable="true"> </ListView> </LinearLayout> - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:id="@+id/textView1" - android:text="TextView" - android:layout_alignParentBottom="true" - android:layout_centerHorizontal="true" - android:layout_marginBottom="10dp"/> </LinearLayout> diff --git a/client/Piztor/res/menu/update_info.xml b/client/Piztor/res/menu/update_info.xml new file mode 100644 index 0000000..c002028 --- /dev/null +++ b/client/Piztor/res/menu/update_info.xml @@ -0,0 +1,9 @@ +<menu xmlns:android="http://schemas.android.com/apk/res/android" > + + <item + android:id="@+id/action_settings" + android:orderInCategory="100" + android:showAsAction="never" + android:title="@string/action_settings"/> + +</menu> diff --git a/client/Piztor/res/values/strings.xml b/client/Piztor/res/values/strings.xml index 8752b0d..7cf728c 100644 --- a/client/Piztor/res/values/strings.xml +++ b/client/Piztor/res/values/strings.xml @@ -4,11 +4,11 @@ <string name="app_name">Piztor</string> <string name="action_settings">Settings</string> <string name="hello_world">Hello world!</string> - <string name="settings">Settings</string> - <string name="search">Search</string> - <string name="fetch">Fetch</string> - <string name="checkin">Checkin</string> - <string name="focus">Focus</string> + <string name="settings">设置</string> + <string name="search">搜索</string> + <string name="fetch">获取</string> + <string name="checkin">签到</string> + <string name="focus">聚焦</string> <string name="show_sex">Show sex: </string> <string name="male">Male</string> <string name="female">Female</string> @@ -18,15 +18,25 @@ <string name="title_activity_login">Login</string> <string name="title_activity_main">Main</string> <string name="title_activity_settings">Settings</string> - <string name="password">password</string> - <string name="username">username</string> - <string name="login">login</string> + <string name="password">密码</string> + <string name="username">用户名</string> + <string name="login">登录</string> <string name="desc">desc</string> - <string name="logout">Logout</string> - <string name="update_info">My Account</string> - <string name="subscribe_info">Subscribe information</string> - <string name="change">Check & Update</string> + <string name="logout">注销</string> + <string name="update_info">修改密码</string> + <string name="subscribe_info">关注信息</string> + <string name="change">查看及修改</string> <string name="title_activity_subscribesettings">SubscribeSettings</string> <string name="title_activity_subscribe_settings">SubscribeSettings</string> + <string name="title_activity_update_info">UpdateInfo</string> + <string name="cancel">取消</string> + <string name="remove">移除</string> + <string name="company">连队</string> + <string name="section">班级</string> + <string name="add">添加</string> + <string name="GPSrefreshrate">GPS刷新率</string> + <string name="old_password">旧密码</string> + <string name="new_password">新密码</string> + <string name="submit">提交</string> </resources> diff --git a/client/Piztor/src/com/macaroon/piztor/AccountSettings.java b/client/Piztor/src/com/macaroon/piztor/AccountSettings.java deleted file mode 100644 index 150bc64..0000000 --- a/client/Piztor/src/com/macaroon/piztor/AccountSettings.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.macaroon.piztor; - -public class AccountSettings extends PiztorAct{ - -} diff --git a/client/Piztor/src/com/macaroon/piztor/AlertMaker.java b/client/Piztor/src/com/macaroon/piztor/AlertMaker.java index 7e36310..bc8e138 100644 --- a/client/Piztor/src/com/macaroon/piztor/AlertMaker.java +++ b/client/Piztor/src/com/macaroon/piztor/AlertMaker.java @@ -70,16 +70,16 @@ public class AlertMaker { closeBoard(context); AlertDialog.Builder gpsDialog = new AlertDialog.Builder(context); - gpsDialog.setTitle("GPS settings"); - gpsDialog.setMessage("GPS is not enabled. Please turn it on."); - gpsDialog.setPositiveButton("Settings", + gpsDialog.setTitle("GPS设置"); + gpsDialog.setMessage("GPS未开启,是否前去打开?"); + gpsDialog.setPositiveButton("设置", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); context.startActivity(intent); } }); - gpsDialog.setNegativeButton("Go without GPS", + gpsDialog.setNegativeButton("不使用GPS", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); @@ -131,7 +131,7 @@ public class AlertMaker { Log.d("marker", "marker alert calls drawmarker"); } else if (!flag) { Toast toast = Toast.makeText(context, - "Too early! Give me at least 2 minutes!", Toast.LENGTH_LONG); + "太早了!多给一点时间", Toast.LENGTH_LONG); toast.show(); closeBoard(context); showMarkerAlert(markerPoint); @@ -149,7 +149,7 @@ public class AlertMaker { LayoutInflater infaler = LayoutInflater.from(context); final LinearLayout layout = (LinearLayout)infaler.inflate(R.layout.checkindialog, null); checkinDialog.setView(layout); - checkinDialog.setNeutralButton("cancel", new DialogInterface.OnClickListener() { + checkinDialog.setNeutralButton("取消", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { InputMethodManager im = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); im.hideSoftInputFromWindow(layout.getWindowToken(), 0); @@ -171,10 +171,10 @@ public class AlertMaker { //TODO pbar.setVisibility(View.GONE); mapMaker.removeMarker(); - Toast toast = Toast.makeText(context, "Marker checked!", 2000); + Toast toast = Toast.makeText(context, "已签到!", 2000); toast.setGravity(Gravity.TOP, 0, 80); toast.show(); - checkinInfo.setText("Success!"); + checkinInfo.setText("成功!"); } }.start(); } diff --git a/client/Piztor/src/com/macaroon/piztor/AppMgr.java b/client/Piztor/src/com/macaroon/piztor/AppMgr.java index f1a3445..a7f1af0 100644 --- a/client/Piztor/src/com/macaroon/piztor/AppMgr.java +++ b/client/Piztor/src/com/macaroon/piztor/AppMgr.java @@ -1,11 +1,10 @@ package com.macaroon.piztor; import java.util.HashMap; -import java.util.HashSet; +import java.util.Stack; import android.annotation.SuppressLint; import android.content.Intent; -import com.baidu.mapapi.BMapManager; @SuppressLint("UseSparseArrays") public class AppMgr { @@ -18,31 +17,33 @@ public class AppMgr { final static int logout = 106; final static int subscribe = 107; final static int account = 108; + final static int finish = 109; + public enum ActivityStatus { create, start, resume, restart, stop, pause, destroy } + myApp app; HashMap<Class<?>, HashMap<Integer, Class<?>>> mp; - HashSet<PiztorAct> acts; + Stack<PiztorAct> acts; ActivityStatus status; PiztorAct nowAct; void addAct(PiztorAct act) { if (acts == null) - acts = new HashSet<PiztorAct>(); - acts.add(act); + acts = new Stack<PiztorAct>(); + acts.push(act); } - void removeAct(PiztorAct act) { - if (acts.contains(act)) - acts.remove(act); - else - System.out.println("Piztor has a bug!!!!"); - } + /* + * void removeAct(PiztorAct act) { if (acts.contains(act)) acts.remove(act); + * else System.out.println("Piztor has a bug!!!!"); } + */ void exit() { - for (PiztorAct act : acts) { - act.finish(); + while (!acts.isEmpty()) { + acts.peek().finish(); + acts.pop(); } app.token = null; app.mBMapManager.destroy(); @@ -53,8 +54,10 @@ public class AppMgr { } void trigger(int event) { - Intent i = new Intent(); - i.setClass(nowAct, mp.get(nowAct.getClass()).get(event)); + if (event == finish) { + nowAct.finish(); + return; + } if (event == errorToken) app.token = null; if (event == loginSuccess || event == hasToken) { @@ -63,8 +66,13 @@ public class AppMgr { } if (event == logout) { System.out.println("我来停一发!!!!"); + app.isLogout = true; app.mBMapManager.stop(); + nowAct.finish(); + return; } + Intent i = new Intent(); + i.setClass(nowAct, mp.get(nowAct.getClass()).get(event)); nowAct.startActivity(i); } @@ -101,9 +109,10 @@ public class AppMgr { addStatus(Login.class); addStatus(Main.class); addStatus(Settings.class); + addTransition(UpdateInfo.class, logout, Login.class); addTransition(Settings.class, subscribe, SubscribeSettings.class); addTransition(SubscribeSettings.class, logout, Login.class); - addTransition(Settings.class, account, AccountSettings.class); + addTransition(Settings.class, account, UpdateInfo.class); addTransition(InitAct.class, noToken, Login.class); addTransition(InitAct.class, hasToken, Main.class); addTransition(InitAct.class, errorToken, Login.class); diff --git a/client/Piztor/src/com/macaroon/piztor/CopyMap.java b/client/Piztor/src/com/macaroon/piztor/CopyMap.java deleted file mode 100644 index 6d49767..0000000 --- a/client/Piztor/src/com/macaroon/piztor/CopyMap.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.macaroon.piztor; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.InputStream; -import android.content.Context; - -public class CopyMap { - /** - * - * @param myContext - * @param ASSETS_NAME 要复制的文件名 - * @param savePath 要保存的路径 - * @param saveName 复制后的文件名 - * testCopy(Context context)是一个测试例子。 - */ - - public static void copy(Context myContext, String ASSETS_NAME, - String savePath, String saveName) { - String filename = savePath + "/" + saveName; - - File dir = new File(savePath); - // 如果目录不中存在,创建这个目录 - if (!dir.exists()) - dir.mkdir(); - try { - if (!(new File(filename)).exists()) { - InputStream is = myContext.getResources().getAssets() - .open(ASSETS_NAME); - System.out.println(ASSETS_NAME); - FileOutputStream fos = new FileOutputStream(filename); - byte[] buffer = new byte[7168]; - int count = 0; - while ((count = is.read(buffer)) > 0) { - fos.write(buffer, 0, count); - } - fos.close(); - is.close(); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - public void testCopy(Context context) { - String path=context.getFilesDir().getAbsolutePath(); - String name="test"; - CopyMap.copy(context, name, path, name); - } -} - diff --git a/client/Piztor/src/com/macaroon/piztor/Infomation.java b/client/Piztor/src/com/macaroon/piztor/Infomation.java deleted file mode 100644 index dbae0a0..0000000 --- a/client/Piztor/src/com/macaroon/piztor/Infomation.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.macaroon.piztor; - -import java.util.Vector; - -public class Infomation { - -} diff --git a/client/Piztor/src/com/macaroon/piztor/InitAct.java b/client/Piztor/src/com/macaroon/piztor/InitAct.java index a4f82ff..5f7f61d 100644 --- a/client/Piztor/src/com/macaroon/piztor/InitAct.java +++ b/client/Piztor/src/com/macaroon/piztor/InitAct.java @@ -1,17 +1,19 @@ package com.macaroon.piztor; -import com.baidu.mapapi.MKGeneralListener; - import android.app.Activity; +import android.content.Intent; import android.os.Bundle; import android.util.Log; import android.view.Menu; +import com.baidu.mapapi.MKGeneralListener; + public class InitAct extends PiztorAct { @Override protected void onCreate(Bundle savedInstanceState) { id = "initAct"; super.onCreate(savedInstanceState); + app.isExiting = false; app.mBMapManager.init(app.getStrkey(), new MKGeneralListener() { @Override public void onGetNetworkState(int iError) { @@ -33,12 +35,15 @@ public class InitAct extends PiztorAct { @Override protected void onResume() { + if (app.isExiting) + finish(); super.onResume(); - if (app.token == null) + if (app.token == null || app.isLogout) { app.appMgr.trigger(AppMgr.noToken); + } else { - System.out.println("has token!!!"); app.appMgr.trigger(AppMgr.hasToken); + System.out.println("has token!!!"); } } diff --git a/client/Piztor/src/com/macaroon/piztor/Login.java b/client/Piztor/src/com/macaroon/piztor/Login.java index bdbf7ed..3b9cbc2 100644 --- a/client/Piztor/src/com/macaroon/piztor/Login.java +++ b/client/Piztor/src/com/macaroon/piztor/Login.java @@ -37,6 +37,7 @@ public class Login extends PiztorAct { res.uinfo.gid.section, res.uinfo.sex, res.uinfo.nickname); app.mapInfo.myInfo.level = res.uinfo.level; + app.mapInfo.myInfo.nickname = res.uinfo.nickname; System.out.println("login !!!!" + res.sublist.size()); actMgr.trigger(AppMgr.loginSuccess); } else { @@ -85,12 +86,6 @@ public class Login extends PiztorAct { protected void onCreate(Bundle savedInstanceState) { id = "login"; super.onCreate(savedInstanceState); - ActStatus[] r = new ActStatus[2]; - r[0] = new StartStatus(); - r[1] = new LoginStatus(); - actMgr = new ActMgr(appMgr, this, r[0], r); - actMgr.add(r[0], loginButtonClick, r[1]); - actMgr.add(r[1], loginFailed, r[0]); setContentView(R.layout.activity_login); } @@ -110,15 +105,23 @@ public class Login extends PiztorAct { @Override protected void onResume() { + if (app.isExiting) + finish(); + app.isLogout = false; super.onResume(); + ActStatus[] r = new ActStatus[2]; + r[0] = new StartStatus(); + r[1] = new LoginStatus(); + actMgr = new ActMgr(appMgr, this, r[0], r); + actMgr.add(r[0], loginButtonClick, r[1]); + actMgr.add(r[1], loginFailed, r[0]); transam.setHandler(handler); } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { - appMgr.exit(); - return true; + app.isExiting = true; } return super.onKeyDown(keyCode, event); } diff --git a/client/Piztor/src/com/macaroon/piztor/Main.java b/client/Piztor/src/com/macaroon/piztor/Main.java index 4efea11..7ac1b21 100644 --- a/client/Piztor/src/com/macaroon/piztor/Main.java +++ b/client/Piztor/src/com/macaroon/piztor/Main.java @@ -41,7 +41,6 @@ public class Main extends PiztorAct { GeoPoint markerPoint = null; private MKMapTouchListener mapTouchListener; private final int checkinRadius = 10; - public static int GPSrefreshrate = 5; /** * Locating component @@ -52,6 +51,7 @@ public class Main extends PiztorAct { LocationData locData = null; public MyLocationListener myListener = new MyLocationListener(); boolean isFirstLocation = true; + public static int GPSrefreshrate = 5; ImageButton btnCheckin, btnFetch, btnFocus, btnSettings; @@ -210,21 +210,21 @@ public class Main extends PiztorAct { int TMP = location.getLocType(); if (TMP == 61) { Toast toast = Toast.makeText(Main.this, - "Piztor : Update from GPS result (" + GPSrefreshrate + "Piztor : 由GPS更新 (刷新时间" + GPSrefreshrate + "s)", 2000); toast.setGravity(Gravity.TOP, 0, 80); toast.show(); } if (TMP == 161) { Toast toast = Toast.makeText(Main.this, - "Piztor : Update from Network (" + GPSrefreshrate + "Piztor : 由网络更新 (刷新时间" + GPSrefreshrate + "s)", 2000); toast.setGravity(Gravity.TOP, 0, 80); toast.show(); } if (TMP == 65) { Toast toast = Toast.makeText(Main.this, - "Piztor : Update from Cache (" + GPSrefreshrate + "s)", + "Piztor : 由缓存更新 (刷新时间" + GPSrefreshrate + "s)", 2000); toast.setGravity(Gravity.TOP, 0, 80); toast.show(); @@ -311,7 +311,7 @@ public class Main extends PiztorAct { public void markerCheckin() { Log.d("checkin", "ok!!!"); if (mapMaker.getMakerLocation() == null) { - Toast toast = Toast.makeText(Main.this, "No marker now!", 2000); + Toast toast = Toast.makeText(Main.this, "暂无路标", 2000); toast.setGravity(Gravity.TOP, 0, 80); toast.show(); return; @@ -325,7 +325,7 @@ public class Main extends PiztorAct { alertMaker.showCheckinAlter(); } else { Toast toast = Toast.makeText(Main.this, - "Please get closer to the marker!", 2000); + "请靠近路标", 2000); toast.setGravity(Gravity.TOP, 0, 80); toast.show(); } @@ -340,11 +340,6 @@ public class Main extends PiztorAct { .getSystemService(LOCATION_SERVICE); isGPSEnabled = locationManager .isProviderEnabled(locationManager.GPS_PROVIDER); - ActStatus[] r = new ActStatus[1]; - ActStatus startStatus = r[0] = new StartStatus(); - transam = app.transam; - - actMgr = new ActMgr(appMgr, this, startStatus, r); setContentView(R.layout.activity_main); app.mBMapManager.start(); @@ -415,11 +410,19 @@ public class Main extends PiztorAct { @Override protected void onResume() { + if (app.isExiting || app.isLogout) + finish(); + ActStatus[] r = new ActStatus[1]; + ActStatus startStatus = r[0] = new StartStatus(); + actMgr = new ActMgr(appMgr, this, startStatus, r); mMapView.onResume(); transam.setHandler(handler); isFirstLocation = true; mLocClient.start(); - requestUserInfo(); + if (app.token == null) { + System.out.println("fuck!!"); + } else + requestUserInfo(); // mapMaker.onResume(); flushMap(); super.onResume(); @@ -446,7 +449,9 @@ public class Main extends PiztorAct { if (mLocClient != null) { mLocClient.stop(); } - // mMapView.destroy(); + // mapMaker.mOffline.destroy(); + mMapView.destroy(); + app.mBMapManager.stop(); // while null? // mMapView.destroy(); // @@ -457,9 +462,8 @@ public class Main extends PiztorAct { public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { System.out.println("ready to exit!!!"); - app.mBMapManager.stop(); - appMgr.exit(); - return true; + // + app.isExiting = true; } return super.onKeyDown(keyCode, event); } @@ -467,7 +471,7 @@ public class Main extends PiztorAct { @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); + // getMenuInflater().inflate(R.menu.main, menu); return false; } diff --git a/client/Piztor/src/com/macaroon/piztor/MainActivity.java b/client/Piztor/src/com/macaroon/piztor/MainActivity.java deleted file mode 100644 index 483112d..0000000 --- a/client/Piztor/src/com/macaroon/piztor/MainActivity.java +++ /dev/null @@ -1,133 +0,0 @@ -package com.macaroon.piztor; - -import java.util.Vector; - -import android.app.Activity; -import android.os.Bundle; -import android.os.Handler; -import android.os.Message; -import android.view.Menu; -import android.view.View; - -public class MainActivity extends Activity { - public String token = ""; - public String uname = ""; - public int com; - public int sec; - public int step = 0; - Transam t; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); - t = new Transam("192.168.1.171",2223,handler); - Thread thread = new Thread(t); - thread.start(); - - } - - Handler handler = new Handler() { - public void handleMessage(Message msg) { - switch (msg.what) { - case 0: - token = ((ResLogin) msg.obj ).t; - uname = ((ResLogin) msg.obj ).uinfo.username; - com = ((ResLogin) msg.obj ).uinfo.gid.company; - sec = ((ResLogin) msg.obj ).uinfo.gid.section; - System.out.println(com); - System.out.println(sec); - System.out.println(((ResLogin) msg.obj ).uinfo.sex); - for(int i=0;i<((ResLogin) msg.obj ).subscribeNumber;i++){ - System.out.println(((ResLogin) msg.obj ).sublist.get(i).company); - System.out.println(((ResLogin) msg.obj ).sublist.get(i).section); - } - System.out.println(token); - break; - case 2: - ResUserInfo r = (ResUserInfo) msg.obj ; - System.out.println(r.number); - for(int i=0;i<r.number;i++){ - System.out.println(r.uinfo.get(i).nickname); - System.out.println(r.uinfo.get(i).latitude); - System.out.println(r.uinfo.get(i).longitude); - } - break; - case 100: - System.out.println(((ResPushMessage) msg.obj).message); - break; - case 101: - int nn = ((ResPushLocation)msg.obj).n; - Vector<RLocation> ll = ((ResPushLocation)msg.obj).l; - for(int i=0;i<nn;i++){ - System.out.println(ll.get(i).latitude + " " + ll.get(i).longitude); - } - break; - case -1: - System.out.println(-1); - } - super.handleMessage(msg); - } - }; - - - - @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; - } - - - - - - public void sendMessage(View view) { - - if(step == 0){ - long time = System.currentTimeMillis(); - ReqLogin r = new ReqLogin("hello","world",time,2000); - t.send(r); - step++; - } - else if(step == 1){ - long time = System.currentTimeMillis(); - ReqUpdate r = new ReqUpdate (token,uname,123.456,654.321,time,2000); - t.send(r); - step++; - } - else if(step == 2){ - long time = System.currentTimeMillis(); - ReqSendMessage r = new ReqSendMessage (token,uname,"wurusai",time,2000); - t.send(r); - step++; - } - else if(step == 3){ - long time = System.currentTimeMillis(); - ReqLogout r = new ReqLogout(token,uname,time,2000); - t.send(r); - step++; - } - - - - } - - - - - - - - - - - -} - - - - - - diff --git a/client/Piztor/src/com/macaroon/piztor/MapMaker.java b/client/Piztor/src/com/macaroon/piztor/MapMaker.java index 3268a57..d3699c3 100644 --- a/client/Piztor/src/com/macaroon/piztor/MapMaker.java +++ b/client/Piztor/src/com/macaroon/piztor/MapMaker.java @@ -30,7 +30,7 @@ import com.baidu.mapapi.map.PopupClickListener; import com.baidu.mapapi.map.PopupOverlay; import com.baidu.platform.comapi.basestruct.GeoPoint; -public class MapMaker extends Activity { +public class MapMaker { // MapView controlling component private MapView mMapView = null; @@ -138,7 +138,7 @@ public class MapMaker extends Activity { OverlayItem item = getItem(index); UserInfo tmpInfo = preMapInfo .getUserInfo(markerToInt.get(item)); - String itemInfo = tmpInfo.company + "连" + tmpInfo.section + "班"; + String itemInfo = tmpInfo.company + "连" + tmpInfo.section + "班 " + tmpInfo.nickname; popupText.setText(itemInfo); Bitmap bitmap = BMapUtil.getBitmapFromView(popupInfo); popLay.showPopup(bitmap, item.getPoint(), 32); @@ -180,15 +180,16 @@ public class MapMaker extends Activity { } }); int num = mOffline.scan(); - String msg = ""; + if (num == 0) { // msg = // "No offline map found. It may have been loaded already or misplaced."; } else { - msg = String.format("Loaded %d offline maps.", num); + Toast.makeText(context, String.format("加载了%d个离线地图包", num), + Toast.LENGTH_SHORT).show(); } Log.d("offline", "inited"); - Toast.makeText(context, msg, Toast.LENGTH_SHORT).show(); + } /** @@ -266,7 +267,7 @@ public class MapMaker extends Activity { InitLocationOverlay(); InitMyOverLay(); InitPopup(); - InitOfflineMap(); + //InitOfflineMap(); myBM = new Drawable[20]; initMyIcons(); // InitTouchListenr(); @@ -302,6 +303,14 @@ public class MapMaker extends Activity { } } + boolean isInvalidLocation(GeoPoint point) { + if (point == null) return false; + if (point.getLatitudeE6() / 1E6 > 180.0 || point.getLatitudeE6() / 1E6 < -180.0 + || point.getLongitudeE6() > 180.0 || point.getLongitudeE6() / 1E6 < -180.0) + return false; + return true; + } + /** * Update to draw other users */ @@ -324,6 +333,11 @@ public class MapMaker extends Activity { markerToInt.remove(hash.get(i.uid)); hash.remove(i.uid); } + if (mapInfo.getUserInfo(i.uid) != null && isInvalidLocation(mapInfo.getUserInfo(i.uid).location)) { + mOverlay.removeItem(hash.get(i.uid)); + markerToInt.remove(hash.get(i.uid)); + hash.remove(i.uid); + } } } mMapView.refresh(); @@ -334,26 +348,28 @@ public class MapMaker extends Activity { if (i.uid == preMapInfo.myInfo.uid) continue; if (hash.containsKey(i.uid) == false) { - GeoPoint p = new GeoPoint((int) (i.getLatitude() * 1E6), - (int) (i.getLongitude() * 1E6)); - curItem = new OverlayItem(p, "USERNAME_HERE", + if (isInvalidLocation(i.location)) { + + } else { + curItem = new OverlayItem(i.location, "USERNAME_HERE", "USER_SNIPPET_HERE"); - // TODO getDrawable - // ///////////////////////////// - curItem.setMarker(getGroupIcon(i.section)); - mOverlay.addItem(curItem); - hash.put(i.uid, curItem); - markerToInt.put(curItem, i.uid); - // if (mMapView != null) - // mMapView.refresh(); + // TODO getDrawable + // ///////////////////////////// + curItem.setMarker(getGroupIcon(i.section)); + mOverlay.addItem(curItem); + hash.put(i.uid, curItem); + markerToInt.put(curItem, i.uid); + } } else { - GeoPoint p = new GeoPoint((int) (i.getLatitude() * 1E6), - (int) (i.getLongitude() * 1E6)); - curItem = hash.get(i.uid); - curItem.setGeoPoint(p); - mOverlay.updateItem(curItem); - // if (mMapView != null) - // mMapView.refresh(); + if (isInvalidLocation(i.location)) { + mOverlay.removeItem(hash.get(i.uid)); + markerToInt.remove(hash.get(i.uid)); + hash.remove(i.uid); + } else { + curItem = hash.get(i.uid); + curItem.setGeoPoint(i.location); + mOverlay.updateItem(curItem); + } } } if (mMapView != null) { @@ -488,20 +504,4 @@ public class MapMaker extends Activity { clearOverlay(null); mOverlay.addItem(mItems); } - - @Override - protected void onPause() { - mMapView.onPause(); - } - - @Override - protected void onResume() { - mMapView.onResume(); - } - - @Override - protected void onDestroy() { - mMapView.destroy(); - } - } diff --git a/client/Piztor/src/com/macaroon/piztor/Rlocation.java b/client/Piztor/src/com/macaroon/piztor/Rlocation.java deleted file mode 100644 index c2d429c..0000000 --- a/client/Piztor/src/com/macaroon/piztor/Rlocation.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.macaroon.piztor;
-
-class Rlocation{
- int id; //id
- double latitude; //latitude
- double longitude; //longitude
-
- Rlocation(int i,double lat,double lot){
- id = i;
- latitude = lat;
- longitude = lot;
- }
-}
\ No newline at end of file diff --git a/client/Piztor/src/com/macaroon/piztor/Settings.java b/client/Piztor/src/com/macaroon/piztor/Settings.java index ad98662..8b4a948 100644 --- a/client/Piztor/src/com/macaroon/piztor/Settings.java +++ b/client/Piztor/src/com/macaroon/piztor/Settings.java @@ -147,7 +147,7 @@ public class Settings extends PiztorAct { public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if (progress == 0) progress = 1; - refreshrate.setText(progress + "s each update"); + refreshrate.setText(progress + "s一次更新"); currentRate = progress; Log.d("seek", "cur " + progress); } @@ -237,6 +237,13 @@ public class Settings extends PiztorAct { } @Override + protected void onResume() { + super.onResume(); + if (app.isExiting || app.isLogout) + finish(); + } + + @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.setting, menu); diff --git a/client/Piztor/src/com/macaroon/piztor/SubscribeSettings.java b/client/Piztor/src/com/macaroon/piztor/SubscribeSettings.java index 74d1b83..ff7c00d 100644 --- a/client/Piztor/src/com/macaroon/piztor/SubscribeSettings.java +++ b/client/Piztor/src/com/macaroon/piztor/SubscribeSettings.java @@ -3,8 +3,10 @@ package com.macaroon.piztor; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.Vector; import android.app.Activity; @@ -33,7 +35,6 @@ public class SubscribeSettings extends PiztorAct { static class ReCall extends Handler { WeakReference<SubscribeSettings> outerClass; - ReCall(SubscribeSettings activity) { outerClass = new WeakReference<SubscribeSettings>(activity); } @@ -109,6 +110,7 @@ public class SubscribeSettings extends PiztorAct { private EditText edit_company; private EditText edit_section; private Vector<RGroup> listGroup; + private Set<Integer> recSubcribe; void upMapInfo(Vector<RLocation> l) { @@ -142,28 +144,48 @@ public class SubscribeSettings extends PiztorAct { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.subscribe_settings); + mShowInfo = (TextView) findViewById(R.id.textView1); + mShowInfo.setText("若要关注整个连请将班级号留空"); + listGroup = new Vector<RGroup>(); + recSubcribe = new HashSet<Integer>(); + app = (myApp) getApplication(); app.transam.setHandler(handler); mListView = (ListView) findViewById(R.id.listView1); edit_company = (EditText) findViewById(R.id.subscribe_company); edit_section = (EditText) findViewById(R.id.subscribe_section); mList = new ArrayList<HashMap<String, Object>>(); + final MySimpleAdapter simpleAdapter = new MySimpleAdapter(this, mList, R.layout.subscribe_item, new String[] { "subscribe_text", "btnadd" }, new int[] { R.id.textView1, R.id.button_add }); + mListView.setAdapter(simpleAdapter); // TODO get current subscribe + for (RGroup i : ((myApp) getApplication()).sublist) { + if (i.section == 255) + recSubcribe.add(i.company); + } + for (int i : recSubcribe) { + HashMap<String, Object> map = new HashMap<String, Object>(); + map.put("subscribe_text", i + "连"); + mList.add(map); + + RGroup listItem = new RGroup(i, 255); + listGroup.add(listItem); + simpleAdapter.notifyDataSetChanged(); + } + for (RGroup i : ((myApp) getApplication()).sublist) { + if (i.section == 255) continue; + //else HashMap<String, Object> map = new HashMap<String, Object>(); - int cc = i.company; - int ss = i.section; - - map.put("subscribe_text", cc + "连 " + ss + "班"); + map.put("subscribe_text", i.company + "连 " + i.section + "班"); mList.add(map); - RGroup listItem = new RGroup(cc, ss); + RGroup listItem = new RGroup(i.company, i.section); listGroup.add(listItem); simpleAdapter.notifyDataSetChanged(); } @@ -172,21 +194,75 @@ public class SubscribeSettings extends PiztorAct { @Override public void onClick(View v) { - int cc = Integer.parseInt(edit_company.getText().toString()); - int ss = Integer.parseInt(edit_section.getText().toString()); - HashMap<String, Object> map = new HashMap<String, Object>(); - map.put("subscribe_text", cc + "连 " + ss + "班"); - mList.add(map); + + int cc,ss; + //Log.d("sub", edit_company.getText().toString() + " " + edit_section.getText().toString()); + if (edit_company.getText().toString().length() == 0) { + mShowInfo.setText("连号为空,请输入正确的连队、班级号(关注整个连,则班号留空)"); + Log.d("sub", "连号为空"); + return; + } else { + cc = Integer.parseInt(edit_company.getText().toString()); + if (cc <= 0 || cc > 40) { + mShowInfo.setText("连号超限,请输入正确的连队、班级号(关注整个连,则班号留空)"); + Log.d("sub", "连号超限" + cc); + return; + } + } + + if (edit_section.getText().toString().length() == 0) { + ss = 255; + Log.d("sub", "订阅全连" + cc); + } else { + ss = Integer.parseInt(edit_section.getText().toString()); + if (ss <= 0 || ss > 20) { + mShowInfo.setText("班号超限,请输入正确的连队、班级号(关注整个连,则班号留空)"); + Log.d("sub", "班号超限" + ss); + return; + } + } + + // TODO get real company and section number + if (recSubcribe.contains(cc)) return; + if (ss == 255) { + recSubcribe.add(cc); + for (int i = 0; i < listGroup.size(); i++) { + if (listGroup.get(i).company == cc) { + listGroup.remove(i); + mList.remove(i); + i--; + simpleAdapter.notifyDataSetChanged(); + } + } + + RGroup listItem = new RGroup(cc, 255); + listGroup.add(listItem); + HashMap<String, Object> map = new HashMap<String, Object>(); + map.put("subscribe_text", cc + "连"); + mList.add(map); + simpleAdapter.notifyDataSetChanged(); + subscribe(); + mShowInfo.setText("已关注第" + cc + "连"); + return; + } RGroup listItem = new RGroup(cc, ss); - listGroup.add(listItem); - subscribe(); + for (RGroup i : listGroup) { + if (i.company == cc && i.section == ss) + return; + } + listGroup.add(listItem); + + HashMap<String, Object> map = new HashMap<String, Object>(); + map.put("subscribe_text", cc + "连 " + ss + "班"); + mList.add(map); - simpleAdapter.notifyDataSetChanged(); - mShowInfo.setText("添加了一条订阅"); + subscribe(); + + simpleAdapter.notifyDataSetChanged(); + mShowInfo.setText("已关注第" + cc + "连" + ss + "班"); } }); - mShowInfo = (TextView) findViewById(R.id.textView1); } private class MySimpleAdapter extends SimpleAdapter { @@ -223,19 +299,14 @@ public class SubscribeSettings extends PiztorAct { // TODO Auto-generated method stub super.handleMessage(msg); switch (msg.what) { - case BUTTON_ADD: - HashMap<String, Object> map = new HashMap<String, Object>(); - mList.add(map); - notifyDataSetChanged(); - break; - case BUTTON_DELETE: + if (listGroup.get(msg.arg1).section == 255) + recSubcribe.remove(listGroup.get(msg.arg1).company); mList.remove(msg.arg1); - RGroup listItem = listGroup.get(msg.arg1); listGroup.remove(msg.arg1); subscribe(); notifyDataSetChanged(); - mShowInfo.setText("删除了第" + (msg.arg1 + 1) + "条订阅"); + mShowInfo.setText("删除了第" + (msg.arg1 + 1) + "条关注"); break; } } diff --git a/client/Piztor/src/com/macaroon/piztor/UpdateInfo.java b/client/Piztor/src/com/macaroon/piztor/UpdateInfo.java index 0521432..66ead66 100644 --- a/client/Piztor/src/com/macaroon/piztor/UpdateInfo.java +++ b/client/Piztor/src/com/macaroon/piztor/UpdateInfo.java @@ -1,5 +1,144 @@ package com.macaroon.piztor; -public class UpdateInfo { +import java.lang.ref.WeakReference; +import java.util.Vector; + +import com.baidu.platform.comapi.basestruct.GeoPoint; +import com.macaroon.piztor.Settings.ReCall; + +import android.os.Bundle; +import android.os.Handler; +import android.os.Message; +import android.util.Log; +import android.view.Menu; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; +import android.widget.TextView; +import android.widget.Toast; + +public class UpdateInfo extends PiztorAct { + TextView userName, nickName; + EditText oldPass, newPass; + Button submit; + + static class ReCall extends Handler { + WeakReference<UpdateInfo> outerClass; + + ReCall(UpdateInfo activity) { + outerClass = new WeakReference<UpdateInfo>(activity); + } + + @Override + public void handleMessage(Message m) { + UpdateInfo out = outerClass.get(); + if (out == null) { + System.out.println("act被回收了"); + } + switch (m.what) { + case Res.Login:// 上传自己信息成功or失败 + Log.d("update location", "successfull"); + break; + case Res.UserInfo:// 得到用户信息 + ResUserInfo userInfo = (ResUserInfo) m.obj; + System.out.println("revieve ........" + userInfo.uinfo.size()); + Vector<RUserInfo> uinfo = userInfo.uinfo; + for (RUserInfo info : uinfo) { + System.out + .println(info.latitude + " " + info.longitude); + UserInfo r = out.mapInfo.getUserInfo(info.uid); + if (r != null) { + r.setInfo(info.gid.company, info.gid.section, info.sex, + info.nickname); + r.setLocation(info.latitude, info.longitude); + } else { + r = new UserInfo(info.uid); + r.setInfo(info.gid.company, info.gid.section, info.sex, + info.nickname); + r.setLocation(info.latitude, info.longitude); + out.mapInfo.addUserInfo(r); + } + } + break; + case Res.Logout:// 登出 + out.appMgr.trigger(AppMgr.logout); + break; + case Res.SendMessage: + Log.d(LogInfo.resquest, "send message successfully"); + break; + case Res.SetPassword: + ResSetPassword res = (ResSetPassword) m.obj; + switch (res.type) { + case 0: + out.receiveMessage("修改成功,请重新登录"); + out.appMgr.trigger(AppMgr.logout); + break; + case 1: + out.appMgr.trigger(AppMgr.logout); + break; + case 3: + out.receiveMessage("密码错误"); + default: + break; + } + break; + case -1: + out.appMgr.trigger(AppMgr.logout); + break; + default: + break; + } + } + } + ReCall handler = new ReCall(this); + void receiveMessage(String msg) { + Log.d("recieve message", msg); + Toast toast = Toast.makeText(getApplicationContext(), msg, + Toast.LENGTH_LONG); + toast.show(); + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + id = "updateInfo"; + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_updateinfo); + } + + @Override + protected void onStart() { + super.onStart(); + oldPass = (EditText) findViewById(R.id.password_old); + newPass = (EditText) findViewById(R.id.password_new); + submit = (Button) findViewById(R.id.btn_submit); + userName = (TextView) findViewById(R.id.username); + nickName = (TextView) findViewById(R.id.nickname); + userName.setText(app.username); + nickName.setText(app.mapInfo.myInfo.nickname); + submit.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View arg0) { + String oldpass = oldPass.getText().toString(); + String newpass = newPass.getText().toString(); + ReqSetPassword req = new ReqSetPassword(app.token, + app.username, oldpass, newpass, System + .currentTimeMillis(), 3000); + transam.send(req); + } + }); + } + + @Override + protected void onResume() { + super.onResume(); + transam.setHandler(handler); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.update_info, menu); + return true; + } } diff --git a/client/Piztor/src/com/macaroon/piztor/myApp.java b/client/Piztor/src/com/macaroon/piztor/myApp.java index e60e9b4..ef99a3b 100644 --- a/client/Piztor/src/com/macaroon/piztor/myApp.java +++ b/client/Piztor/src/com/macaroon/piztor/myApp.java @@ -10,9 +10,10 @@ import android.util.Log; @SuppressLint("UseSparseArrays") public class myApp extends Application { - private static final String strKey = "8a0ae50048d103b2b8b12b7066f4ea7d"; + private static final String strKey = "E612ee541946c90d7b9add0347c9e601"; BMapManager mBMapManager; - + boolean isExiting = false; + boolean isLogout = false; String ip = "202.120.7.4"; // static String ip = "69.85.86.42"; // static String ip = "192.168.1.101"; @@ -23,7 +24,6 @@ public class myApp extends Application { AppMgr appMgr; - // TODO fix Handler handler; Transam transam; Thread tTransam; |