From 6093815099eb6d6c3d978579ccbdde38fa916f13 Mon Sep 17 00:00:00 2001 From: Joe Robinson Date: Fri, 29 Oct 2010 00:48:14 +0100 Subject: Untouched work since submission for university project 04/05/2010. Messy code, a bit glitchy. --- .classpath | 9 + .project | 33 + AndroidManifest.xml | 24 + bin/classes.dex | Bin 0 -> 574620 bytes bin/com/lc8n/android/CustomCameraView$1.class | Bin 0 -> 1882 bytes bin/com/lc8n/android/CustomCameraView.class | Bin 0 -> 1169 bytes bin/com/lc8n/android/LCCameraView$1.class | Bin 0 -> 2389 bytes .../android/LCCameraView$LocationOverlay.class | Bin 0 -> 4900 bytes .../android/LCCameraView$MyLocationListener.class | Bin 0 -> 2727 bytes .../android/LCCameraView$MySensorListener.class | Bin 0 -> 1846 bytes bin/com/lc8n/android/LCCameraView.class | Bin 0 -> 8149 bytes bin/com/lc8n/android/LCGoogleSearch.class | Bin 0 -> 4391 bytes bin/com/lc8n/android/LCMapOverlay.class | Bin 0 -> 2330 bytes bin/com/lc8n/android/LCMapView$1.class | Bin 0 -> 3741 bytes bin/com/lc8n/android/LCMapView$2.class | Bin 0 -> 1058 bytes .../android/LCMapView$MyLocationListener.class | Bin 0 -> 2060 bytes .../lc8n/android/LCMapView$MyLocationOverlay.class | Bin 0 -> 2121 bytes .../lc8n/android/LCMapView$MySensorListener.class | Bin 0 -> 1178 bytes bin/com/lc8n/android/LCMapView.class | Bin 0 -> 7958 bytes bin/com/lc8n/android/Phone.class | Bin 0 -> 712 bytes bin/com/lc8n/android/R$array.class | Bin 0 -> 389 bytes bin/com/lc8n/android/R$attr.class | Bin 0 -> 334 bytes bin/com/lc8n/android/R$drawable.class | Bin 0 -> 650 bytes bin/com/lc8n/android/R$id.class | Bin 0 -> 697 bytes bin/com/lc8n/android/R$layout.class | Bin 0 -> 418 bytes bin/com/lc8n/android/R$string.class | Bin 0 -> 454 bytes bin/com/lc8n/android/R.class | Bin 0 -> 563 bytes bin/com/lc8n/android/ResponseData.class | Bin 0 -> 593 bytes bin/com/lc8n/android/Result.class | Bin 0 -> 4950 bytes bin/com/lc8n/android/Results.class | Bin 0 -> 755 bytes bin/lc8n.apk | Bin 0 -> 261201 bytes bin/resources.ap_ | Bin 0 -> 18080 bytes default.properties | 13 + gen/com/lc8n/android/R.java | 50 ++ jackson-core-asl-1.5.0.jar | Bin 0 -> 171612 bytes jackson-mapper-asl-1.5.0.jar | Bin 0 -> 483809 bytes res/drawable/androidmarker.png | Bin 0 -> 702 bytes res/drawable/camera.png | Bin 0 -> 1642 bytes res/drawable/icon.png | Bin 0 -> 702 bytes res/drawable/icon1.png | Bin 0 -> 2574 bytes res/drawable/lolarrow.png | Bin 0 -> 332 bytes res/drawable/marker.png | Bin 0 -> 1245 bytes res/drawable/markerandroid.png | Bin 0 -> 2239 bytes res/drawable/pointer.png | Bin 0 -> 1400 bytes res/drawable/search.png | Bin 0 -> 4505 bytes res/layout/camera.xml | 62 ++ res/layout/main.xml | 54 ++ res/values/arrays.xml | 8 + res/values/strings.xml | 6 + src/com/lc8n/android/CustomCameraView.java | 59 ++ src/com/lc8n/android/LCCameraView.java | 718 +++++++++++++++++++++ src/com/lc8n/android/LCGoogleSearch.java | 86 +++ src/com/lc8n/android/LCMapOverlay.java | 60 ++ src/com/lc8n/android/LCMapView.java | 307 +++++++++ src/com/lc8n/android/Phone.java | 20 + src/com/lc8n/android/ResponseData.java | 14 + src/com/lc8n/android/Result.java | 204 ++++++ src/com/lc8n/android/Results.java | 15 + 58 files changed, 1742 insertions(+) create mode 100644 .classpath create mode 100644 .project create mode 100644 AndroidManifest.xml create mode 100644 bin/classes.dex create mode 100644 bin/com/lc8n/android/CustomCameraView$1.class create mode 100644 bin/com/lc8n/android/CustomCameraView.class create mode 100644 bin/com/lc8n/android/LCCameraView$1.class create mode 100644 bin/com/lc8n/android/LCCameraView$LocationOverlay.class create mode 100644 bin/com/lc8n/android/LCCameraView$MyLocationListener.class create mode 100644 bin/com/lc8n/android/LCCameraView$MySensorListener.class create mode 100644 bin/com/lc8n/android/LCCameraView.class create mode 100644 bin/com/lc8n/android/LCGoogleSearch.class create mode 100644 bin/com/lc8n/android/LCMapOverlay.class create mode 100644 bin/com/lc8n/android/LCMapView$1.class create mode 100644 bin/com/lc8n/android/LCMapView$2.class create mode 100644 bin/com/lc8n/android/LCMapView$MyLocationListener.class create mode 100644 bin/com/lc8n/android/LCMapView$MyLocationOverlay.class create mode 100644 bin/com/lc8n/android/LCMapView$MySensorListener.class create mode 100644 bin/com/lc8n/android/LCMapView.class create mode 100644 bin/com/lc8n/android/Phone.class create mode 100644 bin/com/lc8n/android/R$array.class create mode 100644 bin/com/lc8n/android/R$attr.class create mode 100644 bin/com/lc8n/android/R$drawable.class create mode 100644 bin/com/lc8n/android/R$id.class create mode 100644 bin/com/lc8n/android/R$layout.class create mode 100644 bin/com/lc8n/android/R$string.class create mode 100644 bin/com/lc8n/android/R.class create mode 100644 bin/com/lc8n/android/ResponseData.class create mode 100644 bin/com/lc8n/android/Result.class create mode 100644 bin/com/lc8n/android/Results.class create mode 100644 bin/lc8n.apk create mode 100644 bin/resources.ap_ create mode 100644 default.properties create mode 100644 gen/com/lc8n/android/R.java create mode 100644 jackson-core-asl-1.5.0.jar create mode 100644 jackson-mapper-asl-1.5.0.jar create mode 100644 res/drawable/androidmarker.png create mode 100644 res/drawable/camera.png create mode 100644 res/drawable/icon.png create mode 100644 res/drawable/icon1.png create mode 100644 res/drawable/lolarrow.png create mode 100644 res/drawable/marker.png create mode 100644 res/drawable/markerandroid.png create mode 100644 res/drawable/pointer.png create mode 100644 res/drawable/search.png create mode 100644 res/layout/camera.xml create mode 100644 res/layout/main.xml create mode 100644 res/values/arrays.xml create mode 100644 res/values/strings.xml create mode 100644 src/com/lc8n/android/CustomCameraView.java create mode 100644 src/com/lc8n/android/LCCameraView.java create mode 100644 src/com/lc8n/android/LCGoogleSearch.java create mode 100644 src/com/lc8n/android/LCMapOverlay.java create mode 100644 src/com/lc8n/android/LCMapView.java create mode 100644 src/com/lc8n/android/Phone.java create mode 100644 src/com/lc8n/android/ResponseData.java create mode 100644 src/com/lc8n/android/Result.java create mode 100644 src/com/lc8n/android/Results.java diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..4e77f39 --- /dev/null +++ b/.classpath @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..5abe862 --- /dev/null +++ b/.project @@ -0,0 +1,33 @@ + + + lc8n + + + + + + com.android.ide.eclipse.adt.ResourceManagerBuilder + + + + + com.android.ide.eclipse.adt.PreCompilerBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + com.android.ide.eclipse.adt.ApkBuilder + + + + + + com.android.ide.eclipse.adt.AndroidNature + org.eclipse.jdt.core.javanature + + diff --git a/AndroidManifest.xml b/AndroidManifest.xml new file mode 100644 index 0000000..2eedfa8 --- /dev/null +++ b/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/bin/classes.dex b/bin/classes.dex new file mode 100644 index 0000000..35ef583 Binary files /dev/null and b/bin/classes.dex differ diff --git a/bin/com/lc8n/android/CustomCameraView$1.class b/bin/com/lc8n/android/CustomCameraView$1.class new file mode 100644 index 0000000..30570df Binary files /dev/null and b/bin/com/lc8n/android/CustomCameraView$1.class differ diff --git a/bin/com/lc8n/android/CustomCameraView.class b/bin/com/lc8n/android/CustomCameraView.class new file mode 100644 index 0000000..1b8c497 Binary files /dev/null and b/bin/com/lc8n/android/CustomCameraView.class differ diff --git a/bin/com/lc8n/android/LCCameraView$1.class b/bin/com/lc8n/android/LCCameraView$1.class new file mode 100644 index 0000000..680a7ca Binary files /dev/null and b/bin/com/lc8n/android/LCCameraView$1.class differ diff --git a/bin/com/lc8n/android/LCCameraView$LocationOverlay.class b/bin/com/lc8n/android/LCCameraView$LocationOverlay.class new file mode 100644 index 0000000..191689a Binary files /dev/null and b/bin/com/lc8n/android/LCCameraView$LocationOverlay.class differ diff --git a/bin/com/lc8n/android/LCCameraView$MyLocationListener.class b/bin/com/lc8n/android/LCCameraView$MyLocationListener.class new file mode 100644 index 0000000..5fbb4bf Binary files /dev/null and b/bin/com/lc8n/android/LCCameraView$MyLocationListener.class differ diff --git a/bin/com/lc8n/android/LCCameraView$MySensorListener.class b/bin/com/lc8n/android/LCCameraView$MySensorListener.class new file mode 100644 index 0000000..0996987 Binary files /dev/null and b/bin/com/lc8n/android/LCCameraView$MySensorListener.class differ diff --git a/bin/com/lc8n/android/LCCameraView.class b/bin/com/lc8n/android/LCCameraView.class new file mode 100644 index 0000000..bed96a5 Binary files /dev/null and b/bin/com/lc8n/android/LCCameraView.class differ diff --git a/bin/com/lc8n/android/LCGoogleSearch.class b/bin/com/lc8n/android/LCGoogleSearch.class new file mode 100644 index 0000000..40ec55a Binary files /dev/null and b/bin/com/lc8n/android/LCGoogleSearch.class differ diff --git a/bin/com/lc8n/android/LCMapOverlay.class b/bin/com/lc8n/android/LCMapOverlay.class new file mode 100644 index 0000000..caa8501 Binary files /dev/null and b/bin/com/lc8n/android/LCMapOverlay.class differ diff --git a/bin/com/lc8n/android/LCMapView$1.class b/bin/com/lc8n/android/LCMapView$1.class new file mode 100644 index 0000000..448c69e Binary files /dev/null and b/bin/com/lc8n/android/LCMapView$1.class differ diff --git a/bin/com/lc8n/android/LCMapView$2.class b/bin/com/lc8n/android/LCMapView$2.class new file mode 100644 index 0000000..00d8617 Binary files /dev/null and b/bin/com/lc8n/android/LCMapView$2.class differ diff --git a/bin/com/lc8n/android/LCMapView$MyLocationListener.class b/bin/com/lc8n/android/LCMapView$MyLocationListener.class new file mode 100644 index 0000000..a719bbd Binary files /dev/null and b/bin/com/lc8n/android/LCMapView$MyLocationListener.class differ diff --git a/bin/com/lc8n/android/LCMapView$MyLocationOverlay.class b/bin/com/lc8n/android/LCMapView$MyLocationOverlay.class new file mode 100644 index 0000000..1c71946 Binary files /dev/null and b/bin/com/lc8n/android/LCMapView$MyLocationOverlay.class differ diff --git a/bin/com/lc8n/android/LCMapView$MySensorListener.class b/bin/com/lc8n/android/LCMapView$MySensorListener.class new file mode 100644 index 0000000..4eea5a6 Binary files /dev/null and b/bin/com/lc8n/android/LCMapView$MySensorListener.class differ diff --git a/bin/com/lc8n/android/LCMapView.class b/bin/com/lc8n/android/LCMapView.class new file mode 100644 index 0000000..ddfe75f Binary files /dev/null and b/bin/com/lc8n/android/LCMapView.class differ diff --git a/bin/com/lc8n/android/Phone.class b/bin/com/lc8n/android/Phone.class new file mode 100644 index 0000000..64f4c19 Binary files /dev/null and b/bin/com/lc8n/android/Phone.class differ diff --git a/bin/com/lc8n/android/R$array.class b/bin/com/lc8n/android/R$array.class new file mode 100644 index 0000000..4e0a5d5 Binary files /dev/null and b/bin/com/lc8n/android/R$array.class differ diff --git a/bin/com/lc8n/android/R$attr.class b/bin/com/lc8n/android/R$attr.class new file mode 100644 index 0000000..57384bd Binary files /dev/null and b/bin/com/lc8n/android/R$attr.class differ diff --git a/bin/com/lc8n/android/R$drawable.class b/bin/com/lc8n/android/R$drawable.class new file mode 100644 index 0000000..9da5c40 Binary files /dev/null and b/bin/com/lc8n/android/R$drawable.class differ diff --git a/bin/com/lc8n/android/R$id.class b/bin/com/lc8n/android/R$id.class new file mode 100644 index 0000000..a918dde Binary files /dev/null and b/bin/com/lc8n/android/R$id.class differ diff --git a/bin/com/lc8n/android/R$layout.class b/bin/com/lc8n/android/R$layout.class new file mode 100644 index 0000000..202b3bd Binary files /dev/null and b/bin/com/lc8n/android/R$layout.class differ diff --git a/bin/com/lc8n/android/R$string.class b/bin/com/lc8n/android/R$string.class new file mode 100644 index 0000000..7478d55 Binary files /dev/null and b/bin/com/lc8n/android/R$string.class differ diff --git a/bin/com/lc8n/android/R.class b/bin/com/lc8n/android/R.class new file mode 100644 index 0000000..fd89ae3 Binary files /dev/null and b/bin/com/lc8n/android/R.class differ diff --git a/bin/com/lc8n/android/ResponseData.class b/bin/com/lc8n/android/ResponseData.class new file mode 100644 index 0000000..5feff34 Binary files /dev/null and b/bin/com/lc8n/android/ResponseData.class differ diff --git a/bin/com/lc8n/android/Result.class b/bin/com/lc8n/android/Result.class new file mode 100644 index 0000000..7ad7b12 Binary files /dev/null and b/bin/com/lc8n/android/Result.class differ diff --git a/bin/com/lc8n/android/Results.class b/bin/com/lc8n/android/Results.class new file mode 100644 index 0000000..f07e348 Binary files /dev/null and b/bin/com/lc8n/android/Results.class differ diff --git a/bin/lc8n.apk b/bin/lc8n.apk new file mode 100644 index 0000000..0dd1566 Binary files /dev/null and b/bin/lc8n.apk differ diff --git a/bin/resources.ap_ b/bin/resources.ap_ new file mode 100644 index 0000000..bb38b8e Binary files /dev/null and b/bin/resources.ap_ differ diff --git a/default.properties b/default.properties new file mode 100644 index 0000000..2b1d47c --- /dev/null +++ b/default.properties @@ -0,0 +1,13 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system use, +# "build.properties", and override values to adapt the script to your +# project structure. + +# Indicates whether an apk should be generated for each density. +split.density=false +# Project target. +target=Google Inc.:Google APIs:3 diff --git a/gen/com/lc8n/android/R.java b/gen/com/lc8n/android/R.java new file mode 100644 index 0000000..f1d7854 --- /dev/null +++ b/gen/com/lc8n/android/R.java @@ -0,0 +1,50 @@ +/* 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 com.lc8n.android; + +public final class R { + public static final class array { + public static final int database=0x7f040000; + } + public static final class attr { + } + public static final class drawable { + public static final int androidmarker=0x7f020000; + public static final int camera=0x7f020001; + public static final int icon=0x7f020002; + public static final int icon1=0x7f020003; + public static final int lolarrow=0x7f020004; + public static final int marker=0x7f020005; + public static final int markerandroid=0x7f020006; + public static final int pointer=0x7f020007; + public static final int search=0x7f020008; + } + public static final class id { + public static final int camera=0x7f06000b; + public static final int camview=0x7f060000; + public static final int entry=0x7f060009; + public static final int entry1=0x7f060002; + public static final int loc=0x7f060004; + public static final int loc1=0x7f060005; + public static final int mapview=0x7f060008; + public static final int ok=0x7f06000a; + public static final int ok1=0x7f060003; + public static final int overlay=0x7f060001; + public static final int seek=0x7f060006; + public static final int spinner=0x7f060007; + } + public static final class layout { + public static final int camera=0x7f030000; + public static final int main=0x7f030001; + } + public static final class string { + public static final int app_name=0x7f050001; + public static final int db_prompt=0x7f050002; + public static final int hello=0x7f050000; + } +} diff --git a/jackson-core-asl-1.5.0.jar b/jackson-core-asl-1.5.0.jar new file mode 100644 index 0000000..872a8ee Binary files /dev/null and b/jackson-core-asl-1.5.0.jar differ diff --git a/jackson-mapper-asl-1.5.0.jar b/jackson-mapper-asl-1.5.0.jar new file mode 100644 index 0000000..30bbdf0 Binary files /dev/null and b/jackson-mapper-asl-1.5.0.jar differ diff --git a/res/drawable/androidmarker.png b/res/drawable/androidmarker.png new file mode 100644 index 0000000..8c43d46 Binary files /dev/null and b/res/drawable/androidmarker.png differ diff --git a/res/drawable/camera.png b/res/drawable/camera.png new file mode 100644 index 0000000..c0be221 Binary files /dev/null and b/res/drawable/camera.png differ diff --git a/res/drawable/icon.png b/res/drawable/icon.png new file mode 100644 index 0000000..8c43d46 Binary files /dev/null and b/res/drawable/icon.png differ diff --git a/res/drawable/icon1.png b/res/drawable/icon1.png new file mode 100644 index 0000000..a07c69f Binary files /dev/null and b/res/drawable/icon1.png differ diff --git a/res/drawable/lolarrow.png b/res/drawable/lolarrow.png new file mode 100644 index 0000000..6a3f550 Binary files /dev/null and b/res/drawable/lolarrow.png differ diff --git a/res/drawable/marker.png b/res/drawable/marker.png new file mode 100644 index 0000000..0e9c1f5 Binary files /dev/null and b/res/drawable/marker.png differ diff --git a/res/drawable/markerandroid.png b/res/drawable/markerandroid.png new file mode 100644 index 0000000..cb05719 Binary files /dev/null and b/res/drawable/markerandroid.png differ diff --git a/res/drawable/pointer.png b/res/drawable/pointer.png new file mode 100644 index 0000000..3b87c9d Binary files /dev/null and b/res/drawable/pointer.png differ diff --git a/res/drawable/search.png b/res/drawable/search.png new file mode 100644 index 0000000..e7c17c2 Binary files /dev/null and b/res/drawable/search.png differ diff --git a/res/layout/camera.xml b/res/layout/camera.xml new file mode 100644 index 0000000..d60c27b --- /dev/null +++ b/res/layout/camera.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/res/layout/main.xml b/res/layout/main.xml new file mode 100644 index 0000000..a2e4f03 --- /dev/null +++ b/res/layout/main.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/res/values/arrays.xml b/res/values/arrays.xml new file mode 100644 index 0000000..63a06c5 --- /dev/null +++ b/res/values/arrays.xml @@ -0,0 +1,8 @@ + + + + University Campus + Google Maps + + + diff --git a/res/values/strings.xml b/res/values/strings.xml new file mode 100644 index 0000000..dda1bdf --- /dev/null +++ b/res/values/strings.xml @@ -0,0 +1,6 @@ + + + Hello World, lc8n! + lc8n + Choose a Database + diff --git a/src/com/lc8n/android/CustomCameraView.java b/src/com/lc8n/android/CustomCameraView.java new file mode 100644 index 0000000..a663e1e --- /dev/null +++ b/src/com/lc8n/android/CustomCameraView.java @@ -0,0 +1,59 @@ +package com.lc8n.android; + +import android.content.Context; +import android.graphics.PixelFormat; +import android.hardware.Camera; +import android.hardware.Camera.Parameters; +import android.util.AttributeSet; +import android.view.SurfaceHolder; +import android.view.SurfaceView; + +public class CustomCameraView extends SurfaceView + { + + Camera camera; + SurfaceHolder previewHolder; + public CustomCameraView(Context context) { + super(context); + } + public CustomCameraView(Context context, AttributeSet attrs) + { + super(context, attrs); + SurfaceHolder.Callback shl = new SurfaceHolder.Callback() { + + public void surfaceDestroyed(SurfaceHolder holder) { + camera.stopPreview(); + camera.release(); + + } + + public void surfaceCreated(SurfaceHolder holder) { + camera = Camera.open(); + try{ + camera.setPreviewDisplay(previewHolder); + } + catch(Throwable t) + { + + } + } + + public void surfaceChanged(SurfaceHolder holder, int format, int width, + int height) { + Parameters params = camera.getParameters(); + params.setPreviewSize(width, height); + params.setPreviewFormat(PixelFormat.JPEG); + camera.setParameters(params); + camera.startPreview(); + + + + } + }; + + previewHolder = this.getHolder(); + previewHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); + previewHolder.addCallback(shl); + } + + } \ No newline at end of file diff --git a/src/com/lc8n/android/LCCameraView.java b/src/com/lc8n/android/LCCameraView.java new file mode 100644 index 0000000..c4a97fe --- /dev/null +++ b/src/com/lc8n/android/LCCameraView.java @@ -0,0 +1,718 @@ +package com.lc8n.android; + +import java.net.URLEncoder; +import java.util.Collections; +import java.util.List; + +import android.app.Activity; +import android.app.Dialog; +import android.app.ProgressDialog; +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.Canvas; +import android.graphics.Color; +import android.graphics.Matrix; +import android.graphics.Paint; +import android.graphics.Paint.Style; +import android.hardware.Sensor; +import android.hardware.SensorEvent; +import android.hardware.SensorEventListener; +import android.hardware.SensorManager; +import android.location.Location; +import android.location.LocationListener; +import android.location.LocationManager; +import android.os.Bundle; +import android.view.View; +import android.view.ViewGroup.LayoutParams; +import android.widget.ArrayAdapter; +import android.widget.EditText; +import android.widget.ImageButton; +import android.widget.Spinner; +import android.widget.TextView; + +import com.google.android.maps.GeoPoint; + +public class LCCameraView extends Activity { + + private GeoPoint p; + private float dir; + private Location myL; + private List locs; + private LocationManager lm; + private LocationListener ll; + private SensorManager sm; + private SensorEventListener sel; + private LocationOverlay overlay; + private Bitmap bmp; + private String query; + private float[] vals; + private float aob; + private float aob2; + private Location ls; + private Paint paint; + private float angle; + private float rot; + private float span; + private Matrix matrix; + private TextView texty; + private String database; + @Override + public void onCreate(Bundle savedInstanceState) + { + span = 2; + query = "init"; + matrix = new Matrix(); + Paint paint = new Paint(); + paint.setAntiAlias(true); + paint.setFilterBitmap(true); + paint.setStyle(Style.FILL); + paint.setColor(Color.CYAN); + ls = new Location(""); + vals = new float[3]; + vals[0]=(float) 0.0; + vals[1]=(float) 0.0; + vals[2]=(float) 0.0; + + bmp = BitmapFactory.decodeResource(getResources(),R.drawable.marker); + dir = (float)0; + locs = Collections.emptyList(); + super.onCreate(savedInstanceState); +// CustomCameraView cv = new CustomCameraView(this.getApplicationContext()); + + + setContentView(R.layout.camera); + +// addContentView(cv, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); + + + final Spinner s = (Spinner) findViewById(R.id.spinner); + ArrayAdapter adapter = ArrayAdapter.createFromResource( + this, R.array.database, android.R.layout.simple_spinner_item); + adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + s.setAdapter(adapter); + + + final LCGoogleSearch gs = new LCGoogleSearch(); + ImageButton button = (ImageButton)findViewById(R.id.ok1); + texty = (TextView)findViewById(R.id.loc1); + final EditText edit = (EditText)findViewById(R.id.entry1); + button.setOnClickListener(new View.OnClickListener() { + + public void onClick(View v) { + double lat = p.getLatitudeE6()/1E6; + double lng = p.getLongitudeE6()/1E6; +// System.out.println(edit.getText().toString()); + query = URLEncoder.encode((edit.getText().toString())); + database = s.getSelectedItem().toString(); + + + locs = gs.runJSONParser(query,lat,lng,span,span, database); + + overlay.invalidate(); + + } + }); + + + +// final SeekBar bar = (SeekBar)findViewById(R.id.bar); +// bar.setProgress(2); +// span = bar.getProgress(); +// bar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { +// +// @Override +// public void onStopTrackingTouch(SeekBar seekBar) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void onStartTrackingTouch(SeekBar seekBar) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void onProgressChanged(SeekBar seekBar, int progress, +// boolean fromUser) { +// span = progress; +// } +// }); + + + + + + + lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE); + sm = (SensorManager)getSystemService(Context.SENSOR_SERVICE); + + ll = new MyLocationListener(); + lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 100, 1, ll); + sel = new MySensorListener(); + sm.registerListener(sel, sm.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_FASTEST); + sm.registerListener(sel, sm.getDefaultSensor(Sensor.TYPE_ORIENTATION), SensorManager.SENSOR_DELAY_FASTEST); + + overlay = new LocationOverlay(this); + + addContentView(overlay, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); + + + + + } + + + @Override + public void onStop() { + super.onStop(); + + lm.removeUpdates(ll); + sm.unregisterListener(sel); + } + + + @Override + public void onStart() { + super.onStart(); + + /* recheck which provider to use */ + + + lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, + 1000, // 1min + 5, // 100m + ll); + sm.registerListener(sel, sm.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_FASTEST); + sm.registerListener(sel, sm.getDefaultSensor(Sensor.TYPE_ORIENTATION), SensorManager.SENSOR_DELAY_FASTEST); + + } + + + + private class MySensorListener implements SensorEventListener + { + + + + public void onSensorChanged(SensorEvent event) + { + + float[] values = event.values; + if(event.sensor.getType() == Sensor.TYPE_ORIENTATION) + { + + Float check = (Float)values[0]; + if((check - check.intValue()) == 0) + { + vals=values; + } + + + } + else if(event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) + { + aob = values[2]; + aob2 = values[1]; + } + + + +// System.out.println(dir+"-"+tmpDir); + + +// +// float dif = dir-tmpDir; +// System.out.println(dif); +// +// +// +// +// if((dif>3&&dif<10)||dif>357) +// { +// dir = tmpDir; +// } +// + + overlay.invalidate(); + //System.out.println(vals[0]+","+vals[1]+","+vals[2]); + + + } + public void onAccuracyChanged(Sensor sensor, int accuracy) + { + + } + } + private class MyLocationListener implements LocationListener + { + + public void onLocationChanged(Location loc) { + if (loc != null) { + + + Integer lat = (int)(loc.getLatitude()*1E6); + Integer lon = (int)(loc.getLongitude()*1E6); + + GeoPoint point = new GeoPoint(lat,lon); + + p = point; + myL = loc; + overlay.invalidate(); + if(!query.equals("init")) + { + LCGoogleSearch gs = new LCGoogleSearch(); + locs = gs.runJSONParser(query, loc.getLatitude(), loc.getLongitude(), span, span, database); + } + + } + } + + + + + public void onProviderDisabled(String provider) { + // TODO Auto-generated method stub + } + + + public void onProviderEnabled(String provider) { + // TODO Auto-generated method stub + } + + + public void onStatusChanged(String provider, int status, + Bundle extras) { + // TODO Auto-generated method stub + } + } + +// private class AnotherOverlay extends View { +// +// public AnotherOverlay(Context context) { +// super(context); +// } +// +// @Override +// protected void onDraw(Canvas canvas) +// { +// +// } +// } + private class LocationOverlay extends View { + + public LocationOverlay(Context context) { + super(context); + // TODO Auto-generated constructor stub + } + + @Override + protected void onDraw(Canvas canvas) + { + + +// Paint paint1 = new Paint(); +// paint1.setStyle(Paint.Style.FILL_AND_STROKE); +// paint1.setStrokeWidth(1); +// paint1.setARGB(100, 100,100,100); +// RectF rect = new RectF(); +// rect.set(0, 0, canvas.getWidth(), 100); +// canvas.drawRoundRect(rect, 5, 5, paint); + + float wcenter = canvas.getWidth()/2; + float hcenter = canvas.getHeight()/2; + float wposition; + float hposition; + Float check = vals[0]; + float tRot = vals[1]; + + + if(hcenter > wcenter) + { + angle = vals[1]+90; + + dir = vals[0]; + } + else + { + + if(aob < 0) + { + if(aob2 < 0) + { + angle = (float) (vals[2]-90+(180-vals[1])); + dir = (float) (vals[0] + 90 +(180-vals[1])); +// System.out.println(1); + + + } + else + { + angle = (float) (vals[2]-90+((-180-vals[1])*-1)); + dir = (float) (vals[0] + 90 + (-180-vals[1])); +// System.out.println(2); + + } + + if(rot-tRot!=0) + { + rot = 180 - tRot; + } + + + } + else + { + if(aob2 < 0) + { + angle = (float) ((vals[2]-90+vals[1])*-1); + dir = (float) (vals[0] + 90 + vals[1]); +// System.out.println(3); + } + else + { + angle = (float) ((vals[2]-90-vals[1])*-1); + dir = (float) (vals[0] + 90 + vals[1]); +// System.out.println(4); + + } + + if(rot-tRot!=0) + { + rot = tRot; + } + } + + + + + } + + + + Float dirr = dir; + float modu = check - check.intValue(); +// System.out.println(dir); + Result front = new Result(); + front.setTitle(" "); + float best = 1000; + for(final Result rs : locs) + { + + if(front.getTitle().equals(null)) + { + front = rs; + } + + ls.setLatitude(rs.getLat()); + ls.setLongitude(rs.getLng()); + float thisDir = myL.bearingTo(ls); + float dist = myL.distanceTo(ls); + + + + double ldist = Math.log10(dist); + double dist1; +// +// if(span==1) +// { +// if(ldist <=0.5) +// { +// dist1 = 1; +// } +// +// else if(ldist>0.5&ldist<=1) +// { +// dist1=0.8; +// } +// else if(ldist>1&&ldist<=1.25) +// { +// dist1=0.6; +// } +// else if(ldist>1.25&&ldist<=1.5) +// { +// dist1=0.5; +// } +// else if(ldist>1.5&&ldist<=1.75) +// { +// dist1=0.4; +// } +// else if(ldist>1.75&&ldist<=2) +// { +// dist1=0.2; +// } +// else +// { +// dist1=0; +// } +// } +// else if(span==2) +// { +// + if(ldist <=1) + { + dist1 = 1; + } + + else if(ldist>1&ldist<=1.5) + { + dist1=0.8; + } + else if(ldist>1.5&&ldist<=1.75) + { + dist1=0.6; + } + else if(ldist>1.75&&ldist<=2) + { + dist1=0.4; + } + else if(ldist>2&&ldist<=2.25) + { + dist1=0.3; + } + else if(ldist>2.25&&ldist<=2.5) + { + dist1=0.2; + } + else if(ldist>2.5&&ldist<=2.75) + { + dist1=0.1; + } + else + { + dist1=0; + } +// +// +// } +// else if(span==3) +// { +// if(ldist <=1.5) +// { +// dist1 = 1; +// } +// +// else if(ldist>1.5&ldist<=2) +// { +// dist1=0.8; +// } +// else if(ldist>2&&ldist<=2.25) +// { +// dist1=0.6; +// } +// else if(ldist>2&&ldist<=2.25) +// { +// dist1=0.5; +// } +// else if(ldist>2.25&&ldist<=2.5) +// { +// dist1=0.4; +// } +// else if(ldist>2.5&&ldist<=2.75) +// { +// dist1=0.3; +// } +// else if(ldist>2.75&&ldist<=3) +// { +// dist1=0.2; +// } +// else +// { +// dist1=0; +// } +// } +// else if(span==4) +// { +// if(ldist <=1.5) +// { +// dist1 = 1; +// } +// +// else if(ldist>1.5&ldist<=2) +// { +// dist1=0.8; +// } +// else if(ldist>2&&ldist<=2.5) +// { +// dist1=0.6; +// } +// else if(ldist>2.5&&ldist<=2.75) +// { +// dist1=0.5; +// } +// else if(ldist>2.75&&ldist<=3) +// { +// dist1=0.4; +// } +// else if(ldist>3&&ldist<=3.25) +// { +// dist1=0.3; +// } +// else if(ldist>3.25&&ldist<=3.5) +// { +// dist1=0.2; +// } +// else if(ldist>3.5&&ldist<=3.75) +// { +// dist1=0.1; +// } +// else +// { +// dist1=0; +// } +// } +// else +// { +// if(ldist <=1.75) +// { +// dist1 = 1; +// } +// else if(ldist>1.75&&ldist<=2) +// { +// dist1=0.9; +// } +// else if(ldist>2&&ldist<=2.25) +// { +// dist1=0.8; +// } +// else if(ldist>2.25&&ldist<=2.5) +// { +// dist1=0.7; +// } +// else if(ldist>2.5&&ldist<=2.75) +// { +// dist1=0.6; +// } +// else if(ldist>2.75&&ldist<=3) +// { +// dist1=0.5; +// } +// else if(ldist>3&&ldist<=3.25) +// { +// dist1=0.4; +// } +// else if(ldist>3.25&&ldist<=3.5) +// { +// dist1=0.3; +// } +// else if(ldist>3.5&&ldist<=3.75) +// { +// dist1=0.2; +// } +// else if(ldist>3.75&&ldist<=4) +// { +// dist1=0.15; +// } +// else +// { +// dist1=0.1; +// } +// } + +// System.out.println("a"+((dist))); +// System.out.println("b"+((dist1))); + if(thisDir<0) + { + thisDir = 360+thisDir; + } + + + + float dif = thisDir - dir; +// System.out.println("c"+dif); +// if((dif < best)&&(dif>0)||(dif > (0-best))&&(dif<0)) +// { +// front = rs; +// best = dif; +// } + if(dif>-60&&dif<60||dif>315) + { + if(dif>315) + { + dif = dif-360; + } +// thisDir = thisDir - (dir-45); + + + + wposition = (float) (wcenter +(dif * (30 * dist1))); + + hposition = (float) (hcenter-80 -((angle) * (30 * dist1))); + matrix.reset(); + matrix.postTranslate(-40, -50); + matrix.postScale((float)dist1*2, (float)dist1*2); + matrix.postRotate(rot); + matrix.postTranslate(wposition, hposition); + + canvas.drawBitmap(bmp, matrix, paint); + + float xdif = Math.abs(240-wposition); + + if(xdif < best) + { + best = xdif; + front = rs; + } + + + } +// if(dif>-45&&dif<0) +// { +// thisDir = thisDir - dir; +// position =center - (thisDir * (canvas.getWidth()/90)); +// canvas.drawBitmap(bmp, position, canvas.getHeight()/2, paint); +// } +// if(thisDir<45) +// { +// +// +// position = (canvas.getWidth()/2) - 50 - (thisDir *(canvas.getWidth()/90)); +// canvas.drawBitmap(bmp, position, canvas.getHeight()/2, paint); +// +// } +// else if(thisDir>45&&thisDir<135) +// { +// thisDir = thisDir-45; +// position = canvas.getWidth() - 50 - (thisDir *(canvas.getWidth()/90)); +// canvas.drawBitmap(bmp, position, canvas.getHeight()/2, paint); +// } +// else if(thisDir>135&&thisDir<225) +// { +// thisDir = thisDir-135; +// position = canvas.getWidth() - 50 - (thisDir *(canvas.getWidth()/90)); +// canvas.drawBitmap(bmp, position, canvas.getHeight()/2, paint); +// } +// else if(thisDir>225&&thisDir<315) +// { +// thisDir = thisDir-225; +// position = canvas.getWidth() - 50 - (thisDir *(canvas.getWidth()/90)); +// canvas.drawBitmap(bmp, position, canvas.getHeight()/2, paint); +// } +// else +// { +// thisDir = thisDir-315; +// position = canvas.getWidth() - 50 - (thisDir *(canvas.getWidth()/90)); +// canvas.drawBitmap(bmp, position, canvas.getHeight()/2, paint); +// } + + } + + + texty.setText(front.getTitle()); + + + + } + + + + + } + + + + + + +} diff --git a/src/com/lc8n/android/LCGoogleSearch.java b/src/com/lc8n/android/LCGoogleSearch.java new file mode 100644 index 0000000..a0b207c --- /dev/null +++ b/src/com/lc8n/android/LCGoogleSearch.java @@ -0,0 +1,86 @@ +package com.lc8n.android; + +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.net.URI; +import java.util.Collections; +import java.util.List; + +import org.apache.http.HttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.impl.client.DefaultHttpClient; +import org.codehaus.jackson.JsonParseException; +import org.codehaus.jackson.map.DeserializationConfig; +import org.codehaus.jackson.map.JsonMappingException; +import org.codehaus.jackson.map.ObjectMapper; + +public class LCGoogleSearch { + + public InputStream getJSONData(String url){ + + DefaultHttpClient httpClient = new DefaultHttpClient(); + URI uri; + InputStream data = null; + try{ + uri = new URI(url); + + + HttpGet method = new HttpGet(uri); + method.addHeader("Referer", "http://www.lc8n.co.uk"); + HttpResponse response = httpClient.execute(method); + data = response.getEntity().getContent(); + + } + catch(Exception e) + { + e.printStackTrace(); + } + + + return data; + + } + + public List runJSONParser(String request, double lat, double lng, double latspan, double lngspan, String db){ + + String url = "http://lc8n.co.uk/search.php?q="+request; + + if(db.equals("Google Maps")) + { + url = "http://ajax.googleapis.com/ajax/services/search/local?v=3.0&q="+request+"&sll="+lat+","+lng+"&sspn="+latspan+","+lngspan+"&rsz=large" + +"&key=ABQIAAAAdosJ9FP7ajF_9f3Z_cbYoRSy5sbAFFtUu9frF3oeYhqN3FjpixTyLH_nlb9PV1c3EJNEVLBTLfI7JQ&sensor=true"; + } + + List results = Collections.emptyList(); + Reader r = new InputStreamReader(getJSONData(url)); +// Reader r = new InputStreamReader(getJSONData("http://ajax.googleapis.com/ajax/services/search/local?v=3.0&q="+request+"&sll="+lat+","+lng+"&sspn="+latspan+","+lngspan+"&rsz=large" +// +"&key=ABQIAAAAdosJ9FP7ajF_9f3Z_cbYoRSy5sbAFFtUu9frF3oeYhqN3FjpixTyLH_nlb9PV1c3EJNEVLBTLfI7JQ&sensor=true")); + ObjectMapper mapper = new ObjectMapper(); + + try { + mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); + ResponseData responseData = mapper.readValue(r, ResponseData.class); + System.out.println(responseData.getResponseData().getResults()); + Results result = responseData.getResponseData(); + results = result.getResults(); + + + } catch (JsonParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (JsonMappingException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return results; + + + } + +} diff --git a/src/com/lc8n/android/LCMapOverlay.java b/src/com/lc8n/android/LCMapOverlay.java new file mode 100644 index 0000000..1e6c384 --- /dev/null +++ b/src/com/lc8n/android/LCMapOverlay.java @@ -0,0 +1,60 @@ +package com.lc8n.android; + +import java.util.ArrayList; + +import android.app.AlertDialog; +import android.content.Context; +import android.graphics.drawable.Drawable; + +import com.google.android.maps.ItemizedOverlay; +import com.google.android.maps.OverlayItem; + +public class LCMapOverlay extends ItemizedOverlay { + private ArrayList mOverlays = new ArrayList(); + private Context mContext; + public LCMapOverlay(Drawable defaultMarker) { + super(boundCenterBottom(defaultMarker)); + // TODO Auto-generated constructor stub + } + public LCMapOverlay(Drawable defaultMarker, Context context) { + super(boundCenterBottom(defaultMarker)); + mContext = context; + } + + + public void addOverlay(OverlayItem overlay) + { + mOverlays.add(overlay); + populate(); + } + public void clearOverlays() + { + mOverlays.clear(); + + } + + + @Override + protected boolean onTap(int index) { + OverlayItem item = mOverlays.get(index); + AlertDialog.Builder dialog = new AlertDialog.Builder(mContext); + dialog.setTitle(item.getTitle()); + dialog.setMessage(item.getSnippet()); + dialog.show(); + return true; + } + + + @Override + protected OverlayItem createItem(int i) { + // TODO Auto-generated method stub + return mOverlays.get(i); + } + + @Override + public int size() { + // TODO Auto-generated method stub + return mOverlays.size(); + } + +} diff --git a/src/com/lc8n/android/LCMapView.java b/src/com/lc8n/android/LCMapView.java new file mode 100644 index 0000000..9cdf3c0 --- /dev/null +++ b/src/com/lc8n/android/LCMapView.java @@ -0,0 +1,307 @@ +package com.lc8n.android; + +import java.net.URLEncoder; +import java.util.List; +import java.util.Locale; + +import android.content.Context; +import android.content.Intent; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.Canvas; +import android.graphics.Matrix; +import android.graphics.Paint; +import android.graphics.Point; +import android.graphics.drawable.Drawable; +import android.hardware.Sensor; +import android.hardware.SensorEvent; +import android.hardware.SensorEventListener; +import android.hardware.SensorManager; +import android.location.Geocoder; +import android.location.Location; +import android.location.LocationListener; +import android.location.LocationManager; +import android.os.Bundle; +import android.view.View; +import android.widget.ArrayAdapter; +import android.widget.EditText; +import android.widget.ImageButton; +import android.widget.Spinner; + +import com.google.android.maps.GeoPoint; +import com.google.android.maps.MapActivity; +import com.google.android.maps.MapController; +import com.google.android.maps.MapView; +import com.google.android.maps.Overlay; +import com.google.android.maps.OverlayItem; + +public class LCMapView extends MapActivity { + + + private MapView mapView; + private MapController mc; + private LCMapOverlay itemizedoverlay; + private List mapOverlays; + private LocationManager lm; + private SensorManager sm; + private LocationListener ll; + private SensorEventListener sel; + private GeoPoint p; + private float ori; + private Geocoder gc; + private Paint paint; + private Bitmap bmp; + private Point pt; + private Matrix matrix; + private List results; + private String database; + /** Called when the activity is first created. */ + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + bmp = BitmapFactory.decodeResource(getResources(),R.drawable.pointer); + paint = new Paint(); + pt = new Point(); + matrix = new Matrix(); + paint.setAntiAlias(true); + paint.setFilterBitmap(true); + setContentView(R.layout.main); + + lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE); + sm = (SensorManager)getSystemService(Context.SENSOR_SERVICE); + gc = new Geocoder(this, Locale.UK); + ll = new MyLocationListener(); + mapView = (MapView) findViewById(R.id.mapview); + mapView.setBuiltInZoomControls(true); + mapView.setSatellite(true); + mc = mapView.getController(); + mapOverlays = mapView.getOverlays(); + + Drawable drawable = this.getResources().getDrawable(R.drawable.marker); +// Drawable arrow = this.getResources().getDrawable(R.drawable.lolarrow); + itemizedoverlay = new LCMapOverlay(drawable,this); + +// GeoPoint point = new GeoPoint(19240000,-99120000); + //OverlayItem overlayitem = new OverlayItem(point, "Hola, Mundo!", "I'm in Mexico City!"); + + //itemizedoverlay.addOverlay(overlayitem); + + + + lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 100, 1, ll); +// p = new GeoPoint((int)(lm.getLastKnownLocation(LocationManager.GPS_PROVIDER).getLatitude()*1E6),(int)(lm.getLastKnownLocation(LocationManager.GPS_PROVIDER).getLongitude()*1E6)); +// mc.animateTo(p); + + /*MyLocationOverlay mlo = new MyLocationOverlay(this, mapView); + mlo.enableMyLocation(); + mlo.enableCompass(); + */ + + + /* + Float bear = myLocation2.getBearing(); + */ + + //itemizedoverlay.addOverlay(overlayitem2); + +// mapOverlays.add(mlo); +// mlo.enableCompass(); +// mlo.enableMyLocation(); +// + + + final Spinner s = (Spinner) findViewById(R.id.spinner); + ArrayAdapter adapter = ArrayAdapter.createFromResource( + this, R.array.database, android.R.layout.simple_spinner_item); + adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + s.setAdapter(adapter); + + + Sensor compass = sm.getDefaultSensor(Sensor.TYPE_ORIENTATION); + sel = new MySensorListener(); + MyLocationOverlay ml = new MyLocationOverlay(); + final LCGoogleSearch gs = new LCGoogleSearch(); + ImageButton button = (ImageButton)findViewById(R.id.ok); + final EditText edit = (EditText)findViewById(R.id.entry); + button.setOnClickListener(new View.OnClickListener() { + + public void onClick(View v) { + double lat = p.getLatitudeE6()/1E6; + double lng = p.getLongitudeE6()/1E6; + double latspan = mapView.getLatitudeSpan()/1E6; + double lngspan = mapView.getLongitudeSpan()/1E6; + database = s.getSelectedItem().toString(); + results = gs.runJSONParser(URLEncoder.encode(edit.getText().toString()),lat,lng,latspan,lngspan, database); + System.out.println(latspan+","+lngspan); + OverlayItem oi; + GeoPoint gp; + int lati; + int lngi; + itemizedoverlay.clearOverlays(); + for(Result rs : results) + { + lati = (int)(rs.getLat()*1E6); + lngi = (int)(rs.getLng()*1E6); + + gp = new GeoPoint(lati,lngi); + oi = new OverlayItem(gp,rs.getTitle(),rs.getStreetAddress()); + itemizedoverlay.addOverlay(oi); + } + } + }); + ImageButton button2 = (ImageButton)findViewById(R.id.camera); + button2.setOnClickListener(new View.OnClickListener() { + + + public void onClick(View v) { + Intent intent = new Intent(v.getContext(),LCCameraView.class); + startActivityForResult(intent, 0); + + } + }); + mapOverlays.add(ml); + + sm.registerListener(sel, compass, SensorManager.SENSOR_DELAY_UI); + GeoPoint gp1 = new GeoPoint(19240000,-99120000); + OverlayItem oi1 = new OverlayItem(gp1," "," "); + itemizedoverlay.addOverlay(oi1); + + + + mapOverlays.add(itemizedoverlay); + + + } + + + @Override + public void onStop() { + super.onStop(); + + lm.removeUpdates(ll); + sm.unregisterListener(sel); + } + + + @Override + public void onStart() { + super.onStart(); + + /* recheck which provider to use */ + + + + sm.registerListener(sel, sm.getDefaultSensor(Sensor.TYPE_ORIENTATION), SensorManager.SENSOR_DELAY_UI); + + } + + + @Override + protected boolean isRouteDisplayed() { + // TODO Auto-generated method stub + return false; + } + + private class MySensorListener implements SensorEventListener + { + public void onSensorChanged(SensorEvent event) + { + float[] values = event.values; + + ori = values[0]+values[2]; + + } + public void onAccuracyChanged(Sensor sensor, int accuracy) + { + + } + } + private class MyLocationListener implements LocationListener + { + + public void onLocationChanged(Location loc) { + if (loc != null) { + + + Integer lat = (int)(loc.getLatitude()*1E6); + Integer lon = (int)(loc.getLongitude()*1E6); + + + p = new GeoPoint(lat,lon); + + mc.animateTo(p); + + + + } + } + + + + + public void onProviderDisabled(String provider) { + // TODO Auto-generated method stub + } + + + public void onProviderEnabled(String provider) { + // TODO Auto-generated method stub + } + + + public void onStatusChanged(String provider, int status, + Bundle extras) { + // TODO Auto-generated method stub + } + } + private class MyLocationOverlay extends Overlay + { + @Override + public void draw(Canvas canvas, MapView mapView, boolean shadow) + { + if(p!=null) + { + + + //super.draw(canvas, mapView, false); + + mapView.getProjection().toPixels(p, pt); + + + matrix.reset(); + matrix.postTranslate(-25, -25); + matrix.postRotate(ori); + matrix.postTranslate(pt.x, pt.y); + + + + canvas.drawBitmap(bmp, matrix, paint); + + } + + + + } + +// @Override +// public boolean onTap(GeoPoint gp, MapView mv){ +// +// Toast.makeText(getBaseContext(), +// "Location changed : Lat: " + p.getLatitudeE6() + +// " Lng: " + p.getLongitudeE6(), +// Toast.LENGTH_SHORT).show(); +// +// return true; +// +// +// } +// public boolean onSnapToItem(int x, int y, Point snapPoint, +// MapView mapView) { +// // TODO Auto-generated method stub +// return false; +// } + } + + +} + diff --git a/src/com/lc8n/android/Phone.java b/src/com/lc8n/android/Phone.java new file mode 100644 index 0000000..800f03f --- /dev/null +++ b/src/com/lc8n/android/Phone.java @@ -0,0 +1,20 @@ +package com.lc8n.android; + +public class Phone { + + private String type; + private String number; + + public String getNumber() { + return number; + } + public String getType() { + return type; + } + public void setNumber(String number) { + this.number = number; + } + public void setType(String type) { + this.type = type; + } +} diff --git a/src/com/lc8n/android/ResponseData.java b/src/com/lc8n/android/ResponseData.java new file mode 100644 index 0000000..cf0ddd8 --- /dev/null +++ b/src/com/lc8n/android/ResponseData.java @@ -0,0 +1,14 @@ +package com.lc8n.android; + +public class ResponseData { + + private Results responseData; + +public Results getResponseData() { + return responseData; +} +public void setResponseData(Results responseData) { + this.responseData = responseData; +} + +} diff --git a/src/com/lc8n/android/Result.java b/src/com/lc8n/android/Result.java new file mode 100644 index 0000000..02416b4 --- /dev/null +++ b/src/com/lc8n/android/Result.java @@ -0,0 +1,204 @@ +package com.lc8n.android; + +import java.util.List; + + +public class Result { + private String gsearchResultClass; + private double lat; + private double lng; + private String titleNoFormatting; + private String ddUrl; + private String viewportmode; + private String listingtype; + private int accuracy; + private String title; + private String ddUrlToHere; + private String ddUrlFromHere; + private String streetAddress; + private String city; + private String region; + private String country; + private String staticMapUrl; + private String url; + private String content; + private int maxAge; + private List phoneNumbers; + private String[] addressLines; + + + + public double getLng() { + return lng; + } + + public double getLat() { + return lat; + } + + public String getTitleNoFormatting() { + return titleNoFormatting; + } + + public String getDdUrl() { + return ddUrl; + } + + public void setLon(double lng) { + this.lng = lng; + } + public void setLat(double lat) { + this.lat = lat; + } + + public void setTitleNoFormatting(String titleNoFormatting) { + this.titleNoFormatting = titleNoFormatting; + } + + public void setDdUrl(String ddUrl) { + this.ddUrl = ddUrl; + } + + public String getGsearchResultClass() { + return gsearchResultClass; + } + + public void setGsearchResultClass(String gsearchResultClass) { + this.gsearchResultClass = gsearchResultClass; + } + + public String getViewportmode() { + return viewportmode; + } + + public void setViewportmode(String viewportmode) { + this.viewportmode = viewportmode; + } + + public String getListingtype() { + return listingtype; + } + + public void setListingtype(String listingtype) { + this.listingtype = listingtype; + } + + public int getAccuracy() { + return accuracy; + } + + public void setAccuracy(int accuracy) { + this.accuracy = accuracy; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getDdUrlToHere() { + return ddUrlToHere; + } + + public void setDdUrlToHere(String ddUrlToHere) { + this.ddUrlToHere = ddUrlToHere; + } + + public String getDdUrlFromHere() { + return ddUrlFromHere; + } + + public void setDdUrlFromHere(String ddUrlFromHere) { + this.ddUrlFromHere = ddUrlFromHere; + } + + public String getStreetAddress() { + return streetAddress; + } + + public void setStreetAddress(String streetAddress) { + this.streetAddress = streetAddress; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getRegion() { + return region; + } + + public void setRegion(String region) { + this.region = region; + } + + public String getCountry() { + return country; + } + + public void setCountry(String country) { + this.country = country; + } + + public String getStaticMapUrl() { + return staticMapUrl; + } + + public void setStaticMapUrl(String staticMapUrl) { + this.staticMapUrl = staticMapUrl; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public int getMaxAge() { + return maxAge; + } + + public void setMaxAge(int maxAge) { + this.maxAge = maxAge; + } + + public List getPhoneNumbers() { + return phoneNumbers; + } + + public void setPhoneNumbers(List phoneNumbers) { + this.phoneNumbers = phoneNumbers; + } + + public String[] getAddressLines() { + return addressLines; + } + + public void setAddressLines(String[] addressLines) { + this.addressLines = addressLines; + } + + public void setLng(double lng) { + this.lng = lng; + } + + + +} diff --git a/src/com/lc8n/android/Results.java b/src/com/lc8n/android/Results.java new file mode 100644 index 0000000..4ea9954 --- /dev/null +++ b/src/com/lc8n/android/Results.java @@ -0,0 +1,15 @@ +package com.lc8n.android; + +import java.util.List; + +public class Results { + + private List results; + + public List getResults() { + return results; + } + public void setResults(List results) { + this.results = results; + } +} -- cgit v1.2.3