diff --git a/phoneClients/android/.idea/workspace.xml b/phoneClients/android/.idea/workspace.xml
index 5c3e91c..53e0424 100644
--- a/phoneClients/android/.idea/workspace.xml
+++ b/phoneClients/android/.idea/workspace.xml
@@ -41,12 +41,9 @@
-
-
-
+
-
@@ -109,32 +106,36 @@
-
+
-
-
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
+
+
@@ -145,6 +146,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -923,17 +947,18 @@
-
+
+
-
+
-
+
@@ -1118,6 +1143,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1350,7 +1405,7 @@
-
+
@@ -1366,14 +1421,14 @@
-
+
-
+
@@ -1439,16 +1494,20 @@
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1509,16 +1568,20 @@
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1536,16 +1599,20 @@
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1563,16 +1630,20 @@
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1590,16 +1661,20 @@
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1744,14 +1819,6 @@
-
-
-
-
-
-
-
-
@@ -1768,37 +1835,10 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -1808,6 +1848,48 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
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 b25d9b4..4985ab7 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
@@ -52,21 +52,61 @@
txtWebsite = (EditText)findViewById(R.id.txtWebsite);
txtUserName = (EditText)findViewById(R.id.txtUserName);
+ intervalRadioGroup = (RadioGroup)findViewById(R.id.intervalRadioGroup);
trackingButton = (Button)findViewById(R.id.trackingButton);
txtUserName.setImeOptions(EditorInfo.IME_ACTION_DONE);
SharedPreferences sharedPreferences = this.getSharedPreferences("com.websmithing.gpstracker.prefs", Context.MODE_PRIVATE);
currentlyTracking = sharedPreferences.getBoolean("currentlyTracking", false);
+ intervalRadioGroup.setOnCheckedChangeListener(
+ new RadioGroup.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(RadioGroup radioGroup, int i) {
+ saveInterval();
+ }
+ });
+
trackingButton.setOnClickListener(new View.OnClickListener() {
- public void onClick(View v) {
- trackLocation(v);
+ public void onClick(View view) {
+ trackLocation(view);
}
});
}
- private void startAlarmManager(Context context) {
+ private void saveInterval() {
+ if (currentlyTracking) {
+ Toast.makeText(getApplicationContext(), R.string.user_needs_to_restart_tracking, Toast.LENGTH_LONG).show();
+ }
+
+ SharedPreferences sharedPreferences = this.getSharedPreferences("com.websmithing.gpstracker.prefs", Context.MODE_PRIVATE);
+ SharedPreferences.Editor editor = sharedPreferences.edit();
+
+ switch (intervalRadioGroup.getCheckedRadioButtonId()) {
+ case R.id.i1:
+ editor.putInt("intervalInMinutes", 1);
+ break;
+ case R.id.i5:
+ editor.putInt("intervalInMinutes", 5);
+ break;
+ case R.id.i15:
+ editor.putInt("intervalInMinutes", 15);
+ break;
+ case R.id.i30:
+ editor.putInt("intervalInMinutes", 30);
+ break;
+ case R.id.i60:
+ editor.putInt("intervalInMinutes", 60);
+ break;
+ }
+
+ editor.commit();
+ }
+
+ private void startAlarmManager() {
Log.d(TAG, "startAlarmManager");
+
+ Context context = getBaseContext();
alarmManager = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
gpsTrackerIntent = new Intent(context, GpsTrackerAlarmReceiver.class);
pendingIntent = PendingIntent.getBroadcast(context, 0, gpsTrackerIntent, 0);
@@ -77,8 +117,9 @@
pendingIntent);
}
- private void cancelAlarm() {
- Log.d(TAG, "cancelAlarm");
+ private void cancelAlarmManager() {
+ Log.d(TAG, "cancelAlarmManager");
+
if (alarmManager != null) {
alarmManager.cancel(pendingIntent);
alarmManager = null;
@@ -101,7 +142,7 @@
if (currentlyTracking) {
Toast.makeText(getApplicationContext(), R.string.tracking_has_now_stopped, Toast.LENGTH_LONG).show();
- cancelAlarm();
+ cancelAlarmManager();
currentlyTracking = false;
editor.putBoolean("currentlyTracking", false);
@@ -109,7 +150,7 @@
} else {
Toast.makeText(getApplicationContext(), R.string.tracking_has_now_started, Toast.LENGTH_LONG).show();
- startAlarmManager(getBaseContext());
+ startAlarmManager();
currentlyTracking = true;
editor.putBoolean("currentlyTracking", true);
@@ -176,8 +217,6 @@
SharedPreferences sharedPreferences = this.getSharedPreferences("com.websmithing.gpstracker.prefs", Context.MODE_PRIVATE);
int interval = sharedPreferences.getInt("intervalInMinutes", 1);
- intervalRadioGroup = (RadioGroup)findViewById(R.id.intervalRadioGroup);
-
switch (intervalInMinutes) {
case 1:
intervalRadioGroup.check(R.id.i1);
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 172574b..b44650d 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
@@ -163,7 +163,12 @@
// we have our desired accuracy of 100 meters so lets quit this service,
// onDestroy will be called and stop our location uodates
if (location.getAccuracy() < 100.0f) {
- sendLocationDataToWebsite(location);
+ SharedPreferences sharedPreferences = this.getSharedPreferences("com.websmithing.gpstracker.prefs", Context.MODE_PRIVATE);
+ String sessionID = sharedPreferences.getString("userName", "");
+
+ if (sessionID.trim().length() != 0) {
+ sendLocationDataToWebsite(location);
+ }
}
}
}
diff --git a/phoneClients/android/app/src/main/res/values/strings.xml b/phoneClients/android/app/src/main/res/values/strings.xml
index 28793c9..85df8ab 100644
--- a/phoneClients/android/app/src/main/res/values/strings.xml
+++ b/phoneClients/android/app/src/main/res/values/strings.xml
@@ -7,6 +7,7 @@
Tracking is On
Tracking has now started.
Tracking has now stopped.
+ Please restart tracking to change the time interval.
Cannot reach the website that you have entered. Did you spell it correctly? Does your website use http or https?
Please fill in both fields. User names cannot have a space.
Please go into Settings > Apps > All and enable Google Play Services.