summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/Piztor/res/drawable/alien.pngbin0 -> 1255 bytes
-rw-r--r--client/Piztor/res/drawable/marker_02.pngbin0 -> 15728 bytes
-rw-r--r--client/Piztor/res/drawable/marker_red.pngbin0 -> 1600 bytes
-rw-r--r--client/Piztor/src/com/macaroon/piztor/AlertMaker.java111
-rw-r--r--client/Piztor/src/com/macaroon/piztor/Main.java84
-rw-r--r--client/Piztor/src/com/macaroon/piztor/MapMaker.java50
6 files changed, 197 insertions, 48 deletions
diff --git a/client/Piztor/res/drawable/alien.png b/client/Piztor/res/drawable/alien.png
new file mode 100644
index 0000000..071d697
--- /dev/null
+++ b/client/Piztor/res/drawable/alien.png
Binary files differ
diff --git a/client/Piztor/res/drawable/marker_02.png b/client/Piztor/res/drawable/marker_02.png
new file mode 100644
index 0000000..d1b923c
--- /dev/null
+++ b/client/Piztor/res/drawable/marker_02.png
Binary files differ
diff --git a/client/Piztor/res/drawable/marker_red.png b/client/Piztor/res/drawable/marker_red.png
new file mode 100644
index 0000000..60a4821
--- /dev/null
+++ b/client/Piztor/res/drawable/marker_red.png
Binary files differ
diff --git a/client/Piztor/src/com/macaroon/piztor/AlertMaker.java b/client/Piztor/src/com/macaroon/piztor/AlertMaker.java
new file mode 100644
index 0000000..cc70e62
--- /dev/null
+++ b/client/Piztor/src/com/macaroon/piztor/AlertMaker.java
@@ -0,0 +1,111 @@
+package com.macaroon.piztor;
+
+import java.util.Calendar;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import android.annotation.SuppressLint;
+import android.app.AlertDialog;
+import android.app.TimePickerDialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.location.LocationManager;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.provider.Settings;
+import android.util.Log;
+import android.view.KeyEvent;
+import android.view.Menu;
+import android.view.View;
+import android.view.inputmethod.InputMethodManager;
+import android.widget.EditText;
+import android.widget.ImageButton;
+import android.widget.TextView;
+import android.widget.TimePicker;
+import android.widget.Toast;
+
+import com.baidu.location.BDLocation;
+import com.baidu.location.BDLocationListener;
+import com.baidu.location.LocationClient;
+import com.baidu.location.LocationClientOption;
+import com.baidu.mapapi.map.LocationData;
+import com.baidu.mapapi.map.MKMapTouchListener;
+import com.baidu.mapapi.map.MapView;
+import com.baidu.mapapi.map.OverlayItem;
+import com.baidu.mapapi.map.PopupOverlay;
+import com.baidu.platform.comapi.basestruct.GeoPoint;
+
+public class AlertMaker {
+
+ private Calendar calendar;
+ private Context context;
+ private GeoPoint markerPoint;
+ private MapMaker mapMaker;
+
+ public AlertMaker(Context cc, MapMaker mm) {
+ context =cc;
+ mapMaker = mm;
+ }
+
+ public static void closeBoard(Context cc) {
+ InputMethodManager imm = (InputMethodManager) cc
+ .getSystemService(Context.INPUT_METHOD_SERVICE);
+ if (imm.isActive())
+ imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT,
+ InputMethodManager.HIDE_NOT_ALWAYS);
+ }
+
+ public void showSettingsAlert() {
+
+ 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",
+ 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",
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.cancel();
+ }
+ });
+ gpsDialog.show();
+ }
+
+ public void showMarkerAlert(GeoPoint point) {
+
+ closeBoard(context);
+ if (point == null) return;
+ markerPoint = point;
+ calendar = Calendar.getInstance();
+ TimePickerDialog markerDialog = new TimePickerDialog(context
+ , new TimePickerDialog.OnTimeSetListener() {
+
+ @Override
+ 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))
+ mapMaker.DrawMarker(markerPoint);
+ else {
+ Toast toast = Toast.makeText(context,
+ "Too early! Give me at least 2 minutes!", Toast.LENGTH_LONG);
+ toast.show();
+ closeBoard(context);
+ showMarkerAlert(markerPoint);
+ }
+ }
+ }
+ , calendar.get(Calendar.HOUR_OF_DAY)
+ , calendar.get(Calendar.MINUTE), false);
+ markerDialog.show();
+ }
+
+}
diff --git a/client/Piztor/src/com/macaroon/piztor/Main.java b/client/Piztor/src/com/macaroon/piztor/Main.java
index 03e7ebc..cfa77c5 100644
--- a/client/Piztor/src/com/macaroon/piztor/Main.java
+++ b/client/Piztor/src/com/macaroon/piztor/Main.java
@@ -1,18 +1,29 @@
package com.macaroon.piztor;
+import java.util.Calendar;
import java.util.Timer;
import java.util.TimerTask;
import android.annotation.SuppressLint;
+import android.app.AlertDialog;
+import android.app.TimePickerDialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.location.LocationManager;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
+import android.provider.Settings;
import android.util.Log;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.View;
+import android.view.inputmethod.InputMethodManager;
+import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.TextView;
+import android.widget.TimePicker;
import android.widget.Toast;
import com.baidu.location.BDLocation;
@@ -20,38 +31,37 @@ import com.baidu.location.BDLocationListener;
import com.baidu.location.LocationClient;
import com.baidu.location.LocationClientOption;
import com.baidu.mapapi.map.LocationData;
+import com.baidu.mapapi.map.MKMapTouchListener;
import com.baidu.mapapi.map.MapView;
import com.baidu.mapapi.map.OverlayItem;
import com.baidu.mapapi.map.PopupOverlay;
+import com.baidu.platform.comapi.basestruct.GeoPoint;
public class Main extends PiztorAct {
+
final static int SearchButtonPress = 1;
final static int FocuseButtonPress = 3;
final static int SuccessFetch = 4;
final static int FailedFetch = 5;
final static int Fetch = 6;
final static int mapViewtouched = 7;
-
- /**
- * popups
- */
- private PopupOverlay pop = null;
- private TextView popupText = null;
- private View viewCache = null;
- private View popupInfo = null;
- private View popupLeft = null;
- private View popupRight = null;
- private MapView.LayoutParams layoutParam = null;
- private OverlayItem mCurItem = null;
-
+
MapMaker mapMaker = null;
MapView mMapView;
+ AlertMaker alertMaker;
+ private Calendar calendar;
+ GeoPoint markerPoint = null;
+
+ // map touch listener
+ private MKMapTouchListener mapTouchListener;
boolean isFirstLocation = true;
/**
* Locating component
*/
+ LocationManager locationManager;
+ boolean isGPSEnabled;
LocationClient mLocClient;
LocationData locData = null;
public MyLocationListener myListener = new MyLocationListener();
@@ -284,11 +294,45 @@ public class Main extends PiztorAct {
actMgr.trigger(Main.Fetch);
}
}
+
+ public void InitTouchListenr() {
+ mapTouchListener = new MKMapTouchListener() {
+
+ @Override
+ public void onMapLongClick(GeoPoint arg0) {
+ closeBoard(Main.this);
+ alertMaker.showMarkerAlert(arg0);
+ /*
+ if (mapMaker != null)
+ mapMaker.DrawMarker(arg0);
+ Log.d("marker", "draw a new marker");
+ */
+ }
+
+ @Override
+ public void onMapDoubleClick(GeoPoint arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void onMapClick(GeoPoint arg0) {
+ // TODO Auto-generated method stub
+
+ }
+ };
+ mMapView.regMapTouchListner(mapTouchListener);
+ }
+
@Override
protected void onCreate(Bundle savedInstanceState) {
id = "Main";
super.onCreate(savedInstanceState);
+
+ locationManager = (LocationManager)this.getSystemService(LOCATION_SERVICE);
+ isGPSEnabled = locationManager.isProviderEnabled(locationManager.GPS_PROVIDER);
+
mapInfo = AppMgr.mapInfo;
ActStatus[] r = new ActStatus[3];
ActStatus startStatus = r[0] = new StartStatus();
@@ -310,8 +354,11 @@ public class Main extends PiztorAct {
setContentView(R.layout.activity_main);
mMapView = (MapView) findViewById(R.id.bmapView);
mapMaker = new MapMaker(mMapView, getApplicationContext());
+ alertMaker = new AlertMaker(Main.this, mapMaker);
+ if (isGPSEnabled == false) alertMaker.showSettingsAlert();
mapMaker.clearOverlay(mMapView);
mapMaker.InitMap();
+ InitTouchListenr();
mLocClient = new LocationClient(this);
locData = new LocationData();
mLocClient.registerLocationListener(myListener);
@@ -323,6 +370,14 @@ public class Main extends PiztorAct {
mLocClient.start();
mapMaker.UpdateLocationOverlay(locData, false);
}
+
+ public static void closeBoard(Context cc) {
+ InputMethodManager imm = (InputMethodManager) cc
+ .getSystemService(Context.INPUT_METHOD_SERVICE);
+ if (imm.isActive())
+ imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT,
+ InputMethodManager.HIDE_NOT_ALWAYS);
+ }
/*
* public boolean onTap(int index) { OverlayItem item = getItem(index);
@@ -358,6 +413,7 @@ public class Main extends PiztorAct {
@Override
protected void onResume() {
+ isFirstLocation = true;
mapMaker.onResume();
flushMap();
super.onResume();
@@ -412,4 +468,4 @@ public class Main extends PiztorAct {
mMapView.onRestoreInstanceState(savedInstanceState);
}
-} \ No newline at end of file
+}
diff --git a/client/Piztor/src/com/macaroon/piztor/MapMaker.java b/client/Piztor/src/com/macaroon/piztor/MapMaker.java
index 4e30df6..d11fe5c 100644
--- a/client/Piztor/src/com/macaroon/piztor/MapMaker.java
+++ b/client/Piztor/src/com/macaroon/piztor/MapMaker.java
@@ -8,6 +8,7 @@ import android.util.Log;
import android.util.AttributeSet;
import android.annotation.SuppressLint;
import android.location.Location;
+import android.location.LocationManager;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
@@ -20,7 +21,10 @@ import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import android.app.Activity;
+import android.app.AlertDialog;
import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
@@ -29,6 +33,7 @@ import android.widget.Toast;
import android.view.View.OnClickListener;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
+import android.provider.Settings;
import com.baidu.location.BDLocation;
import com.baidu.location.BDLocationListener;
@@ -72,17 +77,17 @@ public class MapMaker extends Activity {
private MyOverlay markerOverlay;
private OverlayItem nowMarker = null;
- //
- private Context context;
-
- private MKMapTouchListener mapTouchListener;
-
// Popup component
private PopupOverlay popLay = null;
private TextView popupText = null;
private View viewCache = null;
private View popupInfo = null;
+ //misc
+ private Context context;
+ private LocationManager locationManager = null;
+ boolean isGPSEnabled;
+
/**
* Constructor
*/
@@ -199,30 +204,7 @@ public class MapMaker extends Activity {
/**
* Initialize touch listener
*/
- public void InitTouchListenr() {
-
- mapTouchListener = new MKMapTouchListener() {
-
- @Override
- public void onMapLongClick(GeoPoint arg0) {
- DrawMarker(arg0);
- Log.d("marker", "draw a new marker");
- }
-
- @Override
- public void onMapDoubleClick(GeoPoint arg0) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void onMapClick(GeoPoint arg0) {
- // TODO Auto-generated method stub
-
- }
- };
- mMapView.regMapTouchListner(mapTouchListener);
- }
+ // moved to main
/**
* Initialize map
@@ -232,8 +214,9 @@ public class MapMaker extends Activity {
InitLocationOverlay();
InitMyOverLay();
InitPopup();
- InitTouchListenr();
+ //InitTouchListenr();
}
+
/**
* Update location layer when new location is received
*/
@@ -311,11 +294,10 @@ public class MapMaker extends Activity {
public void DrawMarker(GeoPoint markerPoint) {
nowMarker = new OverlayItem(markerPoint, "THIS IS A MARKER", "");
- nowMarker.setMarker(context.getResources().getDrawable(R.drawable.marker1));
- Log.d("marker", "new marker created");
- System.out.println("mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm " + markerPoint.getLatitudeE6() + " " + markerPoint.getLongitudeE6());
-
+ nowMarker.setMarker(context.getResources().getDrawable(R.drawable.marker_red));
+ Log.d("marker", "new marker created");
UpdateMap(preMapInfo);
+ mMapController.animateTo(markerPoint);
}
/**