Aidl file copy for strikelines - in progress
This commit is contained in:
parent
f33f4eed5f
commit
9592f5e469
5 changed files with 77 additions and 10 deletions
|
@ -68,4 +68,5 @@ public class IndexConstants {
|
|||
public static final String RENDERERS_DIR = "rendering/"; //$NON-NLS-1$
|
||||
public static final String ROUTING_XML_FILE= "routing.xml";
|
||||
public static final String SETTINGS_DIR = "settings/"; //$NON-NLS-1$
|
||||
public static final String TEMP_DIR = "temp/";
|
||||
}
|
||||
|
|
|
@ -179,4 +179,6 @@ interface IOsmAndAidlInterface {
|
|||
boolean registerForOsmandInitListener(in IOsmAndAidlCallback callback);
|
||||
|
||||
boolean getBitmapForGpx(in CreateGpxBitmapParams file, IOsmAndAidlCallback callback);
|
||||
|
||||
boolean appendDataToFile(in String filename, in byte[] data);
|
||||
}
|
|
@ -1967,6 +1967,36 @@ public class OsmandAidlApi {
|
|||
gpxAsyncLoaderTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
|
||||
boolean appendDataToFile(final String filename, final byte[] data) {
|
||||
if (filename.isEmpty() || data == null || data.length == 0) {
|
||||
return false;
|
||||
} else {
|
||||
File f = app.getAppPath(IndexConstants.TEMP_DIR + filename);
|
||||
|
||||
try {
|
||||
if (!f.exists()) {
|
||||
f.getParentFile().mkdirs();
|
||||
f.createNewFile();
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
LOG.debug(ioe.getMessage(), ioe);
|
||||
}
|
||||
try {
|
||||
FileOutputStream outputStream
|
||||
= new FileOutputStream(IndexConstants.TEMP_DIR+filename, true);
|
||||
outputStream.write(data);
|
||||
} catch (IOException ioe) {
|
||||
LOG.debug(ioe.getMessage(), ioe);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private static class GpxAsyncLoaderTask extends AsyncTask<Void, Void, GPXFile> {
|
||||
|
||||
private final OsmandApplication app;
|
||||
|
|
|
@ -845,5 +845,11 @@ public class OsmandAidlService extends Service {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean appendDataToFile(String filename, byte[] data) {
|
||||
OsmandAidlApi api = getApi("appendDataToFile");
|
||||
return api != null && api.appendDataToFile(filename, data);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -82,11 +82,11 @@ public class GPXUtilities {
|
|||
String clrValue = null;
|
||||
if (extensions != null) {
|
||||
clrValue = extensions.get("color");
|
||||
if (clrValue == null) {
|
||||
if (clrValue == null||clrValue.isEmpty()) {
|
||||
clrValue = extensions.get("colour");
|
||||
}
|
||||
if (clrValue == null) {
|
||||
clrValue = extensions.get("displaycolor");
|
||||
if (clrValue == null ||clrValue.isEmpty()) {
|
||||
clrValue = extensions.get("DisplayColor");
|
||||
}
|
||||
}
|
||||
if (clrValue != null && clrValue.length() > 0) {
|
||||
|
@ -1522,6 +1522,25 @@ public class GPXUtilities {
|
|||
return text;
|
||||
}
|
||||
|
||||
private static Map<String, String> readExtensionText(XmlPullParser parser, String key) throws XmlPullParserException, IOException {
|
||||
int tok;
|
||||
Map<String, String> innerTagAndText = new HashMap<>();
|
||||
String innerTag = "";
|
||||
while ((tok = parser.next()) != XmlPullParser.END_DOCUMENT) {
|
||||
innerTag = parser.getName();
|
||||
log.debug("tag: " + parser.getName()+ ", prefix: " + parser.getPrefix());
|
||||
if (tok == XmlPullParser.END_TAG && parser.getName().equals(key)) {
|
||||
break;
|
||||
} else if (tok == XmlPullParser.TEXT) {
|
||||
String text = parser.getText();
|
||||
if (text!=null || !text.isEmpty() ) {
|
||||
innerTagAndText.put(innerTag, text);
|
||||
}
|
||||
}
|
||||
}
|
||||
return innerTagAndText;
|
||||
}
|
||||
|
||||
public static GPXFile loadGPXFile(Context ctx, File f) {
|
||||
FileInputStream fis = null;
|
||||
try {
|
||||
|
@ -1567,15 +1586,24 @@ public class GPXUtilities {
|
|||
Object parse = parserState.peek();
|
||||
String tag = parser.getName();
|
||||
if (extensionReadMode && parse != null) {
|
||||
String value = readText(parser, tag);
|
||||
if (value != null) {
|
||||
((GPXExtensions) parse).getExtensionsToWrite().put(tag.toLowerCase(), value);
|
||||
if (tag.equals("speed") && parse instanceof WptPt) {
|
||||
try {
|
||||
((WptPt) parse).speed = Float.parseFloat(value);
|
||||
} catch (NumberFormatException e) {}
|
||||
if (tag.equals("TrackExtension")) {
|
||||
Map<String, String> innerTagAndText = readExtensionText(parser, tag);
|
||||
for (Map.Entry<String, String> entity : innerTagAndText.entrySet()) {
|
||||
((GPXExtensions) parse).getExtensionsToWrite().put(entity.getKey(), entity.getValue());
|
||||
}
|
||||
|
||||
} else {
|
||||
String value = readText(parser, tag);
|
||||
if (value != null) {
|
||||
((GPXExtensions) parse).getExtensionsToWrite().put(tag, value);
|
||||
if (tag.equals("speed") && parse instanceof WptPt) {
|
||||
try {
|
||||
((WptPt) parse).speed = Float.parseFloat(value);
|
||||
} catch (NumberFormatException e) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else if (parse instanceof GPXExtensions && tag.equals("extensions")) {
|
||||
extensionReadMode = true;
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue