Compare commits
2 Commits
36f58c3fd1
...
12d6af8ff1
| Author | SHA1 | Date |
|---|---|---|
|
|
12d6af8ff1 | |
|
|
14b9aae22c |
|
|
@ -22,15 +22,20 @@ import java.util.List;
|
||||||
public class FilePicker extends ListActivity {
|
public class FilePicker extends ListActivity {
|
||||||
|
|
||||||
public final static String EXTRA_FILE_PATH = "file_path";
|
public final static String EXTRA_FILE_PATH = "file_path";
|
||||||
|
public final static String EXTRA_TRACE_TYPE = "trace_type";
|
||||||
public final static String EXTRA_SHOW_HIDDEN_FILES = "show_hidden_files";
|
public final static String EXTRA_SHOW_HIDDEN_FILES = "show_hidden_files";
|
||||||
public final static String EXTRA_ACCEPTED_FILE_EXTENSIONS = "accepted_file_extensions";
|
public final static String EXTRA_ACCEPTED_FILE_EXTENSIONS = "accepted_file_extensions";
|
||||||
private final static String DEFAULT_INITIAL_DIRECTORY = "/";
|
private final static String DEFAULT_INITIAL_DIRECTORY = "/";
|
||||||
|
|
||||||
|
public static final String EXTRA_TRACE_TYPE_VALUE_DOG = "dog";
|
||||||
|
public static final String EXTRA_TRACE_TYPE_VALUE_TRAIL = "trail";
|
||||||
|
|
||||||
protected File Directory;
|
protected File Directory;
|
||||||
protected ArrayList<File> Files;
|
protected ArrayList<File> Files;
|
||||||
protected FilePickerListAdapter Adapter;
|
protected FilePickerListAdapter Adapter;
|
||||||
protected boolean ShowHiddenFiles = false;
|
protected boolean ShowHiddenFiles = false;
|
||||||
protected String[] acceptedFileExtensions;
|
protected String[] acceptedFileExtensions;
|
||||||
|
protected String traceType;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
@ -62,6 +67,10 @@ public class FilePicker extends ListActivity {
|
||||||
Directory = new File(getIntent().getStringExtra(EXTRA_FILE_PATH));
|
Directory = new File(getIntent().getStringExtra(EXTRA_FILE_PATH));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getIntent().hasExtra(EXTRA_TRACE_TYPE)) {
|
||||||
|
traceType = getIntent().getStringExtra(EXTRA_TRACE_TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
if (getIntent().hasExtra(EXTRA_SHOW_HIDDEN_FILES)) {
|
if (getIntent().hasExtra(EXTRA_SHOW_HIDDEN_FILES)) {
|
||||||
ShowHiddenFiles = getIntent().getBooleanExtra(EXTRA_SHOW_HIDDEN_FILES, false);
|
ShowHiddenFiles = getIntent().getBooleanExtra(EXTRA_SHOW_HIDDEN_FILES, false);
|
||||||
}
|
}
|
||||||
|
|
@ -111,6 +120,7 @@ public class FilePicker extends ListActivity {
|
||||||
if (newFile.isFile()) {
|
if (newFile.isFile()) {
|
||||||
Intent extra = new Intent();
|
Intent extra = new Intent();
|
||||||
extra.putExtra(EXTRA_FILE_PATH, newFile.getAbsolutePath());
|
extra.putExtra(EXTRA_FILE_PATH, newFile.getAbsolutePath());
|
||||||
|
extra.putExtra(EXTRA_TRACE_TYPE, traceType);
|
||||||
setResult(RESULT_OK, extra);
|
setResult(RESULT_OK, extra);
|
||||||
finish();
|
finish();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -361,8 +361,12 @@ public class MainActivity extends AppCompatActivity implements IOrientationConsu
|
||||||
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
|
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
|
||||||
int id = item.getItemId();
|
int id = item.getItemId();
|
||||||
|
|
||||||
if (id == R.id.action_import_gpx) {
|
if (id == R.id.action_import_trail_gpx) {
|
||||||
startActivityPickFile();
|
startActivityPickFile(FilePicker.EXTRA_TRACE_TYPE_VALUE_TRAIL);
|
||||||
|
mDrawerLayout.closeDrawers();
|
||||||
|
return true;
|
||||||
|
} else if (id == R.id.action_import_dog_gpx) {
|
||||||
|
startActivityPickFile(FilePicker.EXTRA_TRACE_TYPE_VALUE_DOG);
|
||||||
mDrawerLayout.closeDrawers();
|
mDrawerLayout.closeDrawers();
|
||||||
return true;
|
return true;
|
||||||
} else if (id == R.id.action_send_gpx_trail) {
|
} else if (id == R.id.action_send_gpx_trail) {
|
||||||
|
|
@ -404,9 +408,10 @@ public class MainActivity extends AppCompatActivity implements IOrientationConsu
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startActivityPickFile() {
|
private void startActivityPickFile(String traceType) {
|
||||||
Intent intent = new Intent(this, FilePicker.class);
|
Intent intent = new Intent(this, FilePicker.class);
|
||||||
intent.putExtra(FilePicker.EXTRA_FILE_PATH, Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + appName);
|
intent.putExtra(FilePicker.EXTRA_FILE_PATH, Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + appName);
|
||||||
|
intent.putExtra(FilePicker.EXTRA_TRACE_TYPE, traceType);
|
||||||
startActivityForResult(intent, ACTIVITY_REQUEST_PICK_FILE);
|
startActivityForResult(intent, ACTIVITY_REQUEST_PICK_FILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -434,6 +439,7 @@ public class MainActivity extends AppCompatActivity implements IOrientationConsu
|
||||||
map.getOverlayManager().removeAll(listTrailObject);
|
map.getOverlayManager().removeAll(listTrailObject);
|
||||||
listTrailObject.clear();
|
listTrailObject.clear();
|
||||||
this.textViewCurrentLocation.setVisibility(View.GONE);
|
this.textViewCurrentLocation.setVisibility(View.GONE);
|
||||||
|
map.invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clearDog() {
|
private void clearDog() {
|
||||||
|
|
@ -446,6 +452,7 @@ public class MainActivity extends AppCompatActivity implements IOrientationConsu
|
||||||
map.getOverlayManager().removeAll(listDogObject);
|
map.getOverlayManager().removeAll(listDogObject);
|
||||||
listDogObject.clear();
|
listDogObject.clear();
|
||||||
this.textViewCurrentLocation.setVisibility(View.GONE);
|
this.textViewCurrentLocation.setVisibility(View.GONE);
|
||||||
|
map.invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void activeVibrationObject(MenuItem item) {
|
private void activeVibrationObject(MenuItem item) {
|
||||||
|
|
@ -522,32 +529,36 @@ public class MainActivity extends AppCompatActivity implements IOrientationConsu
|
||||||
switch (requestCode) {
|
switch (requestCode) {
|
||||||
case ACTIVITY_REQUEST_PICK_FILE:
|
case ACTIVITY_REQUEST_PICK_FILE:
|
||||||
if (data.hasExtra(FilePicker.EXTRA_FILE_PATH)) {
|
if (data.hasExtra(FilePicker.EXTRA_FILE_PATH)) {
|
||||||
serviceTrackingDog.importGpxTrace(new File(data.getStringExtra(FilePicker.EXTRA_FILE_PATH)));
|
String traceType = data.getStringExtra(FilePicker.EXTRA_TRACE_TYPE);
|
||||||
updateDogTrace();
|
if (traceType != null && traceType.equals(FilePicker.EXTRA_TRACE_TYPE_VALUE_DOG)) {
|
||||||
updateTrailTrace();
|
serviceTrackingDog.importDogGpxTrace(new File(data.getStringExtra(FilePicker.EXTRA_FILE_PATH)));
|
||||||
updateSendTraceMenu();
|
updateDogTrace();
|
||||||
|
|
||||||
// Update distance
|
for (MyLocation loc: serviceTrackingDog.getListGeoPointObjectsDog()) {
|
||||||
distance = serviceTrackingDog.calculTrailDistance();
|
boolean isFound = false;
|
||||||
if (distance != 0) {
|
if (loc instanceof WayPointLocation) {
|
||||||
updatePlaceholder();
|
isFound = ((WayPointLocation) loc).isFound();
|
||||||
}
|
}
|
||||||
|
addMarker(new GeoPoint(loc.getLatitude(), loc.getLongitude(), loc.getAltitude()), isFound);
|
||||||
for (MyLocation loc: serviceTrackingDog.getListGeoPointObjectsTrail()) {
|
|
||||||
addMarker(new GeoPoint(loc.getLatitude(), loc.getLongitude(), loc.getAltitude()), false);
|
|
||||||
}
|
|
||||||
for (MyLocation loc: serviceTrackingDog.getListGeoPointObjectsDog()) {
|
|
||||||
boolean isFound = false;
|
|
||||||
if (loc instanceof WayPointLocation) {
|
|
||||||
isFound = ((WayPointLocation) loc).isFound();
|
|
||||||
}
|
}
|
||||||
addMarker(new GeoPoint(loc.getLatitude(), loc.getLongitude(), loc.getAltitude()), isFound);
|
|
||||||
}
|
|
||||||
if (!serviceTrackingDog.getListGeoPointTraceur().isEmpty()) {
|
|
||||||
updatePlaceholder(getTextTraceur());
|
|
||||||
} else if (!serviceTrackingDog.getListGeoPointDog().isEmpty()) {
|
|
||||||
updatePlaceholder(getTextDog());
|
updatePlaceholder(getTextDog());
|
||||||
|
|
||||||
|
} else if (traceType != null && traceType.equals(FilePicker.EXTRA_TRACE_TYPE_VALUE_TRAIL)) {
|
||||||
|
serviceTrackingDog.importTrailGpxTrace(new File(data.getStringExtra(FilePicker.EXTRA_FILE_PATH)));
|
||||||
|
updateTrailTrace();
|
||||||
|
|
||||||
|
// Update distance
|
||||||
|
distance = serviceTrackingDog.calculTrailDistance();
|
||||||
|
if (distance != 0) {
|
||||||
|
updatePlaceholder();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (MyLocation loc: serviceTrackingDog.getListGeoPointObjectsTrail()) {
|
||||||
|
addMarker(new GeoPoint(loc.getLatitude(), loc.getLongitude(), loc.getAltitude()), false);
|
||||||
|
}
|
||||||
|
updatePlaceholder(getTextTraceur());
|
||||||
}
|
}
|
||||||
|
updateSendTraceMenu();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -447,28 +447,35 @@ public class ServiceTrackingDog implements Observer {
|
||||||
lastExportedTrailFile = file;
|
lastExportedTrailFile = file;
|
||||||
return exportGpx.export();
|
return exportGpx.export();
|
||||||
}
|
}
|
||||||
public void importGpxTrace(File file) {
|
public void importTrailGpxTrace(File file) {
|
||||||
ImportGpx importGpx = new ImportGpx(file);
|
ImportGpx importGpx = new ImportGpx(file);
|
||||||
try {
|
try {
|
||||||
List<MyLocation> list = importGpx.parse();
|
List<MyLocation> list = importGpx.parse();
|
||||||
String traceName = importGpx.getTraceName();
|
lastExportedTrailFile = file;
|
||||||
if (traceName.equals(Gpx.TRAIL_TRACE_NAME)) {
|
|
||||||
lastExportedTrailFile = file;
|
|
||||||
}
|
|
||||||
for (int i=0; i<list.size(); i++) {
|
for (int i=0; i<list.size(); i++) {
|
||||||
MyLocation o = list.get(i);
|
MyLocation o = list.get(i);
|
||||||
if (o instanceof WayPointLocation) {
|
if (o instanceof WayPointLocation) {
|
||||||
if (traceName.equals(Gpx.DOG_TRACE_NAME)) {
|
traces.addPointObjectTrail((WayPointLocation) o);
|
||||||
traces.addPointObjectDog((WayPointLocation) o);
|
|
||||||
} else if (traceName.equals(Gpx.TRAIL_TRACE_NAME)) {
|
|
||||||
traces.addPointObjectTrail((WayPointLocation) o);
|
|
||||||
}
|
|
||||||
} else if (o instanceof TraceLocation) {
|
} else if (o instanceof TraceLocation) {
|
||||||
if (traceName.equals(Gpx.DOG_TRACE_NAME)) {
|
traces.addPointTraceur(o);
|
||||||
traces.addPointDog((TraceLocation) o);
|
}
|
||||||
} else if (traceName.equals(Gpx.TRAIL_TRACE_NAME)) {
|
}
|
||||||
traces.addPointTraceur((TraceLocation) o);
|
} catch (XmlPullParserException e) {
|
||||||
}
|
e.printStackTrace();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void importDogGpxTrace(File file) {
|
||||||
|
ImportGpx importGpx = new ImportGpx(file);
|
||||||
|
try {
|
||||||
|
List<MyLocation> list = importGpx.parse();
|
||||||
|
for (int i=0; i<list.size(); i++) {
|
||||||
|
MyLocation o = list.get(i);
|
||||||
|
if (o instanceof WayPointLocation) {
|
||||||
|
traces.addPointObjectDog((WayPointLocation) o);
|
||||||
|
} else if (o instanceof TraceLocation) {
|
||||||
|
traces.addPointDog(o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (XmlPullParserException e) {
|
} catch (XmlPullParserException e) {
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,12 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_import_gpx"
|
android:id="@+id/action_import_trail_gpx"
|
||||||
android:title="@string/action_import_gpx"
|
android:title="@string/action_import_trail_gpx"
|
||||||
|
android:icon="@drawable/ic_import" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_import_dog_gpx"
|
||||||
|
android:title="@string/action_import_dog_gpx"
|
||||||
android:icon="@drawable/ic_import" />
|
android:icon="@drawable/ic_import" />
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_send_gpx_trail"
|
android:id="@+id/action_send_gpx_trail"
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,8 @@
|
||||||
<string name="dog_stop">Stop</string>
|
<string name="dog_stop">Stop</string>
|
||||||
<string name="dog_object">Objet trouvé</string>
|
<string name="dog_object">Objet trouvé</string>
|
||||||
|
|
||||||
<string name="action_import_gpx">Import GPX</string>
|
<string name="action_import_trail_gpx">Import GPX traceur</string>
|
||||||
|
<string name="action_import_dog_gpx">Import GPX chien</string>
|
||||||
<string name="action_send_gpx_trail">Envoyer trace du traceur</string>
|
<string name="action_send_gpx_trail">Envoyer trace du traceur</string>
|
||||||
<string name="action_send_to">Envoyer par</string>
|
<string name="action_send_to">Envoyer par</string>
|
||||||
<string name="action_clear_trail">Supprimer données traceur</string>
|
<string name="action_clear_trail">Supprimer données traceur</string>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue