commit 12b994e57f8f934dea7d9374269328bb171340ef Author: Paul Walko Date: Tue Jun 2 09:26:12 2015 -0400 init commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9c4de58 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +.gradle +/local.properties +/.idea/workspace.xml +/.idea/libraries +.DS_Store +/build +/captures diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..bfcd305 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +WaypointLogger \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..96cc43e --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml new file mode 100644 index 0000000..e7bedf3 --- /dev/null +++ b/.idea/copyright/profiles_settings.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..8d2df47 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..e4a5fa4 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..4431553 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/WaypointLogger.iml b/WaypointLogger.iml new file mode 100644 index 0000000..0c895cf --- /dev/null +++ b/WaypointLogger.iml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/app.iml b/app/app.iml new file mode 100644 index 0000000..73f98e7 --- /dev/null +++ b/app/app.iml @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..850b847 --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,25 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 22 + buildToolsVersion "22.0.1" + + defaultConfig { + applicationId "walko.paul.waypointlogger" + minSdkVersion 15 + targetSdkVersion 22 + versionCode 1 + versionName "1.0" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) + compile 'com.android.support:appcompat-v7:22.2.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..26619de --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in /home/paul/Android/Sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/app/src/androidTest/java/walko/paul/waypointlogger/ApplicationTest.java b/app/src/androidTest/java/walko/paul/waypointlogger/ApplicationTest.java new file mode 100644 index 0000000..13d48cc --- /dev/null +++ b/app/src/androidTest/java/walko/paul/waypointlogger/ApplicationTest.java @@ -0,0 +1,13 @@ +package walko.paul.waypointlogger; + +import android.app.Application; +import android.test.ApplicationTestCase; + +/** + * Testing Fundamentals + */ +public class ApplicationTest extends ApplicationTestCase { + public ApplicationTest() { + super(Application.class); + } +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..2d7204f --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + diff --git a/app/src/main/java/walko/paul/waypointlogger/ShowLocationActivity.java b/app/src/main/java/walko/paul/waypointlogger/ShowLocationActivity.java new file mode 100644 index 0000000..d80656f --- /dev/null +++ b/app/src/main/java/walko/paul/waypointlogger/ShowLocationActivity.java @@ -0,0 +1,147 @@ +package walko.paul.waypointlogger; + +import android.app.Activity; +import android.content.Context; +import android.location.Criteria; +import android.location.Location; +import android.location.LocationListener; +import android.location.LocationManager; +import android.os.Bundle; +import android.widget.TextView; +import android.widget.Toast; +import android.widget.Button; +import android.view.View; +import android.os.Environment; +import java.io.FileWriter; +import java.io.IOException; +import java.io.BufferedWriter; +import android.widget.EditText; + + +public class ShowLocationActivity extends Activity implements LocationListener { + private TextView latituteField; + private TextView longitudeField; + private LocationManager locationManager; + private String provider; + public static final String LOG_TAG = "myLogs"; + double lat = 0; + double lon = 0; + EditText label; + + + /** Called when the activity is first created. */ + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_show_location); + latituteField = (TextView) findViewById(R.id.TextView02); + longitudeField = (TextView) findViewById(R.id.TextView04); + label = (EditText)findViewById(R.id.label); + final Button button = (Button) findViewById(R.id.Button); + final Button refresh = (Button) findViewById(R.id.refresh); + updateLocation(); + + refresh.setOnClickListener(new View.OnClickListener(){ + public void onClick(View v){ + updateLocation(); + } + }); + + + + button.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + // Perform action on click + BufferedWriter output; + if (isExternalStorageWritable()) { + FileWriter f; + try { + output = new BufferedWriter(new FileWriter(Environment.getExternalStorageDirectory() + "/waypoints.csv", true)); + String st = "\""; + output.append(label.getText().toString() + "," + st + lat + "," + lon + st); + output.newLine(); + output.close(); + + /*f = new FileWriter(Environment.getExternalStorageDirectory() + "/waypoints" + ".csv", true); + f.write(lat + ",," + lon); + f.flush(); + f.close();*/ + } catch (IOException e) { + e.printStackTrace(); + } + } + } + }); + } + + public void updateLocation(){ + // Get the location manager + locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); + // Define the criteria how to select the locatioin provider -> use + // default + Criteria criteria = new Criteria(); + provider = locationManager.getBestProvider(criteria, false); + Location location = locationManager.getLastKnownLocation(provider); + + // Initialize the location fields + if (location != null) { + System.out.println("Provider " + provider + " has been selected."); + onLocationChanged(location); + } else { + latituteField.setText("Location not available"); + longitudeField.setText("Location not available"); + } + } + + public boolean isExternalStorageWritable() { + String state = Environment.getExternalStorageState(); + if (Environment.MEDIA_MOUNTED.equals(state)) { + return true; + } + return false; + + } + + /* Request updates at startup */ + @Override + protected void onResume() { + super.onResume(); + locationManager.requestLocationUpdates(provider, 400, 1, this); + } + + /* Remove the locationlistener updates when Activity is paused */ + @Override + protected void onPause() { + super.onPause(); + locationManager.removeUpdates(this); + } + + @Override + public void onLocationChanged(Location location) { + lat = location.getLatitude(); + lon = location.getLongitude(); + latituteField.setText(String.valueOf(lat)); + longitudeField.setText(String.valueOf(lon)); + } + + @Override + public void onStatusChanged(String provider, int status, Bundle extras) { + // TODO Auto-generated method stub + + } + + @Override + public void onProviderEnabled(String provider) { + Toast.makeText(this, "Enabled new provider " + provider, + Toast.LENGTH_SHORT).show(); + + } + + @Override + public void onProviderDisabled(String provider) { + Toast.makeText(this, "Disabled provider " + provider, + Toast.LENGTH_SHORT).show(); + } +} + diff --git a/app/src/main/res/layout/activity_show_location.xml b/app/src/main/res/layout/activity_show_location.xml new file mode 100644 index 0000000..fd75b9d --- /dev/null +++ b/app/src/main/res/layout/activity_show_location.xml @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +