diff --git a/libSafeMobile/src/main/res/drawable-xhdpi/custom_info_bubble.9.png b/libSafeMobile/src/main/res/drawable-xhdpi/custom_info_bubble.9.png new file mode 100644 index 0000000..21dc176 Binary files /dev/null and b/libSafeMobile/src/main/res/drawable-xhdpi/custom_info_bubble.9.png differ diff --git a/libSafeMobile/src/main/res/drawable-xhdpi/l_bg_gps.jpg b/libSafeMobile/src/main/res/drawable-xhdpi/l_bg_gps.jpg new file mode 100644 index 0000000..e940b10 Binary files /dev/null and b/libSafeMobile/src/main/res/drawable-xhdpi/l_bg_gps.jpg differ diff --git a/libSafeMobile/src/main/res/drawable-xhdpi/l_speed.png b/libSafeMobile/src/main/res/drawable-xhdpi/l_speed.png new file mode 100644 index 0000000..9451fc2 Binary files /dev/null and b/libSafeMobile/src/main/res/drawable-xhdpi/l_speed.png differ diff --git a/libSafeMobile/src/main/res/drawable-xhdpi/l_street.png b/libSafeMobile/src/main/res/drawable-xhdpi/l_street.png new file mode 100644 index 0000000..af3f177 Binary files /dev/null and b/libSafeMobile/src/main/res/drawable-xhdpi/l_street.png differ diff --git a/libSafeMobile/src/main/res/drawable-xhdpi/l_time.png b/libSafeMobile/src/main/res/drawable-xhdpi/l_time.png new file mode 100644 index 0000000..72e4ebf Binary files /dev/null and b/libSafeMobile/src/main/res/drawable-xhdpi/l_time.png differ diff --git a/libSafeMobile/src/main/res/layout/map_marker_info_bubble.xml b/libSafeMobile/src/main/res/layout/map_marker_info_bubble.xml new file mode 100644 index 0000000..08ce499 --- /dev/null +++ b/libSafeMobile/src/main/res/layout/map_marker_info_bubble.xml @@ -0,0 +1,140 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/libSafeMobile/src/main/res/values/color.xml b/libSafeMobile/src/main/res/values/color.xml new file mode 100644 index 0000000..503e1f0 --- /dev/null +++ b/libSafeMobile/src/main/res/values/color.xml @@ -0,0 +1,5 @@ + + + #FFFFFF + #000000 + \ No newline at end of file diff --git a/safeDispatch/src/main/java/com/safemobile/dispatch/GoogleMapsInfoBubble.java b/safeDispatch/src/main/java/com/safemobile/dispatch/GoogleMapsInfoBubble.java new file mode 100644 index 0000000..4aea17d --- /dev/null +++ b/safeDispatch/src/main/java/com/safemobile/dispatch/GoogleMapsInfoBubble.java @@ -0,0 +1,93 @@ +package com.safemobile.dispatch; + +import android.content.Context; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.ImageView; +import android.widget.RelativeLayout; +import android.widget.TextView; + +import androidx.annotation.NonNull; + +import com.google.android.gms.maps.GoogleMap; +import com.google.android.gms.maps.model.Marker; +import com.safemobile.lib.SuperVehicle; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Hashtable; +import java.util.Locale; + + +public class GoogleMapsInfoBubble implements GoogleMap.InfoWindowAdapter { + private final String TAG = GoogleMapsInfoBubble.class.getName(); + + private final View mWindow; + private final Hashtable superVehHash; + private final Context context; + + + public GoogleMapsInfoBubble(LayoutInflater layoutInflater, Context context, Hashtable vehicles) { + this.context = context; + this.superVehHash = vehicles; + mWindow = layoutInflater.inflate(R.layout.map_marker_info_bubble, null); + } + + @Override + public View getInfoWindow(@NonNull Marker marker) { + render(marker, mWindow); + return mWindow; + } + + @Override + public View getInfoContents(@NonNull Marker marker) { + render(marker, mWindow); + return mWindow; + } + + 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"); + } + SuperVehicle vehicle = superVehHash.get(key); + + RelativeLayout rlMapInfoBubbleInfo = view.findViewById(R.id.rlMapInfoBubbleInfo); + TextView tvUnitName = view.findViewById(R.id.tvUnitName); + TextView tvGPSLocation = view.findViewById(R.id.tvGPSLocation); + TextView tvTimeAgo = view.findViewById(R.id.tvTimeAgo); + TextView tvSpeed = view.findViewById(R.id.tvSpeed); + TextView tvStreetView = view.findViewById(R.id.tvStreetView); + ImageView streetView = view.findViewById(R.id.streetView); + rlMapInfoBubbleInfo.setVisibility(View.VISIBLE); + + boolean isMilitaryTime = false; + Date positionTime = new Date(vehicle.timeGMT); + + + 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) + "]"); + } +} + diff --git a/safeDispatch/src/main/java/com/safemobile/dispatch/LiveActivity.java b/safeDispatch/src/main/java/com/safemobile/dispatch/LiveActivity.java index 081e942..3cf2168 100644 --- a/safeDispatch/src/main/java/com/safemobile/dispatch/LiveActivity.java +++ b/safeDispatch/src/main/java/com/safemobile/dispatch/LiveActivity.java @@ -32,6 +32,8 @@ import android.widget.TextView; import android.widget.Toast; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.constraintlayout.widget.ConstraintLayout; import com.google.android.gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.GoogleMap; @@ -307,7 +309,8 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall @Override public void onMapReady(@NonNull GoogleMap googleMap) { this.googleMap = googleMap; - + GoogleMapsInfoBubble infoBubble = new GoogleMapsInfoBubble(getLayoutInflater(), this, getParentTab().SuperVehHash); + this.googleMap.setInfoWindowAdapter(infoBubble); // Add a marker in Sydney and move the camera LatLng sydney = new LatLng(-34, 151); this.googleMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney")); @@ -475,12 +478,12 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall if (tmpSuper != null) { LatLng newLocation = new LatLng(tmpSuper.lat, tmpSuper.lng); - MarkerOptions markerOptions = new MarkerOptions().position(newLocation).title(tmpSuper.name); + MarkerOptions markerOptions = new MarkerOptions().position(newLocation).title(liveVehicle.get(i).imei); BitmapDescriptor markerIcon = getProperBitmap(tmpSuper.getLargeIcon(), tmpSuper.name); markerOptions.icon(markerIcon); - Marker marker = this.googleMap.addMarker(markerOptions); + Marker marker = this.googleMap.addMarker(markerOptions); } } } diff --git a/safeDispatch/src/main/res/values-de/strings.xml b/safeDispatch/src/main/res/values-de/strings.xml index caf053d..c0fd0fc 100644 --- a/safeDispatch/src/main/res/values-de/strings.xml +++ b/safeDispatch/src/main/res/values-de/strings.xml @@ -232,4 +232,7 @@ German Romanian + + %1$d mph + \ No newline at end of file diff --git a/safeDispatch/src/main/res/values-es/strings.xml b/safeDispatch/src/main/res/values-es/strings.xml index 6f0fd3c..c8269bb 100644 --- a/safeDispatch/src/main/res/values-es/strings.xml +++ b/safeDispatch/src/main/res/values-es/strings.xml @@ -236,4 +236,7 @@ Spanish Russian + + %1$d mph + \ No newline at end of file diff --git a/safeDispatch/src/main/res/values-ro/strings.xml b/safeDispatch/src/main/res/values-ro/strings.xml index d1a0dff..168d4fb 100644 --- a/safeDispatch/src/main/res/values-ro/strings.xml +++ b/safeDispatch/src/main/res/values-ro/strings.xml @@ -233,4 +233,7 @@ Turca Romana + + %1$d mph + \ No newline at end of file diff --git a/safeDispatch/src/main/res/values-tr/strings.xml b/safeDispatch/src/main/res/values-tr/strings.xml index 21068cd..b7fd8ac 100644 --- a/safeDispatch/src/main/res/values-tr/strings.xml +++ b/safeDispatch/src/main/res/values-tr/strings.xml @@ -232,4 +232,7 @@ German Romanian + + %1$d mph + \ 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 6630330..f415089 100644 --- a/safeDispatch/src/main/res/values/strings.xml +++ b/safeDispatch/src/main/res/values/strings.xml @@ -254,4 +254,8 @@ NewLiveActivity GoogleMapsActivity + + + %1$d mph + \ No newline at end of file