Compare commits

...

21 Commits

Author SHA1 Message Date
2855e9bde6 new credential generated 2022-03-23 13:33:54 +02:00
ee8bfe56b4 Merge pull request 'feature/icon_and_background' (#8) from feature/icon_and_background into develop
Reviewed-on: #8
2022-03-23 09:23:35 +00:00
d519a2be14 change app name 2022-03-23 11:12:20 +02:00
1b3912c682 change background image 2022-03-23 11:12:00 +02:00
ba9383248c chage icon 2022-03-23 10:56:09 +02:00
07127cea18 Merge pull request 'feature/apk_versioning_mechanism' (#7) from feature/apk_versioning_mechanism into develop
Reviewed-on: #7
2022-03-22 13:19:47 +00:00
6a235d1d3f merge with develop 2022-03-22 15:18:25 +02:00
bac12825c9 edit apk name 2022-03-22 15:10:29 +02:00
bbed107c42 get versionCode & name from tag 2022-03-22 12:11:08 +02:00
bca16caf94 new marker icon 2022-03-21 13:01:04 +02:00
0b887deb99 remove marker icon 2022-03-21 12:19:23 +02:00
c85dc279dc clean history activity 2022-03-21 11:58:34 +02:00
db360c4d45 speed limit 2022-03-21 11:50:52 +02:00
89f8cbfcae WIP 2022-03-18 23:12:20 +02:00
456c27b829 Merge pull request '#SD-207 - send more data for ack to occur' (#5) from features/SD-207-get_alarms_and_send_ack into develop
Reviewed-on: #5
2022-03-18 16:44:57 +00:00
8127caa949 #SD-207 - send more data for ack to occur 2022-03-18 18:43:48 +02:00
4420af337d cleanups 2022-03-18 15:40:15 +02:00
6b6543ca3f display test positions 2022-03-18 15:22:35 +02:00
f554356af1 small cleanups 2022-03-18 15:03:34 +02:00
2540b5f511 Merge pull request '#SD-185 - Make the UI compatible with SMS parsing changes' (#4) from features/SD-185-update-app-to_support-new-message-parsing into develop
Reviewed-on: #4
2022-03-18 06:41:30 +00:00
0fabbc73be comment line in order to move vehicle 2022-03-17 15:13:25 +02:00
45 changed files with 801 additions and 997 deletions

0
gradlew vendored Normal file → Executable file
View File

View File

@ -19,6 +19,13 @@ android {
buildFeatures {
viewBinding false
}
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
//abortOnError false
}
}
dependencies {

View File

@ -6,7 +6,7 @@
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
</application>

View File

@ -155,12 +155,12 @@ public abstract class AbstractSDParentActivity extends TabActivity {
}
public boolean sendAlarmAcknowledge(int alarm_id, int type)
public boolean sendAlarmAcknowledge(int alarm_id, int type, String unitName)
{
if(tcp == null)
return false;
boolean res = tcp.Write("0.0", "#28#" + alarm_id + "#" + type + "#");
boolean res = tcp.Write("0.0", "#28#" + alarm_id + "#" + type + "#" + AppParams.USERID + "#" + unitName + "#");
if(res)
SM.Debug("Message [sendAlarmAcknowledge] sent to app server alarm_id:" + alarm_id + " type:" + type);
else
@ -198,12 +198,11 @@ public abstract class AbstractSDParentActivity extends TabActivity {
return res;
}
public boolean getHistoryPositions(int sc_id, long timeGMTStart, long timeGMTStop)
{
public boolean getHistoryPositions(int sc_id, long timeGMTStart, long timeGMTStop) {
if(tcp == null)
return false;
String histSeqID = "1."+Integer.toString((int) (System.currentTimeMillis() / 1000L));
String histSeqID = "1."+ (int) (System.currentTimeMillis() / 1000L);
boolean res = tcp.Write(histSeqID,"#26#"+sc_id+"#"+timeGMTStart+"#"+timeGMTStop+"#");
if(res)
SM.Debug("Message [getHistoryPositions] sent to app server");
@ -213,8 +212,7 @@ public abstract class AbstractSDParentActivity extends TabActivity {
return res;
}
public boolean getRadiosList()
{
public boolean getRadiosList() {
if(tcp == null)
return false;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1020 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -1,5 +1,24 @@
apply plugin: 'com.android.application'
apply plugin: 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin'
apply plugin: "com.gladed.androidgitversion"
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
mavenCentral()
}
dependencies {
classpath "gradle.plugin.com.gladed.gradle.androidgitversion:gradle-android-git-version:0.4.3"
}
}
androidGitVersion {
codeFormat 'MNNBBBB'
format '%tag%%.count%'
hideBranches = ['develop']
}
android {
compileSdkVersion 31
@ -9,6 +28,9 @@ android {
applicationId "com.safemobile.dispatch"
minSdkVersion 21
targetSdkVersion 31
versionName androidGitVersion.name()
versionCode androidGitVersion.code()
archivesBaseName = "SafeDispatchMobile_v.$versionName"
}
buildTypes {
@ -20,6 +42,13 @@ android {
buildFeatures {
viewBinding false
}
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
//abortOnError false
}
}
dependencies {
implementation project(':libSafeMobile')

View File

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

View File

@ -1,9 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.safemobile.dispatch"
android:versionCode="9"
android:versionName="1.0.9">
package="com.safemobile.dispatch">
<!-- require OpenGL ES version 2 for Google Maps -->
<uses-feature
@ -28,7 +25,7 @@
<application
android:configChanges="orientation"
android:icon="@drawable/ic_launcher"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:screenOrientation="landscape"
android:theme="@style/AppTheme">

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View File

@ -3,7 +3,6 @@ package com.safemobile.dispatch;
import java.util.ArrayList;
import java.util.Locale;
/** fix import*/
import com.safemobile.adapters.AlertGridViewAdapter;
import com.safemobile.adapters.AlertGridViewAdapter.ViewHolder;
@ -15,11 +14,11 @@ import com.safemobile.lib.SM;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.res.Configuration;
import android.graphics.Typeface;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.view.View;
import android.widget.AdapterView;
import android.widget.TextView;
@ -28,232 +27,213 @@ import android.widget.GridView;
public class AlarmActivity extends Activity {
private Context context;
public TabLayoutActivity parentTab;
public ArrayList<Alarm> allAlarms = new ArrayList<Alarm>();
private ArrayList<Boolean> acknowledged = new ArrayList<Boolean>();
private TabLayoutActivity parentTab;
private ArrayList<Alarm> allAlarms = new ArrayList<>();
private ArrayList<Boolean> acknowledged = new ArrayList<>();
private AlertGridViewAdapter adapter;
/* Visual resources */
private GridView gridView;
public View convertViewAlarm;
private int ack_position;
public Bundle savedInstanceState;
// Need handler for callbacks to the UI thread
private final Handler myHandler = new Handler();
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.savedInstanceState = savedInstanceState;
// get parentTab
parentTab = (TabLayoutActivity)getParent();
Locale locale = new Locale(AppParams.LANGUAGETMP);
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
getBaseContext().getResources().updateConfiguration(config,
getBaseContext().getResources().getDisplayMetrics());
context = this;
setContentView(R.layout.tabalarm);
private View convertViewAlarm;
gridView = (GridView) findViewById(R.id.gridViewAlarms);
adapter = new AlertGridViewAdapter(this, allAlarms, context, acknowledged);
gridView.setAdapter(adapter);
gridView.setOnItemClickListener(onItemClickListener);
// change tab header fontface
TextView textView1 = (TextView) findViewById(R.id.textView1);
textView1.setTypeface(Typeface.createFromAsset(getAssets(), "Sketch_Block.ttf"));
textView1.setTextSize(24);
parentTab.alarmActivity = this;
}
@Override
public void onBackPressed()
{
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(getString(R.string.exit))
.setCancelable(false)
.setNeutralButton(getString(R.string.logout), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
parentTab.whenBackPressed(AppParams.ActivityResult.logout);
}
})
.setPositiveButton(getString(R.string.ext), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
parentTab.whenBackPressed(AppParams.ActivityResult.exit);
}
})
.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert = builder.create();
alert.show();
}
@Override
public void onPause()
{
super.onPause();
SM.Debug("onPause");
}
@Override
public void onResume()
{
super.onResume();
if(!AppParams.DEMO)
GetAlarms();
else if (AppParams.DEMO)
{
for(int i=allAlarms.size()-1; i>=0; i--)
{
Alarm alarm = allAlarms.get(i);
if(alarm.ack==1)
allAlarms.remove(i);
}
acknowledged = new ArrayList<Boolean>();
for(int i=0;i<allAlarms.size();i++)
acknowledged.add(false);
updateResultsInUi("alarm");
}
SM.Debug("onResume");
}
private OnItemClickListener onItemClickListener = new OnItemClickListener() {
private int ackPosition;
private Bundle savedInstanceState;
// Need handler for callbacks to the UI thread
private final Handler myHandler = new Handler(Looper.getMainLooper());
private static final String ALARM = "alarm";
/**
* Called when the activity is first created.
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setSavedInstanceState(savedInstanceState);
// get parentTab
setParentTab((TabLayoutActivity) getParent());
Locale locale = new Locale(AppParams.LANGUAGETMP);
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
getBaseContext().getResources().updateConfiguration(config,
getBaseContext().getResources().getDisplayMetrics());
context = this;
setContentView(R.layout.tabalarm);
gridView = findViewById(R.id.gridViewAlarms);
adapter = new AlertGridViewAdapter(this, getAllAlarms(), context, acknowledged);
gridView.setAdapter(adapter);
gridView.setOnItemClickListener(onItemClickListener);
// change tab header fontFace
TextView textView1 = findViewById(R.id.textView1);
textView1.setTypeface(Typeface.createFromAsset(getAssets(), "Sketch_Block.ttf"));
textView1.setTextSize(24);
getParentTab().alarmActivity = this;
}
@Override
public void onBackPressed() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(getString(R.string.exit))
.setCancelable(false)
.setNeutralButton(getString(R.string.logout), (dialog, id) -> getParentTab().whenBackPressed(AppParams.ActivityResult.logout))
.setPositiveButton(getString(R.string.ext), (dialog, id) -> getParentTab().whenBackPressed(AppParams.ActivityResult.exit))
.setNegativeButton(getString(R.string.cancel), (dialog, id) -> dialog.cancel());
AlertDialog alert = builder.create();
alert.show();
}
@Override
public void onPause() {
super.onPause();
SM.Debug("onPause");
}
@Override
public void onResume() {
super.onResume();
if (!AppParams.DEMO)
getAlarms();
else {
for (int i = getAllAlarms().size() - 1; i >= 0; i--) {
Alarm alarm = getAllAlarms().get(i);
if (alarm.ack == 1)
getAllAlarms().remove(i);
}
acknowledged = new ArrayList<>();
for (int i = 0; i < getAllAlarms().size(); i++)
acknowledged.add(false);
updateResultsInUi(ALARM);
}
SM.Debug("onResume");
}
private final OnItemClickListener onItemClickListener = new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int position,
long arg3) {
long arg3) {
SM.Debug(" ### CLICK Alarm : " + position);
convertViewAlarm = arg1;
setConvertViewAlarm(arg1);
// save position
ack_position = position;
//Toast.makeText(context, "SETACK " + idx, 1000).show();
if(!AppParams.DEMO)
setACK(allAlarms.get(position).idx,allAlarms.get(position).type);
else
{
allAlarms.get(position).ack = 1;
ackPosition = position;
if (!AppParams.DEMO)
setACK(getAllAlarms().get(position).idx, getAllAlarms().get(position).type, getAllAlarms().get(position).unitName);
else {
getAllAlarms().get(position).ack = 1;
updateResultsInUi("else");
}
}
// send ACK to AppServer
private void setACK(int idx, int type, String unitName) {
getParentTab().executeNetworkStuff(new String[]{OperationCodes.SendAlarmAcknoledge + "", idx + "", type + "", unitName});
}
};
// Update Alarms received from AppServer
public void UpdateAlarms(ArrayList<Alarm> list)
{
SM.Debug("## UpdateAlarms: " + list.size());
allAlarms = list;
acknowledged = new ArrayList<Boolean>();
// Update Alarms received from AppServer
public void updateAlarms(ArrayList<Alarm> list) {
SM.Debug("## updateAlarms: " + list.size());
setAllAlarms(list);
acknowledged = new ArrayList<>();
// set acknowledged based on alarm.ack value
for(Alarm alarm: allAlarms)
{
acknowledged.add((alarm.ack == 1)? true: false);
SM.Debug("ALARM", "SC_ID> " + alarm.sc_id + " | "
+ (parentTab.getVehHashByScId().get(alarm.sc_id) == null ? "null" : parentTab.getVehHashByScId().get(alarm.sc_id).name ));
if (parentTab.getVehHashByScId().get(alarm.sc_id)!=null)
alarm.unitName = parentTab.getVehHashByScId().get(alarm.sc_id).name;
/*Enumeration<Long> keylist = parentTab.SuperVehHash.keys();
while(keylist.hasMoreElements())
{
SuperVehicle tmp = (SuperVehicle)((parentTab.SuperVehHash.get((long)keylist.nextElement())));
if (tmp.sc_id==alarm.sc_id)
{
alarm.unitName = tmp.name;
break;
}
}*/
}
myHandler.post(UpdateResultsRUN);
}
// Create runnable for posting
final Runnable UpdateResultsRUN = new Runnable() {
public void run() {
updateResultsInUi("alarm");
}
};
private void updateResultsInUi(String param)
{
if(param.equals("alarm"))
{
// set adapter
adapter = new AlertGridViewAdapter(this, allAlarms, context, acknowledged);
gridView.setAdapter(adapter);
}
else
{
adapter.changeACK(ack_position);
SM.Debug("Set ACK: " + ack_position + " | " + (acknowledged.get(ack_position) ? "true": "false"));
for (Alarm alarm : getAllAlarms()) {
acknowledged.add(alarm.ack == 1);
SM.Debug("ALARM", "SC_ID> " + alarm.sc_id + " | "
+ (getParentTab().getVehHashByScId().get(alarm.sc_id) == null ? "null" : getParentTab().getVehHashByScId().get(alarm.sc_id).name));
ViewHolder viewAlarm = new ViewHolder();
viewAlarm = (ViewHolder) convertViewAlarm.getTag();
switch(acknowledged.get(ack_position) ? 1 : 0)
{
if (getParentTab().getVehHashByScId().get(alarm.sc_id) != null)
alarm.unitName = getParentTab().getVehHashByScId().get(alarm.sc_id).name;
}
myHandler.post(updateResultsRUN);
}
// Create runnable for posting
final Runnable updateResultsRUN = () -> updateResultsInUi(ALARM);
private void updateResultsInUi(String param) {
if (param.equals(ALARM)) {
// set adapter
adapter = new AlertGridViewAdapter(this, getAllAlarms(), context, acknowledged);
gridView.setAdapter(adapter);
} else {
adapter.changeACK(ackPosition);
SM.Debug("Set ACK: " + ackPosition + " | " + (Boolean.TRUE.equals(acknowledged.get(ackPosition)) ? "true" : "false"));
ViewHolder viewAlarm;
viewAlarm = (ViewHolder) getConvertViewAlarm().getTag();
switch (Boolean.TRUE.equals(acknowledged.get(ackPosition)) ? 1 : 0) {
case 1:
viewAlarm.imageViewAlert.setImageResource(R.drawable.alert_off);
//view.imgViewIcon.setImageDrawable(adapter.convertToGrayscale(activity.getResources().getDrawable(liveVehicle.get(position).getSmallIcon())));
break;
case 0:
//view.imgViewAlarm.setImageResource(R.drawable.siren);
//view.imgViewIcon.setImageResource(liveVehicle.get(position).getSmallIcon());
viewAlarm.imageViewAlert.setImageResource(R.drawable.siren);
break;
default:
throw new IllegalStateException("Unexpected value: " + (Boolean.TRUE.equals(acknowledged.get(ackPosition)) ? 1 : 0));
}
}
}
// update ACK received from AppServer
public void UpdateACK()
{
myHandler.post(UpdateAckRUN);
public void updateACK() {
myHandler.post(updateAckRUN);
}
// Create runnable for posting
final Runnable UpdateAckRUN = new Runnable() {
public void run() {
SM.Debug(" UpdateACK: ");
updateResultsInUi("adapter");
}
};
// send to AppServer
private void GetAlarms()
{
parentTab.executeNetworkStuff(new String[]{OperationCodes.GetAlarms +"", AppParams.USERID + ""});
//parentTab.getAlarms(AppParams.USERID);
// Create runnable for posting
final Runnable updateAckRUN = () -> {
SM.Debug(" updateACK: ");
updateResultsInUi("adapter");
};
// send to AppServer
private void getAlarms() {
getParentTab().executeNetworkStuff(new String[]{OperationCodes.GetAlarms + "", AppParams.USERID + ""});
}
public TabLayoutActivity getParentTab() {
return parentTab;
}
public void setParentTab(TabLayoutActivity parentTab) {
this.parentTab = parentTab;
}
public ArrayList<Alarm> getAllAlarms() {
return allAlarms;
}
public void setAllAlarms(ArrayList<Alarm> allAlarms) {
this.allAlarms = allAlarms;
}
public View getConvertViewAlarm() {
return convertViewAlarm;
}
public void setConvertViewAlarm(View convertViewAlarm) {
this.convertViewAlarm = convertViewAlarm;
}
public Bundle getSavedInstanceState() {
return savedInstanceState;
}
public void setSavedInstanceState(Bundle savedInstanceState) {
this.savedInstanceState = savedInstanceState;
}
// send ACK to AppServer
private void setACK(int idx, int type)
{
parentTab.executeNetworkStuff(new String[]{OperationCodes.SendAlarmAcknoledge +"", idx + "", type + ""});
//parentTab.sendAlarmAcknowledge(idx, type);
}
}

View File

@ -12,10 +12,12 @@ import androidx.annotation.NonNull;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.model.Marker;
import com.safemobile.lib.HistPos;
import com.safemobile.lib.SuperVehicle;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Hashtable;
import java.util.Locale;
@ -25,8 +27,10 @@ public class GoogleMapsInfoBubble implements GoogleMap.InfoWindowAdapter {
private final String TAG = GoogleMapsInfoBubble.class.getName();
private final View mWindow;
private final Hashtable<Long, SuperVehicle> superVehHash;
private Hashtable<Long, SuperVehicle> superVehHash;
private final Context context;
private ArrayList<HistPos> histPosList;
private boolean isLiveTab = true;
public GoogleMapsInfoBubble(LayoutInflater layoutInflater, Context context, Hashtable<Long, SuperVehicle> vehicles) {
@ -35,6 +39,17 @@ public class GoogleMapsInfoBubble implements GoogleMap.InfoWindowAdapter {
mWindow = layoutInflater.inflate(R.layout.map_marker_info_bubble, null);
}
public GoogleMapsInfoBubble(LayoutInflater layoutInflater, Context context) {
isLiveTab = false;
this.context = context;
// this.superVehHash = vehicles;
mWindow = layoutInflater.inflate(R.layout.map_marker_info_bubble, null);
}
public void setHistoryPositions(ArrayList<HistPos> positions) {
this.histPosList = positions;
}
@Override
public View getInfoWindow(@NonNull Marker marker) {
render(marker, mWindow);
@ -49,13 +64,21 @@ public class GoogleMapsInfoBubble implements GoogleMap.InfoWindowAdapter {
private void render(Marker marker, View view) {
long key = 0;
try {
key = Long.parseLong(marker.getTitle());
} catch (Exception ex) {
Log.v(TAG, "Unable to parse Google Maps Info Bubble title");
int position = 0;
if (isLiveTab) {
try {
key = Long.parseLong(marker.getTitle());
} catch (Exception ex) {
Log.v(TAG, "Unable to parse Google Maps Info Bubble title");
}
} else {
try {
position = Integer.getInteger(marker.getTitle());
} catch (Exception e) {
Log.v(TAG, "Unable to parse Google Maps Info Bubble title on History");
}
}
SuperVehicle vehicle = superVehHash.get(key);
RelativeLayout rlMapInfoBubbleInfo = view.findViewById(R.id.rlMapInfoBubbleInfo);
TextView tvUnitName = view.findViewById(R.id.tvUnitName);
@ -67,27 +90,39 @@ public class GoogleMapsInfoBubble implements GoogleMap.InfoWindowAdapter {
rlMapInfoBubbleInfo.setVisibility(View.VISIBLE);
boolean isMilitaryTime = false;
Date positionTime = new Date(vehicle.timeGMT);
Date positionTime;
String speed, address, gpsLocation, name = "";
if (isLiveTab) {
SuperVehicle vehicle = superVehHash.get(key);
positionTime = new Date(vehicle.timeGMT);
address = vehicle.Address != null ? vehicle.Address : "";
name = vehicle.name;
speed = String.format(context.getResources().getString(R.string.speedMph), vehicle.speed);
gpsLocation = "[" + String.format("%.4f", vehicle.lat) + "," + String.format("%.4f",vehicle.lng) + "]";
} else {
HistPos histPos = histPosList.get(position);
positionTime = new Date(histPos.timeGMT);
address = histPos.Address != null ? histPos.Address : "";
speed = String.format(context.getResources().getString(R.string.speedMph), histPos.speed);
gpsLocation = "[" + String.format("%.4f", histPos.lat) + "," + String.format("%.4f",histPos.lng) + "]";
}
String timeFormat = isMilitaryTime
? "HH:mm:ss dd.MMM.yyyy"
: "hh:mm:ss a dd.MMM.yyy";
DateFormat format = new SimpleDateFormat(timeFormat, Locale.ENGLISH);
tvTimeAgo.setText(format.format(positionTime));
tvSpeed.setText(String.format(context.getResources().getString(R.string.speedMph), vehicle.speed));
String address = vehicle.Address != null ? vehicle.Address : "";
tvStreetView.setText(address);
streetView.setVisibility(address.length() > 0 ? View.VISIBLE : View.GONE);
tvStreetView.setVisibility(address.length() > 0 ? View.VISIBLE : View.GONE);
tvUnitName.setText(vehicle.name);
tvGPSLocation.setText("[" + String.format("%.4f", vehicle.lat)
+ "," + String.format("%.4f",vehicle.lng) + "]");
if (!isLiveTab)
tvUnitName.setVisibility(View.GONE);
else
tvUnitName.setText(name);
tvSpeed.setText(speed);
tvGPSLocation.setText(gpsLocation);
}
}

View File

@ -1,17 +1,33 @@
package com.safemobile.dispatch;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Spinner;
import android.widget.TextView;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.BitmapDescriptor;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.gms.maps.model.PolylineOptions;
import com.safemobile.lib.AppParams;
import com.safemobile.lib.HistPos;
import com.safemobile.lib.OperationCodes;
import com.safemobile.lib.SM;
import com.safemobile.lib.Vehicle;
@ -21,19 +37,21 @@ import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
public class HistoryActivity extends AppCompatActivity {
public class HistoryActivity extends AppCompatActivity implements OnMapReadyCallback {
public Bundle savedInstanceState;
private TabLayoutActivity parentTab;
private GoogleMap googleMap;
private Spinner spinnerVehicle;
private ImageView changeMapType, checkTraffic, slideLayoutImage;
private LinearLayout layoutTraffic, slidelayout, layoutVehicles;
private Button displayButton;
private Date startDate, endDate;
private final Handler myHandler = new Handler();
private GoogleMapsInfoBubble infoBubble;
private final ArrayList<Vehicle> allVehicle = new ArrayList<>();
private final ArrayList<String> allVehicleNames = new ArrayList<>();
private final SimpleDateFormat sdf = new SimpleDateFormat("MMMM dd yyyy");
private ArrayList<Vehicle> allVehicle = new ArrayList<>();
private ArrayList<String> allVehicleNames = new ArrayList<>();
private ArrayAdapter<String> adapter;
private boolean showVehicle = true;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -47,14 +65,15 @@ public class HistoryActivity extends AppCompatActivity {
Locale locale = new Locale(AppParams.LANGUAGETMP);
Locale.setDefault(locale);
googleMap = parentTab.liveActivity.getMap();
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
if (mapFragment != null)
mapFragment.getMapAsync(this);
spinnerVehicle = findViewById(R.id.spinnerVehicle);
getVehicles();
adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, allVehicleNames);
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, allVehicleNames);
adapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
spinnerVehicle.setAdapter(adapter);
spinnerVehicle.setSelection(0);
@ -62,49 +81,87 @@ public class HistoryActivity extends AppCompatActivity {
changeMapType();
changeTraffic();
slidelayout = findViewById(R.id.slidelayout);
slideLayoutImage = findViewById(R.id.slideLayoutImage);
layoutVehicles = findViewById(R.id.layoutBig);
// slidelayout.setOnTouchListener((v, event) -> {
// if (showVehicle) {
// layoutVehicles.setVisibility(View.GONE);
// slideLayoutImage.setImageResource(R.drawable.arrow_right);
// showVehicle = false;
// } else {
// layoutVehicles.setVisibility(View.VISIBLE);
// slideLayoutImage.setImageResource(R.drawable.arrow_left);
// showVehicle = true;
// }
// return false;
// });
displayButton = findViewById(R.id.buttonDisplay);
displayButton.setOnClickListener(view -> {
googleMap.clear();
if (!AppParams.DEMO) {
parentTab.dropAllData =false;
parentTab.firstHistData = true;
parentTab.HistMsgList.clear();
parentTab.HistPosList.clear();
// request history
parentTab.executeNetworkStuff(new String[] {OperationCodes.GetHistoryPositions + "", allVehicle.get(spinnerVehicle.getSelectedItemPosition()).sc_id + "",
(startDate.getTime()/ 1000L) + "", (endDate.getTime()/ 1000L) + ""});
} else {
parentTab.demoPositionsList();
displayHistory(parentTab.demoPositions);
}
});
setDate();
}
private void displayHistory(ArrayList<HistPos> positions) {
LatLng latLng = null;
PolylineOptions polylineOptions = new PolylineOptions();
BitmapDescriptor markerIcon = BitmapDescriptorFactory.fromResource(R.drawable.history_pin);
for (int i = 0; i < positions.size(); i++) {
HistPos pos = positions.get(i);
if (pos.speed > 0) {
latLng = new LatLng(pos.lat, pos.lng);
polylineOptions.add(latLng);
googleMap.addMarker(new MarkerOptions()
.position(latLng)
.icon(markerIcon)
.title(String.valueOf(i)));
}
}
googleMap.addPolyline(polylineOptions);
if (latLng != null)
googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 14));
}
private void setDate() {
Calendar calendar = Calendar.getInstance();
Date endDate = calendar.getTime();
endDate = calendar.getTime();
calendar.add(Calendar.DATE, -1);
Date startDate = calendar.getTime();
startDate = calendar.getTime();
LinearLayout layoutStartPicker = findViewById(R.id.layoutStartPicker);
TextView textViewDate = findViewById(R.id.textViewStartDate);
TextView textViewStartDate = findViewById(R.id.textViewStartDate);
TextView textViewEndDate = findViewById(R.id.textViewEndDate);
textViewDate.setText(new SimpleDateFormat("HH:mm, dd.MM.yyyy").format(startDate));
// layoutStartPicker.setOnTouchListener((v, event) -> {
// showDialog(layoutStartPicker);
// return false;
// });
textViewStartDate.setText(sdf.format(startDate));
textViewEndDate.setText(sdf.format(endDate));
// layoutEndPicker.setOnTouchListener(new OnTouchListener() {
// @Override
// public boolean onTouch(View v, MotionEvent event) {
// showDialog(layoutEndPicker);
// return false;
// }
// });
textViewStartDate.setOnClickListener(view -> openDialog(textViewStartDate, true));
textViewEndDate.setOnClickListener(view -> openDialog(textViewEndDate, false));
}
private void openDialog(TextView textView, Boolean isStartDate) {
Date date = startDate;
if (!isStartDate)
date = endDate;
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
DatePickerDialog.OnDateSetListener setListener = (datePicker, y, m, d) -> {
calendar.set(y, m, d);
String dateString = sdf.format(calendar.getTime());
textView.setText(dateString);
if (isStartDate)
startDate = calendar.getTime();
else
endDate = calendar.getTime();
};
Dialog dialog = new DatePickerDialog(this, android.R.style.Theme_Holo_Light_Dialog_MinWidth, setListener,
calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH));
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
dialog.show();
}
private void changeTraffic() {
@ -121,14 +178,13 @@ public class HistoryActivity extends AppCompatActivity {
}
private void changeMapType() {
changeMapType = findViewById(R.id.changeMapType);
ImageView changeMapTypeImageView = findViewById(R.id.changeMapType);
ImageView changeMapType = findViewById(R.id.changeMapType);
changeMapType.setOnClickListener(view -> {
if (googleMap.getMapType() == GoogleMap.MAP_TYPE_SATELLITE) {
changeMapTypeImageView.setImageResource(R.drawable.satellite);
changeMapType.setImageResource(R.drawable.satellite);
googleMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
} else {
changeMapTypeImageView.setImageResource(R.drawable.map);
changeMapType.setImageResource(R.drawable.map);
googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
}
});
@ -136,15 +192,27 @@ public class HistoryActivity extends AppCompatActivity {
public void getVehicles() {
try {
allVehicle.clear();
allVehicleNames.clear();
for (Vehicle vehicle : parentTab.getAllVehicle()) {
allVehicleNames.add(vehicle.name);
allVehicle.add(vehicle);
}
} catch (Exception ex) { }
} catch (Exception ignored) { }
}
final Runnable UpdateMapResults = new Runnable() {
public void run() {
Log.v("updateMap", parentTab.HistPosList.toString());
SM.Debug("Do the Display");
infoBubble.setHistoryPositions(parentTab.HistPosList);
displayHistory(parentTab.HistPosList);
}
};
public void UpdateMap() {
myHandler.post(UpdateMapResults);
SM.Debug("Do the updateMAP post");
}
@ -159,4 +227,15 @@ public class HistoryActivity extends AppCompatActivity {
public void UpdateNrPos(int size) {
SM.Debug("Do Cancelwindow");
}
@Override
public void onMapReady(@NonNull GoogleMap googleMap) {
this.googleMap = googleMap;
infoBubble = new GoogleMapsInfoBubble(getLayoutInflater(), this);
this.googleMap.setInfoWindowAdapter(infoBubble);
parentTab.demoPositionsList();
displayButton.performClick();
}
}

View File

@ -673,10 +673,10 @@ public class RadioActivity extends Activity {
dialog.setCancelable(true);
dialog.setCanceledOnTouchOutside(true);
TextView text = (TextView) dialog.findViewById(R.id.text);
ImageView image = (ImageView) dialog.findViewById(R.id.image);
TextView text = dialog.findViewById(R.id.text);
ImageView image = dialog.findViewById(R.id.image);
image.setImageResource(R.drawable.ic_launcher);
image.setImageResource(R.mipmap.ic_launcher);
text.setText(errorMsg);
dialog.show();
}

View File

@ -184,10 +184,10 @@ public class RecordingsActivity extends Activity {
dialog.setCancelable(true);
dialog.setCanceledOnTouchOutside(true);
TextView text = (TextView) dialog.findViewById(R.id.text);
ImageView image = (ImageView) dialog.findViewById(R.id.image);
TextView text = dialog.findViewById(R.id.text);
ImageView image = dialog.findViewById(R.id.image);
image.setImageResource(R.drawable.ic_launcher);
image.setImageResource(R.mipmap.ic_launcher);
text.setText(errorMsg);
dialog.show();
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 207 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 145 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -11,7 +11,7 @@
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_gravity="center_vertical"
android:src="@drawable/ic_launcher"
android:src="@mipmap/ic_launcher"
/>
<LinearLayout
android:layout_width="wrap_content"

View File

@ -24,7 +24,7 @@
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_gravity="center_vertical"
android:src="@drawable/ic_launcher"
android:src="@mipmap/ic_launcher"
android:contentDescription="image for dialog"
/>
<LinearLayout

View File

@ -7,7 +7,7 @@
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher"
android:src="@mipmap/ic_launcher"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="5dp"

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:id="@+id/tab1Layout" android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/tab1Layout"
android:orientation="horizontal"
style="?bg">
<RelativeLayout
@ -162,10 +164,11 @@
android:text="@string/startDate"
android:textSize="22dp"
android:paddingLeft="5dp"
android:layout_marginTop="15sp"
android:textColor="#000000"
android:gravity="left"
android:id="@+id/labelStartDate"
android:visibility="gone"/>
/>
<LinearLayout
android:id="@+id/layoutStartPicker"
android:layout_height="wrap_content"
@ -202,7 +205,7 @@
android:textColor="#000000"
android:gravity="left"
android:id="@+id/labelEndDate"
android:visibility="gone"/>
/>
<LinearLayout
android:id="@+id/layoutEndPicker"
android:layout_height="wrap_content"
@ -284,14 +287,15 @@
</LinearLayout>
<fragment
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/map"
android:layout_toRightOf="@id/slidelayout"
android:layout_weight="1"
tools:context=".HistoryActivity"
android:name="com.google.android.gms.maps.SupportMapFragment" />
</LinearLayout>
<ImageView
android:id="@+id/changeMapType"

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#FFFFFF</color>
</resources>

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">SafeMobile Dispatch</string>
<string name="app_name_demo">SafeMobile Dispatch Demo</string>
<string name="app_name">SafeDispatch Mobile</string>
<string name="app_name_demo">SafeDispatch Mobile Demo</string>
<string name="app_name_radiopod">RadioPod</string>
<string name="app_name_radiopad">RadioPad</string>
<string name="app_name_radiopodd">RadioPod</string>

View File

@ -82,7 +82,7 @@
<style name="mainBackground_sd">
<item name="android:orientation">vertical</item>
<item name="android:background">@drawable/safedispatch</item>
<item name="android:background">@drawable/safedispatch_logo</item>
<item name="android:scaleType">centerInside</item>
</style>
@ -138,7 +138,7 @@
</style>
<style name="bg_sd">
<item name="android:background">@drawable/safedispatch</item>
<item name="android:background">@drawable/safedispatch_logo</item>
</style>
<style name="header_sd">
@ -155,7 +155,7 @@
<style name="mainBackground_hy">
<item name="android:orientation">vertical</item>
<item name="android:background">@drawable/safedispatch</item>
<item name="android:background">@drawable/safedispatch_logo</item>
<item name="android:scaleType">centerInside</item>
</style>
@ -211,7 +211,7 @@
</style>
<style name="bg_hy">
<item name="android:background">@drawable/safedispatch</item>
<item name="android:background">@drawable/safedispatch_logo</item>
</style>
<style name="header_hy">
@ -228,7 +228,7 @@
<style name="mainBackground_vi">
<item name="android:orientation">vertical</item>
<item name="android:background">@drawable/safedispatch</item>
<item name="android:background">@drawable/safedispatch_logo</item>
<item name="android:scaleType">centerInside</item>
</style>
@ -285,7 +285,7 @@
</style>
<style name="bg_vi">
<item name="android:background">@drawable/safedispatch</item>
<item name="android:background">@drawable/safedispatch_logo</item>
</style>
<style name="header_vi">