summaryrefslogtreecommitdiff
path: root/client/Piztor/src/com/macaroon
diff options
context:
space:
mode:
Diffstat (limited to 'client/Piztor/src/com/macaroon')
-rw-r--r--client/Piztor/src/com/macaroon/piztor/AlertMaker.java33
-rw-r--r--client/Piztor/src/com/macaroon/piztor/Main.java7
-rw-r--r--client/Piztor/src/com/macaroon/piztor/MapMaker.java48
-rw-r--r--client/Piztor/src/com/macaroon/piztor/Settings.java36
-rw-r--r--client/Piztor/src/com/macaroon/piztor/myApp.java2
5 files changed, 101 insertions, 25 deletions
diff --git a/client/Piztor/src/com/macaroon/piztor/AlertMaker.java b/client/Piztor/src/com/macaroon/piztor/AlertMaker.java
index bc8e138..b1087a2 100644
--- a/client/Piztor/src/com/macaroon/piztor/AlertMaker.java
+++ b/client/Piztor/src/com/macaroon/piztor/AlertMaker.java
@@ -1,5 +1,6 @@
package com.macaroon.piztor;
+import java.io.Closeable;
import java.util.Calendar;
import java.util.Timer;
import java.util.TimerTask;
@@ -87,18 +88,33 @@ public class AlertMaker {
});
gpsDialog.show();
}
+
+ public void showLateAlert() {
+
+ closeBoard(context);
+ AlertDialog.Builder lateDialog = new AlertDialog.Builder(context);
+ lateDialog.setTitle("阿哦");
+ lateDialog.setMessage("你迟到了!");
+ lateDialog.setNeutralButton("知道了", new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface arg0, int arg1) {
+ arg0.cancel();
+ }
+ });
+ lateDialog.show();
+ closeBoard(context);
+ }
public long toTimestamp(int hour, int minute) {
+
calendar = Calendar.getInstance();
- int nhour = calendar.get(Calendar.HOUR_OF_DAY);
- int nminute = calendar.get(Calendar.MINUTE);
- int tmp = 0;
- if (hour > nhour) tmp = (hour - nhour) * 60 + minute - nminute;
- else if (minute > nminute) tmp = minute - nminute;
- timestamp = System.currentTimeMillis() + tmp * 60 * 1000;
- return timestamp;
+ calendar.set(calendar.get(Calendar.YEAR),
+ calendar.get(Calendar.MONTH),
+ calendar.get(Calendar.DAY_OF_MONTH),
+ hour,minute);
+ return calendar.getTimeInMillis();
}
-
+
//TODO
public void updateMarkerTime(int hour, int minute) {
Log.d("time", hour + " " + minute);
@@ -141,6 +157,7 @@ public class AlertMaker {
, calendar.get(Calendar.HOUR_OF_DAY)
, calendar.get(Calendar.MINUTE), true);
markerDialog.show();
+ closeBoard(context);
}
public void showCheckinAlter() {
diff --git a/client/Piztor/src/com/macaroon/piztor/Main.java b/client/Piztor/src/com/macaroon/piztor/Main.java
index 7ac1b21..052e267 100644
--- a/client/Piztor/src/com/macaroon/piztor/Main.java
+++ b/client/Piztor/src/com/macaroon/piztor/Main.java
@@ -40,8 +40,10 @@ public class Main extends PiztorAct {
AlertMaker alertMaker;
GeoPoint markerPoint = null;
private MKMapTouchListener mapTouchListener;
- private final int checkinRadius = 10;
-
+ public static int colorMode = 1;
+ public static int show_by_team = 1;
+ public static int show_by_sex = 2;
+
/**
* Locating component
*/
@@ -52,6 +54,7 @@ public class Main extends PiztorAct {
public MyLocationListener myListener = new MyLocationListener();
boolean isFirstLocation = true;
public static int GPSrefreshrate = 5;
+ private final int checkinRadius = 10;
ImageButton btnCheckin, btnFetch, btnFocus, btnSettings;
diff --git a/client/Piztor/src/com/macaroon/piztor/MapMaker.java b/client/Piztor/src/com/macaroon/piztor/MapMaker.java
index d3699c3..967a34d 100644
--- a/client/Piztor/src/com/macaroon/piztor/MapMaker.java
+++ b/client/Piztor/src/com/macaroon/piztor/MapMaker.java
@@ -12,6 +12,7 @@ import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.location.LocationManager;
import android.util.Log;
+import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
@@ -80,7 +81,7 @@ public class MapMaker {
boolean isGPSEnabled;
private int[] myIcons;
private Drawable[] myBM;
- private final int iconNum = 4;
+ private final int iconNum = 9;
myApp app;
@@ -275,17 +276,25 @@ public class MapMaker {
public void initMyIcons() {
myBM[0] = context.getResources().getDrawable(R.drawable.circle_blue);
- myBM[1] = context.getResources().getDrawable(R.drawable.circle_green);
+ myBM[1] = context.getResources().getDrawable(R.drawable.circle_red);
myBM[2] = context.getResources().getDrawable(R.drawable.circle_glass);
myBM[3] = context.getResources().getDrawable(R.drawable.circle_yellow);
myBM[4] = context.getResources().getDrawable(R.drawable.circle_wood);
+ myBM[5] = context.getResources().getDrawable(R.drawable.circle_green);
+ myBM[6] = context.getResources().getDrawable(R.drawable.circle_metal);
+ myBM[7] = context.getResources().getDrawable(R.drawable.circle_paper);
+ myBM[8] = context.getResources().getDrawable(R.drawable.circle_tan);
}
- public Drawable getGroupIcon(int gid) {
- if (gid == preMapInfo.myInfo.section)
- return myBM[0];
- else
- return myBM[gid % iconNum];
+ public Drawable getGroupIcon(UserInfo userInfo) {
+ if (Main.colorMode == Main.show_by_team) {
+ if (userInfo.section == preMapInfo.myInfo.section)
+ return myBM[0];
+ else
+ return myBM[userInfo.section % iconNum + 1];
+ } else {
+ return myBM[userInfo.sex ^ preMapInfo.myInfo.sex];
+ }
}
/**
@@ -293,7 +302,6 @@ public class MapMaker {
*/
public void UpdateLocationOverlay(LocationData locationData,
boolean hasAnimation) {
-
mLocationOverlay.setData(locationData);
mMapView.refresh();
if (hasAnimation) {
@@ -301,6 +309,7 @@ public class MapMaker {
(int) (locationData.latitude * 1E6),
(int) (locationData.longitude * 1E6)));
}
+ checkMarkerTime();
}
boolean isInvalidLocation(GeoPoint point) {
@@ -315,7 +324,6 @@ public class MapMaker {
* Update to draw other users
*/
public void UpdateMap(MapInfo mapInfo) {
-
if (mapInfo == null) {
if (mOverlay != null && mOverlay.getAllItem().size() != 0) {
mOverlay.removeAll();
@@ -355,7 +363,7 @@ public class MapMaker {
"USER_SNIPPET_HERE");
// TODO getDrawable
// /////////////////////////////
- curItem.setMarker(getGroupIcon(i.section));
+ curItem.setMarker(getGroupIcon(i));
mOverlay.addItem(curItem);
hash.put(i.uid, curItem);
markerToInt.put(curItem, i.uid);
@@ -375,8 +383,9 @@ public class MapMaker {
if (mMapView != null) {
mMapView.refresh();
}
+ checkMarkerTime();
}
-
+
@SuppressWarnings("deprecation")
public void receiveMarker(MarkerInfo markerInfo) {
Log.d("marker", "Marker received!");
@@ -395,6 +404,9 @@ public class MapMaker {
mOverlay.updateItem(nowMarker);
mMapView.refresh();
mMapController.animateTo(markerInfo.markerPoint);
+ Toast toast = Toast.makeText(context,"收到新路标,集合时间:" + nowMarkerHour + ":" + nowMarkerMinute, 5000);
+ toast.setGravity(Gravity.TOP, 0, 80);
+ toast.show();
return;
}
if (nowMarker == null) {
@@ -417,6 +429,9 @@ public class MapMaker {
mOverlay.addItem(nowMarker);
mMapView.refresh();
mMapController.animateTo(markerInfo.markerPoint);
+ Toast toast = Toast.makeText(context,"收到新路标,集合时间:" + nowMarkerHour + ":" + nowMarkerMinute, 5000);
+ toast.setGravity(Gravity.TOP, 0, 80);
+ toast.show();
return;
}
}
@@ -468,6 +483,9 @@ public class MapMaker {
mMapView.refresh();
mMapController.animateTo(markerPoint);
}
+ Toast toast = Toast.makeText(context,"创建新路标,集合时间:" + nowMarkerHour + ":" + nowMarkerMinute, 5000);
+ toast.setGravity(Gravity.TOP, 0, 80);
+ toast.show();
}
public GeoPoint getMakerLocation() {
@@ -485,6 +503,14 @@ public class MapMaker {
mMapView.refresh();
}
+ public void checkMarkerTime() {
+ if (nowMarker != null && nowMarkerTimestamp <= System.currentTimeMillis()) {
+ AlertMaker lateAlert = new AlertMaker(context, this);
+ lateAlert.showLateAlert();
+ removeMarker();
+ }
+ }
+
/**
* Remove all other users
*/
diff --git a/client/Piztor/src/com/macaroon/piztor/Settings.java b/client/Piztor/src/com/macaroon/piztor/Settings.java
index 8b4a948..14d5b3e 100644
--- a/client/Piztor/src/com/macaroon/piztor/Settings.java
+++ b/client/Piztor/src/com/macaroon/piztor/Settings.java
@@ -13,19 +13,27 @@ import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
+import android.widget.RadioGroup.OnCheckedChangeListener;import android.widget.CompoundButton;
+import android.widget.RadioGroup;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;
public class Settings extends PiztorAct {
+
+ public final int show_by_team = 1;
+ public final int show_by_sex = 2;
+
Button logout, subscribe, account;
MapInfo mapInfo;
Transam transam;
+ private int currentRate;
+ OnCheckedChangeListener radioButtonListener = null;
+ RadioGroup radioGroup;
+
// Event
final static int logoutButtonPressed = 10;
final static int logoutFailed = 11;
-
- private int currentRate;
static class ReCall extends Handler {
WeakReference<Settings> outerClass;
@@ -175,6 +183,23 @@ public class Settings extends PiztorAct {
actMgr.add(start, logoutButtonPressed, logout);
actMgr.add(logout, logoutFailed, start);
setContentView(R.layout.activity_settings);
+ radioGroup = (RadioGroup)this.findViewById(R.id.radioGroup);
+ if (Main.colorMode == Main.show_by_sex) radioGroup.check(R.id.show_by_sex);
+ else radioGroup.check(R.id.show_by_team);
+ radioButtonListener = new OnCheckedChangeListener() {
+
+ @Override
+ public void onCheckedChanged(RadioGroup group, int checkedId) {
+ if (checkedId == R.id.show_by_team){
+ setColorMode(show_by_team);
+ }
+ if (checkedId == R.id.show_by_sex){
+ setColorMode(show_by_sex);
+ }
+ }
+ };
+ radioGroup.setOnCheckedChangeListener(radioButtonListener);
+
}
@Override
@@ -212,12 +237,17 @@ public class Settings extends PiztorAct {
private void initGPSrate() {
currentRate = Main.GPSrefreshrate;
TextView text1 = (TextView) Settings.this.findViewById(R.id.settings_GPSrefreshrate);
- text1.setText(currentRate + "s each update");
+ text1.setText(currentRate + "s一次更新");
SeekBar bar1 = (SeekBar) Settings.this.findViewById(R.id.settings_GPSrefreshrate_bar);
bar1.setProgress(currentRate);
bar1.setOnSeekBarChangeListener(new mySeekBarListener());
}
+ private void setColorMode(int colorMode) {
+ Main.colorMode = colorMode;
+ Log.d("color", "switch to " + colorMode);
+ }
+
@Override
protected void onDestroy() {
setGPSrate();
diff --git a/client/Piztor/src/com/macaroon/piztor/myApp.java b/client/Piztor/src/com/macaroon/piztor/myApp.java
index ef99a3b..ab38efa 100644
--- a/client/Piztor/src/com/macaroon/piztor/myApp.java
+++ b/client/Piztor/src/com/macaroon/piztor/myApp.java
@@ -10,7 +10,7 @@ import android.util.Log;
@SuppressLint("UseSparseArrays")
public class myApp extends Application {
- private static final String strKey = "E612ee541946c90d7b9add0347c9e601";
+ private static final String strKey = "8a0ae50048d103b2b8b12b7066f4ea7d";
BMapManager mBMapManager;
boolean isExiting = false;
boolean isLogout = false;