diff options
58 files changed, 1742 insertions, 0 deletions
diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..4e77f39 --- /dev/null +++ b/.classpath @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="src"/> + <classpathentry kind="src" path="gen"/> + <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> + <classpathentry kind="lib" path="jackson-core-asl-1.5.0.jar"/> + <classpathentry kind="lib" path="jackson-mapper-asl-1.5.0.jar"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/.project b/.project new file mode 100644 index 0000000..5abe862 --- /dev/null +++ b/.project @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>lc8n</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>com.android.ide.eclipse.adt.ApkBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>com.android.ide.eclipse.adt.AndroidNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/AndroidManifest.xml b/AndroidManifest.xml new file mode 100644 index 0000000..2eedfa8 --- /dev/null +++ b/AndroidManifest.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.lc8n.android" + android:versionCode="1" + android:versionName="1.1"> + <uses-permission android:name="android.permission.INTERNET" /> + <uses-permission android:name="android.permission.CAMERA" /> + <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> + <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> + <application android:icon="@drawable/icon" android:label="@string/app_name" + android:theme="@android:style/Theme.NoTitleBar" android:debuggable="true"> + <uses-library android:name="com.google.android.maps" /> + <activity android:name=".LCMapView" + android:label="@string/app_name"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> + <activity android:name=".LCCameraView"></activity> + </application> + <uses-sdk android:minSdkVersion="3" /> + +</manifest>
\ No newline at end of file diff --git a/bin/classes.dex b/bin/classes.dex Binary files differnew file mode 100644 index 0000000..35ef583 --- /dev/null +++ b/bin/classes.dex diff --git a/bin/com/lc8n/android/CustomCameraView$1.class b/bin/com/lc8n/android/CustomCameraView$1.class Binary files differnew file mode 100644 index 0000000..30570df --- /dev/null +++ b/bin/com/lc8n/android/CustomCameraView$1.class diff --git a/bin/com/lc8n/android/CustomCameraView.class b/bin/com/lc8n/android/CustomCameraView.class Binary files differnew file mode 100644 index 0000000..1b8c497 --- /dev/null +++ b/bin/com/lc8n/android/CustomCameraView.class diff --git a/bin/com/lc8n/android/LCCameraView$1.class b/bin/com/lc8n/android/LCCameraView$1.class Binary files differnew file mode 100644 index 0000000..680a7ca --- /dev/null +++ b/bin/com/lc8n/android/LCCameraView$1.class diff --git a/bin/com/lc8n/android/LCCameraView$LocationOverlay.class b/bin/com/lc8n/android/LCCameraView$LocationOverlay.class Binary files differnew file mode 100644 index 0000000..191689a --- /dev/null +++ b/bin/com/lc8n/android/LCCameraView$LocationOverlay.class diff --git a/bin/com/lc8n/android/LCCameraView$MyLocationListener.class b/bin/com/lc8n/android/LCCameraView$MyLocationListener.class Binary files differnew file mode 100644 index 0000000..5fbb4bf --- /dev/null +++ b/bin/com/lc8n/android/LCCameraView$MyLocationListener.class diff --git a/bin/com/lc8n/android/LCCameraView$MySensorListener.class b/bin/com/lc8n/android/LCCameraView$MySensorListener.class Binary files differnew file mode 100644 index 0000000..0996987 --- /dev/null +++ b/bin/com/lc8n/android/LCCameraView$MySensorListener.class diff --git a/bin/com/lc8n/android/LCCameraView.class b/bin/com/lc8n/android/LCCameraView.class Binary files differnew file mode 100644 index 0000000..bed96a5 --- /dev/null +++ b/bin/com/lc8n/android/LCCameraView.class diff --git a/bin/com/lc8n/android/LCGoogleSearch.class b/bin/com/lc8n/android/LCGoogleSearch.class Binary files differnew file mode 100644 index 0000000..40ec55a --- /dev/null +++ b/bin/com/lc8n/android/LCGoogleSearch.class diff --git a/bin/com/lc8n/android/LCMapOverlay.class b/bin/com/lc8n/android/LCMapOverlay.class Binary files differnew file mode 100644 index 0000000..caa8501 --- /dev/null +++ b/bin/com/lc8n/android/LCMapOverlay.class diff --git a/bin/com/lc8n/android/LCMapView$1.class b/bin/com/lc8n/android/LCMapView$1.class Binary files differnew file mode 100644 index 0000000..448c69e --- /dev/null +++ b/bin/com/lc8n/android/LCMapView$1.class diff --git a/bin/com/lc8n/android/LCMapView$2.class b/bin/com/lc8n/android/LCMapView$2.class Binary files differnew file mode 100644 index 0000000..00d8617 --- /dev/null +++ b/bin/com/lc8n/android/LCMapView$2.class diff --git a/bin/com/lc8n/android/LCMapView$MyLocationListener.class b/bin/com/lc8n/android/LCMapView$MyLocationListener.class Binary files differnew file mode 100644 index 0000000..a719bbd --- /dev/null +++ b/bin/com/lc8n/android/LCMapView$MyLocationListener.class diff --git a/bin/com/lc8n/android/LCMapView$MyLocationOverlay.class b/bin/com/lc8n/android/LCMapView$MyLocationOverlay.class Binary files differnew file mode 100644 index 0000000..1c71946 --- /dev/null +++ b/bin/com/lc8n/android/LCMapView$MyLocationOverlay.class diff --git a/bin/com/lc8n/android/LCMapView$MySensorListener.class b/bin/com/lc8n/android/LCMapView$MySensorListener.class Binary files differnew file mode 100644 index 0000000..4eea5a6 --- /dev/null +++ b/bin/com/lc8n/android/LCMapView$MySensorListener.class diff --git a/bin/com/lc8n/android/LCMapView.class b/bin/com/lc8n/android/LCMapView.class Binary files differnew file mode 100644 index 0000000..ddfe75f --- /dev/null +++ b/bin/com/lc8n/android/LCMapView.class diff --git a/bin/com/lc8n/android/Phone.class b/bin/com/lc8n/android/Phone.class Binary files differnew file mode 100644 index 0000000..64f4c19 --- /dev/null +++ b/bin/com/lc8n/android/Phone.class diff --git a/bin/com/lc8n/android/R$array.class b/bin/com/lc8n/android/R$array.class Binary files differnew file mode 100644 index 0000000..4e0a5d5 --- /dev/null +++ b/bin/com/lc8n/android/R$array.class diff --git a/bin/com/lc8n/android/R$attr.class b/bin/com/lc8n/android/R$attr.class Binary files differnew file mode 100644 index 0000000..57384bd --- /dev/null +++ b/bin/com/lc8n/android/R$attr.class diff --git a/bin/com/lc8n/android/R$drawable.class b/bin/com/lc8n/android/R$drawable.class Binary files differnew file mode 100644 index 0000000..9da5c40 --- /dev/null +++ b/bin/com/lc8n/android/R$drawable.class diff --git a/bin/com/lc8n/android/R$id.class b/bin/com/lc8n/android/R$id.class Binary files differnew file mode 100644 index 0000000..a918dde --- /dev/null +++ b/bin/com/lc8n/android/R$id.class diff --git a/bin/com/lc8n/android/R$layout.class b/bin/com/lc8n/android/R$layout.class Binary files differnew file mode 100644 index 0000000..202b3bd --- /dev/null +++ b/bin/com/lc8n/android/R$layout.class diff --git a/bin/com/lc8n/android/R$string.class b/bin/com/lc8n/android/R$string.class Binary files differnew file mode 100644 index 0000000..7478d55 --- /dev/null +++ b/bin/com/lc8n/android/R$string.class diff --git a/bin/com/lc8n/android/R.class b/bin/com/lc8n/android/R.class Binary files differnew file mode 100644 index 0000000..fd89ae3 --- /dev/null +++ b/bin/com/lc8n/android/R.class diff --git a/bin/com/lc8n/android/ResponseData.class b/bin/com/lc8n/android/ResponseData.class Binary files differnew file mode 100644 index 0000000..5feff34 --- /dev/null +++ b/bin/com/lc8n/android/ResponseData.class diff --git a/bin/com/lc8n/android/Result.class b/bin/com/lc8n/android/Result.class Binary files differnew file mode 100644 index 0000000..7ad7b12 --- /dev/null +++ b/bin/com/lc8n/android/Result.class diff --git a/bin/com/lc8n/android/Results.class b/bin/com/lc8n/android/Results.class Binary files differnew file mode 100644 index 0000000..f07e348 --- /dev/null +++ b/bin/com/lc8n/android/Results.class diff --git a/bin/lc8n.apk b/bin/lc8n.apk Binary files differnew file mode 100644 index 0000000..0dd1566 --- /dev/null +++ b/bin/lc8n.apk diff --git a/bin/resources.ap_ b/bin/resources.ap_ Binary files differnew file mode 100644 index 0000000..bb38b8e --- /dev/null +++ b/bin/resources.ap_ 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 Binary files differnew file mode 100644 index 0000000..872a8ee --- /dev/null +++ b/jackson-core-asl-1.5.0.jar diff --git a/jackson-mapper-asl-1.5.0.jar b/jackson-mapper-asl-1.5.0.jar Binary files differnew file mode 100644 index 0000000..30bbdf0 --- /dev/null +++ b/jackson-mapper-asl-1.5.0.jar diff --git a/res/drawable/androidmarker.png b/res/drawable/androidmarker.png Binary files differnew file mode 100644 index 0000000..8c43d46 --- /dev/null +++ b/res/drawable/androidmarker.png diff --git a/res/drawable/camera.png b/res/drawable/camera.png Binary files differnew file mode 100644 index 0000000..c0be221 --- /dev/null +++ b/res/drawable/camera.png diff --git a/res/drawable/icon.png b/res/drawable/icon.png Binary files differnew file mode 100644 index 0000000..8c43d46 --- /dev/null +++ b/res/drawable/icon.png diff --git a/res/drawable/icon1.png b/res/drawable/icon1.png Binary files differnew file mode 100644 index 0000000..a07c69f --- /dev/null +++ b/res/drawable/icon1.png diff --git a/res/drawable/lolarrow.png b/res/drawable/lolarrow.png Binary files differnew file mode 100644 index 0000000..6a3f550 --- /dev/null +++ b/res/drawable/lolarrow.png diff --git a/res/drawable/marker.png b/res/drawable/marker.png Binary files differnew file mode 100644 index 0000000..0e9c1f5 --- /dev/null +++ b/res/drawable/marker.png diff --git a/res/drawable/markerandroid.png b/res/drawable/markerandroid.png Binary files differnew file mode 100644 index 0000000..cb05719 --- /dev/null +++ b/res/drawable/markerandroid.png diff --git a/res/drawable/pointer.png b/res/drawable/pointer.png Binary files differnew file mode 100644 index 0000000..3b87c9d --- /dev/null +++ b/res/drawable/pointer.png diff --git a/res/drawable/search.png b/res/drawable/search.png Binary files differnew file mode 100644 index 0000000..e7c17c2 --- /dev/null +++ b/res/drawable/search.png 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 @@ +<?xml version="1.0" encoding="utf-8"?> +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="fill_parent"> + <com.lc8n.android.CustomCameraView + android:id="@+id/camview" + android:layout_width="wrap_content" + android:layout_height="wrap_content"/> + <LinearLayout + android:id="@+id/overlay" + android:orientation="horizontal" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_alignParentTop="true" + android:layout_centerHorizontal="true"> + <EditText + android:id="@+id/entry1" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_weight="2"/> + <ImageButton + android:id="@+id/ok1" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_weight="8" + android:src="@drawable/search"/> + </LinearLayout> + <LinearLayout + android:id="@+id/loc" + android:orientation="vertical" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_alignParentBottom="true" + android:layout_centerHorizontal="true"> + <TextView + android:id="@+id/loc1" + android:text="location" + android:textSize="10pt" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:gravity="center_horizontal" + android:layout_weight="1"/> + <LinearLayout + android:id="@+id/seek" + android:orientation="horizontal" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_alignParentBottom="true" + android:layout_centerHorizontal="true"> + <Spinner + android:id="@+id/spinner" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:drawSelectorOnTop="true" + android:prompt="@string/db_prompt" + android:layout_weight="8" + /> + + + </LinearLayout> + </LinearLayout> +</RelativeLayout>
\ 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 @@ +<?xml version="1.0" encoding="utf-8"?> +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="fill_parent"> + <com.google.android.maps.MapView + android:id="@+id/mapview" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:clickable="true" + android:apiKey="0ksIJGFhvoENlKbGMqb1qukBrG7bc0k16leprGA" + /> + <LinearLayout + android:orientation="vertical" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_alignParentTop="true" + android:layout_centerHorizontal="true"> + + <LinearLayout + android:orientation="horizontal" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_alignParentTop="true" + android:layout_centerHorizontal="true"> + + <Spinner + android:id="@+id/spinner" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:drawSelectorOnTop="true" + android:prompt="@string/db_prompt" + android:layout_weight="2" + /> + <EditText + android:id="@+id/entry" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_weight="2"/> + <ImageButton + android:id="@+id/ok" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_weight="3" + android:src="@drawable/search"/> + + <ImageButton + android:id="@+id/camera" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_weight="3" + android:src="@drawable/camera"/> + </LinearLayout> +</LinearLayout> +</RelativeLayout>
\ 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 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <string-array name="database"> + <item>University Campus</item> + <item>Google Maps</item> + </string-array> + +</resources> 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 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <string name="hello">Hello World, lc8n!</string> + <string name="app_name">lc8n</string> + <string name="db_prompt">Choose a Database</string> +</resources> 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<Result> 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<Result> 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<Result> 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<OverlayItem> { + private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>(); + 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<Overlay> 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<Result> 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<Phone> 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<Phone> getPhoneNumbers() { + return phoneNumbers; + } + + public void setPhoneNumbers(List<Phone> 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<Result> results; + + public List<Result> getResults() { + return results; + } + public void setResults(List<Result> results) { + this.results = results; + } +} |