Fix Android 1.6

This commit is contained in:
Victor Shcherb 2013-01-20 00:30:23 +01:00
parent 340fbbdce8
commit c8fe023c2b
2 changed files with 67 additions and 25 deletions

View file

@ -3,4 +3,25 @@ package com.OsMoDroid;
interface IRemoteOsMoDroidService { interface IRemoteOsMoDroidService {
int getVersion(); int getVersion();
/*
int getNumberOfLayers();
int getLayerId(int pos);
String getLayerName(int layerId);
String getLayerDescription(int layerId);
int getNumberOfObjects(int layerId);
int getObjectId(int layerId, int pos);
float getObjectLat(int layerId, int objectId);
float getObjectLon(int layerId, int objectId);
String getObjectName(int layerId, int objectId);
String getObjectDescription(int layerId, int objectId);
*/
} }

View file

@ -1,7 +1,9 @@
package net.osmand.plus.audionotes; package net.osmand.plus.audionotes;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -31,8 +33,8 @@ import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.LocalIndexHelper.LocalIndexType; import net.osmand.plus.activities.LocalIndexHelper.LocalIndexType;
import net.osmand.plus.activities.LocalIndexInfo; import net.osmand.plus.activities.LocalIndexInfo;
import net.osmand.plus.activities.LocalIndexesActivity.LoadLocalIndexTask;
import net.osmand.plus.activities.LocalIndexesActivity; import net.osmand.plus.activities.LocalIndexesActivity;
import net.osmand.plus.activities.LocalIndexesActivity.LoadLocalIndexTask;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.SettingsActivity; import net.osmand.plus.activities.SettingsActivity;
import net.osmand.plus.views.MapInfoLayer; import net.osmand.plus.views.MapInfoLayer;
@ -46,18 +48,17 @@ import android.app.Dialog;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent;
import android.content.DialogInterface.OnClickListener; import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.graphics.BitmapFactory.Options; import android.graphics.BitmapFactory.Options;
import android.graphics.Matrix;
import android.hardware.Camera; import android.hardware.Camera;
import android.media.AudioManager; import android.media.AudioManager;
import android.media.ExifInterface;
import android.media.MediaPlayer; import android.media.MediaPlayer;
import android.media.MediaRecorder;
import android.media.MediaPlayer.OnPreparedListener; import android.media.MediaPlayer.OnPreparedListener;
import android.media.MediaRecorder;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.preference.ListPreference; import android.preference.ListPreference;
@ -150,29 +151,49 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
//log.info("deg rational: " + s); //log.info("deg rational: " + s);
return s; return s;
} }
public void updatePhotoInformation(double lat, double lon, double rot) throws IOException{
ExifInterface exif = new ExifInterface(file.getAbsolutePath()); @SuppressWarnings("rawtypes")
exif.setAttribute(ExifInterface.TAG_GPS_LATITUDE, convertDegToExifRational(lat)); public void updatePhotoInformation(double lat, double lon, double rot) throws IOException {
exif.setAttribute(ExifInterface.TAG_GPS_LATITUDE_REF, lat > 0 ?"N" :"S"); try {
exif.setAttribute(ExifInterface.TAG_GPS_LONGITUDE, convertDegToExifRational(lon)); Class exClass = Class.forName("android.media.ExifInterface");
exif.setAttribute(ExifInterface.TAG_GPS_LONGITUDE_REF, lon > 0?"E" : "W");
if(!Double.isNaN(rot)){ Constructor c = exClass.getConstructor(new Class[] { String.class });
exif.setAttribute("GPSImgDirectionRef", "T"); //true north Object exInstance = c.newInstance(file.getAbsolutePath());
String rotString = (int) (rot * 100.0) + "/100"; Method setAttribute = exClass.getMethod("setAttribute",
//log.info("rot rational: " + rotString); new Class[] { String.class, String.class } );
exif.setAttribute("GPSImgDirection", rotString); setAttribute.invoke(exInstance,"GPSLatitude", convertDegToExifRational(lat));
} setAttribute.invoke(exInstance,"GPSLatitudeRef", lat > 0 ?"N" :"S");
exif.saveAttributes(); setAttribute.invoke(exInstance,"GPSLongitude", convertDegToExifRational(lon));
setAttribute.invoke(exInstance,"GPSLongitudeRef", lon > 0?"E" : "W");
if(!Double.isNaN(rot)){
setAttribute.invoke(exInstance,"GPSImgDirectionRef", "T");
String rotString = (int) (rot * 100.0) + "/100";
setAttribute.invoke(exInstance,"GPSImgDirection", rotString);
}
Method saveAttributes = exClass.getMethod("saveAttributes",
new Class[] {} );
saveAttributes.invoke(exInstance);
} catch (Exception e) {
e.printStackTrace();
log.error(e);
}
} }
@SuppressWarnings("rawtypes")
private int getExifOrientation() { private int getExifOrientation() {
ExifInterface exif;
int orientation = 0; int orientation = 0;
try { try {
exif = new ExifInterface(file.getAbsolutePath()); Class exClass = Class.forName("android.media.ExifInterface");
orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, 1);
} catch (IOException e) { Constructor c = exClass.getConstructor(new Class[] { String.class });
Object exInstance = c.newInstance(file.getAbsolutePath());
Method getAttributeInt = exClass.getMethod("getAttributeInt",
new Class[] { String.class, Integer.TYPE} );
Integer it = (Integer) getAttributeInt.invoke(exInstance, "Orientation", new Integer(1));
orientation = it.intValue();
} catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
log.error(e);
} }
return orientation; return orientation;
} }
@ -531,11 +552,11 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
try { try {
Method m = mr.getClass().getDeclaredMethod("setOrientationHint", Integer.TYPE); Method m = mr.getClass().getDeclaredMethod("setOrientationHint", Integer.TYPE);
Display display = ((WindowManager) mapActivity.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); Display display = ((WindowManager) mapActivity.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
if (display.getRotation() == Surface.ROTATION_0) { if (display.getOrientation() == Surface.ROTATION_0) {
m.invoke(mr, 90); m.invoke(mr, 90);
} else if (display.getRotation() == Surface.ROTATION_270) { } else if (display.getOrientation() == Surface.ROTATION_270) {
m.invoke(mr, 180); m.invoke(mr, 180);
} else if (display.getRotation() == Surface.ROTATION_180) { } else if (display.getOrientation() == Surface.ROTATION_180) {
m.invoke(mr, 270); m.invoke(mr, 270);
} }
} catch (Exception e) { } catch (Exception e) {