Compare commits

..

7 Commits

Author SHA1 Message Date
4ba0ceb627 Merge pull request 'convert to mph' (#34) from convert_to_mph into develop
Reviewed-on: #34
Reviewed-by: Cristi Ene <cristi.ene@safemobile.com>
2024-03-14 11:07:48 +00:00
4b09464638 convert to mph 2024-02-28 18:06:13 +02:00
a9732e5a52 Merge pull request 'SD_256_incorect_timestamp_in_buble_live_tab' (#33) from SD_256_incorect_timestamp_in_buble_live_tab into develop
Reviewed-on: #33
Reviewed-by: Cristi Ene <cristi.ene@safemobile.com>
2023-05-26 15:05:59 +00:00
31d6b0027f Merge branch 'develop' into SD_256_incorect_timestamp_in_buble_live_tab 2023-05-26 17:41:53 +03:00
5c8b857664 format timestamp as time ago 2023-05-26 17:40:07 +03:00
8b89319d09 Merge pull request 'handle network swap' (#32) from SD-230 into develop
Reviewed-on: #32
Reviewed-by: Cristi Ene <cristi.ene@safemobile.com>
2022-05-03 08:27:34 +00:00
8cc6dfceca Merge pull request 'SD-230' (#31) from SD-230 into develop
Reviewed-on: #31
2022-04-27 12:00:40 +00:00
5 changed files with 69 additions and 53 deletions

3
.gitignore vendored
View File

@ -184,3 +184,6 @@ $RECYCLE.BIN/
/.idea/misc.xml /.idea/misc.xml
/.idea /.idea
/.idea/modules.xml /.idea/modules.xml
/safeDispatch/debug
/safeDispatch/release

View File

@ -16,9 +16,9 @@ import android.widget.Toast;
public class TCPService extends Service { public class TCPService extends Service {
private int[] startModes = {START_STICKY, START_NOT_STICKY, START_REDELIVER_INTENT}; private int[] startModes = {START_STICKY, START_NOT_STICKY, START_REDELIVER_INTENT};
private int mStartMode = startModes[0]; // indicates how to behave if the service is killed private int mStartMode = startModes[0]; // indicates how to behave if the service is killed
private IBinder mBinder = new TCPBinder(); // interface for clients that bind private IBinder mBinder = new TCPBinder(); // interface for clients that bind
private boolean mAllowRebind = true; // indicates whether onRebind should be used private boolean mAllowRebind = true; // indicates whether onRebind should be used
private TCPhandler tcp = null; private TCPhandler tcp = null;
private TCPmsgParser tcpParser = null; private TCPmsgParser tcpParser = null;
@ -112,27 +112,7 @@ public class TCPService extends Service {
/** restart the TCP Connection after the connection parameters had been changed */ /** restart the TCP Connection after the connection parameters had been changed */
public void recreateTCPConnection() public void recreateTCPConnection()
{ {
/* recreateTCPConnection(AppParams.IP, AppParams.PORT);
Thread t = new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(1000*2);
} catch (InterruptedException e) {
e.printStackTrace();
}
*/
// create a tcp connection
int port = 13589;
try {
port = Integer.parseInt(AppParams.PORT);
}
catch(Exception ex) { }
tcp = new TCPhandler(getApplicationContext(), AppParams.IP, port);
/* }
});
t.start();
*/
} }
public void recreateTCPConnection(String _ip, String _port) public void recreateTCPConnection(String _ip, String _port)

View File

@ -1,20 +0,0 @@
{
"version": 3,
"artifactType": {
"type": "APK",
"kind": "Directory"
},
"applicationId": "com.safemobile.safedispatch",
"variantName": "release",
"elements": [
{
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 8000091,
"versionName": "8.0.91",
"outputFile": "SafeDispatchMobile_v.8.0.91-release.apk"
}
],
"elementType": "File"
}

View File

@ -21,6 +21,7 @@ import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Locale; import java.util.Locale;
import java.util.concurrent.TimeUnit;
public class GoogleMapsInfoBubble implements GoogleMap.InfoWindowAdapter { public class GoogleMapsInfoBubble implements GoogleMap.InfoWindowAdapter {
@ -90,28 +91,38 @@ public class GoogleMapsInfoBubble implements GoogleMap.InfoWindowAdapter {
boolean isMilitaryTime = false; boolean isMilitaryTime = false;
Date positionTime; Date positionTime;
long timeGMT = 0;
String speed, address, gpsLocation, name = ""; String speed, address, gpsLocation, name = "";
if (isLiveTab) { if (isLiveTab) {
SuperVehicle vehicle = superVehHash.get(key); SuperVehicle vehicle = superVehHash.get(key);
positionTime = new Date((new Date()).getTime() - vehicle.timeGMT);
//positionTime = new Date((new Date()).getTime() - vehicle.timeGMT);
timeGMT = vehicle.timeGMT;
address = vehicle.Address != null ? vehicle.Address : ""; address = vehicle.Address != null ? vehicle.Address : "";
name = vehicle.name; name = vehicle.name;
speed = String.format(context.getResources().getString(R.string.speedMph), vehicle.speed); speed = String.format(context.getResources().getString(R.string.speedMph), (int)(0.621371192 * vehicle.speed));
gpsLocation = "[" + String.format("%.4f", vehicle.lat) + "," + String.format("%.4f",vehicle.lng) + "]"; gpsLocation = "[" + String.format("%.4f", vehicle.lat) + "," + String.format("%.4f",vehicle.lng) + "]";
} else { } else {
HistPos histPos = histPosList.get(position); HistPos histPos = histPosList.get(position);
positionTime = new Date((new Date()).getTime() - histPos.timeGMT);
//positionTime = new Date((new Date()).getTime() - histPos.timeGMT);
timeGMT = histPos.timeGMT;
address = histPos.Address != null ? histPos.Address : ""; address = histPos.Address != null ? histPos.Address : "";
speed = String.format(context.getResources().getString(R.string.speedMph), histPos.speed); speed = String.format(context.getResources().getString(R.string.speedMph), (int)(0.621371192 * histPos.speed));
gpsLocation = "[" + String.format("%.4f", histPos.lat) + "," + String.format("%.4f",histPos.lng) + "]"; gpsLocation = "[" + String.format("%.4f", histPos.lat) + "," + String.format("%.4f",histPos.lng) + "]";
} }
String timeFormat = isMilitaryTime //String timeFormat = isMilitaryTime
? "HH:mm:ss dd.MMM.yyyy" // ? "HH:mm:ss dd.MMM.yyyy"
: "hh:mm:ss a dd.MMM.yyy"; // : "hh:mm:ss a dd.MMM.yyy";
//DateFormat format = new SimpleDateFormat(timeFormat, Locale.ENGLISH);
//tvTimeAgo.setText(format.format(positionTime));
DateFormat format = new SimpleDateFormat("hh:mm:ss", Locale.ENGLISH);
tvTimeAgo.setText( getDateTimeAgo(timeGMT * 1000) + " [" + format.format(new Date(timeGMT*1000) ) + "]");
DateFormat format = new SimpleDateFormat(timeFormat, Locale.ENGLISH);
tvTimeAgo.setText(format.format(positionTime));
tvStreetView.setText(address); tvStreetView.setText(address);
streetView.setVisibility(address.length() > 0 ? View.VISIBLE : View.GONE); streetView.setVisibility(address.length() > 0 ? View.VISIBLE : View.GONE);
tvStreetView.setVisibility(address.length() > 0 ? View.VISIBLE : View.GONE); tvStreetView.setVisibility(address.length() > 0 ? View.VISIBLE : View.GONE);
@ -123,5 +134,38 @@ public class GoogleMapsInfoBubble implements GoogleMap.InfoWindowAdapter {
tvSpeed.setText(speed); tvSpeed.setText(speed);
tvGPSLocation.setText(gpsLocation); tvGPSLocation.setText(gpsLocation);
} }
/// <summary>
/// Get a text representation for the date time representing
/// the difference in minutes/hours/days from now
/// </summary>
/// <param name="utcTime">DateTime value which needs to be converted</param>
/// <returns>String 'Ago' representation fot he date</returns>
public static String getDateTimeAgo(long time)
{
String timeValue = "";
long diffInMs = (new Date().getTime() - time);
long secondsDifference = TimeUnit.MILLISECONDS.toSeconds(diffInMs);;
if (secondsDifference < 60)
timeValue = "less than 1 minute";
else if (secondsDifference < 3600)
timeValue = (secondsDifference / 60) + " minute" + ((secondsDifference / 60) > 1 ? "s" : "") + " ago";
else if (secondsDifference < 7200)
timeValue = "1 hour ago";
else if (secondsDifference < 86400)
{
timeValue = (secondsDifference / 3600) + " hours ago";
}
else
{
timeValue = (secondsDifference / 86400) + " days ago";
}
return timeValue;
}
} }

View File

@ -2354,7 +2354,16 @@ public class TabLayoutActivity extends AbstractSDParentActivity {
// cancel old notification // cancel old notification
mNotificationManager.cancel(icon); mNotificationManager.cancel(icon);
PendingIntent pendingIntent = PendingIntent.getActivity(context, NOTIFICATION_ACTIVITY_RESULT, intent, PendingIntent.FLAG_CANCEL_CURRENT); PendingIntent pendingIntent;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
pendingIntent = PendingIntent.getActivity(context, NOTIFICATION_ACTIVITY_RESULT, intent, PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_MUTABLE);
}else {
pendingIntent = PendingIntent.getActivity(context, NOTIFICATION_ACTIVITY_RESULT, intent, PendingIntent.FLAG_CANCEL_CURRENT);
}
createNotificationChannel(icon, contentTitle, contentText, pendingIntent); createNotificationChannel(icon, contentTitle, contentText, pendingIntent);
} }