track selection is now fully functional (#10)
This commit is contained in:
parent
4cc5c7e5fa
commit
22df3abb24
16 changed files with 242 additions and 108 deletions
|
@ -5,7 +5,9 @@ AUTHORS
|
||||||
Trackbook is designed, developed and maintained by: [y20k](https://github.com/y20k)
|
Trackbook is designed, developed and maintained by: [y20k](https://github.com/y20k)
|
||||||
|
|
||||||
### Translations
|
### Translations
|
||||||
German version: [y20k](https://github.com/y20k)
|
Dutch version: [Vistaus](Vistaus)
|
||||||
|
|
||||||
|
German version: [y20k](https://github.com/Vistaus)
|
||||||
|
|
||||||
Japanese version: [naofum](https://github.com/y20k)
|
Japanese version: [naofum](https://github.com/y20k)
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,6 @@ dependencies {
|
||||||
compile 'com.android.support:appcompat-v7:25.1.1'
|
compile 'com.android.support:appcompat-v7:25.1.1'
|
||||||
compile 'com.android.support:design:25.1.1'
|
compile 'com.android.support:design:25.1.1'
|
||||||
compile 'com.android.support:cardview-v7:25.1.1'
|
compile 'com.android.support:cardview-v7:25.1.1'
|
||||||
compile 'org.osmdroid:osmdroid-android:5.6.3'
|
compile 'org.osmdroid:osmdroid-android:5.6.4'
|
||||||
compile 'com.google.code.gson:gson:2.8.0'
|
compile 'com.google.code.gson:gson:2.8.0'
|
||||||
}
|
}
|
||||||
|
|
|
@ -621,7 +621,7 @@ public class MainActivity extends AppCompatActivity implements TrackbookKeys {
|
||||||
case FRAGMENT_ID_MAP:
|
case FRAGMENT_ID_MAP:
|
||||||
return getString(R.string.tab_map);
|
return getString(R.string.tab_map);
|
||||||
case FRAGMENT_ID_TRACK:
|
case FRAGMENT_ID_TRACK:
|
||||||
return getString(R.string.tab_last_track);
|
return getString(R.string.tab_last_tracks);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -604,7 +604,7 @@ public class MainActivityMapFragment extends Fragment implements TrackbookKeys {
|
||||||
protected Void doInBackground(Void... voids) {
|
protected Void doInBackground(Void... voids) {
|
||||||
LogHelper.v(LOG_TAG, "Saving track object in background.");
|
LogHelper.v(LOG_TAG, "Saving track object in background.");
|
||||||
// save track object
|
// save track object
|
||||||
mStorageHelper.saveTrack(mTrack, FILE_TYPE_TRACK);
|
mStorageHelper.saveTrack(mTrack, FILE_MOST_CURRENT_TRACK);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -636,7 +636,7 @@ public class MainActivityMapFragment extends Fragment implements TrackbookKeys {
|
||||||
protected Void doInBackground(Void... voids) {
|
protected Void doInBackground(Void... voids) {
|
||||||
LogHelper.v(LOG_TAG, "Loading temporary track object in background.");
|
LogHelper.v(LOG_TAG, "Loading temporary track object in background.");
|
||||||
// load track object
|
// load track object
|
||||||
mTrack = mStorageHelper.loadTrack(FILE_TYPE_TEMP);
|
mTrack = mStorageHelper.loadTrack(FILE_TEMP_TRACK);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@ import android.support.v4.content.LocalBroadcastManager;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.AdapterView;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
@ -50,6 +51,7 @@ import org.y20k.trackbook.helpers.MapHelper;
|
||||||
import org.y20k.trackbook.helpers.StorageHelper;
|
import org.y20k.trackbook.helpers.StorageHelper;
|
||||||
import org.y20k.trackbook.helpers.TrackbookKeys;
|
import org.y20k.trackbook.helpers.TrackbookKeys;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
@ -57,7 +59,7 @@ import java.util.Locale;
|
||||||
/**
|
/**
|
||||||
* MainActivityTrackFragment class
|
* MainActivityTrackFragment class
|
||||||
*/
|
*/
|
||||||
public class MainActivityTrackFragment extends Fragment implements TrackbookKeys {
|
public class MainActivityTrackFragment extends Fragment implements AdapterView.OnItemSelectedListener, TrackbookKeys {
|
||||||
|
|
||||||
/* Define log tag */
|
/* Define log tag */
|
||||||
private static final String LOG_TAG = MainActivityTrackFragment.class.getSimpleName();
|
private static final String LOG_TAG = MainActivityTrackFragment.class.getSimpleName();
|
||||||
|
@ -79,6 +81,7 @@ public class MainActivityTrackFragment extends Fragment implements TrackbookKeys
|
||||||
private TextView mRecordingStartView;
|
private TextView mRecordingStartView;
|
||||||
private TextView mRecordingStopView;
|
private TextView mRecordingStopView;
|
||||||
private BottomSheetBehavior mStatisticsSheetBehavior;
|
private BottomSheetBehavior mStatisticsSheetBehavior;
|
||||||
|
private int mCurrentTrack;
|
||||||
private Track mTrack;
|
private Track mTrack;
|
||||||
private BroadcastReceiver mTrackSavedReceiver;
|
private BroadcastReceiver mTrackSavedReceiver;
|
||||||
|
|
||||||
|
@ -93,6 +96,13 @@ public class MainActivityTrackFragment extends Fragment implements TrackbookKeys
|
||||||
// store activity
|
// store activity
|
||||||
mActivity = getActivity();
|
mActivity = getActivity();
|
||||||
|
|
||||||
|
// get current track
|
||||||
|
if (savedInstanceState != null) {
|
||||||
|
mCurrentTrack = savedInstanceState.getInt(INSTANCE_CURRENT_TRACK, 0);
|
||||||
|
} else {
|
||||||
|
mCurrentTrack = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// create drop-down adapter
|
// create drop-down adapter
|
||||||
mDropdownAdapter = new DropdownAdapter(mActivity);
|
mDropdownAdapter = new DropdownAdapter(mActivity);
|
||||||
|
|
||||||
|
@ -102,9 +112,14 @@ public class MainActivityTrackFragment extends Fragment implements TrackbookKeys
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
if (intent.hasExtra(EXTRA_SAVE_FINISHED) && intent.getBooleanExtra(EXTRA_SAVE_FINISHED, false)) {
|
if (intent.hasExtra(EXTRA_SAVE_FINISHED) && intent.getBooleanExtra(EXTRA_SAVE_FINISHED, false)) {
|
||||||
LogHelper.v(LOG_TAG, "Save operation detected. Start loading the new track.");
|
LogHelper.v(LOG_TAG, "Save operation detected. Start loading the new track.");
|
||||||
|
|
||||||
// load track and display map and statistics
|
// load track and display map and statistics
|
||||||
LoadTrackAsyncHelper loadTrackAsyncHelper = new LoadTrackAsyncHelper();
|
LoadTrackAsyncHelper loadTrackAsyncHelper = new LoadTrackAsyncHelper();
|
||||||
loadTrackAsyncHelper.execute();
|
loadTrackAsyncHelper.execute();
|
||||||
|
|
||||||
|
mDropdownAdapter.refresh();
|
||||||
|
mDropdownAdapter.notifyDataSetChanged();
|
||||||
|
mDropdown.setSelection(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -137,6 +152,8 @@ public class MainActivityTrackFragment extends Fragment implements TrackbookKeys
|
||||||
// add compass to map
|
// add compass to map
|
||||||
CompassOverlay compassOverlay = new CompassOverlay(mActivity, new InternalCompassOrientationProvider(mActivity), mMapView);
|
CompassOverlay compassOverlay = new CompassOverlay(mActivity, new InternalCompassOrientationProvider(mActivity), mMapView);
|
||||||
compassOverlay.enableCompass();
|
compassOverlay.enableCompass();
|
||||||
|
// move the compass overlay down a bit
|
||||||
|
compassOverlay.setCompassCenter(35.0f, 80.0f);
|
||||||
mMapView.getOverlays().add(compassOverlay);
|
mMapView.getOverlays().add(compassOverlay);
|
||||||
|
|
||||||
// initiate map state
|
// initiate map state
|
||||||
|
@ -167,7 +184,7 @@ public class MainActivityTrackFragment extends Fragment implements TrackbookKeys
|
||||||
mTrack = savedInstanceState.getParcelable(INSTANCE_TRACK_TRACK_MAP);
|
mTrack = savedInstanceState.getParcelable(INSTANCE_TRACK_TRACK_MAP);
|
||||||
displayTrack();
|
displayTrack();
|
||||||
} else if (mTrack == null) {
|
} else if (mTrack == null) {
|
||||||
// load track and display map and statistics
|
// load track and display map and statistics // todo get via mCurrentTrack
|
||||||
LoadTrackAsyncHelper loadTrackAsyncHelper = new LoadTrackAsyncHelper();
|
LoadTrackAsyncHelper loadTrackAsyncHelper = new LoadTrackAsyncHelper();
|
||||||
loadTrackAsyncHelper.execute();
|
loadTrackAsyncHelper.execute();
|
||||||
} else {
|
} else {
|
||||||
|
@ -221,14 +238,18 @@ public class MainActivityTrackFragment extends Fragment implements TrackbookKeys
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
|
||||||
|
super.onViewCreated(view, savedInstanceState);
|
||||||
|
mDropdown.setAdapter(mDropdownAdapter);
|
||||||
|
mDropdown.setOnItemSelectedListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
StorageHelper storageHelper = new StorageHelper(mActivity);
|
|
||||||
|
|
||||||
// mTrackSelectorAdapter = new ArrayAdapter<String>(mActivity, android.R.layout.simple_spinner_dropdown_item, storageHelper.getListOfTracks());
|
|
||||||
// mDropdown.setAdapter(mTrackSelectorAdapter);
|
|
||||||
mDropdown.setAdapter(mDropdownAdapter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -258,12 +279,32 @@ public class MainActivityTrackFragment extends Fragment implements TrackbookKeys
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
|
||||||
|
// update current track
|
||||||
|
mCurrentTrack = i;
|
||||||
|
|
||||||
|
// get track file
|
||||||
|
File trackFile = mDropdownAdapter.getItem(i).getTrackFile();
|
||||||
|
|
||||||
|
// load track and display map and statistics
|
||||||
|
LoadTrackAsyncHelper loadTrackAsyncHelper = new LoadTrackAsyncHelper();
|
||||||
|
loadTrackAsyncHelper.execute(trackFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNothingSelected(AdapterView<?> adapterView) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSaveInstanceState(Bundle outState) {
|
public void onSaveInstanceState(Bundle outState) {
|
||||||
outState.putDouble(INSTANCE_LATITUDE_TRACK_MAP, mMapView.getMapCenter().getLatitude());
|
outState.putDouble(INSTANCE_LATITUDE_TRACK_MAP, mMapView.getMapCenter().getLatitude());
|
||||||
outState.putDouble(INSTANCE_LONGITUDE_TRACK_MAP, mMapView.getMapCenter().getLongitude());
|
outState.putDouble(INSTANCE_LONGITUDE_TRACK_MAP, mMapView.getMapCenter().getLongitude());
|
||||||
outState.putInt(INSTANCE_ZOOM_LEVEL_TRACK_MAP, mMapView.getZoomLevel());
|
outState.putInt(INSTANCE_ZOOM_LEVEL_TRACK_MAP, mMapView.getZoomLevel());
|
||||||
outState.putParcelable(INSTANCE_TRACK_TRACK_MAP, mTrack);
|
outState.putParcelable(INSTANCE_TRACK_TRACK_MAP, mTrack);
|
||||||
|
outState.putInt(INSTANCE_CURRENT_TRACK, mCurrentTrack);
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,14 +354,23 @@ public class MainActivityTrackFragment extends Fragment implements TrackbookKeys
|
||||||
/**
|
/**
|
||||||
* Inner class: Loads track from external storage using AsyncTask
|
* Inner class: Loads track from external storage using AsyncTask
|
||||||
*/
|
*/
|
||||||
private class LoadTrackAsyncHelper extends AsyncTask<Void, Void, Void> {
|
private class LoadTrackAsyncHelper extends AsyncTask<File, Void, Void> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground(Void... voids) {
|
protected Void doInBackground(File... files) {
|
||||||
LogHelper.v(LOG_TAG, "Loading track object in background.");
|
LogHelper.v(LOG_TAG, "Loading track object in background.");
|
||||||
// load track object
|
|
||||||
StorageHelper storageHelper = new StorageHelper(mActivity);
|
StorageHelper storageHelper = new StorageHelper(mActivity);
|
||||||
mTrack = storageHelper.loadTrack(FILE_TYPE_TRACK);
|
|
||||||
|
if (files.length > 0) {
|
||||||
|
// load track object from given file
|
||||||
|
mTrack = storageHelper.loadTrack(files[0]);
|
||||||
|
} else {
|
||||||
|
// load track object from most current file
|
||||||
|
mTrack = storageHelper.loadTrack(FILE_MOST_CURRENT_TRACK);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,6 +378,8 @@ public class MainActivityTrackFragment extends Fragment implements TrackbookKeys
|
||||||
protected void onPostExecute(Void aVoid) {
|
protected void onPostExecute(Void aVoid) {
|
||||||
super.onPostExecute(aVoid);
|
super.onPostExecute(aVoid);
|
||||||
LogHelper.v(LOG_TAG, "Loading finished. Displaying map and statistics of track.");
|
LogHelper.v(LOG_TAG, "Loading finished. Displaying map and statistics of track.");
|
||||||
|
|
||||||
|
// display track on map
|
||||||
displayTrack();
|
displayTrack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -424,7 +424,7 @@ public class TrackerService extends Service implements TrackbookKeys, SensorEven
|
||||||
LogHelper.v(LOG_TAG, "Saving temporary track object in background.");
|
LogHelper.v(LOG_TAG, "Saving temporary track object in background.");
|
||||||
// save track object
|
// save track object
|
||||||
StorageHelper storageHelper = new StorageHelper(TrackerService.this);
|
StorageHelper storageHelper = new StorageHelper(TrackerService.this);
|
||||||
storageHelper.saveTrack(mTrack, FILE_TYPE_TEMP);
|
storageHelper.saveTrack(mTrack, FILE_TEMP_TRACK);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
85
app/src/main/java/org/y20k/trackbook/core/TrackBundle.java
Normal file
85
app/src/main/java/org/y20k/trackbook/core/TrackBundle.java
Normal file
|
@ -0,0 +1,85 @@
|
||||||
|
/**
|
||||||
|
* TrackBundle.java
|
||||||
|
* Implements a TrackBundle
|
||||||
|
* TrackBundle is a container for file and corresponding name of a track
|
||||||
|
*
|
||||||
|
* This file is part of
|
||||||
|
* TRACKBOOK - Movement Recorder for Android
|
||||||
|
*
|
||||||
|
* Copyright (c) 2016-17 - Y20K.org
|
||||||
|
* Licensed under the MIT-License
|
||||||
|
* http://opensource.org/licenses/MIT
|
||||||
|
*
|
||||||
|
* Trackbook uses osmdroid - OpenStreetMap-Tools for Android
|
||||||
|
* https://github.com/osmdroid/osmdroid
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.y20k.trackbook.core;
|
||||||
|
|
||||||
|
import org.y20k.trackbook.helpers.LogHelper;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TrackBundle class
|
||||||
|
*/
|
||||||
|
public class TrackBundle {
|
||||||
|
|
||||||
|
/* Define log tag */
|
||||||
|
private static final String LOG_TAG = TrackBundle.class.getSimpleName();
|
||||||
|
|
||||||
|
/* Main class variables */
|
||||||
|
private File mTrackFile;
|
||||||
|
private String mTrackName;
|
||||||
|
|
||||||
|
|
||||||
|
/* Constructor */
|
||||||
|
public TrackBundle(File file) {
|
||||||
|
mTrackFile = file;
|
||||||
|
mTrackName = buildTrackName(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Getter for track file */
|
||||||
|
public File getTrackFile() {
|
||||||
|
return mTrackFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Getter for track name */
|
||||||
|
public String getTrackName() {
|
||||||
|
return mTrackName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Builds a readable track name from the track's file name */
|
||||||
|
private String buildTrackName(File file) {
|
||||||
|
|
||||||
|
// get file name without extension
|
||||||
|
String readableTrackName = file.getName();
|
||||||
|
readableTrackName = readableTrackName.substring(0, readableTrackName.indexOf(".trackbook"));
|
||||||
|
|
||||||
|
try {
|
||||||
|
// convert file name to date
|
||||||
|
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss", Locale.US);
|
||||||
|
Date trackDate = dateFormat.parse(readableTrackName);
|
||||||
|
|
||||||
|
// convert date to track name string according to current locale
|
||||||
|
readableTrackName = DateFormat.getDateInstance(DateFormat.LONG, Locale.getDefault()).format(trackDate) + " - " +
|
||||||
|
DateFormat.getTimeInstance(DateFormat.SHORT, Locale.getDefault()).format(trackDate);
|
||||||
|
|
||||||
|
} catch (ParseException e) {
|
||||||
|
LogHelper.w(LOG_TAG, "Unable to parse file name into date object (yyyy-MM-dd-HH-mm-ss): " + e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return readableTrackName;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -25,20 +25,21 @@ import android.support.v7.widget.ThemedSpinnerAdapter;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.BaseAdapter;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.y20k.trackbook.R;
|
import org.y20k.trackbook.R;
|
||||||
|
import org.y20k.trackbook.core.TrackBundle;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DropdownHelper class
|
* DropdownHelper class
|
||||||
*/
|
*/
|
||||||
public class DropdownAdapter implements ThemedSpinnerAdapter, TrackbookKeys {
|
public class DropdownAdapter extends BaseAdapter implements ThemedSpinnerAdapter, TrackbookKeys {
|
||||||
|
|
||||||
/* Define log tag */
|
/* Define log tag */
|
||||||
private static final String LOG_TAG = DropdownAdapter.class.getSimpleName();
|
private static final String LOG_TAG = DropdownAdapter.class.getSimpleName();
|
||||||
|
@ -157,6 +158,13 @@ public class DropdownAdapter implements ThemedSpinnerAdapter, TrackbookKeys {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Refreshes the adapter data */
|
||||||
|
public void refresh() {
|
||||||
|
// re-initialize the adapter's array list
|
||||||
|
initializeTrackBundleList();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Initializes list of track bundles */
|
/* Initializes list of track bundles */
|
||||||
private void initializeTrackBundleList() {
|
private void initializeTrackBundleList() {
|
||||||
|
|
||||||
|
@ -172,45 +180,4 @@ public class DropdownAdapter implements ThemedSpinnerAdapter, TrackbookKeys {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Inner class: Container for file and corresponding name of a track
|
|
||||||
*/
|
|
||||||
private class TrackBundle {
|
|
||||||
File trackFile;
|
|
||||||
String trackName;
|
|
||||||
|
|
||||||
/* Constructor */
|
|
||||||
TrackBundle(File file) {
|
|
||||||
trackFile = file;
|
|
||||||
trackName = buildTrackName(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Getter for track fike */
|
|
||||||
File getTrackFile() {
|
|
||||||
return trackFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Getter for track name */
|
|
||||||
String getTrackName() {
|
|
||||||
return trackName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Builds a readable track name from the track's file name */
|
|
||||||
String buildTrackName(File file) {
|
|
||||||
// todo get date back from track name
|
|
||||||
Date date = null;
|
|
||||||
|
|
||||||
// todo get name according to current locale
|
|
||||||
String readableTrackName = null;
|
|
||||||
|
|
||||||
return file.getName();
|
|
||||||
// return readableTrackName;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* End of inner class
|
|
||||||
*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,7 +104,7 @@ public class StorageHelper implements TrackbookKeys {
|
||||||
if (mFolder != null && mFolder.exists() && mFolder.isDirectory() && mFolder.canWrite() && recordingStart != null && track != null) {
|
if (mFolder != null && mFolder.exists() && mFolder.isDirectory() && mFolder.canWrite() && recordingStart != null && track != null) {
|
||||||
// create file object
|
// create file object
|
||||||
String fileName;
|
String fileName;
|
||||||
if (fileType == FILE_TYPE_TEMP) {
|
if (fileType == FILE_TEMP_TRACK) {
|
||||||
// case: temp file
|
// case: temp file
|
||||||
fileName = FILE_NAME_TEMP + FILE_TYPE_EXTENSION;
|
fileName = FILE_NAME_TEMP + FILE_TYPE_EXTENSION;
|
||||||
} else {
|
} else {
|
||||||
|
@ -130,7 +130,7 @@ public class StorageHelper implements TrackbookKeys {
|
||||||
}
|
}
|
||||||
|
|
||||||
// if write was successful delete old track files - only if not a temp file
|
// if write was successful delete old track files - only if not a temp file
|
||||||
if (fileType != FILE_TYPE_TEMP) {
|
if (fileType != FILE_TEMP_TRACK) {
|
||||||
// include temp file if it exists
|
// include temp file if it exists
|
||||||
deleteOldTracks(true);
|
deleteOldTracks(true);
|
||||||
}
|
}
|
||||||
|
@ -146,19 +146,76 @@ public class StorageHelper implements TrackbookKeys {
|
||||||
|
|
||||||
|
|
||||||
/* Loads given file into memory */
|
/* Loads given file into memory */
|
||||||
public Track loadTrack (int fileType) {
|
public Track loadTrack(int fileType) {
|
||||||
|
|
||||||
// get file reference
|
// get file reference
|
||||||
File file;
|
File trackFile;
|
||||||
if (fileType == FILE_TYPE_TEMP) {
|
switch (fileType) {
|
||||||
file = getTempFile();
|
case FILE_TEMP_TRACK:
|
||||||
} else {
|
trackFile = getTempFile();
|
||||||
file = getMostCurrentTrack();
|
break;
|
||||||
|
case FILE_MOST_CURRENT_TRACK:
|
||||||
|
trackFile = getMostCurrentTrack();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
trackFile = null;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// read & parse file and return track
|
||||||
|
return readTrackFromFile(trackFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Loads given file into memory */
|
||||||
|
public Track loadTrack(File file) {
|
||||||
|
|
||||||
|
// get file reference
|
||||||
|
File trackFile;
|
||||||
|
if (file != null) {
|
||||||
|
trackFile = file;
|
||||||
|
} else {
|
||||||
|
// fallback
|
||||||
|
trackFile = getMostCurrentTrack();
|
||||||
|
}
|
||||||
|
|
||||||
|
// read & parse file and return track
|
||||||
|
return readTrackFromFile(trackFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Gets a list of .trackbook files - excluding the temp file */
|
||||||
|
public File[] getListOfTrackbookFiles() {
|
||||||
|
// TODO HANDLE CASE: EMPTY FILE LIST
|
||||||
|
|
||||||
|
// get files and sort them
|
||||||
|
return sortFiles(mFolder.listFiles());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Gets a list of tracks based on their file names */
|
||||||
|
public List<String> getListOfTracks() {
|
||||||
|
List<String> listOfTracks = new ArrayList<String>();
|
||||||
|
|
||||||
|
// get files and sort them
|
||||||
|
File[] files = mFolder.listFiles();
|
||||||
|
files = sortFiles(files);
|
||||||
|
|
||||||
|
for (File file : files) {
|
||||||
|
listOfTracks.add(file.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO HANDLE CASE: EMPTY FILE LIST
|
||||||
|
return listOfTracks;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// loads file and parses it into a track
|
||||||
|
private Track readTrackFromFile(File file) {
|
||||||
|
|
||||||
// check if given file was null
|
// check if given file was null
|
||||||
if (file == null) {
|
if (file == null) {
|
||||||
LogHelper.e(LOG_TAG, "Did not receive file object.");
|
LogHelper.e(LOG_TAG, "Did not receive a file object.");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,33 +243,6 @@ public class StorageHelper implements TrackbookKeys {
|
||||||
LogHelper.e(LOG_TAG, "Unable to read file from external storage: " + file.toString());
|
LogHelper.e(LOG_TAG, "Unable to read file from external storage: " + file.toString());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Gets a list of .trackbook files - excluding the temp file */
|
|
||||||
public File[] getListOfTrackbookFiles() {
|
|
||||||
// TODO HANDLE CASE: EMPTY FILE LIST
|
|
||||||
|
|
||||||
// get files and sort them
|
|
||||||
return sortFiles(mFolder.listFiles());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Gets a list of tracks based on their file names */
|
|
||||||
public List<String> getListOfTracks() {
|
|
||||||
List<String> listOfTracks = new ArrayList<String>();
|
|
||||||
|
|
||||||
// get files and sort them
|
|
||||||
File[] files = mFolder.listFiles();
|
|
||||||
files = sortFiles(files);
|
|
||||||
|
|
||||||
for (File file : files) {
|
|
||||||
listOfTracks.add(file.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO HANDLE CASE: EMPTY FILE LIST
|
|
||||||
return listOfTracks;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -64,6 +64,7 @@ public interface TrackbookKeys {
|
||||||
String INSTANCE_LONGITUDE_TRACK_MAP = "longitudeTrackMap";
|
String INSTANCE_LONGITUDE_TRACK_MAP = "longitudeTrackMap";
|
||||||
String INSTANCE_ZOOM_LEVEL_TRACK_MAP = "zoomLevelTrackMap";
|
String INSTANCE_ZOOM_LEVEL_TRACK_MAP = "zoomLevelTrackMap";
|
||||||
String INSTANCE_CURRENT_LOCATION = "currentLocation";
|
String INSTANCE_CURRENT_LOCATION = "currentLocation";
|
||||||
|
String INSTANCE_CURRENT_TRACK = "currentTrack";
|
||||||
|
|
||||||
/* FRAGMENT IDS */
|
/* FRAGMENT IDS */
|
||||||
int FRAGMENT_ID_MAP = 0;
|
int FRAGMENT_ID_MAP = 0;
|
||||||
|
@ -89,13 +90,14 @@ public interface TrackbookKeys {
|
||||||
int FAB_STATE_DEFAULT = 0;
|
int FAB_STATE_DEFAULT = 0;
|
||||||
int FAB_STATE_RECORDING = 1;
|
int FAB_STATE_RECORDING = 1;
|
||||||
int FAB_STATE_SAVE = 2;
|
int FAB_STATE_SAVE = 2;
|
||||||
int FILE_TYPE_TEMP = 0;
|
int FILE_TEMP_TRACK = 0;
|
||||||
int FILE_TYPE_TRACK = 1;
|
int FILE_MOST_CURRENT_TRACK = 1;
|
||||||
|
|
||||||
String DIRECTORY_NAME = "tracks";
|
String DIRECTORY_NAME = "tracks";
|
||||||
String FILE_TYPE_EXTENSION = ".trackbook";
|
String FILE_TYPE_EXTENSION = ".trackbook";
|
||||||
String FILE_NAME_TEMP = "temp";
|
String FILE_NAME_TEMP = "temp";
|
||||||
|
|
||||||
|
|
||||||
double DEFAULT_LATITUDE = 49.41667; // latitude Nordkapp, Norway
|
double DEFAULT_LATITUDE = 49.41667; // latitude Nordkapp, Norway
|
||||||
double DEFAULT_LONGITUDE = 8.67201; // longitude Nordkapp, Norway
|
double DEFAULT_LONGITUDE = 8.67201; // longitude Nordkapp, Norway
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:contentDescription="@string/descr_map_last_track" />
|
android:contentDescription="@string/descr_map_last_track" />
|
||||||
|
|
||||||
|
<!-- TRACK SELECTION -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -35,6 +36,7 @@
|
||||||
android:theme="@style/TrackbookAppTheme.PopupOverlay"
|
android:theme="@style/TrackbookAppTheme.PopupOverlay"
|
||||||
android:contentDescription="@string/descr_track_selector" />
|
android:contentDescription="@string/descr_track_selector" />
|
||||||
<ImageButton
|
<ImageButton
|
||||||
|
android:visibility="gone"
|
||||||
android:id="@+id/delete_button"
|
android:id="@+id/delete_button"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -45,13 +47,6 @@
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<!-- MAP VIEW --> <!-- TODO remove -->
|
|
||||||
<!-- <org.osmdroid.views.MapView
|
|
||||||
android:id="@+id/track_map"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="fill_parent"
|
|
||||||
android:contentDescription="@string/descr_map_last_track" /> -->
|
|
||||||
|
|
||||||
<!-- BOTTOM SHEET -->
|
<!-- BOTTOM SHEET -->
|
||||||
<android.support.v4.widget.NestedScrollView
|
<android.support.v4.widget.NestedScrollView
|
||||||
android:id="@+id/statistics_sheet"
|
android:id="@+id/statistics_sheet"
|
||||||
|
@ -232,8 +227,6 @@
|
||||||
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</android.support.v4.widget.NestedScrollView>
|
</android.support.v4.widget.NestedScrollView>
|
||||||
|
|
||||||
</android.support.design.widget.CoordinatorLayout>
|
</android.support.design.widget.CoordinatorLayout>
|
|
@ -14,6 +14,7 @@
|
||||||
<!-- tabs -->
|
<!-- tabs -->
|
||||||
<string name="tab_map">KARTE</string>
|
<string name="tab_map">KARTE</string>
|
||||||
<string name="tab_last_track">LETZTE AUFZEICHNUNG</string>
|
<string name="tab_last_track">LETZTE AUFZEICHNUNG</string>
|
||||||
|
<string name="tab_last_tracks">LETZTE AUFZEICHNUNGEN</string>
|
||||||
|
|
||||||
<!-- notification -->
|
<!-- notification -->
|
||||||
<string name="notification_title_trackbook_not_running">Trackbook ist inaktiv</string>
|
<string name="notification_title_trackbook_not_running">Trackbook ist inaktiv</string>
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
<string name="tab_map">地図</string>
|
<string name="tab_map">地図</string>
|
||||||
<string name="tab_last_track">最後のトラック</string>
|
<string name="tab_last_track">最後のトラック</string>
|
||||||
|
<string name="tab_last_tracks">LAST TRACKS</string>
|
||||||
|
|
||||||
<string name="notification_title_trackbook_running">Trackbook 実行中</string>
|
<string name="notification_title_trackbook_running">Trackbook 実行中</string>
|
||||||
<string name="notification_title_trackbook_not_running">Trackbook は実行していません</string>
|
<string name="notification_title_trackbook_not_running">Trackbook は実行していません</string>
|
||||||
|
@ -25,7 +26,6 @@
|
||||||
<string name="fab_sub_menu_clear">クリア</string>
|
<string name="fab_sub_menu_clear">クリア</string>
|
||||||
<string name="fab_sub_menu_save_and_clear">保存してクリア</string>
|
<string name="fab_sub_menu_save_and_clear">保存してクリア</string>
|
||||||
|
|
||||||
|
|
||||||
<string name="toast_message_permissions_granted">アクセス許可を付与しました。</string>
|
<string name="toast_message_permissions_granted">アクセス許可を付与しました。</string>
|
||||||
<string name="toast_message_unable_to_start_app">Trackbook を起動できません。</string>
|
<string name="toast_message_unable_to_start_app">Trackbook を起動できません。</string>
|
||||||
<string name="toast_message_no_external_storage">外部ストレージにアクセスできません。</string>
|
<string name="toast_message_no_external_storage">外部ストレージにアクセスできません。</string>
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
<string name="tab_map">KAART</string>
|
<string name="tab_map">KAART</string>
|
||||||
<string name="tab_last_track">LAATSTE BAAN</string>
|
<string name="tab_last_track">LAATSTE BAAN</string>
|
||||||
|
<string name="tab_last_tracks">LAST TRACKS</string>
|
||||||
|
|
||||||
<string name="notification_title_trackbook_running">Trackbook is actief</string>
|
<string name="notification_title_trackbook_running">Trackbook is actief</string>
|
||||||
<string name="notification_title_trackbook_not_running">Trackbook is niet actief</string>
|
<string name="notification_title_trackbook_not_running">Trackbook is niet actief</string>
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
<!-- tabs -->
|
<!-- tabs -->
|
||||||
<string name="tab_map">MAP</string>
|
<string name="tab_map">MAP</string>
|
||||||
<string name="tab_last_track">LAST TRACK</string>
|
<string name="tab_last_track">LAST TRACK</string>
|
||||||
|
<string name="tab_last_tracks">LAST TRACKS</string>
|
||||||
|
|
||||||
<!-- notification -->
|
<!-- notification -->
|
||||||
<string name="notification_title_trackbook_running">Trackbook running</string>
|
<string name="notification_title_trackbook_running">Trackbook running</string>
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
<style name="TrackbookAppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
|
<style name="TrackbookAppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
|
||||||
|
|
||||||
<style name="TrackbookAppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light">
|
<style name="TrackbookAppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light">
|
||||||
<!-- <item name="colorBackground">@color/trackbook_red</item> -->
|
<item name="android:colorControlNormal">@color/trackbook_white</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue