mirror of
https://github.com/bspeice/itcs4180
synced 2024-12-04 13:18:16 -05:00
Added Compass capability, QR scanning (requires zxing to be installed),
and main search screen. Added comments at the top of all files. TODO: Fix formatting, add locations to server, add photos of locations, implement database functionality, fix all other TODO's.
This commit is contained in:
parent
31935908b2
commit
995919644b
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="edu.uncc.scavenger"
|
package="edu.uncc.scavenger"
|
||||||
android:versionCode="1"
|
android:versionCode="1"
|
||||||
@ -6,8 +6,10 @@
|
|||||||
|
|
||||||
<uses-sdk
|
<uses-sdk
|
||||||
android:minSdkVersion="11"
|
android:minSdkVersion="11"
|
||||||
android:targetSdkVersion="19" />
|
android:targetSdkVersion="19" />
|
||||||
<uses-permission android:name="android.permission.INTERNET"/>
|
|
||||||
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
@ -23,6 +25,18 @@
|
|||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
<activity
|
||||||
|
android:name="edu.uncc.scavenger.SearchActivity"
|
||||||
|
android:label="@string/title_activity_search" >
|
||||||
|
</activity>
|
||||||
|
<activity
|
||||||
|
android:name="edu.uncc.scavenger.CompassActivity"
|
||||||
|
android:label="@string/title_activity_compass" >
|
||||||
|
</activity>
|
||||||
|
<activity
|
||||||
|
android:name="edu.uncc.scavenger.FoundActivity"
|
||||||
|
android:label="@string/title_activity_found" >
|
||||||
|
</activity>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
|
Binary file not shown.
@ -12,3 +12,4 @@
|
|||||||
|
|
||||||
# Project target.
|
# Project target.
|
||||||
target=android-19
|
target=android-19
|
||||||
|
android.library.reference.1=../../../workspace/appcompat_v7_9
|
||||||
|
BIN
UNCCScavenger/res/drawable-hdpi/arrow_up.png
Normal file
BIN
UNCCScavenger/res/drawable-hdpi/arrow_up.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
BIN
UNCCScavenger/res/drawable-hdpi/compass_rose_brosen.png
Normal file
BIN
UNCCScavenger/res/drawable-hdpi/compass_rose_brosen.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 62 KiB |
43
UNCCScavenger/res/layout/activity_compass.xml
Normal file
43
UNCCScavenger/res/layout/activity_compass.xml
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/container"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
tools:context="edu.uncc.scavenger.CompassActivity"
|
||||||
|
tools:ignore="MergeRootFrame" >
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1" >
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/compassRose"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:src="@drawable/compass_rose_brosen" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/arrowView"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:src="@drawable/arrow_up" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/backButton"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0"
|
||||||
|
android:text="@string/back_button_text" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
41
UNCCScavenger/res/layout/activity_found.xml
Normal file
41
UNCCScavenger/res/layout/activity_found.xml
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/container"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
tools:context="edu.uncc.scavenger.FoundActivity"
|
||||||
|
tools:ignore="MergeRootFrame" >
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/foundText"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:text="@string/found_text"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/numberFoundText"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:text="@string/default_text"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/seeMoreButton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:text="@string/see_more_text" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/tryMoreButton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:text="@string/try_more_button" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
61
UNCCScavenger/res/layout/activity_search.xml
Normal file
61
UNCCScavenger/res/layout/activity_search.xml
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/container"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
tools:context="edu.uncc.scavenger.SearchActivity"
|
||||||
|
tools:ignore="MergeRootFrame" >
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical" >
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/locationImage"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:src="@drawable/abc_ab_bottom_solid_dark_holo" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/riddleView"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:text="@string/default_text" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0"
|
||||||
|
android:orientation="vertical" >
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" >
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/compassButton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="@string/compass_button_text" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/scanButton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="@string/scan_button_text" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
12
UNCCScavenger/res/menu/compass.xml
Normal file
12
UNCCScavenger/res/menu/compass.xml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
tools:context="edu.uncc.scavenger.CompassActivity" >
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_settings"
|
||||||
|
android:orderInCategory="100"
|
||||||
|
android:title="@string/action_settings"
|
||||||
|
app:showAsAction="never"/>
|
||||||
|
|
||||||
|
</menu>
|
12
UNCCScavenger/res/menu/found.xml
Normal file
12
UNCCScavenger/res/menu/found.xml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
tools:context="edu.uncc.scavenger.FoundActivity" >
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_settings"
|
||||||
|
android:orderInCategory="100"
|
||||||
|
android:title="@string/action_settings"
|
||||||
|
app:showAsAction="never"/>
|
||||||
|
|
||||||
|
</menu>
|
12
UNCCScavenger/res/menu/search.xml
Normal file
12
UNCCScavenger/res/menu/search.xml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
tools:context="edu.uncc.scavenger.SearchActivity" >
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_settings"
|
||||||
|
android:orderInCategory="100"
|
||||||
|
android:title="@string/action_settings"
|
||||||
|
app:showAsAction="never"/>
|
||||||
|
|
||||||
|
</menu>
|
10
UNCCScavenger/res/values-w820dp/dimens.xml
Normal file
10
UNCCScavenger/res/values-w820dp/dimens.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<resources>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Example customization of dimensions originally defined in res/values/dimens.xml
|
||||||
|
(such as screen margins) for screens with more than 820dp of available width. This
|
||||||
|
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively).
|
||||||
|
-->
|
||||||
|
<dimen name="activity_horizontal_margin">64dp</dimen>
|
||||||
|
|
||||||
|
</resources>
|
@ -1,9 +1,19 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<string name="app_name">UNCC Scavenger</string>
|
<string name="app_name">UNCC Scavenger</string>
|
||||||
<string name="action_settings">Settings</string>
|
<string name="action_settings">Settings</string>
|
||||||
<string name="hello_world">Hello world!</string>
|
<string name="hello_world">Hello world!</string>
|
||||||
<string name="endpoint">http://djbushido.no-ip.org/</string>
|
<string name="endpoint">http://djbushido.no-ip.org/</string>
|
||||||
|
<string name="title_activity_search">SearchActivity</string>
|
||||||
|
<string name="title_activity_compass">CompassActivity</string>
|
||||||
|
<string name="title_activity_found">FoundActivity</string>
|
||||||
|
<string name="compass_button_text">Compass</string>
|
||||||
|
<string name="scan_button_text">Scan</string>
|
||||||
|
<string name="back_button_text">Back</string>
|
||||||
|
<string name="default_text">DEFAULT</string>
|
||||||
|
<string name="found_text">Location Found!</string>
|
||||||
|
<string name="see_more_text">More Location Information</string>
|
||||||
|
<string name="try_more_button">Try Another Location</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
161
UNCCScavenger/src/edu/uncc/scavenger/CompassActivity.java
Normal file
161
UNCCScavenger/src/edu/uncc/scavenger/CompassActivity.java
Normal file
@ -0,0 +1,161 @@
|
|||||||
|
package edu.uncc.scavenger;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Bradlee Speice, Brandon Rodenmayer
|
||||||
|
* ITIS 4180
|
||||||
|
* UNCCScavenger (NinerFinder)
|
||||||
|
* CompassActivity.java
|
||||||
|
*/
|
||||||
|
/* References:
|
||||||
|
* stackoverflow.com/questions/4308262/calculate-compass-bearing-heading-to-location-in-android
|
||||||
|
* stackoverflow.com/questions/5479753/using-orientation-sensor-to-point-towards-a-specific-location
|
||||||
|
*/
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.hardware.Sensor;
|
||||||
|
import android.hardware.SensorEvent;
|
||||||
|
import android.hardware.SensorEventListener;
|
||||||
|
import android.hardware.SensorManager;
|
||||||
|
import android.location.Location;
|
||||||
|
import android.location.LocationManager;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.View.OnClickListener;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
|
||||||
|
public class CompassActivity extends Activity implements SensorEventListener
|
||||||
|
{
|
||||||
|
ImageView compass, arrowView;
|
||||||
|
Button backButton;
|
||||||
|
SensorManager sManager;
|
||||||
|
Sensor aSensor, mSensor;
|
||||||
|
float[] compassValues = new float[3];
|
||||||
|
float[] rotation = new float[16];
|
||||||
|
float[] rotated = new float[16];
|
||||||
|
float[] inclination = new float[16];
|
||||||
|
float[] gravity = new float[3];
|
||||||
|
float[] magneticField = new float[3];
|
||||||
|
float[] coordinates = new float[3];
|
||||||
|
LocationManager locationManager;
|
||||||
|
DirectionListener locationListener;
|
||||||
|
Location searchLocation;
|
||||||
|
Location testLocation = new Location(LocationManager.NETWORK_PROVIDER);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_compass);
|
||||||
|
|
||||||
|
arrowView = (ImageView)findViewById(R.id.arrowView);
|
||||||
|
compass = (ImageView)findViewById(R.id.compassRose);
|
||||||
|
|
||||||
|
/*Test Values
|
||||||
|
testLocation.setLatitude(35.30719258);//woodward eagle
|
||||||
|
testLocation.setLongitude(-80.73505447);
|
||||||
|
testLocation.setLatitude(35.310043);//Bottom of Student Union bridge
|
||||||
|
testLocation.setLongitude(-80.733734);*/
|
||||||
|
|
||||||
|
searchLocation = new Location(LocationManager.NETWORK_PROVIDER);
|
||||||
|
searchLocation.setLatitude(getIntent().getDoubleExtra("searchLat", 0));
|
||||||
|
searchLocation.setLongitude(getIntent().getDoubleExtra("searchLong", 0));
|
||||||
|
|
||||||
|
locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
|
||||||
|
locationListener = new DirectionListener(searchLocation);
|
||||||
|
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 5000, 10, locationListener);
|
||||||
|
|
||||||
|
sManager = (SensorManager)getSystemService(Context.SENSOR_SERVICE);
|
||||||
|
aSensor = sManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
|
||||||
|
mSensor = sManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);
|
||||||
|
|
||||||
|
backButton = (Button)findViewById(R.id.backButton);
|
||||||
|
backButton.setOnClickListener(new OnClickListener(){
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onResume()
|
||||||
|
{
|
||||||
|
super.onResume();
|
||||||
|
sManager.registerListener(this, aSensor, SensorManager.SENSOR_DELAY_GAME);
|
||||||
|
sManager.registerListener(this, mSensor, SensorManager.SENSOR_DELAY_GAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPause()
|
||||||
|
{
|
||||||
|
super.onPause();
|
||||||
|
sManager.unregisterListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
|
||||||
|
// Inflate the menu; this adds items to the action bar if it is present.
|
||||||
|
getMenuInflater().inflate(R.menu.main, menu);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
// Handle action bar item clicks here. The action bar will
|
||||||
|
// automatically handle clicks on the Home/Up button, so long
|
||||||
|
// as you specify a parent activity in AndroidManifest.xml.
|
||||||
|
int id = item.getItemId();
|
||||||
|
if (id == R.id.action_settings) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSensorChanged(SensorEvent event)
|
||||||
|
{
|
||||||
|
//Check sensor that changed
|
||||||
|
int type = event.sensor.getType();
|
||||||
|
if(type == Sensor.TYPE_ACCELEROMETER)
|
||||||
|
{
|
||||||
|
gravity = event.values;
|
||||||
|
}
|
||||||
|
else if(type == Sensor.TYPE_MAGNETIC_FIELD)
|
||||||
|
{
|
||||||
|
magneticField = event.values;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Compute compass orientation values
|
||||||
|
SensorManager.getInclination(inclination);
|
||||||
|
SensorManager.getRotationMatrix(rotation, inclination, gravity, magneticField);
|
||||||
|
SensorManager.getOrientation(rotation, compassValues);
|
||||||
|
|
||||||
|
//Calculate true north and angle to desired location
|
||||||
|
//float azimuth = (float) (Math.toDegrees(compassValues[0]));
|
||||||
|
float trueHeading = (float)(Math.toDegrees(compassValues[0]) + locationListener.getDeclination());
|
||||||
|
//Calculate bearing to search location
|
||||||
|
float rotateArrow = (float) (trueHeading - locationListener.getBearing());
|
||||||
|
|
||||||
|
//Rotate compass and arrow. Rotations must be opposite to counteract device movement
|
||||||
|
compass.setRotation((long)(-1 * trueHeading));
|
||||||
|
arrowView.setRotation((long)(-1 * rotateArrow));
|
||||||
|
|
||||||
|
//TODO
|
||||||
|
//If within 5 to 10 meters, display image of search
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAccuracyChanged(Sensor sensor, int accuracy) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
82
UNCCScavenger/src/edu/uncc/scavenger/DirectionListener.java
Normal file
82
UNCCScavenger/src/edu/uncc/scavenger/DirectionListener.java
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
package edu.uncc.scavenger;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Bradlee Speice, Brandon Rodenmayer
|
||||||
|
* ITIS 4180
|
||||||
|
* UNCCScavenger (NinerFinder)
|
||||||
|
* DirectionListener.java
|
||||||
|
*/
|
||||||
|
|
||||||
|
import android.hardware.GeomagneticField;
|
||||||
|
import android.location.Location;
|
||||||
|
import android.location.LocationListener;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
public class DirectionListener implements LocationListener
|
||||||
|
{
|
||||||
|
GeomagneticField geoField;
|
||||||
|
Location toGo;
|
||||||
|
float bearing;
|
||||||
|
float distance;
|
||||||
|
|
||||||
|
public DirectionListener(Location toGo)
|
||||||
|
{
|
||||||
|
this.toGo = toGo;
|
||||||
|
this.bearing = 0;
|
||||||
|
this.distance = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLocationChanged(Location location)
|
||||||
|
{
|
||||||
|
//String lat = ""+location.getLatitude();
|
||||||
|
//String lon = ""+location.getLongitude();
|
||||||
|
|
||||||
|
geoField = new GeomagneticField(
|
||||||
|
(float)location.getLatitude(),
|
||||||
|
(float)location.getLongitude(),
|
||||||
|
(float)location.getAltitude(),
|
||||||
|
System.currentTimeMillis()
|
||||||
|
);
|
||||||
|
|
||||||
|
bearing = location.bearingTo(toGo);
|
||||||
|
distance = location.distanceTo(toGo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStatusChanged(String provider, int status, Bundle extras) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onProviderEnabled(String provider) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onProviderDisabled(String provider) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getBearing()
|
||||||
|
{
|
||||||
|
return bearing;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getDeclination()
|
||||||
|
{
|
||||||
|
if(geoField!=null)
|
||||||
|
return geoField.getDeclination();
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getDistance()
|
||||||
|
{
|
||||||
|
return distance;
|
||||||
|
}
|
||||||
|
}
|
78
UNCCScavenger/src/edu/uncc/scavenger/FoundActivity.java
Normal file
78
UNCCScavenger/src/edu/uncc/scavenger/FoundActivity.java
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
package edu.uncc.scavenger;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Bradlee Speice, Brandon Rodenmayer
|
||||||
|
* ITIS 4180
|
||||||
|
* UNCCScavenger (NinerFinder)
|
||||||
|
* FoundActivity.java
|
||||||
|
*/
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.View.OnClickListener;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
public class FoundActivity extends Activity {
|
||||||
|
|
||||||
|
TextView numberFoundText;
|
||||||
|
Button seeMoreButton, tryMoreButton;
|
||||||
|
Intent intent;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_found);
|
||||||
|
|
||||||
|
numberFoundText = (TextView)findViewById(R.id.numberFoundText);
|
||||||
|
seeMoreButton = (Button)findViewById(R.id.seeMoreButton);
|
||||||
|
tryMoreButton = (Button)findViewById(R.id.tryMoreButton);
|
||||||
|
|
||||||
|
seeMoreButton.setOnClickListener(new OnClickListener(){
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
//TODO
|
||||||
|
//Get more information address and open web browser
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
tryMoreButton.setOnClickListener(new OnClickListener(){
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
intent = new Intent(getApplicationContext(), MainActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//TODO
|
||||||
|
//Add found location to database
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
|
||||||
|
// Inflate the menu; this adds items to the action bar if it is present.
|
||||||
|
getMenuInflater().inflate(R.menu.found, menu);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
// Handle action bar item clicks here. The action bar will
|
||||||
|
// automatically handle clicks on the Home/Up button, so long
|
||||||
|
// as you specify a parent activity in AndroidManifest.xml.
|
||||||
|
int id = item.getItemId();
|
||||||
|
if (id == R.id.action_settings) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
|
}
|
@ -1,12 +1,22 @@
|
|||||||
package edu.uncc.scavenger;
|
package edu.uncc.scavenger;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Bradlee Speice, Brandon Rodenmayer
|
||||||
|
* ITIS 4180
|
||||||
|
* UNCCScavenger (NinerFinder)
|
||||||
|
* MainActivity.java
|
||||||
|
*/
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.AdapterView;
|
||||||
|
import android.widget.AdapterView.OnItemClickListener;
|
||||||
import android.widget.BaseAdapter;
|
import android.widget.BaseAdapter;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
@ -18,18 +28,43 @@ import edu.uncc.scavenger.rest.RestLocation;
|
|||||||
public class MainActivity extends Activity {
|
public class MainActivity extends Activity {
|
||||||
|
|
||||||
ListView locationList;
|
ListView locationList;
|
||||||
|
List<RestLocation> locations;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
|
|
||||||
|
/*Test Code
|
||||||
|
RestLocation location = new RestLocation();
|
||||||
|
location.setId(1);
|
||||||
|
location.setName("Bridge");
|
||||||
|
location.setRiddle("Riddle");
|
||||||
|
location.setLocationLong(-80.733734);
|
||||||
|
location.setLocationLat(35.310043);
|
||||||
|
location.setKey("Key");
|
||||||
|
Intent intent = new Intent(getApplicationContext(), SearchActivity.class);
|
||||||
|
intent.putExtra("restLocation", location);
|
||||||
|
startActivity(intent);
|
||||||
|
finish();
|
||||||
|
/*End Test Code*/
|
||||||
|
|
||||||
// Get our list of events loaded
|
// Get our list of events loaded
|
||||||
locationList = (ListView)findViewById(R.id.listLocations);
|
locationList = (ListView)findViewById(R.id.listLocations);
|
||||||
List<RestLocation> locations = LocationDatabaseHelper.getInstance(this).fetchAll();
|
locations = LocationDatabaseHelper.getInstance(this).fetchAll();
|
||||||
if (locations != null && locations.size() > 0) {
|
if (locations != null && locations.size() > 0) {
|
||||||
LocationAdapter mLocationAdapter = new LocationAdapter(locations);
|
LocationAdapter mLocationAdapter = new LocationAdapter(locations);
|
||||||
locationList.setAdapter(mLocationAdapter);
|
locationList.setAdapter(mLocationAdapter);
|
||||||
|
locationList.setOnItemClickListener(new OnItemClickListener(){
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onItemClick(AdapterView<?> parent, View view,
|
||||||
|
int position, long id) {
|
||||||
|
Intent intent = new Intent(getApplicationContext(), SearchActivity.class);
|
||||||
|
intent.putExtra("restLocation", locations.get(position));
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
// We don't yet have any locations...
|
// We don't yet have any locations...
|
||||||
((TextView)findViewById(R.id.txtNoLocations)).setVisibility(View.VISIBLE);
|
((TextView)findViewById(R.id.txtNoLocations)).setVisibility(View.VISIBLE);
|
||||||
@ -54,6 +89,7 @@ public class MainActivity extends Activity {
|
|||||||
LocationDatabaseHelper.getInstance(MainActivity.this).persistAll(result);
|
LocationDatabaseHelper.getInstance(MainActivity.this).persistAll(result);
|
||||||
}
|
}
|
||||||
}.execute();
|
}.execute();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
126
UNCCScavenger/src/edu/uncc/scavenger/SearchActivity.java
Normal file
126
UNCCScavenger/src/edu/uncc/scavenger/SearchActivity.java
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
package edu.uncc.scavenger;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Bradlee Speice, Brandon Rodenmayer
|
||||||
|
* ITIS 4180
|
||||||
|
* UNCCScavenger (NinerFinder)
|
||||||
|
* SearchActivity.java
|
||||||
|
*/
|
||||||
|
|
||||||
|
import edu.uncc.scavenger.rest.RestLocation;
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.ActivityNotFoundException;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.View.OnClickListener;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
public class SearchActivity extends Activity {
|
||||||
|
|
||||||
|
ImageView locationImage;
|
||||||
|
Button compassButton, scanButton;
|
||||||
|
TextView riddleView;
|
||||||
|
Intent intent;
|
||||||
|
RestLocation restLocation;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_search);
|
||||||
|
|
||||||
|
locationImage = (ImageView)findViewById(R.id.locationImage);
|
||||||
|
compassButton = (Button)findViewById(R.id.compassButton);
|
||||||
|
scanButton = (Button)findViewById(R.id.scanButton);
|
||||||
|
riddleView = (TextView)findViewById(R.id.riddleView);
|
||||||
|
|
||||||
|
//TODO
|
||||||
|
//Load picture
|
||||||
|
//Load riddle
|
||||||
|
//Load hints
|
||||||
|
|
||||||
|
scanButton.setOnClickListener(new OnClickListener(){
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
try{
|
||||||
|
intent = new Intent("com.google.zxing.client.android.SCAN");
|
||||||
|
intent.putExtra("SCAN_MODE", "SCAN_MODE");
|
||||||
|
intent.putExtra("SAVE_HISTORY", false);
|
||||||
|
startActivityForResult(intent, 0);
|
||||||
|
}
|
||||||
|
catch(ActivityNotFoundException e){
|
||||||
|
//Does not work on an emulator because there is no access to the market
|
||||||
|
Uri marketUri = Uri.parse("market://details?id=com.google.zxing.client.android");
|
||||||
|
Intent marketIntent = new Intent(Intent.ACTION_VIEW, marketUri);
|
||||||
|
startActivity(marketIntent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
compassButton.setOnClickListener(new OnClickListener(){
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
intent = new Intent(getApplicationContext(), CompassActivity.class);
|
||||||
|
intent.putExtra("searchLat", restLocation.getLocationLat());
|
||||||
|
intent.putExtra("searchLong", restLocation.getLocationLong());
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
restLocation = (RestLocation)(getIntent().getSerializableExtra("restLocation"));
|
||||||
|
Log.d("restLocation", restLocation.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
|
||||||
|
// Inflate the menu; this adds items to the action bar if it is present.
|
||||||
|
getMenuInflater().inflate(R.menu.search, menu);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
// Handle action bar item clicks here. The action bar will
|
||||||
|
// automatically handle clicks on the Home/Up button, so long
|
||||||
|
// as you specify a parent activity in AndroidManifest.xml.
|
||||||
|
int id = item.getItemId();
|
||||||
|
if (id == R.id.action_settings) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
if (requestCode == 0) {
|
||||||
|
if (resultCode == RESULT_OK)
|
||||||
|
{
|
||||||
|
String contents = data.getStringExtra("SCAN_RESULT");
|
||||||
|
if(contents.equals(restLocation.getName()))
|
||||||
|
{
|
||||||
|
intent = new Intent(getApplicationContext(), FoundActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Toast.makeText(getApplicationContext(), "Incorrect url found: "+contents, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (resultCode == RESULT_CANCELED)
|
||||||
|
{
|
||||||
|
Toast.makeText(getApplicationContext(), "Error scanning code", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,12 @@
|
|||||||
package edu.uncc.scavenger.database;
|
package edu.uncc.scavenger.database;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Bradlee Speice, Brandon Rodenmayer
|
||||||
|
* ITIS 4180
|
||||||
|
* UNCCScavenger (NinerFinder)
|
||||||
|
* LocationDatabaseHelper.java
|
||||||
|
*/
|
||||||
|
|
||||||
// Design pattern from: http://www.androiddesignpatterns.com/2012/05/correctly-managing-your-sqlite-database.html
|
// Design pattern from: http://www.androiddesignpatterns.com/2012/05/correctly-managing-your-sqlite-database.html
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
package edu.uncc.scavenger.rest;
|
package edu.uncc.scavenger.rest;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Bradlee Speice, Brandon Rodenmayer
|
||||||
|
* ITIS 4180
|
||||||
|
* UNCCScavenger (NinerFinder)
|
||||||
|
* LocationClient.java
|
||||||
|
*/
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
package edu.uncc.scavenger.rest;
|
package edu.uncc.scavenger.rest;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Bradlee Speice, Brandon Rodenmayer
|
||||||
|
* ITIS 4180
|
||||||
|
* UNCCScavenger (NinerFinder)
|
||||||
|
* LocationService.java
|
||||||
|
*/
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -1,8 +1,17 @@
|
|||||||
package edu.uncc.scavenger.rest;
|
package edu.uncc.scavenger.rest;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Bradlee Speice, Brandon Rodenmayer
|
||||||
|
* ITIS 4180
|
||||||
|
* UNCCScavenger (NinerFinder)
|
||||||
|
* RestLocation.java
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
import android.location.Location;
|
import android.location.Location;
|
||||||
|
|
||||||
public class RestLocation {
|
public class RestLocation implements Serializable{
|
||||||
|
|
||||||
private int id;
|
private int id;
|
||||||
private String name;
|
private String name;
|
||||||
|
Loading…
Reference in New Issue
Block a user