diff --git a/phoneClients/android/.idea/workspace.xml b/phoneClients/android/.idea/workspace.xml index 1721efe..5f992c9 100644 --- a/phoneClients/android/.idea/workspace.xml +++ b/phoneClients/android/.idea/workspace.xml @@ -39,7 +39,12 @@ - + + + + + + - @@ -583,6 +609,8 @@ + + @@ -659,6 +687,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -669,8 +783,6 @@ - - @@ -685,7 +797,7 @@ - + @@ -722,6 +834,19 @@ - - + + + @@ -889,20 +1002,19 @@ - + - + - @@ -911,15 +1023,15 @@ - - - + + + - + @@ -932,8 +1044,8 @@ - + @@ -957,6 +1069,103 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -991,14 +1200,14 @@ - - - + + + @@ -1022,14 +1231,14 @@ - - - + + + @@ -1046,14 +1255,14 @@ - - - + + + @@ -1070,14 +1279,14 @@ - - - + + + @@ -1101,20 +1310,13 @@ - - - - - - - - - + + @@ -1125,14 +1327,14 @@ - - - + + + @@ -1163,16 +1365,6 @@ - - - - - - - - - - @@ -1182,21 +1374,36 @@ - - - + - + + + + + + + + + + + + + + + + + + - + diff --git a/phoneClients/android/GpsTracker/src/main/java/com/websmithing/gpstracker/GpsTrackerActivity.java b/phoneClients/android/GpsTracker/src/main/java/com/websmithing/gpstracker/GpsTrackerActivity.java index 37a68dc..03d0f58 100644 --- a/phoneClients/android/GpsTracker/src/main/java/com/websmithing/gpstracker/GpsTrackerActivity.java +++ b/phoneClients/android/GpsTracker/src/main/java/com/websmithing/gpstracker/GpsTrackerActivity.java @@ -39,22 +39,24 @@ private static TextView accuracyTextView; private static TextView providerTextView; private static TextView timeStampTextView; + private static TextView sessionIDTextView; private LocationRequest locationRequest; private LocationClient locationClient; private Location previousLocation; private float totalDistanceInMeters = 0.0f; private boolean firstTimeGettingPosition = true; + private boolean currentlyTracking = false; private String sessionID; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.activity_gpstracker); + setContentView(android.R.layout.activity_gpstracker); if (savedInstanceState == null) { getSupportFragmentManager().beginTransaction() - .add(R.id.container, new PlaceholderFragment()) + .add(android.R.id.container, new PlaceholderFragment()) .commit(); } @@ -68,11 +70,23 @@ } } - // called when startTrackingButton is tapped - public void startTracking(View v) { + // called when trackingButton is tapped + public void startOrStopTracking(View v) { + if (currentlyTracking) { + stopTracking(); + currentlyTracking = false; + } else { + startTracking(); + currentlyTracking = true; + } + } + + public void startTracking() { + Log.e(TAG, "startTracking"); ((Button) v).setText("stop tracking"); sessionID = UUID.randomUUID().toString(); + sessionIDTextView.setText("sessionID: " + sessionID); totalDistanceInMeters = 0.0f; locationRequest = LocationRequest.create(); @@ -80,8 +94,13 @@ locationRequest.setFastestInterval(60 * 1000); // the fastest rate in milliseconds at which your app can handle location updates locationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY); locationClient.requestLocationUpdates(locationRequest, this); + } - //oneTimeLocationUpdate(); + public void stopTracking() { + Log.e(TAG, "stopTracking"); + ((Button) v).setText("start tracking"); + + sessionIDTextView.setText("sessionID:"); } protected void changeInterval(int intervalInMinutes) { @@ -174,11 +193,6 @@ Log.e(TAG, dateFormat.format(date) + " accuracy: " + location.getAccuracy()); } - public void stopTracking(View v) { - Log.e(TAG, "stopTracking"); - ((Button) v).setText("start tracking"); - } - @Override protected void onStart() { Log.e(TAG, "onStart"); @@ -228,7 +242,7 @@ @Override public boolean onCreateOptionsMenu(Menu menu) { - getMenuInflater().inflate(R.menu.gps_tracker, menu); + getMenuInflater().inflate(android.R.menu.gps_tracker, menu); return true; } @@ -238,7 +252,7 @@ // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. switch (item.getItemId()) { - case R.id.action_settings: + case android.R.id.action_settings: return true; } return super.onOptionsItemSelected(item); @@ -252,12 +266,13 @@ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View rootView = inflater.inflate(R.layout.fragment_gpstracker, container, false); - longitudeTextView = (TextView)rootView.findViewById(R.id.longitudeTextView); - latitudeTextView = (TextView)rootView.findViewById(R.id.latitudeTextView); - accuracyTextView = (TextView)rootView.findViewById(R.id.accuracyTextView); - providerTextView = (TextView)rootView.findViewById(R.id.providerTextView); - timeStampTextView = (TextView)rootView.findViewById(R.id.timeStampTextView); + View rootView = inflater.inflate(android.R.layout.fragment_gpstracker, container, false); + longitudeTextView = (TextView)rootView.findViewById(android.R.id.longitudeTextView); + latitudeTextView = (TextView)rootView.findViewById(android.R.id.latitudeTextView); + accuracyTextView = (TextView)rootView.findViewById(android.R.id.accuracyTextView); + providerTextView = (TextView)rootView.findViewById(android.R.id.providerTextView); + timeStampTextView = (TextView)rootView.findViewById(android.R.id.timeStampTextView); + sessionIDTextView = (TextView)rootView.findViewById(android.R.id.sessionIDTextView); return rootView; } } diff --git a/phoneClients/android/GpsTracker/src/main/res/layout/fragment_gpstracker.xml b/phoneClients/android/GpsTracker/src/main/res/layout/fragment_gpstracker.xml index b8cd5d7..ec2d99d 100644 --- a/phoneClients/android/GpsTracker/src/main/res/layout/fragment_gpstracker.xml +++ b/phoneClients/android/GpsTracker/src/main/res/layout/fragment_gpstracker.xml @@ -51,13 +51,22 @@ android:layout_marginBottom="5dp" android:text="@string/timeStamp" /> -