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
parent d219fe9899
commit ab58f3a120
3 changed files with 12 additions and 4 deletions

View file

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

View file

@ -88,6 +88,7 @@ public class GPXUtilities {
public double lon;
public String name = null;
public String link = null;
// previous undocumented feature 'category' ,now 'type'
public String category = null;
public String desc = null;
// by default
@ -760,7 +761,7 @@ public class GPXUtilities {
serializer.attribute(null, "link", p.link);
serializer.endTag(null, "link");
}
writeNotNullText(serializer, "category", p.category);
writeNotNullText(serializer, "type", p.category);
if (!Double.isNaN(p.hdop)) {
writeNotNullText(serializer, "hdop", p.hdop + "");
}
@ -925,6 +926,10 @@ public class GPXUtilities {
((WptPt) parse).link = parser.getAttributeValue("", "href");
} else if (tag.equals("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")) {
String text = readText(parser, "ele");
if (text != null) {

View file

@ -38,6 +38,7 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Typeface;
import android.net.Uri;
import android.os.AsyncTask;
import android.support.v4.app.FragmentActivity;
import android.text.Spannable;
@ -524,9 +525,11 @@ public class FavouritesTreeFragment extends OsmandExpandableListFragment {
hideProgressBar();
final Intent sendIntent = new Intent();
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.setType("application/gpx+xml");
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(helper.getExternalFile()));
// sendIntent.setType("application/gpx+xml");
sendIntent.setType("text/plain");
startActivity(sendIntent);
}
};