Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'com.android.application'

android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
buildToolsVersion = '28.0.3'

defaultConfig {
applicationId "net.osmtracker"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="net.osmtracker"
android:versionName="0.7" android:versionCode="42" android:installLocation="auto">
android:versionName="0.7.1" android:versionCode="43" android:installLocation="auto">

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/net/osmtracker/OSMTracker.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public static final class Preferences {
public final static String KEY_GPS_CHECKSTARTUP = "gps.checkstartup";
public final static String KEY_GPS_IGNORE_CLOCK = "gps.ignoreclock";
public final static String KEY_GPS_LOGGING_INTERVAL = "gps.logging.interval";
public final static String KEY_GPS_LOGGING_MIN_DISTANCE = "gps.logging.min_distance";
public final static String KEY_OUTPUT_FILENAME = "gpx.filename";
public final static String KEY_OUTPUT_ACCURACY = "gpx.accuracy";
public final static String KEY_OUTPUT_GPX_HDOP_APPROXIMATION = "gpx.hdop.approximation";
Expand Down Expand Up @@ -53,6 +54,7 @@ public static final class Preferences {
public final static boolean VAL_GPS_CHECKSTARTUP = true;
public final static boolean VAL_GPS_IGNORE_CLOCK = false;
public final static String VAL_GPS_LOGGING_INTERVAL = "0";
public final static String VAL_GPS_LOGGING_MIN_DISTANCE = "0";

public final static String VAL_OUTPUT_FILENAME_NAME = "name";
public final static String VAL_OUTPUT_FILENAME_NAME_DATE = "name_date";
Expand Down
20 changes: 19 additions & 1 deletion app/src/main/java/net/osmtracker/activity/DisplayTrackMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
Expand Down Expand Up @@ -185,6 +186,8 @@ public void onCreate(Bundle savedInstanceState) {

selectTileSource();

setTileDpiScaling();

createOverlays();

// Create content observer for trackpoints
Expand Down Expand Up @@ -217,6 +220,14 @@ public void selectTileSource() {
String mapTile = prefs.getString(OSMTracker.Preferences.KEY_UI_MAP_TILE, OSMTracker.Preferences.VAL_UI_MAP_TILE_MAPNIK);
osmView.setTileSource(selectMapTile(mapTile));
}

/**
* Make text on map better readable on high DPI displays
*/
public void setTileDpiScaling () {
osmView.setTilesScaledToDpi(true);
}


/**
* Returns a ITileSource for the map according to the selected mapTile
Expand Down Expand Up @@ -267,6 +278,8 @@ protected void onResume() {
pathChanged();

selectTileSource();

setTileDpiScaling();

// Refresh way points
// wayPointsOverlay.refresh();
Expand Down Expand Up @@ -346,7 +359,12 @@ public boolean onTouchEvent(MotionEvent event) {
* Creates overlays over the OSM view
*/
private void createOverlays() {
pathOverlay = new PathOverlay(Color.BLUE, this);
DisplayMetrics metrics = new DisplayMetrics();
this.getWindowManager().getDefaultDisplay().getMetrics(metrics);

// set with to hopefully DPI independent 0.5mm
pathOverlay = new PathOverlay(Color.BLUE, (float)(metrics.densityDpi / 25.4 / 2),this);

osmView.getOverlays().add(pathOverlay);

myLocationOverlay = new SimpleLocationOverlay(this);
Expand Down
52 changes: 52 additions & 0 deletions app/src/main/java/net/osmtracker/activity/Preferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.osmtracker.R;

import android.Manifest;
import android.app.AlertDialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
Expand All @@ -22,6 +23,10 @@
import android.preference.PreferenceActivity;
import android.preference.PreferenceManager;
import android.provider.Settings;
import android.text.Editable;
import android.text.TextWatcher;
import android.widget.Button;
import android.widget.EditText;


/**
Expand Down Expand Up @@ -110,6 +115,53 @@ public boolean onPreferenceChange(Preference preference, Object newValue) {
}
});

// Update GPS min. distance summary to the current value
pref = findPreference(OSMTracker.Preferences.KEY_GPS_LOGGING_MIN_DISTANCE);
pref.setSummary(
prefs.getString(OSMTracker.Preferences.KEY_GPS_LOGGING_MIN_DISTANCE, OSMTracker.Preferences.VAL_GPS_LOGGING_MIN_DISTANCE)
+ " " + getResources().getString(R.string.prefs_gps_logging_min_distance_meters)
+ ". " + getResources().getString(R.string.prefs_gps_logging_min_distance_summary));
pref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
// Set summary with the interval and "seconds"
preference.setSummary(newValue
+ " " + getResources().getString(R.string.prefs_gps_logging_min_distance_meters)
+ ". " + getResources().getString(R.string.prefs_gps_logging_min_distance_summary));
return true;
}
});

// don't allow the logging_min_distance to be empty
final EditText et = ((EditTextPreference)pref).getEditText();
final EditTextPreference etp = (EditTextPreference)pref;
et.addTextChangedListener(
new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}

@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if (s.length() >= 0) {
try {
Button bt_ok = ((AlertDialog) etp.getDialog()).getButton(AlertDialog.BUTTON_POSITIVE);
if (s.length() == 0) {
bt_ok.setEnabled(false);
} else {
((AlertDialog) etp.getDialog()).getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(true);
}
} catch (Exception ex) {
}
}
}

@Override
public void afterTextChanged(Editable s) {
}
}
);

pref = findPreference(OSMTracker.Preferences.KEY_GPS_OSSETTINGS);
pref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
Expand Down
20 changes: 17 additions & 3 deletions app/src/main/java/net/osmtracker/activity/TrackLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,24 @@ protected void onCreate(Bundle savedInstanceState) {
* Also, the default layout is excluded and the 'osmtracker' tag is added by default.
*/
private void saveTagsForTrack(){
//obtain the current track id and initialize the values variable
Uri trackUri = ContentUris.withAppendedId(TrackContentProvider.CONTENT_URI_TRACK, currentTrackId);
ContentValues values = new ContentValues();

//Checking for previously saved tags
Cursor cursor = getContentResolver().query( trackUri, null, null, null, null);
StringBuilder previouslySavedTags = new StringBuilder();
int index = cursor.getColumnIndex(TrackContentProvider.Schema.COL_TAGS);

while (cursor.moveToNext()) {
if(cursor.getString(index) != null)
previouslySavedTags.append(cursor.getString(index) + ",");
}

StringBuilder tags = new StringBuilder();

tags.append(previouslySavedTags);

ArrayList<String> fixedTags = new ArrayList<String>();

//covert the file name to simple layout name
Expand All @@ -232,9 +249,6 @@ private void saveTagsForTrack(){
tags.append(simpleName).append(",");
}

//obtain the current track id and initialize the values variable
Uri trackUri = ContentUris.withAppendedId(TrackContentProvider.CONTENT_URI_TRACK, currentTrackId);
ContentValues values = new ContentValues();

//set the values tag and update the table
values.put(TrackContentProvider.Schema.COL_TAGS, tags.toString());
Expand Down
51 changes: 37 additions & 14 deletions app/src/main/java/net/osmtracker/activity/TrackManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import android.view.View;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.CursorAdapter;
import android.widget.ImageButton;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
Expand Down Expand Up @@ -69,15 +70,28 @@ public class TrackManager extends ListActivity {
/** Track Identifier to export after request for write permission **/
private long trackId = -1;

private ImageButton btnNewTrack;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.trackmanager);
setContentView(R.layout.trackmanager);
getListView().setEmptyView(findViewById(R.id.trackmgr_empty));
registerForContextMenu(getListView());
if (savedInstanceState != null) {
prevItemVisible = savedInstanceState.getInt(PREV_VISIBLE, -1);
}
//initialize the bottom start track
btnNewTrack = (ImageButton) findViewById(R.id.trackmgr_hint_icon);
//set a listener that makes the same functionality of (+) button in the main menu of this screen
btnNewTrack.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startTrackLogger();
//makes the button invisible when is an active track
btnNewTrack.setVisibility(View.INVISIBLE);
}
});
}

@Override
Expand Down Expand Up @@ -109,6 +123,8 @@ protected void onResume() {
}
}
} else {
//set the button to start a new track visible when there isn't an active track
btnNewTrack.setVisibility(View.VISIBLE);
((TextView) findViewById(R.id.trackmgr_hint)).setText(R.string.trackmgr_newtrack_hint);

// Scroll to the previous listview position,
Expand Down Expand Up @@ -188,19 +204,7 @@ public boolean onPrepareOptionsMenu(Menu menu) {
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.trackmgr_menu_newtrack:
// Start track logger activity
try {
Intent i = new Intent(this, TrackLogger.class);
// New track
currentTrackId = createNewTrack();
i.putExtra(TrackContentProvider.Schema.COL_TRACK_ID, currentTrackId);
startActivity(i);
} catch (CreateTrackException cte) {
Toast.makeText(this,
getResources().getString(R.string.trackmgr_newtrack_error).replace("{0}", cte.getMessage()),
Toast.LENGTH_LONG)
.show();
}
startTrackLogger();
break;
case R.id.trackmgr_menu_continuetrack:
Intent i = new Intent(this, TrackLogger.class);
Expand Down Expand Up @@ -265,6 +269,25 @@ public void onClick(DialogInterface dialog, int which) {
return super.onOptionsItemSelected(item);
}

/**
* This method prepare the new track and set an id, then start a new TrackLogger with the new track id
*/
private void startTrackLogger(){
// Start track logger activity
try {
Intent i = new Intent(this, TrackLogger.class);
// New track
currentTrackId = createNewTrack();
i.putExtra(TrackContentProvider.Schema.COL_TRACK_ID, currentTrackId);
startActivity(i);
} catch (CreateTrackException cte) {
Toast.makeText(this,
getResources().getString(R.string.trackmgr_newtrack_error).replace("{0}", cte.getMessage()),
Toast.LENGTH_LONG)
.show();
}
}


private void requestPermissionAndExport(int typeCode){
if (ContextCompat.checkSelfPermission(this,
Expand Down
6 changes: 5 additions & 1 deletion app/src/main/java/net/osmtracker/db/TracklistAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ private View bind(Cursor cursor, View v, Context context) {
if (cursor.isNull(cursor.getColumnIndex(TrackContentProvider.Schema.COL_OSM_UPLOAD_DATE))) {
vUploadStatus.setVisibility(View.GONE);
}

else{
vUploadStatus.setImageResource(android.R.drawable.stat_sys_upload_done);
vUploadStatus.setVisibility(View.VISIBLE);
}

// Bind id
long trackId = cursor.getLong(cursor.getColumnIndex(TrackContentProvider.Schema.COL_ID));
String strTrackId = Long.toString(trackId);
Expand Down
7 changes: 5 additions & 2 deletions app/src/main/java/net/osmtracker/service/gps/GPSLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public class GPSLogger extends Service implements LocationListener {
* the interval (in ms) to log GPS fixes defined in the preferences
*/
private long gpsLoggingInterval;
private long gpsLoggingMinDistance;

/**
* sensors for magnetic orientation
Expand Down Expand Up @@ -200,6 +201,8 @@ public void onCreate() {
//read the logging interval from preferences
gpsLoggingInterval = Long.parseLong(PreferenceManager.getDefaultSharedPreferences(this.getApplicationContext()).getString(
OSMTracker.Preferences.KEY_GPS_LOGGING_INTERVAL, OSMTracker.Preferences.VAL_GPS_LOGGING_INTERVAL)) * 1000;
gpsLoggingMinDistance = Long.parseLong(PreferenceManager.getDefaultSharedPreferences(this.getApplicationContext()).getString(
OSMTracker.Preferences.KEY_GPS_LOGGING_MIN_DISTANCE, OSMTracker.Preferences.VAL_GPS_LOGGING_MIN_DISTANCE));

// Register our broadcast receiver
IntentFilter filter = new IntentFilter();
Expand All @@ -214,8 +217,8 @@ public void onCreate() {
lmgr = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
lmgr.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
}
lmgr.requestLocationUpdates(LocationManager.GPS_PROVIDER, gpsLoggingInterval, gpsLoggingMinDistance, this);
}

//register for Orientation updates
sensorListener.register(this);
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/net/osmtracker/view/TextNoteDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.WindowManager.LayoutParams;
import android.widget.EditText;

import net.osmtracker.db.TrackContentProvider;
Expand Down Expand Up @@ -109,6 +110,8 @@ protected void onStart() {
intent.putExtra(OSMTracker.INTENT_KEY_NAME, context.getResources().getString(R.string.gpsstatus_record_textnote));
context.sendBroadcast(intent);
}

getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);

super.onStart();
}
Expand Down
Loading