Fix av notes
This commit is contained in:
parent
310def51dc
commit
6e8d1c57c5
4 changed files with 95 additions and 22 deletions
|
@ -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();
|
||||
|
|
26
plugins/Osmand-Skimaps/bin/AndroidManifest.xml
Normal file
26
plugins/Osmand-Skimaps/bin/AndroidManifest.xml
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="net.osmand.skimapsPlugin"
|
||||
android:versionCode="6"
|
||||
android:versionName="1.0" >
|
||||
|
||||
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="16" />
|
||||
<uses-feature android:name="android.hardware.touchscreen" android:required="false"/>
|
||||
<supports-screens android:resizeable="true" android:smallScreens="true" android:normalScreens="true" android:largeScreens="true"
|
||||
android:xlargeScreens="true" android:anyDensity="true" />
|
||||
<application
|
||||
android:icon="@drawable/icon"
|
||||
android:label="OsmAnd Ski Maps" >
|
||||
<activity
|
||||
android:name="net.osmand.skimaps.SkiMapsActivity"
|
||||
android:label="@string/app_name" >
|
||||
<!--
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
-->
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
|
@ -0,0 +1,6 @@
|
|||
/** Automatically generated file. DO NOT MODIFY */
|
||||
package net.osmand.skimapsPlugin;
|
||||
|
||||
public final class BuildConfig {
|
||||
public final static boolean DEBUG = true;
|
||||
}
|
27
plugins/Osmand-Skimaps/gen/net/osmand/skimapsPlugin/R.java
Normal file
27
plugins/Osmand-Skimaps/gen/net/osmand/skimapsPlugin/R.java
Normal file
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue