Browse Source

Minimum accuracy and 50 retries

nolocaltime
Mendhak 10 years ago
parent
commit
aee11c16b2
  1. 1
      .idea/compiler.xml
  2. 5
      GPSLogger/GPSLogger.iml
  3. 11
      GPSLogger/res/values/strings.xml
  4. 17
      GPSLogger/res/xml/settings.xml
  5. 47
      GPSLogger/src/com/mendhak/gpslogger/GpsLoggingService.java
  6. 52
      GPSLogger/src/com/mendhak/gpslogger/GpsSettingsActivity.java
  7. 34
      GPSLogger/src/com/mendhak/gpslogger/common/AppSettings.java
  8. 18
      GPSLogger/src/com/mendhak/gpslogger/common/Session.java
  9. 29
      GPSLogger/src/com/mendhak/gpslogger/common/Utilities.java

1
.idea/compiler.xml

@ -7,6 +7,7 @@
<directory url="file://$PROJECT_DIR$/GPSLogger/gen" includeSubdirectories="true" />
<directory url="file://$PROJECT_DIR$/GPSLogger/target/generated-sources/r" includeSubdirectories="true" />
<directory url="file://$PROJECT_DIR$/tests/gen" includeSubdirectories="true" />
<directory url="file://$PROJECT_DIR$/Testing/gen" includeSubdirectories="true" />
</excludeFromCompile>
<resourceExtensions />
<wildcardResourcePatterns>

5
GPSLogger/GPSLogger.iml

@ -25,6 +25,7 @@
<option name="PROGUARD_CFG_PATH" value="/proguard.cfg" />
<resOverlayFolders />
<includeSystemProguardFile>false</includeSystemProguardFile>
<includeAssetsFromLibraries>true</includeAssetsFromLibraries>
<additionalNativeLibs />
</configuration>
</facet>
@ -38,11 +39,9 @@
<sourceFolder url="file://$MODULE_DIR$/gen" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/target/generated-sources/annotations" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/target/classes" />
<excludeFolder url="file://$MODULE_DIR$/target/generated-sources/combined-assets" />
<excludeFolder url="file://$MODULE_DIR$/target/generated-sources/combined-resources" />
<excludeFolder url="file://$MODULE_DIR$/target/generated-sources/extracted-dependencies" />
<excludeFolder url="file://$MODULE_DIR$/target/test-classes" />
</content>
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.android:android:2.3.3" level="project" />
@ -64,7 +63,7 @@
<orderEntry type="library" name="Maven: oauth.signpost:signpost-commonshttp4:1.2.1.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.james:apache-mime4j:0.6.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpmime:4.0.3" level="project" />
<orderEntry type="jdk" jdkName="Android 2.2 Platform" jdkType="Android SDK" />
<orderEntry type="inheritedJdk" />
</component>
</module>

11
GPSLogger/res/values/strings.xml

@ -126,6 +126,8 @@
<string name="settings_distance_in_feet">Distance in feet</string>
<string name="settings_enter_feet">Enter feet(max 9999)</string>
<string name="settings_distance_in_meters">Distance in meters</string>
<string name="settings_accuracy_in_meters">Accuracy in meters</string>
<string name="settings_accuracy_in_feet">Accuracy in feet</string>
<string name="settings_enter_meters">Enter meters(max 9999)</string>
<string name="settings_converting_title">Converting…</string>
<string name="settings_converting_description">Converting minimum distance units. Values above 9999 are reset to
@ -157,10 +159,19 @@
</string>
<string name="time_before_logging_dialog_title">Time in seconds</string>
<string name="time_before_logging_hint">Enter seconds (max 9999)</string>
<string name="retry_time_title">Time interval for accuracy</string>
<string name="retry_time_summary">Use 0 for maximum frequency, but slower is better for battery life.
</string>
<string name="retry_time_dialog_title">Time in seconds</string>
<string name="retry_time_hint">Enter seconds (max 9999)</string>
<string name="distance_before_logging_title">Distance before logging</string>
<string name="distance_before_logging_summary">How far to travel before logging the next point. Use 0 to log all
points.
</string>
<string name="accuracy_before_logging_title">Accuracy before logging</string>
<string name="accuracy_before_logging_summary">Which min. accuracy to for logging. Use 0 to log all
points.
</string>
<string name="useimperial_title">Use Imperial units</string>
<string name="useimperial_summary">Use feet, miles and pints, none of that newfangled metric stuff.</string>

17
GPSLogger/res/xml/settings.xml

@ -50,6 +50,23 @@
android:hint="@string/settings_enter_meters"/>
<EditTextPreference android:key="accuracy_before_logging"
android:title="@string/accuracy_before_logging_title"
android:summary="@string/accuracy_before_logging_summary"
android:dialogTitle="@string/settings_accuracy_in_meters"
android:numeric="integer" android:maxLength="4"
android:hint="@string/settings_enter_meters"/>
<EditTextPreference android:key="retry_time"
android:title="@string/retry_time_title"
android:summary="@string/retry_time_summary"
android:dialogTitle="@string/retry_time_dialog_title"
android:numeric="integer" android:maxLength="4"
android:hint="@string/retry_time_hint"/>
</PreferenceCategory>
</PreferenceScreen>
<PreferenceScreen android:title="@string/pref_general_title" android:summary="@string/pref_general_summary">

47
GPSLogger/src/com/mendhak/gpslogger/GpsLoggingService.java

@ -30,6 +30,7 @@ import android.os.Binder;
import android.os.Bundle;
import android.os.IBinder;
import android.os.SystemClock;
import android.widget.Toast;
import com.mendhak.gpslogger.common.AppSettings;
import com.mendhak.gpslogger.common.IActionListener;
import com.mendhak.gpslogger.common.Session;
@ -685,6 +686,7 @@ public class GpsLoggingService extends Service implements IActionListener
*/
void OnLocationChanged(Location loc)
{
int retryTimeout = Session.getRetryTimeout();
if (!Session.isStarted())
{
@ -711,6 +713,28 @@ public class GpsLoggingService extends Service implements IActionListener
return;
}
// Don't do anything until the user-defined accuracy is reached
if (AppSettings.getMinimumAccuracyInMeters() > 0)
{
if(AppSettings.getMinimumAccuracyInMeters() < Math.abs(loc.getAccuracy()))
{
if(retryTimeout < 50)
{
Session.setRetryTimeout(retryTimeout+1);
SetStatus("Only accuracy of " + String.valueOf(Math.floor(loc.getAccuracy())) + " reached");
StopManagerAndResetAlarm(AppSettings.getRetryInterval());
return;
}
else
{
Session.setRetryTimeout(0);
SetStatus("Only accuracy of " + String.valueOf(Math.floor(loc.getAccuracy())) + " reached and timeout reached");
StopManagerAndResetAlarm();
return;
}
}
}
//Don't do anything until the user-defined distance has been traversed
if (AppSettings.getMinimumDistanceInMeters() > 0 && Session.hasValidLocation())
{
@ -769,6 +793,12 @@ public class GpsLoggingService extends Service implements IActionListener
SetAlarmForNextPoint();
}
protected void StopManagerAndResetAlarm(int retryInterval)
{
Utilities.LogDebug("GpsLoggingService.StopManagerAndResetAlarm_retryInterval");
StopGpsManager();
SetAlarmForNextPoint(retryInterval);
}
private void StopAlarm()
{
@ -797,6 +827,23 @@ public class GpsLoggingService extends Service implements IActionListener
}
private void SetAlarmForNextPoint(int retryInterval)
{
Utilities.LogDebug("GpsLoggingService.SetAlarmForNextPoint_retryInterval");
Intent i = new Intent(this, GpsLoggingService.class);
i.putExtra("getnextpoint", true);
PendingIntent pi = PendingIntent.getService(this, 0, i, 0);
nextPointAlarmManager.cancel(pi);
nextPointAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,
SystemClock.elapsedRealtime() + retryInterval * 1000, pi);
}
/**
* Calls file helper to write a given location to a file.
*

52
GPSLogger/src/com/mendhak/gpslogger/GpsSettingsActivity.java

@ -62,9 +62,22 @@ public class GpsSettingsActivity extends PreferenceActivity
distanceBeforeLogging.setDialogTitle(R.string.settings_distance_in_meters);
distanceBeforeLogging.getEditText().setHint(R.string.settings_enter_meters);
}
EditTextPreference accuracyBeforeLogging = (EditTextPreference) findPreference("accuracy_before_logging");
if (useImperial)
{
accuracyBeforeLogging.setDialogTitle(R.string.settings_accuracy_in_feet);
accuracyBeforeLogging.getEditText().setHint(R.string.settings_enter_feet);
}
else
{
accuracyBeforeLogging.setDialogTitle(R.string.settings_accuracy_in_meters);
accuracyBeforeLogging.getEditText().setHint(R.string.settings_enter_meters);
}
CheckBoxPreference imperialCheckBox = (CheckBoxPreference) findPreference("useImperial");
imperialCheckBox.setOnPreferenceChangeListener(new ImperialPreferenceChangeListener(prefs, distanceBeforeLogging));
imperialCheckBox.setOnPreferenceChangeListener(new ImperialPreferenceChangeListener(prefs, distanceBeforeLogging, accuracyBeforeLogging));
Preference enableDisablePref = findPreference("enableDisableGps");
@ -121,12 +134,14 @@ public class GpsSettingsActivity extends PreferenceActivity
private class ImperialPreferenceChangeListener implements Preference.OnPreferenceChangeListener
{
EditTextPreference distanceBeforeLogging;
EditTextPreference accuracyBeforeLogging;
SharedPreferences prefs;
public ImperialPreferenceChangeListener(SharedPreferences prefs, EditTextPreference distanceBeforeLogging)
public ImperialPreferenceChangeListener(SharedPreferences prefs, EditTextPreference distanceBeforeLogging, EditTextPreference accuracyBeforeLogging)
{
this.prefs = prefs;
this.distanceBeforeLogging = distanceBeforeLogging;
this.distanceBeforeLogging = accuracyBeforeLogging;
this.accuracyBeforeLogging = accuracyBeforeLogging;
}
public boolean onPreferenceChange(Preference preference, final Object newValue)
@ -155,7 +170,8 @@ public class GpsSettingsActivity extends PreferenceActivity
boolean useImp = Boolean.parseBoolean(newValue.toString());
String minimumDistanceString = prefs.getString("distance_before_logging", "0");
String minimumAccuracyString = prefs.getString("accuracy_before_logging", "0");
int minimumDistance;
if (minimumDistanceString != null && minimumDistanceString.length() > 0)
@ -166,6 +182,17 @@ public class GpsSettingsActivity extends PreferenceActivity
{
minimumDistance = 0;
}
int minimumAccuracy;
if (minimumAccuracyString != null && minimumAccuracyString.length() > 0)
{
minimumAccuracy = Integer.valueOf(minimumAccuracyString);
}
else
{
minimumAccuracy = 0;
}
SharedPreferences.Editor editor = prefs.edit();
@ -175,13 +202,22 @@ public class GpsSettingsActivity extends PreferenceActivity
distanceBeforeLogging.getEditText().setHint(R.string.settings_enter_feet);
minimumDistance = Utilities.MetersToFeet(minimumDistance);
accuracyBeforeLogging.setDialogTitle(R.string.settings_accuracy_in_feet);
accuracyBeforeLogging.getEditText().setHint(R.string.settings_enter_feet);
minimumAccuracy = Utilities.MetersToFeet(minimumAccuracy);
}
else
{
minimumDistance = Utilities.FeetToMeters(minimumDistance);
distanceBeforeLogging.setDialogTitle(R.string.settings_distance_in_meters);
distanceBeforeLogging.getEditText().setHint(R.string.settings_enter_meters);
minimumAccuracy = Utilities.FeetToMeters(minimumAccuracy);
accuracyBeforeLogging.setDialogTitle(R.string.settings_accuracy_in_meters);
accuracyBeforeLogging.getEditText().setHint(R.string.settings_enter_meters);
}
@ -189,9 +225,15 @@ public class GpsSettingsActivity extends PreferenceActivity
{
minimumDistance = 9999;
}
if (minimumAccuracy >= 9999)
{
minimumAccuracy = 9999;
}
editor.putString("distance_before_logging", String.valueOf(minimumDistance));
editor.putString("accuracy_before_logging", String.valueOf(minimumAccuracy));
editor.commit();
handler.post(updateResults);

34
GPSLogger/src/com/mendhak/gpslogger/common/AppSettings.java

@ -33,6 +33,7 @@ public class AppSettings extends Application
private static boolean logToPlainText;
private static boolean showInNotificationBar;
private static int minimumSeconds;
private static int retryInterval;
private static String newFileCreation;
private static Float autoSendDelay = 0f;
private static boolean autoSendEnabled = false;
@ -46,6 +47,7 @@ public class AppSettings extends Application
private static boolean smtpSsl;
private static boolean debugToFile;
private static int minimumDistance;
private static int minimumAccuracy;
private static boolean shouldSendZipFile;
private static boolean LogToOpenGTS;
@ -196,6 +198,22 @@ public class AppSettings extends Application
{
AppSettings.minimumSeconds = minimumSeconds;
}
/**
* @return the retryInterval
*/
public static int getRetryInterval()
{
return retryInterval;
}
/**
* @param retryInterval the retryInterval to set
*/
static void setRetryInterval(int retryInterval)
{
AppSettings.retryInterval = retryInterval;
}
/**
@ -214,6 +232,22 @@ public class AppSettings extends Application
AppSettings.minimumDistance = minimumDistance;
}
/**
* @return the minimumAccuracy
*/
public static int getMinimumAccuracyInMeters()
{
return minimumAccuracy;
}
/**
* @param minimumAccuracy the minimumAccuracy to set
*/
static void setMinimumAccuracyInMeters(int minimumAccuracy)
{
AppSettings.minimumAccuracy = minimumAccuracy;
}
/**
* @return the newFileCreation

18
GPSLogger/src/com/mendhak/gpslogger/common/Session.java

@ -45,6 +45,7 @@ public class Session extends Application
private static boolean readyToBeAutoSent = false;
private static boolean allowDescription = true;
private static boolean isSinglePointMode = false;
private static int retryTimeout=0;
public static boolean isSinglePointMode()
{
@ -156,6 +157,23 @@ public class Session extends Application
Session.satellites = satellites;
}
/**
* @return the retryTimeout
*/
public static int getRetryTimeout()
{
return retryTimeout;
}
/**
* @param retryTimeout sets the retryTimeout
*
* */
public static void setRetryTimeout(int retryTimeout)
{
Session.retryTimeout = retryTimeout;
}
/**
* @return the notificationVisible
*/

29
GPSLogger/src/com/mendhak/gpslogger/common/Utilities.java

@ -148,10 +148,26 @@ public class Utilities
AppSettings.setMinimumDistanceInMeters(0);
}
String minimumAccuracyString = prefs.getString(
"accuracy_before_logging", "0");
if (minimumAccuracyString != null && minimumAccuracyString.length() > 0)
{
AppSettings.setMinimumAccuracyInMeters(Integer
.valueOf(minimumAccuracyString));
}
else
{
AppSettings.setMinimumAccuracyInMeters(0);
}
if (AppSettings.shouldUseImperial())
{
AppSettings.setMinimumDistanceInMeters(Utilities.FeetToMeters(AppSettings
.getMinimumDistanceInMeters()));
AppSettings.setMinimumAccuracyInMeters(Utilities.FeetToMeters(AppSettings
.getMinimumAccuracyInMeters()));
}
@ -168,6 +184,19 @@ public class Utilities
AppSettings.setMinimumSeconds(60);
}
String retryIntervalString = prefs.getString("retry_time",
"60");
if (retryIntervalString != null && retryIntervalString.length() > 0)
{
AppSettings
.setRetryInterval(Integer.valueOf(retryIntervalString));
}
else
{
AppSettings.setRetryInterval(60);
}
AppSettings.setNewFileCreation(prefs.getString("new_file_creation",
"onceaday"));

Loading…
Cancel
Save