summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTeddy <ted.sybil@gmail.com>2013-09-01 23:50:13 +0800
committerTeddy <ted.sybil@gmail.com>2013-09-01 23:50:13 +0800
commite13b38f847050b4ff93bf111104a927a0f2d57b5 (patch)
tree10e50dd003f6deaee446250d10fa50d4ed9863fc
parent4be449207cd12831a1858860eba1c8bb0618aa80 (diff)
parent2f6cb801f2374fd6ded925fb1438d6ce72837d81 (diff)
Merge branch 'master' of github.com:Determinant/piztor
-rw-r--r--client/Piztor/res/drawable/footbar_fetch.pngbin4849 -> 742 bytes
-rw-r--r--client/Piztor/res/drawable/footbar_fetch_1.pngbin3300 -> 319 bytes
-rw-r--r--client/Piztor/res/drawable/footbar_settings.pngbin4340 -> 1051 bytes
-rw-r--r--client/Piztor/res/drawable/footbar_settings0.pngbin0 -> 4340 bytes
-rw-r--r--client/Piztor/res/drawable/footbar_settings_1.pngbin3205 -> 383 bytes
-rw-r--r--client/Piztor/res/layout/activity_login.xml26
-rw-r--r--client/Piztor/res/layout/activity_settings.xml56
-rw-r--r--client/Piztor/res/layout/subscribe_settings.xml4
-rw-r--r--client/Piztor/res/values/strings.xml5
-rw-r--r--client/Piztor/src/com/macaroon/piztor/AlertMaker.java28
-rw-r--r--client/Piztor/src/com/macaroon/piztor/EException.java9
-rw-r--r--client/Piztor/src/com/macaroon/piztor/Login.java5
-rw-r--r--client/Piztor/src/com/macaroon/piztor/Main.java49
-rw-r--r--client/Piztor/src/com/macaroon/piztor/MapInfo.java1
-rw-r--r--client/Piztor/src/com/macaroon/piztor/MapMaker.java55
-rw-r--r--client/Piztor/src/com/macaroon/piztor/PushClient.java24
-rw-r--r--client/Piztor/src/com/macaroon/piztor/Settings.java1
-rw-r--r--client/Piztor/src/com/macaroon/piztor/SocketClient.java3
-rw-r--r--client/Piztor/src/com/macaroon/piztor/SubscribeSettings.java69
-rw-r--r--client/Piztor/src/com/macaroon/piztor/Transam.java50
-rw-r--r--client/Piztor/src/com/macaroon/piztor/UpdateInfo.java22
21 files changed, 277 insertions, 130 deletions
diff --git a/client/Piztor/res/drawable/footbar_fetch.png b/client/Piztor/res/drawable/footbar_fetch.png
index 138ef6a..71d1a20 100644
--- a/client/Piztor/res/drawable/footbar_fetch.png
+++ b/client/Piztor/res/drawable/footbar_fetch.png
Binary files differ
diff --git a/client/Piztor/res/drawable/footbar_fetch_1.png b/client/Piztor/res/drawable/footbar_fetch_1.png
index 0d098ab..564b1da 100644
--- a/client/Piztor/res/drawable/footbar_fetch_1.png
+++ b/client/Piztor/res/drawable/footbar_fetch_1.png
Binary files differ
diff --git a/client/Piztor/res/drawable/footbar_settings.png b/client/Piztor/res/drawable/footbar_settings.png
index a6987f8..7879ceb 100644
--- a/client/Piztor/res/drawable/footbar_settings.png
+++ b/client/Piztor/res/drawable/footbar_settings.png
Binary files differ
diff --git a/client/Piztor/res/drawable/footbar_settings0.png b/client/Piztor/res/drawable/footbar_settings0.png
new file mode 100644
index 0000000..a6987f8
--- /dev/null
+++ b/client/Piztor/res/drawable/footbar_settings0.png
Binary files differ
diff --git a/client/Piztor/res/drawable/footbar_settings_1.png b/client/Piztor/res/drawable/footbar_settings_1.png
index 8b61042..b76fe9f 100644
--- a/client/Piztor/res/drawable/footbar_settings_1.png
+++ b/client/Piztor/res/drawable/footbar_settings_1.png
Binary files differ
diff --git a/client/Piztor/res/layout/activity_login.xml b/client/Piztor/res/layout/activity_login.xml
index c408a1d..cb27495 100644
--- a/client/Piztor/res/layout/activity_login.xml
+++ b/client/Piztor/res/layout/activity_login.xml
@@ -1,10 +1,12 @@
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content" >
<RelativeLayout
android:orientation="vertical"
android:id="@+id/login_layout"
android:background="@android:color/black"
android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- xmlns:android="http://schemas.android.com/apk/res/android">
+ android:layout_height="fill_parent">
<LinearLayout
@@ -12,14 +14,23 @@
android:layout_height="wrap_content"
android:background="@android:color/black"
android:gravity="center_horizontal"
- android:orientation="vertical" >
+ android:orientation="vertical"
+ android:layout_marginTop="16dip">
<ImageView
android:id="@+id/main_headbar_img"
android:layout_width="180dp"
- android:layout_height="190dp"
+ android:layout_height="200dp"
android:layout_gravity="center_horizontal"
android:src="@drawable/title_logo" />
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:gravity="center"
+ android:text="@string/app_name"
+ android:textSize="30dip"
+ android:textColor="#FFFFFF"/>
</LinearLayout>
<LinearLayout
@@ -27,7 +38,7 @@
android:id="@+id/user_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
- android:layout_marginTop="200.0dip"
+ android:layout_marginTop="260.0dip"
android:layout_marginLeft="28.0dip"
android:layout_marginRight="28.0dip">
<EditText
@@ -75,8 +86,9 @@
android:layout_height="wrap_content"
android:layout_marginLeft="70.0dip"
android:layout_marginRight="70.0dip"
- android:layout_marginTop="12.0dip"
+ android:layout_marginTop="40.0dip"
android:text="@string/login"
android:layout_below="@id/user_layout" />
-</RelativeLayout> \ No newline at end of file
+</RelativeLayout>
+</ScrollView> \ 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 36bacf3..ba67683 100644
--- a/client/Piztor/res/layout/activity_settings.xml
+++ b/client/Piztor/res/layout/activity_settings.xml
@@ -30,16 +30,18 @@
android:layout_gravity="center"
android:gravity="center"
android:layout_marginTop="10dip"
+ android:layout_marginBottom="2dip"
android:text="@string/GPSrefreshrate"
android:textColor="@android:color/white"
- android:textSize="20dip" />
+ android:textSize="17dip" />
<TextView
android:id="@+id/settings_GPSrefreshrate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:textSize="20dip"
+ android:textSize="17dip"
android:layout_marginTop="10dip"
- android:layout_marginLeft="10dip"
+ android:layout_marginLeft="4dip"
+ android:layout_marginBottom="2dip"
android:layout_gravity="center_vertical"
android:textColor="@android:color/white"
android:layout_toRightOf="@+id/settings_GPSrefreshrate_text"
@@ -87,31 +89,26 @@
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:background="#ffc0c3c4" />
+
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:gravity="center"
- android:layout_marginTop="10dip"
- android:orientation="horizontal">
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:gravity="center"
- android:textSize="30dip"
- android:textColor="@android:color/white"
- android:text="@string/subscribe_info"/>
-
- <Button
- android:id="@+id/settings_btn_subscribe"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginLeft="20dip"
- android:text="@string/change"
- android:textSize="22dip" />
-
- </LinearLayout>
+ android:layout_marginLeft="50dip"
+ android:layout_marginRight="50dip"
+ android:orientation="vertical">
+
+ <Button
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:paddingTop="5dip"
+ android:paddingBottom="5dip"
+ android:layout_marginTop="20dip"
+ android:text="@string/change"
+ android:textSize="20dip"
+ android:textColor="@android:color/white"
+ android:background="#0F9D58"
+ android:id="@+id/settings_btn_subscribe" />
+ </LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="1.0px"
@@ -141,13 +138,16 @@
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:id="@+id/show_by_team"
+ android:id="@+id/show_by_team"
+ android:textSize="18dip"
android:text="@string/show_team"
android:checked="true"/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_marginLeft="10dip"
android:id="@+id/show_by_sex"
+ android:textSize="18dip"
android:text="@string/show_sex"/>
</RadioGroup>
</LinearLayout>
@@ -171,7 +171,7 @@
android:paddingTop="5dip"
android:paddingBottom="5dip"
android:text="@string/update_info"
- android:textSize="30dip"
+ android:textSize="20dip"
android:textColor="@android:color/white"
android:background="#4285F4"
android:id="@+id/settings_btn_updateinfo" />
@@ -182,7 +182,7 @@
android:paddingBottom="5dip"
android:layout_marginTop="20dip"
android:text="@string/logout"
- android:textSize="30dip"
+ android:textSize="20dip"
android:textColor="@android:color/white"
android:background="#DB4437"
android:id="@+id/settings_btn_logout" />
diff --git a/client/Piztor/res/layout/subscribe_settings.xml b/client/Piztor/res/layout/subscribe_settings.xml
index 1bfd975..a90837c 100644
--- a/client/Piztor/res/layout/subscribe_settings.xml
+++ b/client/Piztor/res/layout/subscribe_settings.xml
@@ -19,7 +19,7 @@
android:gravity="center"
android:orientation="horizontal">
<EditText
- android:layout_width="120dip"
+ android:layout_width="80dip"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="10dip"
@@ -28,7 +28,7 @@
android:phoneNumber="true"
android:id="@+id/subscribe_company"/>
<EditText
- android:layout_width="120dip"
+ android:layout_width="80dip"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:layout_toRightOf="@+id/subscribe_company"
diff --git a/client/Piztor/res/values/strings.xml b/client/Piztor/res/values/strings.xml
index 82132ed..25e980a 100644
--- a/client/Piztor/res/values/strings.xml
+++ b/client/Piztor/res/values/strings.xml
@@ -6,7 +6,7 @@
<string name="hello_world">Hello world!</string>
<string name="settings">设置</string>
<string name="search">搜索</string>
- <string name="fetch">获取</string>
+ <string name="fetch">上传</string>
<string name="checkin">签到</string>
<string name="focus">聚焦</string>
<string name="show_sex">按性别</string>
@@ -25,7 +25,7 @@
<string name="logout">注销</string>
<string name="update_info">修改密码</string>
<string name="subscribe_info">关注信息</string>
- <string name="change">查看及修改</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>
@@ -39,5 +39,6 @@
<string name="new_password">新密码</string>
<string name="submit">提交</string>
<string name="colormode">着色方式</string>
+ <string name="save">保存</string>
</resources>
diff --git a/client/Piztor/src/com/macaroon/piztor/AlertMaker.java b/client/Piztor/src/com/macaroon/piztor/AlertMaker.java
index b1087a2..eec01f5 100644
--- a/client/Piztor/src/com/macaroon/piztor/AlertMaker.java
+++ b/client/Piztor/src/com/macaroon/piztor/AlertMaker.java
@@ -105,6 +105,32 @@ public class AlertMaker {
closeBoard(context);
}
+public void showRemoveMarkerAlert() {
+
+ closeBoard(context);
+ AlertDialog.Builder removeDialog = new AlertDialog.Builder(context);
+ removeDialog.setTitle("取消路标");
+ removeDialog.setMessage("是否取消路标?");
+ removeDialog.setPositiveButton("确定",
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ mapMaker.mOverlay.removeItem(mapMaker.nowMarker);
+ mapMaker.nowMarker = null;
+ mapMaker.mMapView.refresh();
+ mapMaker.popLay.hidePop();
+ }
+ });
+ removeDialog.setNegativeButton("取消",
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ mapMaker.popLay.hidePop();
+ dialog.cancel();
+ }
+ });
+ removeDialog.show();
+ closeBoard(context);
+ }
+
public long toTimestamp(int hour, int minute) {
calendar = Calendar.getInstance();
@@ -112,7 +138,7 @@ public class AlertMaker {
calendar.get(Calendar.MONTH),
calendar.get(Calendar.DAY_OF_MONTH),
hour,minute);
- return calendar.getTimeInMillis();
+ return calendar.getTimeInMillis()/1000;
}
//TODO
diff --git a/client/Piztor/src/com/macaroon/piztor/EException.java b/client/Piztor/src/com/macaroon/piztor/EException.java
index 39d53c8..92f2ab7 100644
--- a/client/Piztor/src/com/macaroon/piztor/EException.java
+++ b/client/Piztor/src/com/macaroon/piztor/EException.java
@@ -13,7 +13,7 @@ public class EException extends Exception {
static final int EStatusFailedException =107;
static final int ELevelFailedException =108;
static final int EPasswordFailedException =109;
-
+ static final int ESubscribeFailedException =110;
private static final long serialVersionUID = 100L;
int Rtype;
@@ -90,4 +90,11 @@ public class EException extends Exception {
}
}
+ class ESubscribeFailedException extends EException{
+ private static final long serialVersionUID = 110L;
+ public ESubscribeFailedException(int t,long timep) {
+ super(110,t,timep);
+ }
+ }
+
\ No newline at end of file
diff --git a/client/Piztor/src/com/macaroon/piztor/Login.java b/client/Piztor/src/com/macaroon/piztor/Login.java
index 3b9cbc2..22c8c91 100644
--- a/client/Piztor/src/com/macaroon/piztor/Login.java
+++ b/client/Piztor/src/com/macaroon/piztor/Login.java
@@ -8,6 +8,7 @@ import android.util.Log;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.View;
+import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
@@ -86,7 +87,11 @@ public class Login extends PiztorAct {
protected void onCreate(Bundle savedInstanceState) {
id = "login";
super.onCreate(savedInstanceState);
+ requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
+ requestWindowFeature(Window.FEATURE_PROGRESS);
setContentView(R.layout.activity_login);
+ setProgressBarIndeterminateVisibility(true);
+ setProgressBarVisibility(true);
}
@Override
diff --git a/client/Piztor/src/com/macaroon/piztor/Main.java b/client/Piztor/src/com/macaroon/piztor/Main.java
index 052e267..5951db1 100644
--- a/client/Piztor/src/com/macaroon/piztor/Main.java
+++ b/client/Piztor/src/com/macaroon/piztor/Main.java
@@ -14,6 +14,7 @@ import android.view.Gravity;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.View;
+import android.view.Window;
import android.view.inputmethod.InputMethodManager;
import android.widget.ImageButton;
import android.widget.Toast;
@@ -53,13 +54,14 @@ public class Main extends PiztorAct {
LocationData locData = null;
public MyLocationListener myListener = new MyLocationListener();
boolean isFirstLocation = true;
- public static int GPSrefreshrate = 5;
- private final int checkinRadius = 10;
+ public static int GPSrefreshrate = 20;
+ private final double checkinRadius = 10.0;
ImageButton btnCheckin, btnFetch, btnFocus, btnSettings;
static class ReCall extends Handler {
WeakReference<Main> outerClass;
+ String id = "main";
ReCall(Main activity) {
outerClass = new WeakReference<Main>(activity);
@@ -71,6 +73,7 @@ public class Main extends PiztorAct {
if (out == null) {
System.out.println("act被回收了");
}
+ Log.d("marker", "what is " + m.what);
switch (m.what) {
case Res.Login:// 上传自己信息成功or失败
Log.d("update location", "successfull");
@@ -122,6 +125,7 @@ public class Main extends PiztorAct {
(int) (pushMarker.latitude * 1e6),
(int) (pushMarker.longitude * 1e6));
markerInfo.markerTimestamp = pushMarker.deadline;
+ Log.d("marker", "Marker received! " + pushMarker.deadline);
out.mapMaker.receiveMarker(markerInfo);
break;
case -1:
@@ -175,6 +179,15 @@ public class Main extends PiztorAct {
toast.show();
}
+ public void updateMyLocation() {
+ if (app.token != null) {
+ app.mapInfo.myInfo.setLocation(locData.latitude, locData.longitude);
+ transam.send(new ReqUpdate(app.token, app.username,
+ locData.latitude, locData.longitude,
+ System.currentTimeMillis(), 2000));
+ }
+ }
+
public class MyLocationListener implements BDLocationListener {
int cnt = 0;
GeoPoint lastPoint = null;
@@ -196,11 +209,7 @@ public class Main extends PiztorAct {
if (lastPoint == null || cnt > 5
|| DistanceUtil.getDistance(point, lastPoint) > 10) {
if (app.token != null) {
- app.mapInfo.myInfo.setLocation(locData.latitude,
- locData.longitude);
- transam.send(new ReqUpdate(app.token, app.username,
- locData.latitude, locData.longitude, System
- .currentTimeMillis(), 2000));
+ updateMyLocation();
lastPoint = point;
cnt = 0;
}
@@ -259,7 +268,7 @@ public class Main extends PiztorAct {
+ app.mapInfo.myInfo.uid);
}
if (e == SuccessFetch)
- flushMap();
+ { }
}
@Override
@@ -293,6 +302,7 @@ public class Main extends PiztorAct {
closeBoard(Main.this);
if (app.mapInfo.myInfo.level != 0) {
alertMaker.showMarkerAlert(arg0);
+ closeBoard(Main.this);
}
}
@@ -324,11 +334,11 @@ public class Main extends PiztorAct {
(int) (locData.longitude * 1E6));
double disFromMarker = DistanceUtil.getDistance(curPoint,
mapMaker.getMakerLocation());
- if (disFromMarker < locData.accuracy) {
+ if (disFromMarker < Math.max(Math.min(locData.accuracy, 20.0), (float)checkinRadius) ) {
alertMaker.showCheckinAlter();
} else {
Toast toast = Toast.makeText(Main.this,
- "请靠近路标", 2000);
+ String.format("请靠近路标,现在距离%.2f米", disFromMarker), 2000);
toast.setGravity(Gravity.TOP, 0, 80);
toast.show();
}
@@ -343,7 +353,13 @@ public class Main extends PiztorAct {
.getSystemService(LOCATION_SERVICE);
isGPSEnabled = locationManager
.isProviderEnabled(locationManager.GPS_PROVIDER);
+
+ requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
+ requestWindowFeature(Window.FEATURE_PROGRESS);
setContentView(R.layout.activity_main);
+ setProgressBarIndeterminateVisibility(true);
+ setProgressBarVisibility(true);
+
app.mBMapManager.start();
mMapView = (MapView) findViewById(R.id.bmapView);
@@ -360,6 +376,7 @@ public class Main extends PiztorAct {
mLocClient.registerLocationListener(myListener);
LocationClientOption option = new LocationClientOption();
option.setOpenGps(true);
+ option.setPriority(LocationClientOption.GpsFirst);
option.setCoorType("bd09ll");
option.setScanSpan(GPSrefreshrate * 1000);
mLocClient.setLocOption(option);
@@ -402,7 +419,17 @@ public class Main extends PiztorAct {
actMgr.trigger(AppMgr.toSettings);
}
});
-
+
+ btnFetch.setOnClickListener(new View.OnClickListener() {
+
+ @Override
+ public void onClick(View arg0) {
+ Toast.makeText(Main.this, "正在定位...", Toast.LENGTH_LONG).show();
+ mLocClient.requestLocation();
+ updateMyLocation();
+ focusOn();
+ }
+ });
}
@Override
diff --git a/client/Piztor/src/com/macaroon/piztor/MapInfo.java b/client/Piztor/src/com/macaroon/piztor/MapInfo.java
index 857ea66..10cb52b 100644
--- a/client/Piztor/src/com/macaroon/piztor/MapInfo.java
+++ b/client/Piztor/src/com/macaroon/piztor/MapInfo.java
@@ -103,6 +103,7 @@ class UserInfo {
this.company = company;
this.section = section;
this.sex = sex;
+ this.nickname = nickName;
}
public GeoPoint getLocation(){
diff --git a/client/Piztor/src/com/macaroon/piztor/MapMaker.java b/client/Piztor/src/com/macaroon/piztor/MapMaker.java
index 967a34d..837df2b 100644
--- a/client/Piztor/src/com/macaroon/piztor/MapMaker.java
+++ b/client/Piztor/src/com/macaroon/piztor/MapMaker.java
@@ -34,7 +34,7 @@ import com.baidu.platform.comapi.basestruct.GeoPoint;
public class MapMaker {
// MapView controlling component
- private MapView mMapView = null;
+ MapView mMapView = null;
MapController mMapController = null;
MKOfflineMap mOffline = null;
@@ -43,7 +43,7 @@ public class MapMaker {
(int) (31.032247 * 1E6), (int) (121.445937 * 1E6));
// Map layers and items
- private MyOverlay mOverlay = null;
+ MyOverlay mOverlay = null;
private OverlayItem curItem = null;
private LocationOverlay mLocationOverlay;
private ArrayList<OverlayItem> mItems = null;
@@ -56,7 +56,7 @@ public class MapMaker {
private HashMap<OverlayItem, Integer> markerToInt = null;
// marker layer
- private OverlayItem nowMarker = null;
+ OverlayItem nowMarker = null;
static int nowMarkerHour;
static int nowMarkerMinute;
static long nowMarkerTimestamp;
@@ -67,7 +67,7 @@ public class MapMaker {
private int nowMarkerLevel;
// Popup component
- private PopupOverlay popLay = null;
+ PopupOverlay popLay = null;
private TextView popupText = null;
private TextView leftText = null;
private View viewCache = null;
@@ -127,8 +127,6 @@ public class MapMaker {
if (nowMarker != null && index == markerIndex) {
OverlayItem item = getItem(index);
- // TODO
- // ///////////////////////////////////////////////////////
leftText.setText(nowMarkerHour + "点");
popupText.setText(nowMarkerMinute + "分");
Bitmap bitmap[] = { BMapUtil.getBitmapFromView(popupLeft),
@@ -137,8 +135,7 @@ public class MapMaker {
popLay.showPopup(bitmap, item.getPoint(), 32);
} else {
OverlayItem item = getItem(index);
- UserInfo tmpInfo = preMapInfo
- .getUserInfo(markerToInt.get(item));
+ UserInfo tmpInfo = app.mapInfo.getUserInfo(markerToInt.get(item));
String itemInfo = tmpInfo.company + "连" + tmpInfo.section + "班 " + tmpInfo.nickname;
popupText.setText(itemInfo);
Bitmap bitmap = BMapUtil.getBitmapFromView(popupInfo);
@@ -243,11 +240,13 @@ public class MapMaker {
// do nothing
}
if (index == 2) {
- // remove current marker
- mOverlay.removeItem(nowMarker);
- nowMarker = null;
- mMapView.refresh();
- popLay.hidePop();
+ // remove current marker if is higher or equal level
+ if (app.mapInfo.myInfo.level >= nowMarkerLevel) {
+ AlertMaker removeAlert = new AlertMaker(context, MapMaker.this);
+ removeAlert.showRemoveMarkerAlert();
+ } else {
+ Toast.makeText(context, "权限不足", Toast.LENGTH_SHORT).show();
+ }
}
}
};
@@ -288,12 +287,13 @@ public class MapMaker {
public Drawable getGroupIcon(UserInfo userInfo) {
if (Main.colorMode == Main.show_by_team) {
- if (userInfo.section == preMapInfo.myInfo.section)
+ if (userInfo.section == app.mapInfo.myInfo.section)
return myBM[0];
else
return myBM[userInfo.section % iconNum + 1];
} else {
- return myBM[userInfo.sex ^ preMapInfo.myInfo.sex];
+ if (userInfo.sex == app.mapInfo.myInfo.sex) return myBM[0];
+ else return myBM[1];
}
}
@@ -334,7 +334,7 @@ public class MapMaker {
// first remove all old users that are not here now
if (preMapInfo != null) {
for (UserInfo i : preMapInfo.getVector()) {
- if (i.uid == preMapInfo.myInfo.uid)
+ if (i.uid == app.mapInfo.myInfo.uid)
continue;
if (mapInfo.getUserInfo(i.uid) == null) {
mOverlay.removeItem(hash.get(i.uid));
@@ -353,7 +353,7 @@ public class MapMaker {
// then update and add items
for (UserInfo i : mapInfo.getVector()) {
- if (i.uid == preMapInfo.myInfo.uid)
+ if (i.uid == app.mapInfo.myInfo.uid)
continue;
if (hash.containsKey(i.uid) == false) {
if (isInvalidLocation(i.location)) {
@@ -386,15 +386,13 @@ public class MapMaker {
checkMarkerTime();
}
- @SuppressWarnings("deprecation")
public void receiveMarker(MarkerInfo markerInfo) {
- Log.d("marker", "Marker received!");
if (nowMarker != null && markerInfo.level >= nowMarkerLevel) {
Log.d("marker", "Old marker replaced by marker with higher level!");
nowMarker.setGeoPoint(markerInfo.markerPoint);
final Calendar cal = Calendar.getInstance();
- cal.setTimeInMillis(markerInfo.markerTimestamp);
+ cal.setTimeInMillis(markerInfo.markerTimestamp * 1000);
Date date = (Date) cal.getTime();
nowMarkerHour = date.getHours();
nowMarkerMinute = date.getMinutes();
@@ -418,7 +416,7 @@ public class MapMaker {
System.out.println(markerInfo.markerPoint.getLatitudeE6() + " "
+ markerInfo.markerPoint.getLongitudeE6());
final Calendar cal = Calendar.getInstance();
- cal.setTimeInMillis(markerInfo.markerTimestamp);
+ cal.setTimeInMillis(markerInfo.markerTimestamp * 1000);
Date date = (Date) cal.getTime();
nowMarkerHour = date.getHours();
nowMarkerMinute = date.getMinutes();
@@ -437,12 +435,13 @@ public class MapMaker {
}
void sendMarker() {
+ Log.d("marker", "Marker prepare! " + nowMarkerTimestamp);
ReqSetMarker req = new ReqSetMarker(app.token, app.username, nowMarker
.getPoint().getLatitudeE6() / 1e6, nowMarker.getPoint()
.getLongitudeE6() / 1e6, (int)nowMarkerTimestamp,
System.currentTimeMillis(), 3000l);
- Log.d("marker", "Sent marker" + nowMarker.getPoint().getLatitudeE6() + " " +
- nowMarker.getPoint().getLongitudeE6());
+
+ Log.d("marker", "Marker sent! " + req.deadline);
app.transam.send(req);
}
@@ -451,14 +450,12 @@ public class MapMaker {
*/
public void DrawMarker(GeoPoint markerPoint) {
- if (preMapInfo == null) return;
-
- if (nowMarker != null && preMapInfo.myInfo.level >= nowMarkerLevel) {
+ if (nowMarker != null && app.mapInfo.myInfo.level >= nowMarkerLevel) {
nowMarker.setGeoPoint(markerPoint);
nowMarkerHour = newMarkerHour;
nowMarkerMinute = newMarkerMinute;
nowMarkerTimestamp = newMarkerTimestamp;
- nowMarkerLevel = preMapInfo.myInfo.level;
+ nowMarkerLevel = app.mapInfo.myInfo.level;
sendMarker();
Log.d("marker", "Sent and replace");
@@ -473,7 +470,7 @@ public class MapMaker {
nowMarkerHour = newMarkerHour;
nowMarkerMinute = newMarkerMinute;
nowMarkerTimestamp = newMarkerTimestamp;
- nowMarkerLevel = preMapInfo.myInfo.level;
+ nowMarkerLevel = app.mapInfo.myInfo.level;
sendMarker();
Log.d("marker", "Send and new");
@@ -504,7 +501,7 @@ public class MapMaker {
}
public void checkMarkerTime() {
- if (nowMarker != null && nowMarkerTimestamp <= System.currentTimeMillis()) {
+ if (nowMarker != null && nowMarkerTimestamp <= System.currentTimeMillis() / 1000) {
AlertMaker lateAlert = new AlertMaker(context, this);
lateAlert.showLateAlert();
removeMarker();
diff --git a/client/Piztor/src/com/macaroon/piztor/PushClient.java b/client/Piztor/src/com/macaroon/piztor/PushClient.java
index 7cecfba..7bd82a6 100644
--- a/client/Piztor/src/com/macaroon/piztor/PushClient.java
+++ b/client/Piztor/src/com/macaroon/piztor/PushClient.java
@@ -5,12 +5,14 @@ import java.io.DataOutputStream;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
+import java.net.SocketException;
import java.net.SocketTimeoutException;
import java.net.UnknownHostException;
import java.util.Vector;
import android.os.Handler;
import android.os.Message;
+import android.util.Log;
@@ -42,12 +44,13 @@ public class PushClient {
private String LastPrint = "";
- public PushClient(String site, int port,int retime) throws UnknownHostException,
+ public PushClient(String site, int port,int retime, Handler handler) throws UnknownHostException,
IOException {
try {
client = new Socket();
client.connect(new InetSocketAddress(site,port), retime);
client.setSoTimeout(2000);
+ recall = handler;
//client.setTcpNoDelay(true);
} catch (UnknownHostException e) {
e.printStackTrace();
@@ -105,15 +108,13 @@ public class PushClient {
return client.isClosed();
}
- public void listen(Handler recall) throws IOException{
+ public void listen() throws IOException{
client.setSoTimeout(0);
DataInputStream in = new DataInputStream(client.getInputStream());
DataOutputStream out = new DataOutputStream(client.getOutputStream());
-
- while(true){
- try {
+ try {
+ while(true){
int len = in.readInt();
- System.out.println(len);
int tmp = in.readUnsignedByte();
byte[] buffer = new byte[32];
in.read(buffer);
@@ -129,6 +130,7 @@ public class PushClient {
String m = new String(b);
in.readUnsignedByte();
if(LastPrint != p) {
+ System.out.println(p);
Message msg = new Message();
msg.what = PushMessage;
msg.obj = new ResPushMessage(m);
@@ -157,6 +159,7 @@ public class PushClient {
n++;
}
if(LastPrint != p) {
+ System.out.println(p);
Message msg = new Message();
msg.obj = new ResPushLocation(n,tmpv);
msg.what = PushLocation;
@@ -178,6 +181,7 @@ public class PushClient {
double lot = in.readDouble();
int dtime = in.readInt();
if(LastPrint != p) {
+
Message msg = new Message();
msg.what = PushMarker;
msg.obj = new ResPushMarker(lat,lot,dtime,lv);
@@ -194,11 +198,13 @@ public class PushClient {
out.flush();