feature/apk_versioning_mechanism #7
@ -12,10 +12,12 @@ import androidx.annotation.NonNull;
|
|||||||
|
|
||||||
import com.google.android.gms.maps.GoogleMap;
|
import com.google.android.gms.maps.GoogleMap;
|
||||||
import com.google.android.gms.maps.model.Marker;
|
import com.google.android.gms.maps.model.Marker;
|
||||||
|
import com.safemobile.lib.HistPos;
|
||||||
import com.safemobile.lib.SuperVehicle;
|
import com.safemobile.lib.SuperVehicle;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
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;
|
||||||
@ -25,8 +27,10 @@ public class GoogleMapsInfoBubble implements GoogleMap.InfoWindowAdapter {
|
|||||||
private final String TAG = GoogleMapsInfoBubble.class.getName();
|
private final String TAG = GoogleMapsInfoBubble.class.getName();
|
||||||
|
|
||||||
private final View mWindow;
|
private final View mWindow;
|
||||||
private final Hashtable<Long, SuperVehicle> superVehHash;
|
private Hashtable<Long, SuperVehicle> superVehHash;
|
||||||
private final Context context;
|
private final Context context;
|
||||||
|
private ArrayList<HistPos> histPosList;
|
||||||
|
private boolean isLiveTab = true;
|
||||||
|
|
||||||
|
|
||||||
public GoogleMapsInfoBubble(LayoutInflater layoutInflater, Context context, Hashtable<Long, SuperVehicle> vehicles) {
|
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);
|
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
|
@Override
|
||||||
public View getInfoWindow(@NonNull Marker marker) {
|
public View getInfoWindow(@NonNull Marker marker) {
|
||||||
render(marker, mWindow);
|
render(marker, mWindow);
|
||||||
@ -49,13 +64,21 @@ public class GoogleMapsInfoBubble implements GoogleMap.InfoWindowAdapter {
|
|||||||
|
|
||||||
private void render(Marker marker, View view) {
|
private void render(Marker marker, View view) {
|
||||||
long key = 0;
|
long key = 0;
|
||||||
|
int position = 0;
|
||||||
|
if (isLiveTab) {
|
||||||
try {
|
try {
|
||||||
key = Long.parseLong(marker.getTitle());
|
key = Long.parseLong(marker.getTitle());
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Log.v(TAG, "Unable to parse Google Maps Info Bubble title");
|
Log.v(TAG, "Unable to parse Google Maps Info Bubble title");
|
||||||
}
|
}
|
||||||
SuperVehicle vehicle = superVehHash.get(key);
|
} else {
|
||||||
|
try {
|
||||||
|
position = Integer.getInteger(marker.getTitle());
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.v(TAG, "Unable to parse Google Maps Info Bubble title on History");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
RelativeLayout rlMapInfoBubbleInfo = view.findViewById(R.id.rlMapInfoBubbleInfo);
|
RelativeLayout rlMapInfoBubbleInfo = view.findViewById(R.id.rlMapInfoBubbleInfo);
|
||||||
TextView tvUnitName = view.findViewById(R.id.tvUnitName);
|
TextView tvUnitName = view.findViewById(R.id.tvUnitName);
|
||||||
@ -67,27 +90,39 @@ public class GoogleMapsInfoBubble implements GoogleMap.InfoWindowAdapter {
|
|||||||
rlMapInfoBubbleInfo.setVisibility(View.VISIBLE);
|
rlMapInfoBubbleInfo.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
boolean isMilitaryTime = false;
|
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
|
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);
|
DateFormat format = new SimpleDateFormat(timeFormat, Locale.ENGLISH);
|
||||||
|
|
||||||
tvTimeAgo.setText(format.format(positionTime));
|
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);
|
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);
|
||||||
tvUnitName.setText(vehicle.name);
|
if (!isLiveTab)
|
||||||
tvGPSLocation.setText("[" + String.format("%.4f", vehicle.lat)
|
tvUnitName.setVisibility(View.GONE);
|
||||||
+ "," + String.format("%.4f",vehicle.lng) + "]");
|
else
|
||||||
|
tvUnitName.setText(name);
|
||||||
|
|
||||||
|
tvSpeed.setText(speed);
|
||||||
|
tvGPSLocation.setText(gpsLocation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,11 +2,18 @@ package com.safemobile.dispatch;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
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.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.View;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
import android.widget.DatePicker;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
@ -45,11 +52,14 @@ public class HistoryActivity extends AppCompatActivity implements OnMapReadyCall
|
|||||||
private Button displayButton;
|
private Button displayButton;
|
||||||
private Date startDate, endDate;
|
private Date startDate, endDate;
|
||||||
private final Handler myHandler = new Handler();
|
private final Handler myHandler = new Handler();
|
||||||
|
private GoogleMapsInfoBubble infoBubble;
|
||||||
|
|
||||||
private ArrayList<Vehicle> allVehicle = new ArrayList<>();
|
private ArrayList<Vehicle> allVehicle = new ArrayList<>();
|
||||||
private ArrayList<String> allVehicleNames = new ArrayList<>();
|
private ArrayList<String> allVehicleNames = new ArrayList<>();
|
||||||
private ArrayAdapter<String> adapter;
|
private ArrayAdapter<String> adapter;
|
||||||
private boolean showVehicle = true;
|
private boolean showVehicle = true;
|
||||||
|
private SimpleDateFormat sdf = new SimpleDateFormat("MMMM dd yyyy");
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -98,18 +108,6 @@ public class HistoryActivity extends AppCompatActivity implements OnMapReadyCall
|
|||||||
displayHistory(parentTab.demoPositions);
|
displayHistory(parentTab.demoPositions);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// 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();
|
setDate();
|
||||||
}
|
}
|
||||||
@ -117,14 +115,16 @@ public class HistoryActivity extends AppCompatActivity implements OnMapReadyCall
|
|||||||
private void displayHistory(ArrayList<HistPos> positions) {
|
private void displayHistory(ArrayList<HistPos> positions) {
|
||||||
LatLng latLng = null;
|
LatLng latLng = null;
|
||||||
PolylineOptions polylineOptions = new PolylineOptions();
|
PolylineOptions polylineOptions = new PolylineOptions();
|
||||||
BitmapDescriptor markerIcon = BitmapDescriptorFactory.fromResource(R.drawable.bus);
|
for (int i = 0; i < positions.size(); i++) {
|
||||||
for (HistPos pos : positions) {
|
HistPos pos = positions.get(i);
|
||||||
|
if (pos.speed > 0) {
|
||||||
latLng = new LatLng(pos.lat, pos.lng);
|
latLng = new LatLng(pos.lat, pos.lng);
|
||||||
polylineOptions.add(latLng);
|
polylineOptions.add(latLng);
|
||||||
|
|
||||||
googleMap.addMarker(new MarkerOptions()
|
googleMap.addMarker(new MarkerOptions()
|
||||||
.position(latLng)
|
.position(latLng)
|
||||||
.icon(markerIcon));
|
.title(String.valueOf(i)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Polyline polyline1 = googleMap.addPolyline(polylineOptions);
|
Polyline polyline1 = googleMap.addPolyline(polylineOptions);
|
||||||
@ -139,23 +139,38 @@ public class HistoryActivity extends AppCompatActivity implements OnMapReadyCall
|
|||||||
startDate = calendar.getTime();
|
startDate = calendar.getTime();
|
||||||
|
|
||||||
LinearLayout layoutStartPicker = findViewById(R.id.layoutStartPicker);
|
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));
|
textViewStartDate.setText(sdf.format(startDate));
|
||||||
// layoutStartPicker.setOnTouchListener((v, event) -> {
|
textViewEndDate.setText(sdf.format(endDate));
|
||||||
// showDialog(layoutStartPicker);
|
|
||||||
// return false;
|
|
||||||
// });
|
|
||||||
|
|
||||||
// layoutEndPicker.setOnTouchListener(new OnTouchListener() {
|
textViewStartDate.setOnClickListener(view -> openDialog(textViewStartDate, true));
|
||||||
// @Override
|
textViewEndDate.setOnClickListener(view -> openDialog(textViewEndDate, false));
|
||||||
// public boolean onTouch(View v, MotionEvent event) {
|
}
|
||||||
// showDialog(layoutEndPicker);
|
|
||||||
// return 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() {
|
private void changeTraffic() {
|
||||||
@ -199,6 +214,7 @@ public class HistoryActivity extends AppCompatActivity implements OnMapReadyCall
|
|||||||
public void run() {
|
public void run() {
|
||||||
Log.v("updateMap", parentTab.HistPosList.toString());
|
Log.v("updateMap", parentTab.HistPosList.toString());
|
||||||
SM.Debug("Do the Display");
|
SM.Debug("Do the Display");
|
||||||
|
infoBubble.setHistoryPositions(parentTab.HistPosList);
|
||||||
displayHistory(parentTab.HistPosList);
|
displayHistory(parentTab.HistPosList);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -224,6 +240,9 @@ public class HistoryActivity extends AppCompatActivity implements OnMapReadyCall
|
|||||||
public void onMapReady(@NonNull GoogleMap googleMap) {
|
public void onMapReady(@NonNull GoogleMap googleMap) {
|
||||||
this.googleMap = googleMap;
|
this.googleMap = googleMap;
|
||||||
|
|
||||||
|
infoBubble = new GoogleMapsInfoBubble(getLayoutInflater(), this);
|
||||||
|
this.googleMap.setInfoWindowAdapter(infoBubble);
|
||||||
|
|
||||||
parentTab.demoPositionsList();
|
parentTab.demoPositionsList();
|
||||||
displayButton.performClick();
|
displayButton.performClick();
|
||||||
}
|
}
|
||||||
|
@ -162,10 +162,11 @@
|
|||||||
android:text="@string/startDate"
|
android:text="@string/startDate"
|
||||||
android:textSize="22dp"
|
android:textSize="22dp"
|
||||||
android:paddingLeft="5dp"
|
android:paddingLeft="5dp"
|
||||||
|
android:layout_marginTop="15sp"
|
||||||
android:textColor="#000000"
|
android:textColor="#000000"
|
||||||
android:gravity="left"
|
android:gravity="left"
|
||||||
android:id="@+id/labelStartDate"
|
android:id="@+id/labelStartDate"
|
||||||
android:visibility="gone"/>
|
/>
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/layoutStartPicker"
|
android:id="@+id/layoutStartPicker"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@ -202,7 +203,7 @@
|
|||||||
android:textColor="#000000"
|
android:textColor="#000000"
|
||||||
android:gravity="left"
|
android:gravity="left"
|
||||||
android:id="@+id/labelEndDate"
|
android:id="@+id/labelEndDate"
|
||||||
android:visibility="gone"/>
|
/>
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/layoutEndPicker"
|
android:id="@+id/layoutEndPicker"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
Loading…
Reference in New Issue
Block a user