Tidied up SMS alarms - date format, use google maps url in message, remove debugging toast messages.
This commit is contained in:
@@ -29,7 +29,7 @@ public class LocationFinder implements LocationListener
|
|||||||
Timer mTimeoutTimer = null;
|
Timer mTimeoutTimer = null;
|
||||||
LocationManager mLocationManager = null;
|
LocationManager mLocationManager = null;
|
||||||
LocationListener mLocationListener;
|
LocationListener mLocationListener;
|
||||||
int mTimeoutPeriod = 30; // Location search timeout period in seconds.
|
int mTimeoutPeriod = 60; // Location search timeout period in seconds.
|
||||||
|
|
||||||
String TAG="LocationFinder";
|
String TAG="LocationFinder";
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ public class LocationFinder implements LocationListener
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Log.v(TAG,"mTimeOutTimer expired - returning last location");
|
Log.v(TAG,"mTimeOutTimer expired - returning last location");
|
||||||
mUtil.showToast("mTimeOutTimer expired - returning last location");
|
//mUtil.showToast("mTimeOutTimer expired - returning last location");
|
||||||
mLocationManager.removeUpdates(mLocationListener);
|
mLocationManager.removeUpdates(mLocationListener);
|
||||||
mSdLocationReceiver.onSdLocationReceived(mLastLocation);
|
mSdLocationReceiver.onSdLocationReceived(mLastLocation);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -594,13 +594,13 @@ public class SdServer extends Service implements SdDataReceiver, SdLocationRecei
|
|||||||
+ loc.getLongitude() + ","
|
+ loc.getLongitude() + ","
|
||||||
+ loc.getLatitude());
|
+ loc.getLatitude());
|
||||||
} else {
|
} else {
|
||||||
mUtil.showToast("ERROR - Last Location is Null");
|
Log.v(TAG,"sendSMSAlarm() - Last Location is Null so sending first SMS without location.");
|
||||||
}
|
}
|
||||||
Log.v(TAG, "sendSMSAlarm() - Sending to " + mSMSNumbers.length + " Numbers");
|
Log.v(TAG, "sendSMSAlarm() - Sending to " + mSMSNumbers.length + " Numbers");
|
||||||
mUtil.writeToSysLogFile("SdServer.sendSMSAlarm()");
|
mUtil.writeToSysLogFile("SdServer.sendSMSAlarm()");
|
||||||
Time tnow = new Time(Time.getCurrentTimezone());
|
Time tnow = new Time(Time.getCurrentTimezone());
|
||||||
tnow.setToNow();
|
tnow.setToNow();
|
||||||
String dateStr = tnow.format("%Y-%m-%d %H-%M-%S");
|
String dateStr = tnow.format("%H:%M:%S %d/%m/%Y");
|
||||||
SmsManager sm = SmsManager.getDefault();
|
SmsManager sm = SmsManager.getDefault();
|
||||||
for (int i = 0; i < mSMSNumbers.length; i++) {
|
for (int i = 0; i < mSMSNumbers.length; i++) {
|
||||||
Log.v(TAG, "sendSMSAlarm() - Sending to " + mSMSNumbers[i]);
|
Log.v(TAG, "sendSMSAlarm() - Sending to " + mSMSNumbers[i]);
|
||||||
@@ -626,24 +626,32 @@ public class SdServer extends Service implements SdDataReceiver, SdLocationRecei
|
|||||||
mUtil.showToast("onSdLocationReceived() - NULL LOCATION RECEIVED");
|
mUtil.showToast("onSdLocationReceived() - NULL LOCATION RECEIVED");
|
||||||
Log.v(TAG, "onSdLocationReceived() - NULL LOCATION RECEIVED");
|
Log.v(TAG, "onSdLocationReceived() - NULL LOCATION RECEIVED");
|
||||||
} else {
|
} else {
|
||||||
mUtil.showToast("onSdLocationReceived() - found location" + ll.toString());
|
//mUtil.showToast("onSdLocationReceived() - found location" + ll.toString());
|
||||||
Log.v(TAG, "onSdLocationReceived() - found location" + ll.toString());
|
Log.v(TAG, "onSdLocationReceived() - found location" + ll.toString());
|
||||||
if (mSMSAlarm) {
|
if (mSMSAlarm) {
|
||||||
Log.v(TAG, "onSdLocationReceived() - Sending to " + mSMSNumbers.length + " Numbers");
|
Log.v(TAG, "onSdLocationReceived() - Sending to " + mSMSNumbers.length + " Numbers");
|
||||||
mUtil.writeToSysLogFile("SdServer.sendSMSAlarm()");
|
mUtil.writeToSysLogFile("SdServer.sendSMSAlarm()");
|
||||||
Time tnow = new Time(Time.getCurrentTimezone());
|
Time tnow = new Time(Time.getCurrentTimezone());
|
||||||
tnow.setToNow();
|
tnow.setToNow();
|
||||||
String dateStr = tnow.format("%Y-%m-%d %H-%M-%S");
|
String dateStr = tnow.format("%H:%M:%S %d/%m/%Y");
|
||||||
NumberFormat df = new DecimalFormat("#0.000");
|
NumberFormat df = new DecimalFormat("#0.000");
|
||||||
String geoUri = "<a href='geo:"
|
String geoUri = "<a href='geo:"
|
||||||
+df.format(ll.getLatitude())+","+df.format(ll.getLongitude())
|
+df.format(ll.getLatitude())+","+df.format(ll.getLongitude())
|
||||||
+";u="+df.format(ll.getAccuracy())+"'>here</a>";
|
+";u="+df.format(ll.getAccuracy())+"'>here</a>";
|
||||||
|
//String googleUrl = "https://www.google.com/maps/place?q="
|
||||||
|
// +ll.getLatitude()+"%2C"+ll.getLongitude()+
|
||||||
|
// "&key=AIzaSyDf-nbkfz9TrhyVRoeS8Mwtq6K2nBpUAts";
|
||||||
|
String googleUrl = "https://www.google.com/maps/place?q="
|
||||||
|
+ll.getLatitude()+"%2C"+ll.getLongitude();
|
||||||
|
String messageStr = mSMSMsgStr + " - " +
|
||||||
|
dateStr + " - "+googleUrl;
|
||||||
|
Log.v(TAG, "onSdLocationReceived() - Message is "+messageStr);
|
||||||
|
mUtil.showToast(messageStr);
|
||||||
SmsManager sm = SmsManager.getDefault();
|
SmsManager sm = SmsManager.getDefault();
|
||||||
for (int i = 0; i < mSMSNumbers.length; i++) {
|
for (int i = 0; i < mSMSNumbers.length; i++) {
|
||||||
Log.v(TAG, "sendSMSAlarm() - Sending to " + mSMSNumbers[i]);
|
Log.v(TAG, "sendSMSAlarm() - Sending to " + mSMSNumbers[i]);
|
||||||
sm.sendTextMessage(mSMSNumbers[i], null,
|
sm.sendTextMessage(mSMSNumbers[i], null,
|
||||||
mSMSMsgStr + " - " +
|
messageStr,
|
||||||
dateStr + " - "+ geoUri,
|
|
||||||
null, null);
|
null, null);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user