summaryrefslogtreecommitdiff
path: root/client/Piztor/src/com
diff options
context:
space:
mode:
Diffstat (limited to 'client/Piztor/src/com')
-rw-r--r--client/Piztor/src/com/macaroon/piztor/AlertMaker.java33
-rw-r--r--client/Piztor/src/com/macaroon/piztor/Main.java80
-rw-r--r--client/Piztor/src/com/macaroon/piztor/MapMaker.java24
-rw-r--r--client/Piztor/src/com/macaroon/piztor/Rlocation.java13
-rw-r--r--client/Piztor/src/com/macaroon/piztor/SubscribeSettings.java122
5 files changed, 217 insertions, 55 deletions
diff --git a/client/Piztor/src/com/macaroon/piztor/AlertMaker.java b/client/Piztor/src/com/macaroon/piztor/AlertMaker.java
index cc70e62..d7a9d69 100644
--- a/client/Piztor/src/com/macaroon/piztor/AlertMaker.java
+++ b/client/Piztor/src/com/macaroon/piztor/AlertMaker.java
@@ -3,6 +3,7 @@ package com.macaroon.piztor;
import java.util.Calendar;
import java.util.Timer;
import java.util.TimerTask;
+import java.util.zip.Inflater;
import android.annotation.SuppressLint;
import android.app.AlertDialog;
@@ -17,6 +18,7 @@ import android.os.Message;
import android.provider.Settings;
import android.util.Log;
import android.view.KeyEvent;
+import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
@@ -43,7 +45,8 @@ public class AlertMaker {
private Context context;
private GeoPoint markerPoint;
private MapMaker mapMaker;
-
+ private long timestamp;
+
public AlertMaker(Context cc, MapMaker mm) {
context =cc;
mapMaker = mm;
@@ -79,6 +82,23 @@ public class AlertMaker {
gpsDialog.show();
}
+ 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;
+ }
+
+ //TODO
+ public void updateMarkerTime(int hour, int minute) {
+ Log.d("time", hour + " " + minute);
+ Log.d("time", " " + toTimestamp(hour, minute));
+ }
+
public void showMarkerAlert(GeoPoint point) {
closeBoard(context);
@@ -92,8 +112,10 @@ public class AlertMaker {
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
////// at least 2 minutes
if ((hourOfDay >= calendar.get(Calendar.HOUR_OF_DAY) && minute >= calendar.get(Calendar.MINUTE))
- || hourOfDay > calendar.get(Calendar.HOUR_OF_DAY))
+ || hourOfDay > calendar.get(Calendar.HOUR_OF_DAY)) {
mapMaker.DrawMarker(markerPoint);
+ updateMarkerTime(hourOfDay, minute);
+ }
else {
Toast toast = Toast.makeText(context,
"Too early! Give me at least 2 minutes!", Toast.LENGTH_LONG);
@@ -104,8 +126,13 @@ public class AlertMaker {
}
}
, calendar.get(Calendar.HOUR_OF_DAY)
- , calendar.get(Calendar.MINUTE), false);
+ , calendar.get(Calendar.MINUTE), true);
markerDialog.show();
}
+ public void showCheckinAlter() {
+ closeBoard(context);
+ AlertDialog.Builder checkinDialog = new AlertDialog.Builder(context);
+ }
+
}
diff --git a/client/Piztor/src/com/macaroon/piztor/Main.java b/client/Piztor/src/com/macaroon/piztor/Main.java
index 623595b..735b1a4 100644
--- a/client/Piztor/src/com/macaroon/piztor/Main.java
+++ b/client/Piztor/src/com/macaroon/piztor/Main.java
@@ -10,6 +10,7 @@ import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
+import android.view.Gravity;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.View;
@@ -31,7 +32,7 @@ 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 CheckinButtonPress = 1;
final static int FocuseButtonPress = 3;
final static int SuccessFetch = 4;
final static int FailedFetch = 5;
@@ -43,6 +44,7 @@ public class Main extends PiztorAct {
private Calendar calendar;
GeoPoint markerPoint = null;
private MKMapTouchListener mapTouchListener;
+ private final int checkinRadius = 10;
/**
* Locating component
@@ -55,7 +57,7 @@ public class Main extends PiztorAct {
boolean isFirstLocation = true;
public static int GPSrefreshrate = 5;
- ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ ImageButton btnCheckin, btnFetch, btnFocus, btnSettings;
MapInfo mapInfo;
Transam transam;
@@ -130,8 +132,8 @@ public class Main extends PiztorAct {
String cause(int t) {
switch (t) {
- case SearchButtonPress:
- return "Search Button Press";
+ case CheckinButtonPress:
+ return "Checkin Button Press";
case FocuseButtonPress:
return "Focuse Button Press";
case SuccessFetch:
@@ -192,9 +194,21 @@ public class Main extends PiztorAct {
isFirstLocation = false;
}
int TMP = location.getLocType();
- if (TMP == 61) Toast.makeText(Main.this, "Piztor : Update from GPS result (" + GPSrefreshrate + "s)", 3000).show();
- if (TMP == 161) Toast.makeText(Main.this, "Piztor : Update from Network (" + GPSrefreshrate + "s)" , 3000).show();
- if (TMP == 65) Toast.makeText(Main.this, "Piztor : Update from Cache (" + GPSrefreshrate + "s)", 3000).show();
+ if (TMP == 61) {
+ Toast toast = Toast.makeText(Main.this, "Piztor : Update from GPS result (" + 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 + "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)", 2000);
+ toast.setGravity(Gravity.TOP, 0, 80);
+ toast.show();
+ }
mapMaker.UpdateLocationOverlay(locData, hasAnimation);
LocationClientOption option = new LocationClientOption();
@@ -218,8 +232,7 @@ public class Main extends PiztorAct {
void enter(int e) {
System.out.println("enter start status!!!!");
if (e == ActMgr.Create) {
- System.out.println(Infomation.token + " "
- + Infomation.username + " " + Infomation.myInfo.uid);
+ System.out.println(Infomation.token + " " + Infomation.username + " " + Infomation.myInfo.uid);
}
if (e == SuccessFetch)
flushMap();
@@ -270,6 +283,27 @@ public class Main extends PiztorAct {
mMapView.regMapTouchListner(mapTouchListener);
}
+ public void markerCheckin() {
+ if (mapMaker.getMakerLocation() == null) {
+ Toast toast = Toast.makeText(Main.this, "No marker now!", 2000);
+ toast.setGravity(Gravity.TOP, 0, 80);
+ toast.show();
+ return;
+ }
+ GeoPoint curPoint = new GeoPoint((int)(locData.latitude * 1E6), (int)(locData.longitude * 1E6));
+ double disFromMarker = DistanceUtil.getDistance(curPoint, mapMaker.getMakerLocation());
+ if (disFromMarker < locData.accuracy) {
+ mapMaker.removeMarker();
+ Toast toast = Toast.makeText(Main.this, "Marker checked!", 2000);
+ toast.setGravity(Gravity.TOP, 0, 80);
+ toast.show();
+ } else {
+ Toast toast = Toast.makeText(Main.this, "Please get closer to the marker!", 2000);
+ toast.setGravity(Gravity.TOP, 0, 80);
+ toast.show();
+ }
+ }
+
@Override
protected void onCreate(Bundle savedInstanceState) {
id = "Main";
@@ -283,23 +317,10 @@ public class Main extends PiztorAct {
mapInfo = AppMgr.mapInfo;
ActStatus[] r = new ActStatus[1];
ActStatus startStatus = r[0] = new StartStatus();
- // ActStatus fetchStatus = r[1] = new FetchStatus();
- // ActStatus focusStatus = r[2] = new FocusStatus();
if (transam == null)
Log.d(LogInfo.exception, "transam = null");
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);
setContentView(R.layout.activity_main);
mMapView = (MapView) findViewById(R.id.bmapView);
@@ -330,17 +351,22 @@ public class Main extends PiztorAct {
InputMethodManager.HIDE_NOT_ALWAYS);
}
- /*
- * public boolean onTap(int index) { OverlayItem item = getItem(index);
- * mCurItem = item; if () }
- */
@Override
protected void onStart() {
super.onStart();
btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
- btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnCheckin = (ImageButton) findViewById(R.id.footbar_btn_checkin);
btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+
+ btnCheckin.setOnClickListener(new View.OnClickListener() {
+
+ @Override
+ public void onClick(View arg0) {
+ markerCheckin();
+ }
+ });
+
btnFetch.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
diff --git a/client/Piztor/src/com/macaroon/piztor/MapMaker.java b/client/Piztor/src/com/macaroon/piztor/MapMaker.java
index ef79f73..8df1f8a 100644
--- a/client/Piztor/src/com/macaroon/piztor/MapMaker.java
+++ b/client/Piztor/src/com/macaroon/piztor/MapMaker.java
@@ -370,18 +370,6 @@ public class MapMaker extends Activity {
}
/**
- * Update marker
- *
- public void UpdateMarker() {
- mOverlay.addItem(nowMarker);
- if (mMapView != null) {
- mMapView.getOverlays().add(mOverlay);
- mMapView.refresh();
- }
- }
- */
-
- /**
* Draw a marker
*/
public void DrawMarker(GeoPoint markerPoint) {
@@ -401,6 +389,18 @@ public class MapMaker extends Activity {
mMapController.animateTo(markerPoint);
}
+ public GeoPoint getMakerLocation() {
+ if (nowMarker == null) return null;
+ else return nowMarker.getPoint();
+ }
+
+ public void removeMarker() {
+ if (nowMarker == null) return;
+ mOverlay.removeItem(nowMarker);
+ nowMarker = null;
+ mMapView.refresh();
+ }
+
/**
* Remove all other users
*/
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/SubscribeSettings.java b/client/Piztor/src/com/macaroon/piztor/SubscribeSettings.java
new file mode 100644
index 0000000..3716549
--- /dev/null
+++ b/client/Piztor/src/com/macaroon/piztor/SubscribeSettings.java
@@ -0,0 +1,122 @@
+package com.macaroon.piztor;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Vector;
+
+import android.app.Activity;
+import android.content.Context;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.ListView;
+import android.widget.SimpleAdapter;
+import android.widget.TextView;
+
+import com.macaroon.piztor.RGroup;
+
+public class SubscribeSettings extends Activity {
+
+ private static final int BUTTON_ADD = 1;
+ private static final int BUTTON_DELETE = 2;
+
+ private ListView mListView;
+ private ArrayList<HashMap<String, Object>> mList;
+ private TextView mShowInfo;
+ private EditText edit_company;
+ private EditText edit_section;
+
+ /** Called when the activity is first created. */
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.subscribe_settings);
+
+ 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 : Infomation.sublist) {
+ HashMap<String, Object> map = new HashMap<String, Object>();
+ int cc = i.company;
+ int ss = i.section;
+ map.put("subscribe_text", cc+ "连 " + ss + "班");
+ }
+ Button btnadd = (Button)findViewById(R.id.button_add);
+ btnadd.setOnClickListener(new View.OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ int cc = Integer.parseInt(edit_company.getText().toString());
+ int ss = Integer.parseInt(edit_section.getText().toString());
+ simpleAdapter.notifyDataSetChanged();
+ HashMap<String, Object> map = new HashMap<String, Object>();
+ map.put("subscribe_text", cc + "连 " + ss + "班");
+ mList.add(map);
+ mShowInfo.setText("添加了一条订阅");
+ }
+ });
+ mShowInfo = (TextView) findViewById(R.id.textView1);
+ }
+
+ private class MySimpleAdapter extends SimpleAdapter {
+
+ public MySimpleAdapter(Context context,
+ List<? extends Map<String, ?>> data, int resource,
+ String[] from, int[] to) {
+ super(context, data, resource, from, to);
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ // TODO Auto-generated method stub
+ final int mPosition = position;
+ convertView = super.getView(position, convertView, parent);
+ Button buttonDelete = (Button) convertView
+ .findViewById(R.id.button_delete);
+ buttonDelete.setOnClickListener(new View.OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ mHandler.obtainMessage(BUTTON_DELETE, mPosition, 0).sendToTarget();
+ }
+ });
+ return convertView;
+ }
+
+ private Handler mHandler = new Handler() {
+
+ @Override
+ public void handleMessage(Message msg) {
+ // 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:
+ mList.remove(msg.arg1);
+ notifyDataSetChanged();
+ mShowInfo.setText("删除了第" + (msg.arg1 + 1) + "条订阅");
+ break;
+ }
+ }
+
+ };
+
+ }
+} \ No newline at end of file