Proper GPX intent handling, replace undocumented 'category' with existing 'type' for favourites.gpx

This commit is contained in:
Victor Shcherb 2015-01-05 01:46:23 +01:00 committed by Alexey Pelykh
parent 8a1a1d86c5
commit c3d5baf996
3 changed files with 12 additions and 4 deletions

View file

@ -317,7 +317,7 @@ public class FavouritesDbHelper {
return false; return false;
} }
private File getExternalFile() { public File getExternalFile() {
return new File(context.getAppPath(null), FILE_TO_SAVE); return new File(context.getAppPath(null), FILE_TO_SAVE);
} }

View file

@ -87,6 +87,7 @@ public class GPXUtilities {
public double lat; public double lat;
public double lon; public double lon;
public String name = null; public String name = null;
// previous undocumented feature 'category' ,now 'type'
public String category = null; public String category = null;
public String desc = null; public String desc = null;
// by default // by default
@ -754,7 +755,7 @@ public class GPXUtilities {
} }
writeNotNullText(serializer, "name", p.name); writeNotNullText(serializer, "name", p.name);
writeNotNullText(serializer, "desc", p.desc); writeNotNullText(serializer, "desc", p.desc);
writeNotNullText(serializer, "category", p.category); writeNotNullText(serializer, "type", p.category);
if (!Double.isNaN(p.hdop)) { if (!Double.isNaN(p.hdop)) {
writeNotNullText(serializer, "hdop", p.hdop + ""); writeNotNullText(serializer, "hdop", p.hdop + "");
} }
@ -917,6 +918,10 @@ public class GPXUtilities {
((WptPt) parse).desc = readText(parser, "desc"); ((WptPt) parse).desc = readText(parser, "desc");
} else if (tag.equals("category")) { } else if (tag.equals("category")) {
((WptPt) parse).category = readText(parser, "category"); ((WptPt) parse).category = readText(parser, "category");
} else if (tag.equals("type")) {
if(((WptPt) parse).category == null) {
((WptPt) parse).category = readText(parser, "type");
}
} else if (parser.getName().equals("ele")) { } else if (parser.getName().equals("ele")) {
String text = readText(parser, "ele"); String text = readText(parser, "ele");
if (text != null) { if (text != null) {

View file

@ -38,6 +38,7 @@ import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.res.Resources; import android.content.res.Resources;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.net.Uri;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentActivity;
import android.text.Spannable; import android.text.Spannable;
@ -524,9 +525,11 @@ public class FavouritesTreeFragment extends OsmandExpandableListFragment {
hideProgressBar(); hideProgressBar();
final Intent sendIntent = new Intent(); final Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND); sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, GPXUtilities.asString(gpxFile, getMyApplication())); sendIntent.putExtra(Intent.EXTRA_TEXT, "Favourites.gpx:\n\n\n"+GPXUtilities.asString(gpxFile, getMyApplication()));
sendIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.share_fav_subject)); sendIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.share_fav_subject));
sendIntent.setType("application/gpx+xml"); sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(helper.getExternalFile()));
// sendIntent.setType("application/gpx+xml");
sendIntent.setType("text/plain");
startActivity(sendIntent); startActivity(sendIntent);
} }
}; };