Updated renaming for audio video notes
This commit is contained in:
parent
7061dfd881
commit
b4b674178d
4 changed files with 118 additions and 124 deletions
|
@ -170,10 +170,10 @@ public class AudioNotesLayer extends OsmandMapLayer implements IContextMenuProvi
|
||||||
@Override
|
@Override
|
||||||
public PointDescription getObjectName(Object o) {
|
public PointDescription getObjectName(Object o) {
|
||||||
if(o instanceof Recording){
|
if(o instanceof Recording){
|
||||||
if(((Recording)o).getName().isEmpty()) {
|
if(((Recording)o).getName(activity).isEmpty()) {
|
||||||
return new PointDescription(PointDescription.POINT_TYPE_NOTE, view.getResources().getString(R.string.recording_default_name));
|
return new PointDescription(PointDescription.POINT_TYPE_NOTE, view.getResources().getString(R.string.recording_default_name));
|
||||||
}
|
}
|
||||||
return new PointDescription(PointDescription.POINT_TYPE_NOTE, ((Recording)o).getName());
|
return new PointDescription(PointDescription.POINT_TYPE_NOTE, ((Recording)o).getName(activity));
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,12 +179,12 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
||||||
|
|
||||||
public boolean setName(String name) {
|
public boolean setName(String name) {
|
||||||
int index = file.getAbsolutePath().lastIndexOf("/") + 1;
|
int index = file.getAbsolutePath().lastIndexOf("/") + 1;
|
||||||
if (index < 0){
|
if (index < 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
File directory = new File(file.getAbsolutePath().substring(0, index));
|
File directory = new File(file.getAbsolutePath().substring(0, index));
|
||||||
File to = new File(directory, name.trim());
|
File to = new File(directory, name.trim());
|
||||||
if (file.renameTo(to)){
|
if (file.renameTo(to)) {
|
||||||
file = to;
|
file = to;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -195,16 +195,20 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
||||||
return file.getName();
|
return file.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName(Context ctx) {
|
||||||
String fileName = file.getName();
|
String fileName = file.getName();
|
||||||
|
|
||||||
String hash;
|
|
||||||
int hashInd = fileName.lastIndexOf("_");
|
int hashInd = fileName.lastIndexOf("_");
|
||||||
if (hashInd != -1) {
|
if (hashInd != -1) {
|
||||||
return fileName.substring(0, hashInd - 1);
|
return fileName.substring(0, hashInd - 1);
|
||||||
} else {
|
} else if (this.isAudio()) {
|
||||||
return "";
|
return ctx.getResources().getString(R.string.audio);
|
||||||
|
} else if (this.isVideo()) {
|
||||||
|
return ctx.getResources().getString(R.string.video);
|
||||||
|
} else if (this.isPhoto()) {
|
||||||
|
return ctx.getResources().getString(R.string.photo);
|
||||||
}
|
}
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPhoto() {
|
public boolean isPhoto() {
|
||||||
|
@ -237,9 +241,9 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
||||||
try {
|
try {
|
||||||
Class exClass = Class.forName("android.media.ExifInterface");
|
Class exClass = Class.forName("android.media.ExifInterface");
|
||||||
|
|
||||||
Constructor c = exClass.getConstructor(new Class[] { String.class });
|
Constructor c = exClass.getConstructor(new Class[]{String.class});
|
||||||
Object exInstance = c.newInstance(file.getAbsolutePath());
|
Object exInstance = c.newInstance(file.getAbsolutePath());
|
||||||
Method setAttribute = exClass.getMethod("setAttribute", new Class[] { String.class, String.class });
|
Method setAttribute = exClass.getMethod("setAttribute", new Class[]{String.class, String.class});
|
||||||
setAttribute.invoke(exInstance, "GPSLatitude", convertDegToExifRational(lat));
|
setAttribute.invoke(exInstance, "GPSLatitude", convertDegToExifRational(lat));
|
||||||
setAttribute.invoke(exInstance, "GPSLatitudeRef", lat > 0 ? "N" : "S");
|
setAttribute.invoke(exInstance, "GPSLatitudeRef", lat > 0 ? "N" : "S");
|
||||||
setAttribute.invoke(exInstance, "GPSLongitude", convertDegToExifRational(lon));
|
setAttribute.invoke(exInstance, "GPSLongitude", convertDegToExifRational(lon));
|
||||||
|
@ -263,7 +267,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
||||||
setAttribute.invoke(exInstance, "GPSAltitude", altString);
|
setAttribute.invoke(exInstance, "GPSAltitude", altString);
|
||||||
setAttribute.invoke(exInstance, "GPSAltitudeRef", alt < 0 ? "1" : "0");
|
setAttribute.invoke(exInstance, "GPSAltitudeRef", alt < 0 ? "1" : "0");
|
||||||
}
|
}
|
||||||
Method saveAttributes = exClass.getMethod("saveAttributes", new Class[] {});
|
Method saveAttributes = exClass.getMethod("saveAttributes", new Class[]{});
|
||||||
saveAttributes.invoke(exInstance);
|
saveAttributes.invoke(exInstance);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -277,9 +281,9 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
||||||
try {
|
try {
|
||||||
Class exClass = Class.forName("android.media.ExifInterface");
|
Class exClass = Class.forName("android.media.ExifInterface");
|
||||||
|
|
||||||
Constructor c = exClass.getConstructor(new Class[] { String.class });
|
Constructor c = exClass.getConstructor(new Class[]{String.class});
|
||||||
Object exInstance = c.newInstance(file.getAbsolutePath());
|
Object exInstance = c.newInstance(file.getAbsolutePath());
|
||||||
Method getAttributeInt = exClass.getMethod("getAttributeInt", new Class[] { String.class, Integer.TYPE });
|
Method getAttributeInt = exClass.getMethod("getAttributeInt", new Class[]{String.class, Integer.TYPE});
|
||||||
Integer it = (Integer) getAttributeInt.invoke(exInstance, "Orientation", 1);
|
Integer it = (Integer) getAttributeInt.invoke(exInstance, "Orientation", 1);
|
||||||
orientation = it;
|
orientation = it;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -292,15 +296,15 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
||||||
public int getBitmapRotation() {
|
public int getBitmapRotation() {
|
||||||
int rotation = 0;
|
int rotation = 0;
|
||||||
switch (getExifOrientation()) {
|
switch (getExifOrientation()) {
|
||||||
case 3:
|
case 3:
|
||||||
rotation = 180;
|
rotation = 180;
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
rotation = 90;
|
rotation = 90;
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
rotation = 270;
|
rotation = 270;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return rotation;
|
return rotation;
|
||||||
}
|
}
|
||||||
|
@ -317,7 +321,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
||||||
|
|
||||||
public String getSmallDescription(Context ctx) {
|
public String getSmallDescription(Context ctx) {
|
||||||
|
|
||||||
String time = AndroidUtils.formatDateTime(ctx,file.lastModified());
|
String time = AndroidUtils.formatDateTime(ctx, file.lastModified());
|
||||||
if (isPhoto()) {
|
if (isPhoto()) {
|
||||||
return ctx.getString(R.string.recording_photo_description, "", time).trim();
|
return ctx.getString(R.string.recording_photo_description, "", time).trim();
|
||||||
}
|
}
|
||||||
|
@ -346,11 +350,11 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
||||||
// API 8
|
// API 8
|
||||||
if (mRegisterMediaButtonEventReceiver == null) {
|
if (mRegisterMediaButtonEventReceiver == null) {
|
||||||
mRegisterMediaButtonEventReceiver = AudioManager.class.getMethod("registerMediaButtonEventReceiver",
|
mRegisterMediaButtonEventReceiver = AudioManager.class.getMethod("registerMediaButtonEventReceiver",
|
||||||
new Class[] { ComponentName.class });
|
new Class[]{ComponentName.class});
|
||||||
}
|
}
|
||||||
if (mUnregisterMediaButtonEventReceiver == null) {
|
if (mUnregisterMediaButtonEventReceiver == null) {
|
||||||
mUnregisterMediaButtonEventReceiver = AudioManager.class.getMethod("unregisterMediaButtonEventReceiver",
|
mUnregisterMediaButtonEventReceiver = AudioManager.class.getMethod("unregisterMediaButtonEventReceiver",
|
||||||
new Class[] { ComponentName.class });
|
new Class[]{ComponentName.class});
|
||||||
}
|
}
|
||||||
/* success, this device will take advantage of better remote */
|
/* success, this device will take advantage of better remote */
|
||||||
/* control event handling */
|
/* control event handling */
|
||||||
|
@ -368,7 +372,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
||||||
public AudioVideoNotesPlugin(OsmandApplication app) {
|
public AudioVideoNotesPlugin(OsmandApplication app) {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
OsmandSettings settings = app.getSettings();
|
OsmandSettings settings = app.getSettings();
|
||||||
ApplicationMode.regWidget("audionotes", (ApplicationMode[])null);
|
ApplicationMode.regWidget("audionotes", (ApplicationMode[]) null);
|
||||||
AV_EXTERNAL_RECORDER = settings.registerBooleanPreference("av_external_recorder", false).makeGlobal();
|
AV_EXTERNAL_RECORDER = settings.registerBooleanPreference("av_external_recorder", false).makeGlobal();
|
||||||
AV_EXTERNAL_PHOTO_CAM = settings.registerBooleanPreference("av_external_cam", true).makeGlobal();
|
AV_EXTERNAL_PHOTO_CAM = settings.registerBooleanPreference("av_external_cam", true).makeGlobal();
|
||||||
AV_VIDEO_FORMAT = settings.registerIntPreference("av_video_format", VIDEO_OUTPUT_MP4).makeGlobal();
|
AV_VIDEO_FORMAT = settings.registerIntPreference("av_video_format", VIDEO_OUTPUT_MP4).makeGlobal();
|
||||||
|
@ -457,7 +461,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerMapContextMenuActions(final MapActivity mapActivity, final double latitude, final double longitude,
|
public void registerMapContextMenuActions(final MapActivity mapActivity, final double latitude, final double longitude,
|
||||||
ContextMenuAdapter adapter, Object selectedObj) {
|
ContextMenuAdapter adapter, Object selectedObj) {
|
||||||
adapter.item(R.string.recording_context_menu_arecord).icons(R.drawable.ic_action_micro_dark, R.drawable.ic_action_micro_light)
|
adapter.item(R.string.recording_context_menu_arecord).icons(R.drawable.ic_action_micro_dark, R.drawable.ic_action_micro_light)
|
||||||
.listen(new OnContextMenuClick() {
|
.listen(new OnContextMenuClick() {
|
||||||
|
|
||||||
|
@ -556,9 +560,9 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
||||||
private void chooseDefaultAction(final double lat, final double lon, final MapActivity mapActivity) {
|
private void chooseDefaultAction(final double lat, final double lon, final MapActivity mapActivity) {
|
||||||
AccessibleAlertBuilder ab = new AccessibleAlertBuilder(mapActivity);
|
AccessibleAlertBuilder ab = new AccessibleAlertBuilder(mapActivity);
|
||||||
ab.setItems(
|
ab.setItems(
|
||||||
new String[] { mapActivity.getString(R.string.recording_context_menu_arecord),
|
new String[]{mapActivity.getString(R.string.recording_context_menu_arecord),
|
||||||
mapActivity.getString(R.string.recording_context_menu_vrecord),
|
mapActivity.getString(R.string.recording_context_menu_vrecord),
|
||||||
mapActivity.getString(R.string.recording_context_menu_precord), }, new OnClickListener() {
|
mapActivity.getString(R.string.recording_context_menu_precord),}, new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
int action = which == 0 ? AV_DEFAULT_ACTION_AUDIO : (which == 1 ? AV_DEFAULT_ACTION_VIDEO
|
int action = which == 0 ? AV_DEFAULT_ACTION_AUDIO : (which == 1 ? AV_DEFAULT_ACTION_VIDEO
|
||||||
|
@ -619,14 +623,15 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
||||||
public void mapActivityPause(MapActivity activity) {
|
public void mapActivityPause(MapActivity activity) {
|
||||||
stopRecording(activity);
|
stopRecording(activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mapActivityResume(MapActivity activity) {
|
public void mapActivityResume(MapActivity activity) {
|
||||||
this.activity = activity;;
|
this.activity = activity;
|
||||||
((AudioManager)activity.getSystemService(Context.AUDIO_SERVICE)).registerMediaButtonEventReceiver(
|
;
|
||||||
new ComponentName(activity,MediaRemoteControlReceiver.class));
|
((AudioManager) activity.getSystemService(Context.AUDIO_SERVICE)).registerMediaButtonEventReceiver(
|
||||||
|
new ComponentName(activity, MediaRemoteControlReceiver.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
public MapActivity getActivity() {
|
public MapActivity getActivity() {
|
||||||
return activity;
|
return activity;
|
||||||
}
|
}
|
||||||
|
@ -675,7 +680,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
||||||
runMediaRecorder(mapActivity, mr, f);
|
runMediaRecorder(mapActivity, mr, f);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logErr(e);
|
logErr(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -707,7 +712,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
||||||
private void logErr(Exception e) {
|
private void logErr(Exception e) {
|
||||||
log.error("Error starting recorder ", e);
|
log.error("Error starting recorder ", e);
|
||||||
AccessibleToast.makeText(app, app.getString(R.string.recording_error) + " : " + e.getMessage(), Toast.LENGTH_LONG).show();
|
AccessibleToast.makeText(app, app.getString(R.string.recording_error) + " : " + e.getMessage(), Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Camera openCamera() {
|
protected Camera openCamera() {
|
||||||
try {
|
try {
|
||||||
|
@ -778,18 +783,18 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
||||||
int rotation = mapActivity.getWindowManager().getDefaultDisplay().getRotation();
|
int rotation = mapActivity.getWindowManager().getDefaultDisplay().getRotation();
|
||||||
int degrees = 0;
|
int degrees = 0;
|
||||||
switch (rotation) {
|
switch (rotation) {
|
||||||
case /* Surface.ROTATION_0 */0:
|
case /* Surface.ROTATION_0 */ 0:
|
||||||
degrees = 0;
|
degrees = 0;
|
||||||
break;
|
break;
|
||||||
case /* Surface.ROTATION_90 */1:
|
case /* Surface.ROTATION_90 */ 1:
|
||||||
degrees = 90;
|
degrees = 90;
|
||||||
break;
|
break;
|
||||||
case /* Surface.ROTATION_180 */2:
|
case /* Surface.ROTATION_180 */ 2:
|
||||||
degrees = 180;
|
degrees = 180;
|
||||||
break;
|
break;
|
||||||
case /* Surface.ROTATION_270 */3:
|
case /* Surface.ROTATION_270 */ 3:
|
||||||
degrees = 270;
|
degrees = 270;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
|
// if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
|
||||||
|
@ -822,51 +827,50 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
||||||
// camera picture size:
|
// camera picture size:
|
||||||
List<Camera.Size> psps = parameters.getSupportedPictureSizes();
|
List<Camera.Size> psps = parameters.getSupportedPictureSizes();
|
||||||
int index = AV_CAMERA_PICTURE_SIZE.get();
|
int index = AV_CAMERA_PICTURE_SIZE.get();
|
||||||
log.debug("takePhotoWithCamera() index=" + index );
|
log.debug("takePhotoWithCamera() index=" + index);
|
||||||
if(index == AV_PHOTO_SIZE_DEFAULT)
|
if (index == AV_PHOTO_SIZE_DEFAULT) {
|
||||||
{
|
|
||||||
index = cameraPictureSizeDefault;
|
index = cameraPictureSizeDefault;
|
||||||
log.debug("takePhotoWithCamera() Default value of picture size. Set index to cameraPictureSizeDefault. Now index="
|
log.debug("takePhotoWithCamera() Default value of picture size. Set index to cameraPictureSizeDefault. Now index="
|
||||||
+ index );
|
+ index);
|
||||||
}
|
}
|
||||||
Camera.Size selectedCamPicSize = psps.get(index);
|
Camera.Size selectedCamPicSize = psps.get(index);
|
||||||
parameters.setPictureSize(selectedCamPicSize.width, selectedCamPicSize.height);
|
parameters.setPictureSize(selectedCamPicSize.width, selectedCamPicSize.height);
|
||||||
log.debug("takePhotoWithCamera() set Picture size: width=" + selectedCamPicSize.width
|
log.debug("takePhotoWithCamera() set Picture size: width=" + selectedCamPicSize.width
|
||||||
+ " height=" + selectedCamPicSize.height );
|
+ " height=" + selectedCamPicSize.height);
|
||||||
|
|
||||||
// camera focus type:
|
// camera focus type:
|
||||||
boolean autofocus = true;
|
boolean autofocus = true;
|
||||||
// boolean autofocus = !Boolean.parseBoolean(parameters.get("auto-exposure-lock-supported"));
|
// boolean autofocus = !Boolean.parseBoolean(parameters.get("auto-exposure-lock-supported"));
|
||||||
parameters.setGpsLatitude(lat);
|
parameters.setGpsLatitude(lat);
|
||||||
parameters.setGpsLongitude(lon);
|
parameters.setGpsLongitude(lon);
|
||||||
switch (AV_CAMERA_FOCUS_TYPE.get()) {
|
switch (AV_CAMERA_FOCUS_TYPE.get()) {
|
||||||
case AV_CAMERA_FOCUS_HIPERFOCAL:
|
case AV_CAMERA_FOCUS_HIPERFOCAL:
|
||||||
parameters.setFocusMode(Parameters.FOCUS_MODE_FIXED);
|
parameters.setFocusMode(Parameters.FOCUS_MODE_FIXED);
|
||||||
autofocus = false;
|
autofocus = false;
|
||||||
log.info("Osmand:AudioNotes set camera FOCUS_MODE_FIXED");
|
log.info("Osmand:AudioNotes set camera FOCUS_MODE_FIXED");
|
||||||
break;
|
break;
|
||||||
case AV_CAMERA_FOCUS_EDOF:
|
case AV_CAMERA_FOCUS_EDOF:
|
||||||
parameters.setFocusMode(Parameters.FOCUS_MODE_EDOF);
|
parameters.setFocusMode(Parameters.FOCUS_MODE_EDOF);
|
||||||
autofocus = false;
|
autofocus = false;
|
||||||
log.info("Osmand:AudioNotes set camera FOCUS_MODE_EDOF");
|
log.info("Osmand:AudioNotes set camera FOCUS_MODE_EDOF");
|
||||||
break;
|
break;
|
||||||
case AV_CAMERA_FOCUS_INFINITY:
|
case AV_CAMERA_FOCUS_INFINITY:
|
||||||
parameters.setFocusMode(Parameters.FOCUS_MODE_INFINITY);
|
parameters.setFocusMode(Parameters.FOCUS_MODE_INFINITY);
|
||||||
autofocus = false;
|
autofocus = false;
|
||||||
log.info("Osmand:AudioNotes set camera FOCUS_MODE_INFINITY");
|
log.info("Osmand:AudioNotes set camera FOCUS_MODE_INFINITY");
|
||||||
break;
|
break;
|
||||||
case AV_CAMERA_FOCUS_MACRO:
|
case AV_CAMERA_FOCUS_MACRO:
|
||||||
parameters.setFocusMode(Parameters.FOCUS_MODE_MACRO);
|
parameters.setFocusMode(Parameters.FOCUS_MODE_MACRO);
|
||||||
log.info("Osmand:AudioNotes set camera FOCUS_MODE_MACRO");
|
log.info("Osmand:AudioNotes set camera FOCUS_MODE_MACRO");
|
||||||
break;
|
break;
|
||||||
case AV_CAMERA_FOCUS_CONTINUOUS:
|
case AV_CAMERA_FOCUS_CONTINUOUS:
|
||||||
parameters.setFocusMode(Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
|
parameters.setFocusMode(Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
|
||||||
log.info("Osmand:AudioNotes set camera FOCUS_MODE_CONTINUOUS_PICTURE");
|
log.info("Osmand:AudioNotes set camera FOCUS_MODE_CONTINUOUS_PICTURE");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
parameters.setFocusMode(Parameters.FOCUS_MODE_AUTO);
|
parameters.setFocusMode(Parameters.FOCUS_MODE_AUTO);
|
||||||
log.info("Osmand:AudioNotes set camera FOCUS_MODE_AUTO");
|
log.info("Osmand:AudioNotes set camera FOCUS_MODE_AUTO");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// parameters.setFocusMode(Parameters.FOCUS_MODE_FIXED);
|
// parameters.setFocusMode(Parameters.FOCUS_MODE_FIXED);
|
||||||
// parameters.set("auto-exposure-lock", "true");
|
// parameters.set("auto-exposure-lock", "true");
|
||||||
|
@ -954,7 +958,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addMyPlacesTab(FavoritesActivity favoritesActivity, List<TabItem> mTabs, Intent intent) {
|
public void addMyPlacesTab(FavoritesActivity favoritesActivity, List<TabItem> mTabs, Intent intent) {
|
||||||
if (getAllRecordings().size() > 0) {
|
if (getAllRecordings().size() > 0) {
|
||||||
|
@ -997,7 +1001,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
||||||
}
|
}
|
||||||
recordings.registerObject(r.lat, r.lon, r);
|
recordings.registerObject(r.lat, r.lon, r);
|
||||||
recordingByFileName.put(f.getName(), r);
|
recordingByFileName.put(f.getName(), r);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1023,33 +1027,33 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
||||||
File[] files = avPath.listFiles();
|
File[] files = avPath.listFiles();
|
||||||
if (files != null) {
|
if (files != null) {
|
||||||
for (File f : files) {
|
for (File f : files) {
|
||||||
indexFile(registerNew, f);
|
indexFile(registerNew, f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void indexFile(boolean registerInGPX, File f) {
|
private void indexFile(boolean registerInGPX, File f) {
|
||||||
if (f.getName().endsWith(THREEGP_EXTENSION) || f.getName().endsWith(MPEG4_EXTENSION)
|
if (f.getName().endsWith(THREEGP_EXTENSION) || f.getName().endsWith(MPEG4_EXTENSION)
|
||||||
|| f.getName().endsWith(IMG_EXTENSION)) {
|
|| f.getName().endsWith(IMG_EXTENSION)) {
|
||||||
boolean newFileIndexed = indexSingleFile(f);
|
boolean newFileIndexed = indexSingleFile(f);
|
||||||
if (newFileIndexed && registerInGPX) {
|
if (newFileIndexed && registerInGPX) {
|
||||||
Recording rec = recordingByFileName.get(f.getName());
|
Recording rec = recordingByFileName.get(f.getName());
|
||||||
if (rec != null &&
|
if (rec != null &&
|
||||||
(app.getSettings().SAVE_TRACK_TO_GPX.get()
|
(app.getSettings().SAVE_TRACK_TO_GPX.get()
|
||||||
|| app.getSettings().SAVE_GLOBAL_TRACK_TO_GPX.get())
|
|| app.getSettings().SAVE_GLOBAL_TRACK_TO_GPX.get())
|
||||||
&& OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class) != null) {
|
&& OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class) != null) {
|
||||||
String name = f.getName();
|
String name = f.getName();
|
||||||
SavingTrackHelper savingTrackHelper = app.getSavingTrackHelper();
|
SavingTrackHelper savingTrackHelper = app.getSavingTrackHelper();
|
||||||
savingTrackHelper.insertPointData(rec.lat, rec.lon, System.currentTimeMillis(), name);
|
savingTrackHelper.insertPointData(rec.lat, rec.lon, System.currentTimeMillis(), name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataTileManager<Recording> getRecordings() {
|
public DataTileManager<Recording> getRecordings() {
|
||||||
return recordings;
|
return recordings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1078,7 +1082,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
||||||
public Class<? extends Activity> getSettingsActivity() {
|
public Class<? extends Activity> getSettingsActivity() {
|
||||||
return SettingsAudioVideoActivity.class;
|
return SettingsAudioVideoActivity.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMapActivityExternalResult(int requestCode, int resultCode, Intent data) {
|
public void onMapActivityExternalResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
@ -1096,8 +1100,6 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public Collection<Recording> getAllRecordings() {
|
public Collection<Recording> getAllRecordings() {
|
||||||
return recordingByFileName.values();
|
return recordingByFileName.values();
|
||||||
}
|
}
|
||||||
|
@ -1215,7 +1217,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
||||||
FileOutputStream fos = new FileOutputStream(pictureFile);
|
FileOutputStream fos = new FileOutputStream(pictureFile);
|
||||||
fos.write(data);
|
fos.write(data);
|
||||||
fos.close();
|
fos.close();
|
||||||
indexFile(true, pictureFile);
|
indexFile(true, pictureFile);
|
||||||
dlg.dismiss();
|
dlg.dismiss();
|
||||||
// play sound after photo - sound file must be loaded at this time:
|
// play sound after photo - sound file must be loaded at this time:
|
||||||
if (AV_PHOTO_PLAY_SOUND.get()) {
|
if (AV_PHOTO_PLAY_SOUND.get()) {
|
||||||
|
|
|
@ -97,7 +97,7 @@ public class DashAudioVideoNotesFragment extends DashBaseFragment {
|
||||||
LayoutInflater inflater = getActivity().getLayoutInflater();
|
LayoutInflater inflater = getActivity().getLayoutInflater();
|
||||||
View view = inflater.inflate(R.layout.note, null, false);
|
View view = inflater.inflate(R.layout.note, null, false);
|
||||||
|
|
||||||
getNoteView(recording, view, getActivity(), plugin);
|
getNoteView(recording, view, getActivity());
|
||||||
view.findViewById(R.id.play).setOnClickListener(new View.OnClickListener() {
|
view.findViewById(R.id.play).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
@ -111,7 +111,7 @@ public class DashAudioVideoNotesFragment extends DashBaseFragment {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
getMyApplication().getSettings().setMapLocationToShow(recording.getLatitude(), recording.getLongitude(), 15,
|
getMyApplication().getSettings().setMapLocationToShow(recording.getLatitude(), recording.getLongitude(), 15,
|
||||||
new PointDescription(PointDescription.POINT_TYPE_NOTE,
|
new PointDescription(PointDescription.POINT_TYPE_NOTE,
|
||||||
(recording.getName() != null) ? recording.getName() : recording.getDescription(getActivity())), true,
|
recording.getName(getActivity())), true,
|
||||||
recording); //$NON-NLS-1$
|
recording); //$NON-NLS-1$
|
||||||
MapActivity.launchMapActivityMoveToTop(getActivity());
|
MapActivity.launchMapActivityMoveToTop(getActivity());
|
||||||
}
|
}
|
||||||
|
@ -121,18 +121,10 @@ public class DashAudioVideoNotesFragment extends DashBaseFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void getNoteView(final AudioVideoNotesPlugin.Recording recording, View view,
|
public static void getNoteView(final AudioVideoNotesPlugin.Recording recording, View view,
|
||||||
final Context ctx, final AudioVideoNotesPlugin plugin) {
|
final Context ctx) {
|
||||||
String name = recording.getName();
|
String name = recording.getName(ctx);
|
||||||
TextView nameText = ((TextView) view.findViewById(R.id.name));
|
TextView nameText = ((TextView) view.findViewById(R.id.name));
|
||||||
if (!name.isEmpty()) {
|
nameText.setText(name);
|
||||||
nameText.setText(name);
|
|
||||||
} else if (recording.isAudio()) {
|
|
||||||
nameText.setText(R.string.audio);
|
|
||||||
} else if (recording.isVideo()) {
|
|
||||||
nameText.setText(R.string.video);
|
|
||||||
} else if (recording.isPhoto()) {
|
|
||||||
nameText.setText(R.string.photo);
|
|
||||||
}
|
|
||||||
((TextView) view.findViewById(R.id.descr)).setText(recording.getDescription(ctx));
|
((TextView) view.findViewById(R.id.descr)).setText(recording.getDescription(ctx));
|
||||||
|
|
||||||
ImageView icon = (ImageView) view.findViewById(R.id.icon);
|
ImageView icon = (ImageView) view.findViewById(R.id.icon);
|
||||||
|
|
|
@ -92,7 +92,7 @@ public class NotesFragment extends ListFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
final AudioVideoNotesPlugin.Recording recording = getItem(position);
|
final AudioVideoNotesPlugin.Recording recording = getItem(position);
|
||||||
DashAudioVideoNotesFragment.getNoteView(recording, row, getActivity(), plugin);
|
DashAudioVideoNotesFragment.getNoteView(recording, row, getActivity());
|
||||||
row.findViewById(R.id.play).setVisibility(View.GONE);
|
row.findViewById(R.id.play).setVisibility(View.GONE);
|
||||||
ImageButton options = (ImageButton) row.findViewById(R.id.options);
|
ImageButton options = (ImageButton) row.findViewById(R.id.options);
|
||||||
options.setOnClickListener(new View.OnClickListener() {
|
options.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@ -113,7 +113,7 @@ public class NotesFragment extends ListFragment {
|
||||||
|
|
||||||
private void showOnMap(Recording recording) {
|
private void showOnMap(Recording recording) {
|
||||||
getMyApplication().getSettings().setMapLocationToShow(recording.getLatitude(), recording.getLongitude(), 15,
|
getMyApplication().getSettings().setMapLocationToShow(recording.getLatitude(), recording.getLongitude(), 15,
|
||||||
new PointDescription(PointDescription.POINT_TYPE_NOTE, recording.getName()), true,
|
new PointDescription(PointDescription.POINT_TYPE_NOTE, recording.getName(getActivity())), true,
|
||||||
recording); //$NON-NLS-1$
|
recording); //$NON-NLS-1$
|
||||||
MapActivity.launchMapActivityMoveToTop(getActivity());
|
MapActivity.launchMapActivityMoveToTop(getActivity());
|
||||||
}
|
}
|
||||||
|
@ -223,7 +223,7 @@ public class NotesFragment extends ListFragment {
|
||||||
hash = fileName.substring(hashInd, fileName.length());
|
hash = fileName.substring(hashInd, fileName.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
editText.setText(recording.getName());
|
editText.setText(recording.getName(getActivity()));
|
||||||
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
|
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
|
imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
|
||||||
builder.setNegativeButton(R.string.default_buttons_cancel, null);
|
builder.setNegativeButton(R.string.default_buttons_cancel, null);
|
||||||
|
|
Loading…
Reference in a new issue