feature/apk_versioning_mechanism #7

Merged
CiufudeanDani merged 12 commits from feature/apk_versioning_mechanism into develop 2022-03-22 13:19:48 +00:00
9 changed files with 538 additions and 763 deletions

0
gradlew vendored Normal file → Executable file
View File

View File

@ -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;

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 {

View File

@ -1,9 +1,7 @@
<?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

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;
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");
}
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);
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();
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -162,10 +162,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 +203,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 +285,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"