From 6e8d1c57c5fc3a105b5f0529a3067c9ca45c73a4 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Mon, 1 Jun 2015 01:44:49 +0200 Subject: [PATCH] Fix av notes --- .../audionotes/AudioVideoNotesPlugin.java | 58 ++++++++++++------- .../Osmand-Skimaps/bin/AndroidManifest.xml | 26 +++++++++ .../net/osmand/skimapsPlugin/BuildConfig.java | 6 ++ .../gen/net/osmand/skimapsPlugin/R.java | 27 +++++++++ 4 files changed, 95 insertions(+), 22 deletions(-) create mode 100644 plugins/Osmand-Skimaps/bin/AndroidManifest.xml create mode 100644 plugins/Osmand-Skimaps/gen/net/osmand/skimapsPlugin/BuildConfig.java create mode 100644 plugins/Osmand-Skimaps/gen/net/osmand/skimapsPlugin/R.java diff --git a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java index eae5122990..5d099d0d1d 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java @@ -133,6 +133,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { private MediaRecorder mediaRec; private File lastTakingPhoto; + private final static char SPLIT_DESC = ' '; public static class Recording { public Recording(File f) { this.file = f; @@ -174,18 +175,12 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { public File getFile() { return file; } + public boolean setName(String name) { - File directory = file.getParentFile(); + File directory = file.getParentFile(); String fileName = getFileName(); - final String hashAndExtension; - int hashInd = fileName.lastIndexOf('_'); - if (hashInd == -1 || hashInd < 8) { - hashAndExtension = "_" + fileName; - } else { - hashAndExtension = fileName.substring(hashInd, fileName.length()); - } - File to = new File(directory, name+hashAndExtension); + File to = new File(directory, name + SPLIT_DESC + getOtherName(fileName)); if (file.renameTo(to)) { file = to; return true; @@ -196,13 +191,35 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { public String getFileName() { return file.getName(); } + + public String getDescriptionName(String fileName) { + int hashInd = fileName.lastIndexOf(SPLIT_DESC); + //backward compatibility + if( fileName.indexOf('.') - fileName.indexOf('_') > 12 && + hashInd < fileName.indexOf('_')) { + hashInd = fileName.indexOf('_'); + } + if(hashInd == -1) { + return null; + } else { + return fileName.substring(0, hashInd); + } + } + + public String getOtherName(String fileName) { + String descriptionName = getDescriptionName(fileName); + if(descriptionName != null) { + return fileName.substring(descriptionName.length() + 1); // SPLIT_DESC + } else { + return fileName; + } + } public String getName(Context ctx) { String fileName = file.getName(); - - int hashInd = fileName.lastIndexOf('_'); - if (hashInd != -1 && hashInd < 8) { - return fileName.substring(0, hashInd); + String desc = getDescriptionName(fileName); + if (desc != null) { + return desc; } else if (this.isAudio()) { return ctx.getResources().getString(R.string.shared_string_audio); } else if (this.isVideo()) { @@ -605,7 +622,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { f.mkdirs(); File fl; do { - fl = new File(f, basename + "-" + (k++) + "." + ext); + fl = new File(f, basename + "." + (k++) + "." + ext); } while (fl.exists()); return fl; } @@ -990,17 +1007,14 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { return false; } Recording r = new Recording(f); - String encodeName = f.getName(); - int i = encodeName.lastIndexOf('_'); - if (i >= 8) { - encodeName = encodeName.substring(i + 1); - } - i = encodeName.indexOf('.'); + String fileName = f.getName(); + String otherName = r.getOtherName(fileName); + int i = otherName.indexOf('.'); if (i > 0) { - encodeName = encodeName.substring(0, i); + otherName = otherName.substring(0, i); } r.file = f; - GeoParsedPoint geo = MapUtils.decodeShortLinkString(encodeName); + GeoParsedPoint geo = MapUtils.decodeShortLinkString(otherName); r.lat = geo.getLatitude(); r.lon = geo.getLongitude(); Float heading = app.getLocationProvider().getHeading(); diff --git a/plugins/Osmand-Skimaps/bin/AndroidManifest.xml b/plugins/Osmand-Skimaps/bin/AndroidManifest.xml new file mode 100644 index 0000000000..f2e70094c9 --- /dev/null +++ b/plugins/Osmand-Skimaps/bin/AndroidManifest.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + diff --git a/plugins/Osmand-Skimaps/gen/net/osmand/skimapsPlugin/BuildConfig.java b/plugins/Osmand-Skimaps/gen/net/osmand/skimapsPlugin/BuildConfig.java new file mode 100644 index 0000000000..f2d733bfe9 --- /dev/null +++ b/plugins/Osmand-Skimaps/gen/net/osmand/skimapsPlugin/BuildConfig.java @@ -0,0 +1,6 @@ +/** Automatically generated file. DO NOT MODIFY */ +package net.osmand.skimapsPlugin; + +public final class BuildConfig { + public final static boolean DEBUG = true; +} \ No newline at end of file diff --git a/plugins/Osmand-Skimaps/gen/net/osmand/skimapsPlugin/R.java b/plugins/Osmand-Skimaps/gen/net/osmand/skimapsPlugin/R.java new file mode 100644 index 0000000000..e53be99a81 --- /dev/null +++ b/plugins/Osmand-Skimaps/gen/net/osmand/skimapsPlugin/R.java @@ -0,0 +1,27 @@ +/* AUTO-GENERATED FILE. DO NOT MODIFY. + * + * This class was automatically generated by the + * aapt tool from the resource data it found. It + * should not be modified by hand. + */ + +package net.osmand.skimapsPlugin; + +public final class R { + public static final class attr { + } + public static final class drawable { + public static final int ic_launcher=0x7f020000; + public static final int icon=0x7f020001; + } + public static final class layout { + public static final int main=0x7f030000; + } + public static final class string { + public static final int app_name=0x7f040003; + public static final int osmand_app_not_found=0x7f040002; + public static final int parking_plugin_installed=0x7f040004; + public static final int shared_string_no=0x7f040000; + public static final int shared_string_yes=0x7f040001; + } +}