diff --git a/phoneClients/android/.idea/workspace.xml b/phoneClients/android/.idea/workspace.xml index f0b7cd4..8e04130 100644 --- a/phoneClients/android/.idea/workspace.xml +++ b/phoneClients/android/.idea/workspace.xml @@ -41,21 +41,9 @@ - - - - - - - - - - - - - + @@ -123,19 +111,12 @@ - - - - - - - - - - - - - + + + + + + @@ -143,8 +124,18 @@ - - + + + + + + + + + + + + @@ -956,16 +947,17 @@ - @@ -1195,7 +1187,7 @@ - + @@ -1204,9 +1196,9 @@ - + @@ -1435,7 +1427,7 @@ - + @@ -1451,7 +1443,7 @@ - + @@ -1531,7 +1523,10 @@ - + + + + @@ -1546,7 +1541,10 @@ - + + + + @@ -1554,7 +1552,10 @@ - + + + + @@ -1569,7 +1570,10 @@ - + + + + @@ -1591,7 +1595,10 @@ - + + + + @@ -1645,7 +1652,10 @@ - + + + + @@ -1661,7 +1671,10 @@ - + + + + @@ -1677,7 +1690,10 @@ - + + + + @@ -1693,7 +1709,10 @@ - + + + + @@ -1822,13 +1841,6 @@ - - - - - - - @@ -1861,14 +1873,6 @@ - - - - - - - - @@ -1883,27 +1887,46 @@ - + - - + + - - + + + + + + + + + + + + + + + + + + - - - + + + + + + diff --git a/phoneClients/android/app/src/main/java/com/websmithing/gpstracker/GpsTrackerActivity.java b/phoneClients/android/app/src/main/java/com/websmithing/gpstracker/GpsTrackerActivity.java index e9b0e58..389d923 100644 --- a/phoneClients/android/app/src/main/java/com/websmithing/gpstracker/GpsTrackerActivity.java +++ b/phoneClients/android/app/src/main/java/com/websmithing/gpstracker/GpsTrackerActivity.java @@ -237,7 +237,7 @@ @Override public void onFailure(int statusCode, org.apache.http.Header[] headers, byte[] errorResponse, Throwable e) { Toast.makeText(getApplicationContext(), R.string.reachability_error, Toast.LENGTH_LONG).show(); - Log.e(TAG, "checkIfWebsiteIsReachable onFailure statusCode: " + statusCode); + LoopjHttpClient.debugLoopJ(TAG, "checkIfWebsiteIsReachable", errorResponse, headers, statusCode, e); } }); } diff --git a/phoneClients/android/app/src/main/java/com/websmithing/gpstracker/LocationService.java b/phoneClients/android/app/src/main/java/com/websmithing/gpstracker/LocationService.java index 38cbecd..d51bd32 100644 --- a/phoneClients/android/app/src/main/java/com/websmithing/gpstracker/LocationService.java +++ b/phoneClients/android/app/src/main/java/com/websmithing/gpstracker/LocationService.java @@ -105,7 +105,9 @@ RequestParams requestParams = new RequestParams(); requestParams.put("latitude", Double.toString(location.getLatitude())); requestParams.put("longitude", Double.toString(location.getLongitude())); - requestParams.put("speed", Double.toString(location.getSpeed())); // in miles per hour + + Double speedInMilesPerHour = location.getSpeed()* 2.2369; + requestParams.put("speed", Integer.toString(speedInMilesPerHour.intValue())); try { requestParams.put("date", URLEncoder.encode(dateFormat.format(date), "UTF-8")); @@ -122,10 +124,17 @@ // phoneNumber is just an identifying string in the database, can be any identifier. requestParams.put("phonenumber", sharedPreferences.getString("userName", "")); requestParams.put("sessionid", sharedPreferences.getString("sessionID", "")); // uuid - requestParams.put("accuracy", Float.toString(location.getAccuracy())); // in meters - requestParams.put("extrainfo", Double.toString(location.getAltitude())); + + Double accuracyInFeet = location.getAccuracy()* 3.28; + requestParams.put("accuracy", Integer.toString(accuracyInFeet.intValue())); + + Double altitudeInFeet = location.getAltitude() * 3.28; + requestParams.put("extrainfo", Integer.toString(altitudeInFeet.intValue())); + requestParams.put("eventtype", "android"); - requestParams.put("direction", Float.toString(location.getBearing())); + + Float direction = location.getBearing(); + requestParams.put("direction", Integer.toString(direction.intValue())); LoopjHttpClient.post(sharedPreferences.getString("defaultUploadWebsite", defaultUploadWebsite), requestParams, new AsyncHttpResponseHandler() { @Override @@ -135,7 +144,7 @@ } @Override public void onFailure(int statusCode, org.apache.http.Header[] headers, byte[] errorResponse, Throwable e) { - Log.e(TAG, "sendLocationDataToWebsite onFailure statusCode: " + statusCode); + LoopjHttpClient.debugLoopJ(TAG, "sendLocationDataToWebsite", errorResponse, headers, statusCode, e); stopSelf(); } }); diff --git a/phoneClients/android/app/src/main/java/com/websmithing/gpstracker/LoopjHttpClient.java b/phoneClients/android/app/src/main/java/com/websmithing/gpstracker/LoopjHttpClient.java index 021472a..4baa1e1 100644 --- a/phoneClients/android/app/src/main/java/com/websmithing/gpstracker/LoopjHttpClient.java +++ b/phoneClients/android/app/src/main/java/com/websmithing/gpstracker/LoopjHttpClient.java @@ -1,9 +1,15 @@ package com.websmithing.gpstracker; +import android.util.Log; + import com.loopj.android.http.AsyncHttpClient; import com.loopj.android.http.AsyncHttpResponseHandler; import com.loopj.android.http.RequestParams; +import org.apache.http.Header; + +import java.util.Locale; + public class LoopjHttpClient { private static AsyncHttpClient client = new AsyncHttpClient(); @@ -14,4 +20,27 @@ public static void post(String url, RequestParams requestParams, AsyncHttpResponseHandler responseHandler) { client.post(url, requestParams, responseHandler); } + + public static void debugLoopJ(String TAG, String methodName, byte[] response, Header[] headers, int statusCode, Throwable t) { + if (headers != null) { + Log.e(TAG, methodName) + ; + Log.e(TAG, "Return Headers:"); + for (Header h : headers) { + String _h = String.format(Locale.US, "%s : %s", h.getName(), h.getValue()); + Log.e(TAG, _h); + } + + if (t != null) { + Log.e(TAG, "Throwable:" + t); + } + + Log.e(TAG, "StatusCode: " + statusCode); + + if (response != null) { + Log.e(TAG, "Resposne: " + new String(response)); + } + + } + } } diff --git a/phoneClients/android/app/src/main/res/values/strings.xml b/phoneClients/android/app/src/main/res/values/strings.xml index 8e15155..6671915 100644 --- a/phoneClients/android/app/src/main/res/values/strings.xml +++ b/phoneClients/android/app/src/main/res/values/strings.xml @@ -2,7 +2,6 @@ Gps Tracker https://www.websmithing.com/gpstracker2/updatelocation.php - Tracking is Off Tracking is On Tracking has now started.