diff --git a/gradlew b/gradlew old mode 100644 new mode 100755 diff --git a/libSafeMobile/build.gradle b/libSafeMobile/build.gradle index 8cecc9c..3ff1bcc 100644 --- a/libSafeMobile/build.gradle +++ b/libSafeMobile/build.gradle @@ -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 { diff --git a/libSafeMobile/src/main/AndroidManifest.xml b/libSafeMobile/src/main/AndroidManifest.xml index b6b0535..dc6d6f5 100644 --- a/libSafeMobile/src/main/AndroidManifest.xml +++ b/libSafeMobile/src/main/AndroidManifest.xml @@ -6,7 +6,7 @@ diff --git a/libSafeMobile/src/main/java/com/safemobile/activities/AbstractSDParentActivity.java b/libSafeMobile/src/main/java/com/safemobile/activities/AbstractSDParentActivity.java index 16b0df2..d0e3a0a 100644 --- a/libSafeMobile/src/main/java/com/safemobile/activities/AbstractSDParentActivity.java +++ b/libSafeMobile/src/main/java/com/safemobile/activities/AbstractSDParentActivity.java @@ -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; diff --git a/libSafeMobile/src/main/res/drawable/ic_launcher.png b/libSafeMobile/src/main/res/drawable/ic_launcher.png deleted file mode 100644 index 63d2d68..0000000 Binary files a/libSafeMobile/src/main/res/drawable/ic_launcher.png and /dev/null differ diff --git a/libSafeMobile/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/libSafeMobile/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..036d09b --- /dev/null +++ b/libSafeMobile/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/libSafeMobile/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/libSafeMobile/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..036d09b --- /dev/null +++ b/libSafeMobile/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/libSafeMobile/src/main/res/mipmap-hdpi/ic_launcher.png b/libSafeMobile/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..20fca4b Binary files /dev/null and b/libSafeMobile/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/libSafeMobile/src/main/res/mipmap-hdpi/ic_launcher_foreground.png b/libSafeMobile/src/main/res/mipmap-hdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..a78bb0d Binary files /dev/null and b/libSafeMobile/src/main/res/mipmap-hdpi/ic_launcher_foreground.png differ diff --git a/libSafeMobile/src/main/res/mipmap-hdpi/ic_launcher_round.png b/libSafeMobile/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..fd5b6e5 Binary files /dev/null and b/libSafeMobile/src/main/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/libSafeMobile/src/main/res/mipmap-mdpi/ic_launcher.png b/libSafeMobile/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..e4405e2 Binary files /dev/null and b/libSafeMobile/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/libSafeMobile/src/main/res/mipmap-mdpi/ic_launcher_foreground.png b/libSafeMobile/src/main/res/mipmap-mdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..6041008 Binary files /dev/null and b/libSafeMobile/src/main/res/mipmap-mdpi/ic_launcher_foreground.png differ diff --git a/libSafeMobile/src/main/res/mipmap-mdpi/ic_launcher_round.png b/libSafeMobile/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..e9786e1 Binary files /dev/null and b/libSafeMobile/src/main/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/libSafeMobile/src/main/res/mipmap-xhdpi/ic_launcher.png b/libSafeMobile/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..40d6401 Binary files /dev/null and b/libSafeMobile/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/libSafeMobile/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png b/libSafeMobile/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..3a57106 Binary files /dev/null and b/libSafeMobile/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png differ diff --git a/libSafeMobile/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/libSafeMobile/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..1a56618 Binary files /dev/null and b/libSafeMobile/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/libSafeMobile/src/main/res/mipmap-xxhdpi/ic_launcher.png b/libSafeMobile/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..ee1fcaf Binary files /dev/null and b/libSafeMobile/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/libSafeMobile/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png b/libSafeMobile/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..155231f Binary files /dev/null and b/libSafeMobile/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png differ diff --git a/libSafeMobile/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/libSafeMobile/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..f69d17d Binary files /dev/null and b/libSafeMobile/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/libSafeMobile/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/libSafeMobile/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..9ef1d44 Binary files /dev/null and b/libSafeMobile/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/libSafeMobile/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png b/libSafeMobile/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..6e27db5 Binary files /dev/null and b/libSafeMobile/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png differ diff --git a/libSafeMobile/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/libSafeMobile/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..51186bc Binary files /dev/null and b/libSafeMobile/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/safeDispatch/build.gradle b/safeDispatch/build.gradle index 216ff1d..94cc018 100644 --- a/safeDispatch/build.gradle +++ b/safeDispatch/build.gradle @@ -1,14 +1,36 @@ 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 buildToolsVersion "31.0.0" defaultConfig { - applicationId "com.safemobile.dispatch" + applicationId "com.safemobile.safedispatch" 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') diff --git a/safeDispatch/release/SafeDispatchMobile_v.8.0.35-release.aab b/safeDispatch/release/SafeDispatchMobile_v.8.0.35-release.aab new file mode 100644 index 0000000..f3928fb Binary files /dev/null and b/safeDispatch/release/SafeDispatchMobile_v.8.0.35-release.aab differ diff --git a/safeDispatch/release/output-metadata.json b/safeDispatch/release/output-metadata.json new file mode 100644 index 0000000..62e52b3 --- /dev/null +++ b/safeDispatch/release/output-metadata.json @@ -0,0 +1,20 @@ +{ + "version": 3, + "artifactType": { + "type": "APK", + "kind": "Directory" + }, + "applicationId": "com.safemobile.safedispatch", + "variantName": "release", + "elements": [ + { + "type": "SINGLE", + "filters": [], + "attributes": [], + "versionCode": 8000035, + "versionName": "8.0.35", + "outputFile": "SafeDispatchMobile_v.8.0.35-release.apk" + } + ], + "elementType": "File" +} \ No newline at end of file diff --git a/safeDispatch/src/main/AndroidManifest.xml b/safeDispatch/src/main/AndroidManifest.xml index 63d87af..db92082 100644 --- a/safeDispatch/src/main/AndroidManifest.xml +++ b/safeDispatch/src/main/AndroidManifest.xml @@ -1,9 +1,6 @@ + package="com.safemobile.safedispatch"> @@ -45,7 +42,7 @@ diff --git a/safeDispatch/src/main/ic_launcher-playstore.png b/safeDispatch/src/main/ic_launcher-playstore.png new file mode 100644 index 0000000..a867291 Binary files /dev/null and b/safeDispatch/src/main/ic_launcher-playstore.png differ diff --git a/safeDispatch/src/main/java/com/safemobile/dispatch/HistoryActivity.java b/safeDispatch/src/main/java/com/safemobile/dispatch/HistoryActivity.java deleted file mode 100644 index bff2914..0000000 --- a/safeDispatch/src/main/java/com/safemobile/dispatch/HistoryActivity.java +++ /dev/null @@ -1,162 +0,0 @@ -package com.safemobile.dispatch; - -import androidx.appcompat.app.AppCompatActivity; - -import android.os.Bundle; -import android.widget.ArrayAdapter; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.Spinner; -import android.widget.TextView; - -import com.google.android.gms.maps.GoogleMap; -import com.google.android.gms.maps.SupportMapFragment; -import com.safemobile.lib.AppParams; -import com.safemobile.lib.SM; -import com.safemobile.lib.Vehicle; - -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Date; -import java.util.Locale; - -public class HistoryActivity extends AppCompatActivity { - - public Bundle savedInstanceState; - private TabLayoutActivity parentTab; - private GoogleMap googleMap; - private Spinner spinnerVehicle; - private ImageView changeMapType, checkTraffic, slideLayoutImage; - private LinearLayout layoutTraffic, slidelayout, layoutVehicles; - - private ArrayList allVehicle = new ArrayList<>(); - private ArrayList allVehicleNames = new ArrayList<>(); - private ArrayAdapter adapter; - private boolean showVehicle = true; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - this.savedInstanceState = savedInstanceState; - setContentView(R.layout.tabhistory); - - parentTab = (TabLayoutActivity) getParent(); - parentTab.setHistoryActivity(this); - - Locale locale = new Locale(AppParams.LANGUAGETMP); - Locale.setDefault(locale); - - googleMap = parentTab.getLiveActivity().getMap(); - SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() - .findFragmentById(R.id.map); - - spinnerVehicle = findViewById(R.id.spinnerVehicle); - getVehicles(); - - 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); - - 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; -// }); - - setDate(); - } - - private void setDate() { - Calendar calendar = Calendar.getInstance(); - Date endDate = calendar.getTime(); - calendar.add(Calendar.DATE, -1); - Date startDate = calendar.getTime(); - - LinearLayout layoutStartPicker = findViewById(R.id.layoutStartPicker); - TextView textViewDate = findViewById(R.id.textViewStartDate); - - textViewDate.setText(new SimpleDateFormat("HH:mm, dd.MM.yyyy").format(startDate)); -// layoutStartPicker.setOnTouchListener((v, event) -> { -// showDialog(layoutStartPicker); -// return false; -// }); - -// layoutEndPicker.setOnTouchListener(new OnTouchListener() { -// @Override -// public boolean onTouch(View v, MotionEvent event) { -// showDialog(layoutEndPicker); -// return false; -// } -// }); - - - } - - private void changeTraffic() { - ImageView changeTrafficImageView = findViewById(R.id.changeTraffic); - changeTrafficImageView.setOnClickListener(v -> { - if (googleMap.isTrafficEnabled()) { - changeTrafficImageView.setImageResource(R.drawable.traffic_off); - googleMap.setTrafficEnabled(false); - } else { - changeTrafficImageView.setImageResource(R.drawable.traffic); - googleMap.setTrafficEnabled(true); - } - }); - } - - private void changeMapType() { - changeMapType = findViewById(R.id.changeMapType); - ImageView changeMapTypeImageView = findViewById(R.id.changeMapType); - changeMapType.setOnClickListener(view -> { - if (googleMap.getMapType() == GoogleMap.MAP_TYPE_SATELLITE) { - changeMapTypeImageView.setImageResource(R.drawable.satellite); - googleMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE); - } else { - changeMapTypeImageView.setImageResource(R.drawable.map); - googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL); - } - }); - } - - public void getVehicles() { - try { - for (Vehicle vehicle : parentTab.getAllVehicle()) { - allVehicleNames.add(vehicle.name); - allVehicle.add(vehicle); - } - } catch (Exception ex) { } - - } - - public void UpdateMap() { - SM.Debug("Do the updateMAP post"); - } - - public void UpdateUnableDisp() { - SM.Debug("Do Cancelwindow"); - } - - public void UpdateCancel() { - SM.Debug("Do Cancelwindow"); - } - - public void UpdateNrPos(int size) { - SM.Debug("Do Cancelwindow"); - } -} \ No newline at end of file diff --git a/safeDispatch/src/main/java/com/safemobile/dispatch/AlarmActivity.java b/safeDispatch/src/main/java/com/safemobile/safedispatch/AlarmActivity.java similarity index 99% rename from safeDispatch/src/main/java/com/safemobile/dispatch/AlarmActivity.java rename to safeDispatch/src/main/java/com/safemobile/safedispatch/AlarmActivity.java index 38fa774..d2db467 100644 --- a/safeDispatch/src/main/java/com/safemobile/dispatch/AlarmActivity.java +++ b/safeDispatch/src/main/java/com/safemobile/safedispatch/AlarmActivity.java @@ -1,4 +1,4 @@ -package com.safemobile.dispatch; +package com.safemobile.safedispatch; import java.util.ArrayList; import java.util.Locale; diff --git a/safeDispatch/src/main/java/com/safemobile/dispatch/GoogleMapsInfoBubble.java b/safeDispatch/src/main/java/com/safemobile/safedispatch/GoogleMapsInfoBubble.java similarity index 51% rename from safeDispatch/src/main/java/com/safemobile/dispatch/GoogleMapsInfoBubble.java rename to safeDispatch/src/main/java/com/safemobile/safedispatch/GoogleMapsInfoBubble.java index 4aea17d..de11ea3 100644 --- a/safeDispatch/src/main/java/com/safemobile/dispatch/GoogleMapsInfoBubble.java +++ b/safeDispatch/src/main/java/com/safemobile/safedispatch/GoogleMapsInfoBubble.java @@ -1,4 +1,4 @@ -package com.safemobile.dispatch; +package com.safemobile.safedispatch; import android.content.Context; import android.util.Log; @@ -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 superVehHash; + private Hashtable superVehHash; private final Context context; + private ArrayList histPosList; + private boolean isLiveTab = true; public GoogleMapsInfoBubble(LayoutInflater layoutInflater, Context context, Hashtable 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 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); } } diff --git a/safeDispatch/src/main/java/com/safemobile/safedispatch/HistoryActivity.java b/safeDispatch/src/main/java/com/safemobile/safedispatch/HistoryActivity.java new file mode 100644 index 0000000..9ac7e70 --- /dev/null +++ b/safeDispatch/src/main/java/com/safemobile/safedispatch/HistoryActivity.java @@ -0,0 +1,241 @@ +package com.safemobile.safedispatch; + +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.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; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.Locale; + +public class HistoryActivity extends AppCompatActivity implements OnMapReadyCallback { + + public Bundle savedInstanceState; + private TabLayoutActivity parentTab; + private GoogleMap googleMap; + private Spinner spinnerVehicle; + private Button displayButton; + private Date startDate, endDate; + private final Handler myHandler = new Handler(); + private GoogleMapsInfoBubble infoBubble; + + private final ArrayList allVehicle = new ArrayList<>(); + private final ArrayList allVehicleNames = new ArrayList<>(); + private final SimpleDateFormat sdf = new SimpleDateFormat("MMMM dd yyyy"); + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + this.savedInstanceState = savedInstanceState; + setContentView(R.layout.tabhistory); + + parentTab = (TabLayoutActivity) getParent(); + parentTab.historyActivity = this; + + Locale locale = new Locale(AppParams.LANGUAGETMP); + Locale.setDefault(locale); + + SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() + .findFragmentById(R.id.map); + if (mapFragment != null) + mapFragment.getMapAsync(this); + + spinnerVehicle = findViewById(R.id.spinnerVehicle); + getVehicles(); + + ArrayAdapter 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); + + changeMapType(); + changeTraffic(); + + 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 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(); + endDate = calendar.getTime(); + calendar.add(Calendar.DATE, -1); + startDate = calendar.getTime(); + + TextView textViewStartDate = findViewById(R.id.textViewStartDate); + TextView textViewEndDate = findViewById(R.id.textViewEndDate); + + textViewStartDate.setText(sdf.format(startDate)); + textViewEndDate.setText(sdf.format(endDate)); + + 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() { + ImageView changeTrafficImageView = findViewById(R.id.changeTraffic); + changeTrafficImageView.setOnClickListener(v -> { + if (googleMap.isTrafficEnabled()) { + changeTrafficImageView.setImageResource(R.drawable.traffic_off); + googleMap.setTrafficEnabled(false); + } else { + changeTrafficImageView.setImageResource(R.drawable.traffic); + googleMap.setTrafficEnabled(true); + } + }); + } + + private void changeMapType() { + ImageView changeMapType = findViewById(R.id.changeMapType); + changeMapType.setOnClickListener(view -> { + if (googleMap.getMapType() == GoogleMap.MAP_TYPE_SATELLITE) { + changeMapType.setImageResource(R.drawable.satellite); + googleMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE); + } else { + changeMapType.setImageResource(R.drawable.map); + googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL); + } + }); + } + + public void getVehicles() { + try { + allVehicle.clear(); + allVehicleNames.clear(); + for (Vehicle vehicle : parentTab.getAllVehicle()) { + allVehicleNames.add(vehicle.name); + allVehicle.add(vehicle); + } + } 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"); + } + + public void UpdateUnableDisp() { + SM.Debug("Do Cancelwindow"); + } + + public void UpdateCancel() { + SM.Debug("Do Cancelwindow"); + } + + 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(); + } +} \ No newline at end of file diff --git a/safeDispatch/src/main/java/com/safemobile/dispatch/IconContextMenu.java b/safeDispatch/src/main/java/com/safemobile/safedispatch/IconContextMenu.java similarity index 99% rename from safeDispatch/src/main/java/com/safemobile/dispatch/IconContextMenu.java rename to safeDispatch/src/main/java/com/safemobile/safedispatch/IconContextMenu.java index bcd2fae..1c67c8d 100644 --- a/safeDispatch/src/main/java/com/safemobile/dispatch/IconContextMenu.java +++ b/safeDispatch/src/main/java/com/safemobile/safedispatch/IconContextMenu.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.safemobile.dispatch; +package com.safemobile.safedispatch; import java.util.ArrayList; diff --git a/safeDispatch/src/main/java/com/safemobile/dispatch/LiveActivity.java b/safeDispatch/src/main/java/com/safemobile/safedispatch/LiveActivity.java similarity index 99% rename from safeDispatch/src/main/java/com/safemobile/dispatch/LiveActivity.java rename to safeDispatch/src/main/java/com/safemobile/safedispatch/LiveActivity.java index 6dfd492..9cb65aa 100644 --- a/safeDispatch/src/main/java/com/safemobile/dispatch/LiveActivity.java +++ b/safeDispatch/src/main/java/com/safemobile/safedispatch/LiveActivity.java @@ -1,4 +1,4 @@ -package com.safemobile.dispatch; +package com.safemobile.safedispatch; import android.app.Activity; import android.app.AlertDialog; diff --git a/safeDispatch/src/main/java/com/safemobile/dispatch/MapDemo.java b/safeDispatch/src/main/java/com/safemobile/safedispatch/MapDemo.java similarity index 88% rename from safeDispatch/src/main/java/com/safemobile/dispatch/MapDemo.java rename to safeDispatch/src/main/java/com/safemobile/safedispatch/MapDemo.java index cee9e0c..696607f 100644 --- a/safeDispatch/src/main/java/com/safemobile/dispatch/MapDemo.java +++ b/safeDispatch/src/main/java/com/safemobile/safedispatch/MapDemo.java @@ -1,4 +1,4 @@ -package com.safemobile.dispatch; +package com.safemobile.safedispatch; import android.os.Bundle; import androidx.fragment.app.FragmentActivity; diff --git a/safeDispatch/src/main/java/com/safemobile/dispatch/MessagesActivity.java b/safeDispatch/src/main/java/com/safemobile/safedispatch/MessagesActivity.java similarity index 99% rename from safeDispatch/src/main/java/com/safemobile/dispatch/MessagesActivity.java rename to safeDispatch/src/main/java/com/safemobile/safedispatch/MessagesActivity.java index e6c048e..577a653 100644 --- a/safeDispatch/src/main/java/com/safemobile/dispatch/MessagesActivity.java +++ b/safeDispatch/src/main/java/com/safemobile/safedispatch/MessagesActivity.java @@ -1,4 +1,4 @@ -package com.safemobile.dispatch; +package com.safemobile.safedispatch; import android.app.Activity; import android.app.AlertDialog; diff --git a/safeDispatch/src/main/java/com/safemobile/dispatch/NotificationActivity.java b/safeDispatch/src/main/java/com/safemobile/safedispatch/NotificationActivity.java similarity index 96% rename from safeDispatch/src/main/java/com/safemobile/dispatch/NotificationActivity.java rename to safeDispatch/src/main/java/com/safemobile/safedispatch/NotificationActivity.java index c775a3b..a64d418 100644 --- a/safeDispatch/src/main/java/com/safemobile/dispatch/NotificationActivity.java +++ b/safeDispatch/src/main/java/com/safemobile/safedispatch/NotificationActivity.java @@ -1,4 +1,4 @@ -package com.safemobile.dispatch; +package com.safemobile.safedispatch; import android.app.Activity; import android.content.Intent; diff --git a/safeDispatch/src/main/java/com/safemobile/dispatch/RadioActivity.java b/safeDispatch/src/main/java/com/safemobile/safedispatch/RadioActivity.java similarity index 99% rename from safeDispatch/src/main/java/com/safemobile/dispatch/RadioActivity.java rename to safeDispatch/src/main/java/com/safemobile/safedispatch/RadioActivity.java index 7ab7cf2..701c25b 100644 --- a/safeDispatch/src/main/java/com/safemobile/dispatch/RadioActivity.java +++ b/safeDispatch/src/main/java/com/safemobile/safedispatch/RadioActivity.java @@ -1,4 +1,4 @@ -package com.safemobile.dispatch; +package com.safemobile.safedispatch; import android.app.Activity; import android.app.AlertDialog; @@ -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(); } diff --git a/safeDispatch/src/main/java/com/safemobile/dispatch/RecordingsActivity.java b/safeDispatch/src/main/java/com/safemobile/safedispatch/RecordingsActivity.java similarity index 98% rename from safeDispatch/src/main/java/com/safemobile/dispatch/RecordingsActivity.java rename to safeDispatch/src/main/java/com/safemobile/safedispatch/RecordingsActivity.java index 92d2431..f4cdcef 100644 --- a/safeDispatch/src/main/java/com/safemobile/dispatch/RecordingsActivity.java +++ b/safeDispatch/src/main/java/com/safemobile/safedispatch/RecordingsActivity.java @@ -1,4 +1,4 @@ -package com.safemobile.dispatch; +package com.safemobile.safedispatch; import android.app.Activity; import android.app.AlertDialog; @@ -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(); } diff --git a/safeDispatch/src/main/java/com/safemobile/dispatch/SDMobileActivity.java b/safeDispatch/src/main/java/com/safemobile/safedispatch/SDMobileActivity.java similarity index 99% rename from safeDispatch/src/main/java/com/safemobile/dispatch/SDMobileActivity.java rename to safeDispatch/src/main/java/com/safemobile/safedispatch/SDMobileActivity.java index 8e1943f..24e1fe0 100644 --- a/safeDispatch/src/main/java/com/safemobile/dispatch/SDMobileActivity.java +++ b/safeDispatch/src/main/java/com/safemobile/safedispatch/SDMobileActivity.java @@ -1,4 +1,4 @@ -package com.safemobile.dispatch; +package com.safemobile.safedispatch; import android.app.Activity; import android.app.AlertDialog; diff --git a/safeDispatch/src/main/java/com/safemobile/dispatch/SDMobileActivity_beforeMod.java b/safeDispatch/src/main/java/com/safemobile/safedispatch/SDMobileActivity_beforeMod.java similarity index 99% rename from safeDispatch/src/main/java/com/safemobile/dispatch/SDMobileActivity_beforeMod.java rename to safeDispatch/src/main/java/com/safemobile/safedispatch/SDMobileActivity_beforeMod.java index ebb03b5..988722e 100644 --- a/safeDispatch/src/main/java/com/safemobile/dispatch/SDMobileActivity_beforeMod.java +++ b/safeDispatch/src/main/java/com/safemobile/safedispatch/SDMobileActivity_beforeMod.java @@ -1,4 +1,4 @@ -package com.safemobile.dispatch; +package com.safemobile.safedispatch; import java.util.ArrayList; import java.util.List; diff --git a/safeDispatch/src/main/java/com/safemobile/dispatch/SetupActivity.java b/safeDispatch/src/main/java/com/safemobile/safedispatch/SetupActivity.java similarity index 99% rename from safeDispatch/src/main/java/com/safemobile/dispatch/SetupActivity.java rename to safeDispatch/src/main/java/com/safemobile/safedispatch/SetupActivity.java index a1b530f..6be79a5 100644 --- a/safeDispatch/src/main/java/com/safemobile/dispatch/SetupActivity.java +++ b/safeDispatch/src/main/java/com/safemobile/safedispatch/SetupActivity.java @@ -1,4 +1,4 @@ -package com.safemobile.dispatch; +package com.safemobile.safedispatch; import java.util.Locale; diff --git a/safeDispatch/src/main/java/com/safemobile/dispatch/TabLayoutActivity.java b/safeDispatch/src/main/java/com/safemobile/safedispatch/TabLayoutActivity.java similarity index 100% rename from safeDispatch/src/main/java/com/safemobile/dispatch/TabLayoutActivity.java rename to safeDispatch/src/main/java/com/safemobile/safedispatch/TabLayoutActivity.java diff --git a/safeDispatch/src/main/res/drawable-hdpi/ic_launcher.png b/safeDispatch/src/main/res/drawable-hdpi/ic_launcher.png deleted file mode 100644 index 63d2d68..0000000 Binary files a/safeDispatch/src/main/res/drawable-hdpi/ic_launcher.png and /dev/null differ diff --git a/safeDispatch/src/main/res/drawable-hdpi/safedispatch.jpg b/safeDispatch/src/main/res/drawable-hdpi/safedispatch.jpg deleted file mode 100644 index db0172f..0000000 Binary files a/safeDispatch/src/main/res/drawable-hdpi/safedispatch.jpg and /dev/null differ diff --git a/safeDispatch/src/main/res/drawable-hdpi/safedispatch3.jpg b/safeDispatch/src/main/res/drawable-hdpi/safedispatch3.jpg deleted file mode 100644 index 7c4dc91..0000000 Binary files a/safeDispatch/src/main/res/drawable-hdpi/safedispatch3.jpg and /dev/null differ diff --git a/safeDispatch/src/main/res/drawable-hdpi/safedispatch_logo.jpg b/safeDispatch/src/main/res/drawable-hdpi/safedispatch_logo.jpg deleted file mode 100644 index 058a2a0..0000000 Binary files a/safeDispatch/src/main/res/drawable-hdpi/safedispatch_logo.jpg and /dev/null differ diff --git a/safeDispatch/src/main/res/drawable-hdpi/safedispatch_logo.png b/safeDispatch/src/main/res/drawable-hdpi/safedispatch_logo.png new file mode 100644 index 0000000..e26e96a Binary files /dev/null and b/safeDispatch/src/main/res/drawable-hdpi/safedispatch_logo.png differ diff --git a/safeDispatch/src/main/res/drawable-mdpi/history_pin.png b/safeDispatch/src/main/res/drawable-mdpi/history_pin.png new file mode 100644 index 0000000..646ee64 Binary files /dev/null and b/safeDispatch/src/main/res/drawable-mdpi/history_pin.png differ diff --git a/safeDispatch/src/main/res/layout/dialog.xml b/safeDispatch/src/main/res/layout/dialog.xml index 2f477c5..3db07c8 100644 --- a/safeDispatch/src/main/res/layout/dialog.xml +++ b/safeDispatch/src/main/res/layout/dialog.xml @@ -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" /> + /> + /> - + + #FFFFFF + \ No newline at end of file diff --git a/safeDispatch/src/main/res/values/strings.xml b/safeDispatch/src/main/res/values/strings.xml index 3cfa5b7..6834004 100644 --- a/safeDispatch/src/main/res/values/strings.xml +++ b/safeDispatch/src/main/res/values/strings.xml @@ -1,8 +1,8 @@ - SafeMobile Dispatch - SafeMobile Dispatch Demo + SafeDispatch Mobile + SafeDispatch Mobile Demo RadioPod RadioPad RadioPod diff --git a/safeDispatch/src/main/res/values/styles.xml b/safeDispatch/src/main/res/values/styles.xml index ffcc73b..6e651d5 100644 --- a/safeDispatch/src/main/res/values/styles.xml +++ b/safeDispatch/src/main/res/values/styles.xml @@ -82,7 +82,7 @@ @@ -138,7 +138,7 @@ @@ -211,7 +211,7 @@ @@ -285,7 +285,7 @@