Skip to content

Commit 3f2b789

Browse files
Update to v3.1.3
2 parents 13d5164 + 2b7a425 commit 3f2b789

32 files changed

+338
-432
lines changed

apk/GPSLogger-3.1.3.apk

3.7 MB
Binary file not shown.

apk/GPSLogger-latest.apk

-4 KB
Binary file not shown.

app/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ android {
4444

4545
// -----------------------------------------------------------------------------------------
4646
// We use the Semantic Versioning (https://semver.org/):
47-
versionName '3.1.2'
48-
versionCode 43
47+
versionName '3.1.3'
48+
versionCode 44
4949
// -----------------------------------------------------------------------------------------
5050

5151
vectorDrawables.useSupportLibrary = true

app/src/main/java/eu/basicairdata/graziano/gpslogger/EGM96.java

-9
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,6 @@ public boolean isGridAvailable(String path) {
136136
}
137137
}
138138

139-
// public void unloadGrid() {
140-
// isEGMGridLoaded = false;
141-
// isEGMGridLoading = false;
142-
// //listener.onEGMGridLoaded(isEGMGridLoaded);
143-
// EventBus.getDefault().post(EventBusMSG.UPDATE_FIX);
144-
// EventBus.getDefault().post(EventBusMSG.UPDATE_TRACK);
145-
// EventBus.getDefault().post(EventBusMSG.UPDATE_TRACKLIST);
146-
// }
147-
148139
/**
149140
* Returns true if the EGM Grid is loaded and ready to work.
150141
*

app/src/main/java/eu/basicairdata/graziano/gpslogger/EventBusMSG.java

-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ public class EventBusMSG {
3636
static final short ADD_PLACEMARK = 9; // The placemark is available
3737
static final short APPLY_SETTINGS = 10; // The new settings must be applied
3838
static final short TOAST_TRACK_EXPORTED = 11; // The exporter has finished to export the track, shows toast
39-
static final short TOAST_STORAGE_PERMISSION_REQUIRED= 12; // The Storage permission is required
4039
static final short UPDATE_JOB_PROGRESS = 13; // Update the progress of the current Job
4140
static final short NOTIFY_TRACKS_DELETED = 14; // Notify that some tracks are deleted
4241
static final short UPDATE_ACTIONBAR = 15; // Notify that the actionbar must be updated

app/src/main/java/eu/basicairdata/graziano/gpslogger/Exporter.java

+34-45
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ class Exporter extends Thread {
5151

5252
private final Track track;
5353
private final ExportingTask exportingTask;
54-
private boolean exportKML = true;
55-
private boolean exportGPX = true;
56-
private boolean exportTXT = true;
57-
private String saveIntoFolder = "/";
58-
private double altitudeManualCorrection = 0;
59-
private boolean egmAltitudeCorrection = false;
60-
private int getPrefKMLAltitudeMode = 0;
61-
private int getPrefGPXVersion = 0;
54+
private final boolean exportKML;
55+
private final boolean exportGPX;
56+
private final boolean exportTXT;
57+
private final String saveIntoFolder;
58+
private final double altitudeManualCorrection;
59+
private final boolean egmAltitudeCorrection;
60+
private final int getPrefKMLAltitudeMode;
61+
private final int getPrefGPXVersion;
6262
private boolean txtFirstTrackpointFlag = true;
6363

6464
private DocumentFile kmlFile;
@@ -152,20 +152,6 @@ private boolean tryToInitFiles(String fName) {
152152
exportingTask.setStatus(ExportingTask.STATUS_ENDED_FAILED);
153153
return false;
154154
}
155-
156-
// Check if all the files are writable:
157-
// try {
158-
// if ((exportGPX && !(gpxFile.createNewFile())) || (exportKML && !(kmlFile.createNewFile())) || (exportTXT && !(txtFile.createNewFile()))) {
159-
// Log.w("myApp", "[#] Exporter.java - Unable to write the file " + fName);
160-
// return false;
161-
// }
162-
// } catch (SecurityException e) {
163-
// Log.w("myApp", "[#] Exporter.java - Unable to write the file: SecurityException");
164-
// return false;
165-
// } catch (IOException e) {
166-
// Log.w("myApp", "[#] Exporter.java - Unable to write the file: IOException");
167-
// return false;
168-
// }
169155
return true;
170156
}
171157

@@ -228,15 +214,6 @@ public void run() {
228214
elements_total = track.getNumberOfLocations() + track.getNumberOfPlacemarks();
229215
long startTime = System.currentTimeMillis();
230216

231-
// ------------------------------------------------- Create the Directory tree if not exist
232-
233-
// if (!sd.exists()) {
234-
// if (!sd.mkdir()) {
235-
// Log.w("myApp", "[#] Exporter.java - UNABLE TO CREATE THE FOLDER");
236-
// exportingTask.setStatus(ExportingTask.STATUS_ENDED_FAILED);
237-
// return;
238-
// }
239-
// }
240217
// ----------------------------------------------------------------------------------------
241218

242219
if (track == null) {
@@ -276,19 +253,6 @@ public void run() {
276253
//final String newLine = System.getProperty("line.separator"); //\n\r
277254
final String newLine = "\r\n";
278255

279-
// Verify if Folder exists
280-
// sd = new File(saveIntoFolder);
281-
// boolean success = true;
282-
// if (!sd.exists()) {
283-
// success = sd.mkdir();
284-
// }
285-
// if (!success) {
286-
// Log.w("myApp", "[#] Exporter.java - Unable to sd.mkdir");
287-
// exportingTask.setStatus(ExportingTask.STATUS_ENDED_FAILED);
288-
// //EventBus.getDefault().post(new EventBusMSGNormal(EventBusMSG.TOAST_UNABLE_TO_WRITE_THE_FILE, track.getId()));
289-
// return;
290-
// }
291-
292256
// If the file is not writable abort exportation:
293257
boolean fileWritable = tryToInitFiles(gpsApp.getFileName(track)); // Try to use the name with the description
294258
//if (!fileWritable) fileWritable = tryToInitFiles(track.getName()); // else try to use the name without description
@@ -404,6 +368,9 @@ public void run() {
404368
gpxBW.write("<!-- Avg Speed = " + phdSpeedAvg.value + " | " + phdSpeedAvgMoving.value + " " + phdSpeedAvg.um + " -->" + newLine);
405369
if (!phdOverallDirection.value.isEmpty())
406370
gpxBW.write("<!-- Direction = " + phdOverallDirection.value + phdOverallDirection.um + " -->" + newLine);
371+
if (track.getEstimatedTrackType() != NOT_AVAILABLE)
372+
gpxBW.write("<!-- Activity = " + Track.ACTIVITY_DESCRIPTION[track.getEstimatedTrackType()] + " -->" + newLine);
373+
407374
gpxBW.write(newLine);
408375
}
409376

@@ -415,8 +382,20 @@ public void run() {
415382
+ " xsi:schemaLocation=\"http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd\">" + newLine);
416383
gpxBW.write("<name>GPS Logger " + track.getName() + "</name>" + newLine);
417384
if (!track.getDescription().isEmpty()) gpxBW.write("<desc>" + stringToXML(track.getDescription()) + "</desc>" + newLine);
418-
gpxBW.write("<time>" + dfdtGPX_NoMillis.format(creationTime) + "</time>" + newLine + newLine);
385+
gpxBW.write("<time>" + dfdtGPX_NoMillis.format(creationTime) + "</time>" + newLine);
386+
if (track.getEstimatedTrackType() != NOT_AVAILABLE) gpxBW.write("<keywords>" + Track.ACTIVITY_DESCRIPTION[track.getEstimatedTrackType()] + "</keywords>" + newLine);
387+
if ((track.getValidMap() != 0)
388+
&& (track.getLatitudeMin() != NOT_AVAILABLE) && (track.getLongitudeMin() != NOT_AVAILABLE)
389+
&& (track.getLatitudeMax() != NOT_AVAILABLE) && (track.getLongitudeMax() != NOT_AVAILABLE)) {
390+
gpxBW.write("<bounds minlat=\"" + String.format(Locale.US, "%.8f", track.getLatitudeMin())
391+
+ "\" minlon=\"" + String.format(Locale.US, "%.8f", track.getLongitudeMin())
392+
+ "\" maxlat=\"" + String.format(Locale.US, "%.8f", track.getLatitudeMax())
393+
+ "\" maxlon=\"" + String.format(Locale.US, "%.8f", track.getLongitudeMax())
394+
+ "\" />" + newLine);
395+
}
396+
gpxBW.write(newLine);
419397
}
398+
420399
if (getPrefGPXVersion == GPX1_1) { // GPX 1.1
421400
gpxBW.write("<gpx version=\"1.1\"" + newLine
422401
+ " creator=\"BasicAirData GPS Logger " + versionName + "\"" + newLine
@@ -430,6 +409,16 @@ public void run() {
430409
gpxBW.write(" <name>GPS Logger " + track.getName() + "</name>" + newLine);
431410
if (!track.getDescription().isEmpty()) gpxBW.write(" <desc>" + stringToXML(track.getDescription()) + "</desc>" + newLine);
432411
gpxBW.write(" <time>" + dfdtGPX_NoMillis.format(creationTime) + "</time>" + newLine);
412+
if (track.getEstimatedTrackType() != NOT_AVAILABLE) gpxBW.write(" <keywords>" + Track.ACTIVITY_DESCRIPTION[track.getEstimatedTrackType()] + "</keywords>" + newLine);
413+
if ((track.getValidMap() != 0)
414+
&& (track.getLatitudeMin() != NOT_AVAILABLE) && (track.getLongitudeMin() != NOT_AVAILABLE)
415+
&& (track.getLatitudeMax() != NOT_AVAILABLE) && (track.getLongitudeMax() != NOT_AVAILABLE)) {
416+
gpxBW.write(" <bounds minlat=\"" + String.format(Locale.US, "%.8f", track.getLatitudeMin())
417+
+ "\" minlon=\"" + String.format(Locale.US, "%.8f", track.getLongitudeMin())
418+
+ "\" maxlat=\"" + String.format(Locale.US, "%.8f", track.getLatitudeMax())
419+
+ "\" maxlon=\"" + String.format(Locale.US, "%.8f", track.getLongitudeMax())
420+
+ "\" />" + newLine);
421+
}
433422
gpxBW.write("</metadata>" + newLine + newLine);
434423
}
435424
}

app/src/main/java/eu/basicairdata/graziano/gpslogger/FragmentAboutDialog.java

+40-19
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,13 @@
2626
import android.content.Intent;
2727
import android.net.Uri;
2828
import android.os.Bundle;
29+
30+
import androidx.annotation.NonNull;
2931
import androidx.annotation.Nullable;
3032
import androidx.fragment.app.DialogFragment;
3133
import androidx.appcompat.app.AlertDialog;
34+
35+
import android.util.Log;
3236
import android.view.LayoutInflater;
3337
import android.view.View;
3438
import android.widget.TextView;
@@ -39,9 +43,15 @@
3943
*/
4044
public class FragmentAboutDialog extends DialogFragment {
4145

46+
private static final String COPYRIGHT_RANGE_END = "2022"; // The number that appears as end-year of the Copyright range
47+
4248
//@SuppressLint("InflateParams")
49+
@NonNull
4350
@Override
4451
public Dialog onCreateDialog(Bundle savedInstanceState) {
52+
final int APP_ORIGIN_NOT_SPECIFIED = 0;
53+
final int APP_ORIGIN_GOOGLE_PLAY_STORE = 1; // The app has been installed from Google Play Store
54+
4555
TextView tvVersion;
4656
TextView tvDescription;
4757

@@ -57,25 +67,28 @@ public Dialog onCreateDialog(Bundle savedInstanceState) {
5767
tvVersion.setText(getString(R.string.about_version) + " " + versionName);
5868

5969
tvDescription = view.findViewById(R.id.id_about_textView_description);
60-
switch (gpsApp.getAppOrigin()) {
61-
case GPSApplication.APP_ORIGIN_NOT_SPECIFIED:
62-
tvDescription.setText(getString(R.string.about_description));
63-
break;
64-
case GPSApplication.APP_ORIGIN_GOOGLE_PLAY_STORE:
65-
tvDescription.setText(getString(R.string.about_description) + "\n\n" + getString(R.string.about_description_googleplaystore));
66-
break;
67-
}
70+
tvDescription.setText(getString(R.string.about_description, COPYRIGHT_RANGE_END));
6871

69-
createAboutAlert.setView(view).setPositiveButton(R.string.about_ok, new DialogInterface.OnClickListener() {
70-
@Override
71-
public void onClick(DialogInterface dialog, int id) {}
72-
});
72+
int appOrigin = APP_ORIGIN_NOT_SPECIFIED; // Which package manager is used to install this app (for Rate button visualization):
73+
// APP_ORIGIN_NOT_SPECIFIED, APP_ORIGIN_GOOGLE_PLAY_STORE
74+
// Determine the app installation source
75+
try {
76+
String installer;
77+
installer = gpsApp.getApplicationContext().getPackageManager().getInstallerPackageName(gpsApp.getApplicationContext().getPackageName());
78+
if (installer.equals("com.android.vending") || installer.equals("com.google.android.feedback"))
79+
appOrigin = APP_ORIGIN_GOOGLE_PLAY_STORE; // App installed from Google Play Store
80+
//else appOrigin = APP_ORIGIN_NOT_SPECIFIED; // Otherwise
81+
} catch (Exception e) {
82+
Log.w("myApp", "[#] GPSApplication.java - Exception trying to determine the package installer");
83+
appOrigin = APP_ORIGIN_NOT_SPECIFIED;
84+
}
7385

74-
if (gpsApp.getAppOrigin() != GPSApplication.APP_ORIGIN_NOT_SPECIFIED) {
75-
createAboutAlert.setView(view).setNegativeButton(R.string.about_rate_this_app, new DialogInterface.OnClickListener() {
76-
@Override
77-
public void onClick(DialogInterface dialog, int id) {
78-
if (gpsApp.getAppOrigin() == GPSApplication.APP_ORIGIN_GOOGLE_PLAY_STORE) {
86+
switch (appOrigin) {
87+
case APP_ORIGIN_GOOGLE_PLAY_STORE:
88+
tvDescription.setText(tvDescription.getText() + "\n\n" + getString(R.string.about_description_googleplaystore));
89+
createAboutAlert.setView(view).setNegativeButton(R.string.about_rate_this_app, new DialogInterface.OnClickListener() {
90+
@Override
91+
public void onClick(DialogInterface dialog, int id) {
7992
boolean marketfailed = false;
8093
try {
8194
getContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + BuildConfig.APPLICATION_ID)));
@@ -92,9 +105,17 @@ public void onClick(DialogInterface dialog, int id) {
92105
}
93106
}
94107
}
95-
}
96-
});
108+
});
109+
break;
110+
default:
111+
break;
97112
}
113+
114+
createAboutAlert.setView(view).setPositiveButton(R.string.about_ok, new DialogInterface.OnClickListener() {
115+
@Override
116+
public void onClick(DialogInterface dialog, int id) {}
117+
});
118+
98119
return createAboutAlert.create();
99120
}
100121

app/src/main/java/eu/basicairdata/graziano/gpslogger/FragmentRecordingControls.java

+16-7
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
*/
5151
public class FragmentRecordingControls extends Fragment {
5252

53+
Toast toast;
54+
5355
private TextView tvGeoPointsNumber;
5456
private TextView tvPlacemarksNumber;
5557
private TextView tvLockButton;
@@ -146,14 +148,16 @@ public void onToggleRecord() {
146148
if (!gpsApp.isStopButtonFlag()) {
147149
gpsApp.setRecording(!gpsApp.isRecording());
148150
if (!gpsApp.isFirstFixFound() && (gpsApp.isRecording())) {
149-
Toast toast = Toast.makeText(gpsApp.getApplicationContext(), R.string.toast_recording_when_gps_found, Toast.LENGTH_LONG);
151+
if (toast != null) toast.cancel();
152+
toast = Toast.makeText(gpsApp.getApplicationContext(), R.string.toast_recording_when_gps_found, Toast.LENGTH_LONG);
150153
toast.setGravity(Gravity.BOTTOM, 0, TOAST_VERTICAL_OFFSET);
151154
toast.show();
152155
}
153156
Update();
154157
}
155158
} else {
156-
Toast toast = Toast.makeText(gpsApp.getApplicationContext(), R.string.toast_bottom_bar_locked, Toast.LENGTH_SHORT);
159+
if (toast != null) toast.cancel();
160+
toast = Toast.makeText(gpsApp.getApplicationContext(), R.string.toast_bottom_bar_locked, Toast.LENGTH_SHORT);
157161
toast.setGravity(Gravity.BOTTOM, 0, TOAST_VERTICAL_OFFSET);
158162
toast.show();
159163
}
@@ -171,14 +175,16 @@ public void onRequestAnnotation() {
171175
if (!gpsApp.isStopButtonFlag()) {
172176
gpsApp.setPlacemarkRequested(!gpsApp.isPlacemarkRequested());
173177
if (!gpsApp.isFirstFixFound() && (gpsApp.isPlacemarkRequested())) {
174-
Toast toast = Toast.makeText(gpsApp.getApplicationContext(), R.string.toast_annotate_when_gps_found, Toast.LENGTH_LONG);
178+
if (toast != null) toast.cancel();
179+
toast = Toast.makeText(gpsApp.getApplicationContext(), R.string.toast_annotate_when_gps_found, Toast.LENGTH_LONG);
175180
toast.setGravity(Gravity.BOTTOM, 0, TOAST_VERTICAL_OFFSET);
176181
toast.show();
177182
}
178183
Update();
179184
}
180185
} else {
181-
Toast toast = Toast.makeText(gpsApp.getApplicationContext(), R.string.toast_bottom_bar_locked, Toast.LENGTH_SHORT);
186+
if (toast != null) toast.cancel();
187+
toast = Toast.makeText(gpsApp.getApplicationContext(), R.string.toast_bottom_bar_locked, Toast.LENGTH_SHORT);
182188
toast.setGravity(Gravity.BOTTOM, 0, TOAST_VERTICAL_OFFSET);
183189
toast.show();
184190
}
@@ -205,13 +211,15 @@ public void onRequestStop() {
205211
tpDialog.setFinalizeTrackWithOk(true);
206212
tpDialog.show(fm, "");
207213
} else {
208-
Toast toast = Toast.makeText(gpsApp.getApplicationContext(), R.string.toast_nothing_to_save, Toast.LENGTH_SHORT);
214+
if (toast != null) toast.cancel();
215+
toast = Toast.makeText(gpsApp.getApplicationContext(), R.string.toast_nothing_to_save, Toast.LENGTH_SHORT);
209216
toast.setGravity(Gravity.BOTTOM, 0, TOAST_VERTICAL_OFFSET);
210217
toast.show();
211218
}
212219
}
213220
} else {
214-
Toast toast = Toast.makeText(gpsApp.getApplicationContext(), R.string.toast_bottom_bar_locked, Toast.LENGTH_SHORT);
221+
if (toast != null) toast.cancel();
222+
toast = Toast.makeText(gpsApp.getApplicationContext(), R.string.toast_bottom_bar_locked, Toast.LENGTH_SHORT);
215223
toast.setGravity(Gravity.BOTTOM, 0, TOAST_VERTICAL_OFFSET);
216224
toast.show();
217225
}
@@ -225,7 +233,8 @@ public void onToggleLock() {
225233
if (isAdded()) {
226234
gpsApp.setBottomBarLocked(!gpsApp.isBottomBarLocked());
227235
if (gpsApp.isBottomBarLocked()) {
228-
Toast toast = Toast.makeText(gpsApp.getApplicationContext(), R.string.toast_bottom_bar_locked, Toast.LENGTH_SHORT);
236+
if (toast != null) toast.cancel();
237+
toast = Toast.makeText(gpsApp.getApplicationContext(), R.string.toast_bottom_bar_locked, Toast.LENGTH_SHORT);
229238
toast.setGravity(Gravity.BOTTOM, 0, TOAST_VERTICAL_OFFSET);
230239
toast.show();
231240
}

0 commit comments

Comments
 (0)