Browse Source

Merge branch 'peter.merge'

master
Marc Poulhiès 6 years ago
parent
commit
5c16df6c24
  1. 7
      .idea/encodings.xml
  2. 12
      .idea/gradle.xml
  3. 11
      .idea/libraries/support_v4_19_1_0.xml
  4. 122
      .idea/misc.xml
  5. 3
      .idea/modules.xml
  6. 5
      .idea/vcs.xml
  7. 2
      .travis.yml
  8. 60
      GPSLogger/GPSLogger.iml
  9. 5
      GPSLogger/build.gradle
  10. 160
      GPSLogger/src/main/AndroidManifest.xml
  11. 218
      GPSLogger/src/main/java/com/mendhak/gpslogger/ConfImportActivity.java
  12. 6
      GPSLogger/src/main/java/com/mendhak/gpslogger/GeneralLocationListener.java
  13. 180
      GPSLogger/src/main/java/com/mendhak/gpslogger/GpsLoggingService.java
  14. 121
      GPSLogger/src/main/java/com/mendhak/gpslogger/GpsMainActivity.java
  15. 6
      GPSLogger/src/main/java/com/mendhak/gpslogger/GpsSettingsActivity.java
  16. 22
      GPSLogger/src/main/java/com/mendhak/gpslogger/common/AppSettings.java
  17. 2
      GPSLogger/src/main/java/com/mendhak/gpslogger/common/DebugLogger.java
  18. 15
      GPSLogger/src/main/java/com/mendhak/gpslogger/common/OpenGTSClient.java
  19. 40
      GPSLogger/src/main/java/com/mendhak/gpslogger/common/PrefsIO.java
  20. 15
      GPSLogger/src/main/java/com/mendhak/gpslogger/common/Session.java
  21. 19
      GPSLogger/src/main/java/com/mendhak/gpslogger/common/Utilities.java
  22. 95
      GPSLogger/src/main/java/com/mendhak/gpslogger/loggers/AbstractLiveLogger.java
  23. 72
      GPSLogger/src/main/java/com/mendhak/gpslogger/loggers/LiveTrack24FileLogger.java
  24. 63
      GPSLogger/src/main/java/com/mendhak/gpslogger/loggers/OpenGTSLogger.java
  25. 12
      GPSLogger/src/main/java/com/mendhak/gpslogger/loggers/SkyLinesLogger.java
  26. 13
      GPSLogger/src/main/java/com/mendhak/gpslogger/loggers/utils/LocationBuffer.java
  27. 3
      GPSLogger/src/main/java/com/mendhak/gpslogger/senders/dropbox/DropBoxHelper.java
  28. 2
      GPSLogger/src/main/java/com/mendhak/gpslogger/senders/email/AutoEmailHelper.java
  29. 3
      GPSLogger/src/main/java/com/mendhak/gpslogger/senders/gdocs/GDocsHelper.java
  30. 59
      GPSLogger/src/main/res/layout/confimport.xml
  31. 19
      GPSLogger/src/main/res/values-es/strings.xml
  32. 34
      GPSLogger/src/main/res/values-fr/strings.xml
  33. 31
      GPSLogger/src/main/res/values-ru/strings.xml
  34. 29
      GPSLogger/src/main/res/values/strings.xml
  35. 2
      GPSLogger/src/main/res/xml/livetrack24settings.xml
  36. 2
      GPSLogger/src/main/res/xml/opengtssettings.xml
  37. 39
      GPSLogger/src/main/res/xml/settings.xml
  38. 8
      GPSLoggerFlight.iml
  39. 2
      build.gradle
  40. 4
      gradle/wrapper/gradle-wrapper.properties
  41. 180
      gradlew.bat

7
.idea/encodings.xml

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
</project>
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false">
<file url="PROJECT" charset="UTF-8" />
</component>
</project>

12
.idea/gradle.xml

@ -5,15 +5,21 @@
<GradleProjectSettings>
<option name="distributionType" value="LOCAL" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleHome" value="$APPLICATION_HOME_DIR$/gradle/gradle-2.2.1" />
<option name="gradleHome" value="$APPLICATION_HOME_DIR$/gradle/gradle-2.10" />
<option name="gradleJvm" value="1.8" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/GPSLogger" />
</set>
</option>
<option name="myModules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/GPSLogger" />
</set>
</option>
</GradleProjectSettings>
</option>
</component>
</project>
</project>

11
.idea/libraries/support_v4_19_1_0.xml

@ -0,0 +1,11 @@
<component name="libraryTable">
<library name="support-v4-19.1.0">
<CLASSES>
<root url="jar://$USER_HOME$/android/android-studio.old/android-studio/sdk/extras/android/m2repository/com/android/support/support-v4/19.1.0/support-v4-19.1.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/android/android-studio.old/android-studio/sdk/extras/android/m2repository/com/android/support/support-v4/19.1.0/support-v4-19.1.0-sources.jar!/" />
</SOURCES>
</library>
</component>

122
.idea/misc.xml

@ -1,11 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DaemonCodeAnalyzer">
<disable_hints />
</component>
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
</list>
</value>
</option>
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
<OptionsSetting value="true" id="Add" />
<OptionsSetting value="true" id="Remove" />
@ -19,97 +40,4 @@
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="RunManager">
<configuration default="true" type="Remote" factoryName="Remote">
<option name="USE_SOCKET_TRANSPORT" value="true" />
<option name="SERVER_MODE" value="false" />
<option name="SHMEM_ADDRESS" value="javadebug" />
<option name="HOST" value="localhost" />
<option name="PORT" value="5005" />
<method />
</configuration>
<configuration default="true" type="TestNG" factoryName="TestNG">
<module name="" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="SUITE_NAME" />
<option name="PACKAGE_NAME" />
<option name="MAIN_CLASS_NAME" />
<option name="METHOD_NAME" />
<option name="GROUP_NAME" />
<option name="TEST_OBJECT" value="CLASS" />
<option name="VM_PARAMETERS" value="-ea" />
<option name="PARAMETERS" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="OUTPUT_DIRECTORY" />
<option name="ANNOTATION_TYPE" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="moduleWithDependencies" />
</option>
<option name="USE_DEFAULT_REPORTERS" value="false" />
<option name="PROPERTIES_FILE" />
<envs />
<properties />
<listeners />
<method />
</configuration>
<configuration default="true" type="Applet" factoryName="Applet">
<module name="" />
<option name="MAIN_CLASS_NAME" />
<option name="HTML_FILE_NAME" />
<option name="HTML_USED" value="false" />
<option name="WIDTH" value="400" />
<option name="HEIGHT" value="300" />
<option name="POLICY_FILE" value="$APPLICATION_HOME_DIR$/bin/appletviewer.policy" />
<option name="VM_PARAMETERS" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<method />
</configuration>
<configuration default="true" type="Application" factoryName="Application">
<option name="MAIN_CLASS_NAME" />
<option name="VM_PARAMETERS" />
<option name="PROGRAM_PARAMETERS" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="ENABLE_SWING_INSPECTOR" value="false" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<module name="" />
<envs />
<method />
</configuration>
<configuration default="true" type="JUnit" factoryName="JUnit">
<module name="" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="PACKAGE_NAME" />
<option name="MAIN_CLASS_NAME" />
<option name="METHOD_NAME" />
<option name="TEST_OBJECT" value="class" />
<option name="VM_PARAMETERS" value="-ea" />
<option name="PARAMETERS" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="moduleWithDependencies" />
</option>
<envs />
<patterns />
<method />
</configuration>
<list size="0" />
<configuration name="&lt;template&gt;" type="#org.jetbrains.idea.devkit.run.PluginConfigurationType" default="true" selected="false">
<option name="VM_PARAMETERS" value="-Xmx512m -Xms256m -XX:MaxPermSize=250m -ea" />
</configuration>
<configuration name="&lt;template&gt;" type="WebApp" default="true" selected="false">
<Host>localhost</Host>
<Port>5050</Port>
</configuration>
</component>
</project>
</project>

3
.idea/modules.xml

@ -6,5 +6,4 @@
<module fileurl="file://$PROJECT_DIR$/GPSLoggerFlight.iml" filepath="$PROJECT_DIR$/GPSLoggerFlight.iml" />
</modules>
</component>
</project>
</project>

5
.idea/vcs.xml

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="" />
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
</project>

2
.travis.yml

@ -14,4 +14,4 @@ script:
# Performs tests (which will do a ./gradlew build task first)
# Skips the uninstallAll task as it's always a fresh emulator
# Does a logcat dump if anything fails
- ./gradlew
- ./gradlew build

60
GPSLogger/GPSLogger.iml

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="GPSLoggerFlight" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<module external.linked.project.id=":GPSLogger" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="GPSLoggerFlight" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle">
<configuration>
@ -12,9 +12,9 @@
<option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugAndroidTest" />
<option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />
<option name="TEST_SOURCE_GEN_TASK_NAME" value="generateDebugAndroidTestSources" />
<afterSyncTasks>
<task>generateDebugSources</task>
</afterSyncTasks>
<option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
@ -23,9 +23,9 @@
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="false">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_6" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/androidTest/debug" />
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/test/debug" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
@ -33,13 +33,13 @@
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/androidTest/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
@ -47,6 +47,15 @@
<sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
@ -54,6 +63,7 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
@ -61,25 +71,36 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/coverage-instrumented-classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.actionbarsherlock/actionbarsherlock/4.4.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/libs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-runtime-classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-safeguard" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-verifier" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-support" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/ndk" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/restart-dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/shaders" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
@ -90,13 +111,12 @@
<orderEntry type="library" exported="" name="commons-codec-1.6" level="project" />
<orderEntry type="library" exported="" name="support-v4-19.1.0" level="project" />
<orderEntry type="library" exported="" name="httpmime-4.3.3" level="project" />
<orderEntry type="library" exported="" name="mailapi-1.4.3" level="project" />
<orderEntry type="library" exported="" name="android-async-http-1.4.4" level="project" />
<orderEntry type="library" exported="" name="mailapi-1.4.3" level="project" />
<orderEntry type="library" exported="" name="signpost-core-1.2.1.2" level="project" />
<orderEntry type="library" exported="" name="httpcore-4.3.2" level="project" />
<orderEntry type="library" exported="" name="actionbarsherlock-4.4.0" level="project" />
<orderEntry type="library" exported="" name="commons-net-2.2" level="project" />
<orderEntry type="library" exported="" name="signpost-commonshttp4-1.2.1.2" level="project" />
</component>
</module>
</module>

5
GPSLogger/build.gradle

@ -7,8 +7,8 @@ android {
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 20150329
versionName "20150329"
versionCode 20140617
versionName "20140617"
}
signingConfigs {
@ -28,7 +28,6 @@ android {
}
releaseUnsigned {
}
}

160
GPSLogger/src/main/AndroidManifest.xml

@ -12,6 +12,7 @@
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.android.email.permission.READ_ATTACHMENT" />
<application
android:allowBackup="true"
@ -25,8 +26,11 @@
</intent-filter>
</service>
<!--android:screenOrientation="portrait" -->
<activity android:name="com.mendhak.gpslogger.GpsMainActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:launchMode="singleTask" android:configChanges="locale">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
@ -38,7 +42,7 @@
android:label="DropBox"
android:launchMode="singleTask">
<intent-filter>
<action android:name="com.mendhak.gpslogger.DROPBOX_SETUP"/>
<action android:name="net.kataplop.gpslogger.DROPBOX_SETUP"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
@ -65,7 +69,7 @@
<activity android:label="@string/osm_preferences_title"
android:name="com.mendhak.gpslogger.senders.osm.OSMAuthorizationActivity">
<intent-filter>
<action android:name="com.mendhak.gpslogger.OSM_AUTHORIZE"/>
<action android:name="net.kataplop.gpslogger.OSM_AUTHORIZE"/>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
@ -82,7 +86,7 @@
android:label="@string/autoftp_setup_title" android:screenOrientation="portrait">
<intent-filter>
<category android:name="android.intent.category.DEFAULT"/>
<action android:name="com.mendhak.gpslogger.AUTOFTP_SETUP"/>
<action android:name="net.kataplop.gpslogger.AUTOFTP_SETUP"/>
</intent-filter>
</activity>
@ -90,12 +94,12 @@
android:label="@string/autoemail_title" android:screenOrientation="portrait">
<intent-filter>
<category android:name="android.intent.category.DEFAULT"/>
<action android:name="com.mendhak.gpslogger.AUTOEMAIL_SETUP"/>
<action android:name="net.kataplop.gpslogger.AUTOEMAIL_SETUP"/>
</intent-filter>
</activity>
<activity android:name="com.mendhak.gpslogger.senders.gdocs.GDocsSettingsActivity" android:label="@string/gdocs_settings_screenname">
<intent-filter>
<action android:name="com.mendhak.gpslogger.GDOCS_SETUP"/>
<action android:name="net.kataplop.gpslogger.GDOCS_SETUP"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
@ -119,7 +123,7 @@
android:label="@string/opengts_setup_title">
<intent-filter>
<category android:name="android.intent.category.DEFAULT"/>
<action android:name="com.mendhak.gpslogger.OPENGTS_SETUP"/>
<action android:name="net.kataplop.gpslogger.OPENGTS_SETUP"/>
</intent-filter>
</activity>
@ -127,7 +131,7 @@
android:label="@string/skylines_setup_title">
<intent-filter>
<category android:name="android.intent.category.DEFAULT"/>
<action android:name="com.mendhak.gpslogger.SKYLINES_SETUP"/>
<action android:name="net.kataplop.gpslogger.SKYLINES_SETUP"/>
</intent-filter>
</activity>
@ -135,7 +139,147 @@
android:label="@string/livetrack24_setup_title">
<intent-filter>
<category android:name="android.intent.category.DEFAULT"/>
<action android:name="com.mendhak.gpslogger.LIVETRACK24_SETUP"/>
<action android:name="net.kataplop.gpslogger.LIVETRACK24_SETUP"/>
</intent-filter>
</activity>
<activity android:name="com.mendhak.gpslogger.ConfImportActivity"
android:label="@string/confimport_activity_title">
<intent-filter>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE" />
<action android:name="android.intent.action.VIEW" />
<data
android:scheme="file"
android:mimeType="*/*"
android:host="*"
android:pathPattern=".*\\.csv"
/>
</intent-filter>
<intent-filter>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE" />
<action android:name="android.intent.action.VIEW" />
<data
android:scheme="content"
android:mimeType="*/*"
android:host="*"
android:pathPattern=".*\\.csv"
/>
</intent-filter>
<intent-filter>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE" />
<action android:name="android.intent.action.VIEW" />
<data
android:scheme="file"
android:mimeType="text/plain"
android:host="*"
android:pathPattern=".*\\.csv"
/>
</intent-filter>
<intent-filter>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE" />
<action android:name="android.intent.action.VIEW" />
<data
android:scheme="content"
android:mimeType="text/plain"
android:host="*"
android:pathPattern=".*\\.csv"
/>
</intent-filter>
<intent-filter>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE" />
<action android:name="android.intent.action.VIEW" />
<data
android:scheme="file"
android:mimeType="application/octet-stream"
android:host="*"
android:pathPattern=".*\\.csv"
/>
</intent-filter>
<intent-filter>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE" />
<action android:name="android.intent.action.VIEW" />
<data
android:scheme="content"
android:mimeType="application/octet-stream"
android:host="*"
android:pathPattern=".*\\.csv"
/>
</intent-filter>
<intent-filter>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE" />
<action android:name="android.intent.action.VIEW" />
<data
android:scheme="file"
android:mimeType="application/csv"
android:host="*"
android:pathPattern=".*\\.csv"
/>
</intent-filter>
<intent-filter>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE" />
<action android:name="android.intent.action.VIEW" />
<data
android:scheme="content"
android:mimeType="application/csv"
android:host="*"
android:pathPattern=".*\\.csv"
/>
</intent-filter>
<intent-filter>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE" />
<action android:name="android.intent.action.VIEW" />
<data
android:scheme="file"
android:mimeType="text/comma-separated-values"
android:host="*"
android:pathPattern=".*"
/>
</intent-filter>
<intent-filter>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE" />
<action android:name="android.intent.action.VIEW" />
<data
android:scheme="content"
android:mimeType="text/comma-separated-values"
android:host="*"
android:pathPattern=".*"
/>
</intent-filter>
<intent-filter>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE" />
<action android:name="android.intent.action.VIEW" />
<data
android:scheme="file"
android:mimeType="text/csv"
android:host="*"
android:pathPattern=".*"
/>
</intent-filter>
<intent-filter>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE" />
<action android:name="android.intent.action.VIEW" />
<data
android:scheme="content"
android:mimeType="text/csv"
android:host="*"
android:pathPattern=".*"
/>
</intent-filter>
<intent-filter>
<category android:name="android.intent.category.DEFAULT"/>
<action android:name="com.mendhak.gpslogger.ConfImport"/>
</intent-filter>
</activity>

218
GPSLogger/src/main/java/com/mendhak/gpslogger/ConfImportActivity.java

@ -0,0 +1,218 @@
/*
* This file is part of GPSLogger for Android.
*
* GPSLogger for Android is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GPSLogger for Android is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GPSLogger for Android. If not, see <http://www.gnu.org/licenses/>.
*/
package com.mendhak.gpslogger;
import android.content.ContentProviderClient;
import android.content.ContentResolver;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.AssetFileDescriptor;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
import android.preference.PreferenceManager;
import android.text.method.ScrollingMovementMethod;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.TextView;
import android.widget.Toast;
//import com.android.email.Email;
//import com.android.email.provider.AttachmentProvider;
import com.actionbarsherlock.app.SherlockActivity;
import com.actionbarsherlock.view.MenuItem;
import com.mendhak.gpslogger.common.PrefsIO;
import com.mendhak.gpslogger.common.Utilities;
import net.kataplop.gpslogger.R;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
public class ConfImportActivity extends SherlockActivity
{
String wholeFile = null;
public static class Columns {
public static final String _ID = "_id";
public static final String DATA = "_data";
public static final String DISPLAY_NAME = "_display_name";
public static final String SIZE = "_size";
}
/**
* Event raised when the form is created for the first time
*/
@Override
public void onCreate(Bundle savedInstanceState)
{
Utilities.LogDebug("ConfImportActivity.onCreate");
super.onCreate(savedInstanceState);
Uri uri = getIntent().getData();
String path = "";
String str = "";
// String typemime = "";
String scheme = "";
File mySetFile = null;
wholeFile = "";
if(uri!=null) {
// getIntent().setData(null);
scheme = uri.getScheme();
if (scheme.equals(ContentResolver.SCHEME_CONTENT)) {
ContentResolver cr = getContentResolver();
// ContentProviderClient cpc = cr.acquireContentProviderClient(uri);
// typemime = cr.getType(uri);
Uri attachmentUri = null;
Cursor c = cr.query(uri, new String[] { Columns.DATA }, null, null, null);
if (c != null) {
try {
if (c.moveToFirst()) {
String struri=c.getString(0);
if(struri!=null) {
attachmentUri = Uri.parse(struri);
int imax = c.getCount();
int jmax = c.getColumnCount();
for (int i = 0; i < imax; i++) {
if (c.moveToNext()) str = c.getString(0);
}
}
else attachmentUri = null;
}
else attachmentUri = null;
} finally {
c.close();
}
}
if(attachmentUri != null) {
uri=attachmentUri;
scheme = uri.getScheme();
}
}
if(scheme==null) {
path = uri.getPath();
// fileName = uri.getLastPathSegment();
if (path != null) {
if (path.length() > 0) {
mySetFile = new File(path);
try {
if (mySetFile.exists()) {
FileReader fr = new FileReader(mySetFile);
BufferedReader br = new BufferedReader(fr);
while ((str = br.readLine()) != null) {
wholeFile += (str + "\n");
}
br.close();
// Intent settingsActivity = new Intent(context, GpsSettingsActivity.class);
// context.startActivity(settingsActivity);
} else
Toast.makeText(this, R.string.confimport_show_failed, Toast.LENGTH_LONG).show();
} catch (Throwable t) {
Toast.makeText(this, "Exception: " + t.toString(), Toast.LENGTH_LONG).show();
Toast.makeText(this, R.string.confimport_show_failed, Toast.LENGTH_LONG).show();
}
}
}
}
else if (scheme.equals(ContentResolver.SCHEME_CONTENT)) {
ContentResolver cr = getContentResolver();
try {
AssetFileDescriptor afd = cr.openAssetFileDescriptor(uri, "r");
long length = afd.getLength();
byte[] filedata = new byte[(int) length];
InputStream is = cr.openInputStream(uri);
if(is != null)
try {
is.read(filedata, 0, (int) length);
wholeFile += new String(filedata,"UTF8");
} catch (IOException e) {
e.printStackTrace();
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
else if (scheme.equals(ContentResolver.SCHEME_FILE)) {
path = uri.getPath();
// fileName = uri.getLastPathSegment();
if (path != null) {
if (path.length() > 0) {
mySetFile = new File(path);
try {
if (mySetFile.exists()) {
FileReader fr = new FileReader(mySetFile);
BufferedReader br = new BufferedReader(fr);
while ((str = br.readLine()) != null) {
wholeFile += (str + "\n");
}
br.close();
// Intent settingsActivity = new Intent(context, GpsSettingsActivity.class);
// context.startActivity(settingsActivity);
} else
Toast.makeText(this, R.string.confimport_show_failed, Toast.LENGTH_LONG).show();
} catch (Throwable t) {
Toast.makeText(this, "Exception: " + t.toString(), Toast.LENGTH_LONG).show();
Toast.makeText(this, R.string.confimport_show_failed, Toast.LENGTH_LONG).show();
}
}
}
}
}
else {
Toast.makeText(this, R.string.confimport_show_failed, Toast.LENGTH_LONG).show();
}
if(wholeFile.length()>0) {
setContentView(R.layout.confimport);
TextView tv = (TextView) findViewById(R.id.confimportview);
tv.setText(wholeFile);
tv.setMovementMethod(new ScrollingMovementMethod());
}
}
public void onCancelClicked(View view) {
finish();
}
public void onImportClicked(View view) {
if(wholeFile.length()>0) {
Intent intent = new Intent(this, GpsMainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra(GpsMainActivity.CONF_DATA, wholeFile);
startActivity(intent);
}
finish();
}
}

6
GPSLogger/src/main/java/com/mendhak/gpslogger/GeneralLocationListener.java

@ -78,18 +78,18 @@ class GeneralLocationListener implements LocationListener, GpsStatus.Listener
{
if (status == LocationProvider.OUT_OF_SERVICE)
{
Utilities.LogDebug(provider + " is out of service");
Utilities.LogDebug("GeneralLocationListener.onStatusChanged: " + provider + " is out of service");
mainActivity.StopManagerAndResetAlarm();
}
if (status == LocationProvider.AVAILABLE)
{
Utilities.LogDebug(provider + " is available");
Utilities.LogDebug("GeneralLocationListener.onStatusChanged: " + provider + " is available");
}
if (status == LocationProvider.TEMPORARILY_UNAVAILABLE)
{
Utilities.LogDebug(provider + " is temporarily unavailable");
Utilities.LogDebug("GeneralLocationListener.onStatusChanged: " + provider + " is temporarily unavailable");
mainActivity.StopManagerAndResetAlarm();
}
}

180
GPSLogger/src/main/java/com/mendhak/gpslogger/GpsLoggingService.java

@ -34,6 +34,7 @@ import android.os.Binder;
import android.os.Bundle;
import android.os.IBinder;
import android.os.SystemClock;
import android.os.Handler;
import com.mendhak.gpslogger.common.AppSettings;
import com.mendhak.gpslogger.common.IActionListener;
@ -58,6 +59,12 @@ public class GpsLoggingService extends Service implements IActionListener
{
private static NotificationManager gpsNotifyManager;
private static int NOTIFICATION_ID = 8675309;
private final static int GPS_LOCATION_REQ_TIMEOUT = 200;
private final static int ON_LOCATION_CHANGED_MIN_FREQ = 100;
private final static int NEXT_ALARM_TIME_MIN = 100;
private final static int MAX_RETRY_START = 10;
private final static int NEXT_ALARM_PANIC = 5000; // milliseconds
private static boolean isRestarting=false;
private final IBinder mBinder = new GpsLoggingBinder();
private static IGpsLoggerServiceClient mainServiceClient;
@ -65,10 +72,11 @@ public class GpsLoggingService extends Service implements IActionListener
// ---------------------------------------------------
// Helpers and managers
// ---------------------------------------------------
private GeneralLocationListener gpsLocationListener;
private GeneralLocationListener towerLocationListener;
private static GeneralLocationListener gpsLocationListener;
private static GeneralLocationListener towerLocationListener;
LocationManager gpsLocationManager;
private LocationManager towerLocationManager;
// private static boolean isStarting = false;
private Intent alarmIntent;
@ -83,6 +91,13 @@ public class GpsLoggingService extends Service implements IActionListener
return mBinder;
}
@Override
public boolean onUnbind(Intent arg0)
{
Utilities.LogDebug("GpsLoggingService.onUnbind");
return true;
}
@Override
public void onCreate()
{
@ -92,27 +107,57 @@ public class GpsLoggingService extends Service implements IActionListener
Utilities.LogInfo("GPSLoggerService created");
}
@Override
public void onStart(Intent intent, int startId)
{
Utilities.LogDebug("GpsLoggingService.onStart");
HandleIntent(intent);
}
@Override
public int onStartCommand(Intent intent, int flags, int startId)
{
Utilities.LogDebug("GpsLoggingService.onStartCommand flags="+String.valueOf(flags)+" startId="+String.valueOf(startId));
long systime = System.currentTimeMillis();
Utilities.LogDebug("GpsLoggingService.onStartCommand");
HandleIntent(intent);
return START_REDELIVER_INTENT;
final Handler handler = new Handler();
final Intent intt = intent;
Session.setWaitingForAlarm(false);
if( ( (flags==START_FLAG_REDELIVERY) || (flags==START_FLAG_RETRY) ) && !Session.isStarted() ) {
/*
Normally should not happen but sometimes Session object values are lost on restart :(
*/
Utilities.LogDebug("GpsLoggingService.onStartCommand with redelivery/restart flags and session not started");
isRestarting=true;
}
if( ( flags==START_FLAG_REDELIVERY ) && (startId>(Session.retryStartService+MAX_RETRY_START)) && (systime>(Session.lastPanicRestartService+2*NEXT_ALARM_PANIC)) ) {
/*
Panic, the system kills our service immediately after starting, then retries to start it
Normally it should not happen anymore with START_STICKY flag used, but in some race conditions we can suppose such situation
*/
Utilities.LogDebug("GpsLoggingService Panic!");
Session.retryStartService = startId;
final Runnable rp = new Runnable() {
public void run() {
Panic();
}
};
handler.post(rp);
return START_NOT_STICKY;
}
final Runnable r = new Runnable() {
public void run() {
HandleIntent(intt);
}
};
handler.post(r);
return START_STICKY;
}
@Override
public void onDestroy()
{
super.onDestroy();
Utilities.LogWarning("GpsLoggingService is being destroyed by Android OS.");
Utilities.LogWarning("GpsLoggingService is being destroyed");
StopGpsManager();
mainServiceClient = null;
}
@ -123,6 +168,25 @@ public class GpsLoggingService extends Service implements IActionListener
super.onLowMemory();
}
/*
In some cases we need to stop anything and completely restart logging using alarm
*/
private void Panic()
{
Utilities.LogDebug("Panic - trying to stop anything");
long systime = System.currentTimeMillis();
StopLogging();
Session.lastPanicRestartService = systime;
Intent i = new Intent(this, GpsLoggingService.class);
i.putExtra("immediate", true);
PendingIntent pi = PendingIntent.getService(this, 0, i, PendingIntent.FLAG_CANCEL_CURRENT);
Utilities.LogDebug("GpsLoggingService Setting panic alarm");
nextPointAlarmManager.set(AlarmManager.RTC_WAKEUP, systime + NEXT_ALARM_PANIC, pi);
Session.setWaitingForAlarm(true);
Utilities.LogDebug("GpsLoggingService Stopping self");
stopSelf();
}
private void HandleIntent(Intent intent)
{
@ -134,7 +198,8 @@ public class GpsLoggingService extends Service implements IActionListener
if (intent != null)
{
Bundle bundle = intent.getExtras();
int flags=intent.getFlags();
Utilities.LogDebug("GpsLoggingService Intent Flags: "+String.valueOf(flags));
if (bundle != null)
{
boolean stopRightNow = bundle.getBoolean("immediatestop");
@ -142,27 +207,27 @@ public class GpsLoggingService extends Service implements IActionListener
boolean sendEmailNow = bundle.getBoolean("emailAlarm");
boolean getNextPoint = bundle.getBoolean("getnextpoint");
Utilities.LogDebug("stopRightNow - " + String.valueOf(stopRightNow));
Utilities.LogDebug("startRightNow - " + String.valueOf(startRightNow));
Utilities.LogDebug("emailAlarm - " + String.valueOf(sendEmailNow));
Utilities.LogDebug("getNextPoint - " + String.valueOf(getNextPoint));
if (startRightNow)
{
Utilities.LogInfo("Auto starting logging");
Utilities.LogInfo("GpsLoggingService Auto starting logging");
StartLogging();
}
if (stopRightNow)
{
Utilities.LogInfo("Auto stop logging");
Utilities.LogInfo("GpsLoggingService Auto stop logging");
StopLogging();
}
if (sendEmailNow)
{
Utilities.LogDebug("setReadyToBeAutoSent = true");
Utilities.LogDebug("GpsLoggingService setReadyToBeAutoSent = true");
Session.setReadyToBeAutoSent(true);
AutoSendLogFile();
@ -170,9 +235,15 @@ public class GpsLoggingService extends Service implements IActionListener
if (getNextPoint && Session.isStarted())
{
Utilities.LogDebug("HandleIntent - getNextPoint");
Utilities.LogDebug("GpsLoggingService.HandleIntent - getNextPoint session started");
StartGpsManager();
}
else if (getNextPoint && isRestarting)
{
Utilities.LogDebug("GpsLoggingService.HandleIntent - getNextPoint isRestarting");
isRestarting=false;
StartLogging();
}
}
}
@ -180,10 +251,10 @@ public class GpsLoggingService extends Service implements IActionListener
{
// A null intent is passed in if the service has been killed and
// restarted.
Utilities.LogDebug("Service restarted with null intent. Start logging.");
Utilities.LogDebug("GpsLoggingService.HandleIntent Service restarted with null intent. Start logging.");
StartLogging();
}
Utilities.LogDebug("GpsLoggingService.HandleIntent Finished");
}
@Override
@ -413,6 +484,7 @@ public class GpsLoggingService extends Service implements IActionListener
closeLoggers();
Session.setStarted(false);
StopGpsManager();
// Email log file before setting location info to null
AutoSendLogFileOnStop();
CancelAlarm();
@ -421,7 +493,6 @@ public class GpsLoggingService extends Service implements IActionListener
RemoveNotification();
StopAlarm();
StopGpsManager();
StopMainActivity();
}
@ -511,7 +582,7 @@ public class GpsLoggingService extends Service implements IActionListener
{
Utilities.LogDebug("GpsLoggingService.StartGpsManager");
GetPreferences();
// GetPreferences(); **** Preferences are updated in HandleIntent function ****
if (gpsLocationListener == null)
{
@ -534,7 +605,7 @@ public class GpsLoggingService extends Service implements IActionListener
Utilities.LogInfo("Requesting GPS location updates");
// gps satellite based
gpsLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
500, 0,
GPS_LOCATION_REQ_TIMEOUT, 0,
gpsLocationListener);
gpsLocationManager.addGpsStatusListener(gpsLocationListener);
@ -583,19 +654,19 @@ public class GpsLoggingService extends Service implements IActionListener
Utilities.LogDebug("GpsLoggingService.StopGpsManager");
if (towerLocationListener != null)
if ( (towerLocationListener != null) && (towerLocationManager != null) )
{
Utilities.LogDebug("Removing towerLocationManager updates");
towerLocationManager.removeUpdates(towerLocationListener);
}
if (gpsLocationListener != null)
if ( (gpsLocationListener != null) && (gpsLocationManager != null) )
{
Utilities.LogDebug("Removing gpsLocationManager updates");
gpsLocationManager.removeUpdates(gpsLocationListener);
gpsLocationManager.removeGpsStatusListener(gpsLocationListener);
gpsLocationManager.removeUpdates(gpsLocationListener);
gpsLocationManager.removeGpsStatusListener(gpsLocationListener);
}
Session.setWaitingForAlarm(false);
SetStatus(getString(R.string.stopped));
}
@ -678,7 +749,7 @@ public class GpsLoggingService extends Service implements IActionListener
}
/**
* Notifies main form that logging has stopped
* Notifies main form that logging has stopped (change interface status)
*/
void StopMainActivity()
{
@ -718,14 +789,19 @@ public class GpsLoggingService extends Service implements IActionListener
return;
}
Utilities.LogDebug("GpsLoggingService.OnLocationChanged");
if (Session.isWaitingForAlarm())
{
Utilities.LogDebug("OnLocationChanged called, but next alarm time is not arrived");
return;
}
Utilities.LogDebug("GpsLoggingService.OnLocationChanged");
long currentTimeStamp = System.currentTimeMillis();
// Wait some time even on 0 frequency so that the UI doesn't lock up
if ((currentTimeStamp - Session.getLatestTimeStamp()) < 300)
if ((currentTimeStamp - Session.getLatestTimeStamp()) < ON_LOCATION_CHANGED_MIN_FREQ)
{
return;
}
@ -760,7 +836,7 @@ public class GpsLoggingService extends Service implements IActionListener
SetDistanceTraveled(loc);
Notify();
WriteToFile(loc);
GetPreferences();
// GetPreferences(); **** Preferences will be updated in HandleIntent function ****
if (IsMainFormVisible()) mainServiceClient.OnLocationUpdate(loc);
}
StopManagerAndResetAlarm();
@ -782,7 +858,7 @@ public class GpsLoggingService extends Service implements IActionListener
private long GetNextAlarmTime() {
List<IFileLogger> loggers = Session.getFileLoggers();
long NextAlarmTime=500; // Minimum alarm time
long NextAlarmTime=NEXT_ALARM_TIME_MIN; // Minimum alarm time
List<Long> nats = new ArrayList<Long>();
long nat=0;
long systime = System.currentTimeMillis();
@ -856,21 +932,35 @@ public class GpsLoggingService extends Service implements IActionListener
Utilities.LogDebug("GpsLoggingService.SetAlarmForNextPoint");
long systime = System.currentTimeMillis();
long nextalarm = GetNextAlarmTime();
Utilities.LogDebug("Systime:" +String.valueOf(systime) + "; Got nextalarm time:" + String.valueOf(nextalarm));
if(nextalarm <= NEXT_ALARM_TIME_MIN) { // Do not cancel/set alarm if we need to log immediately
Utilities.LogDebug("nextalarm is in near future, going to log a point");
if( !AppSettings.shouldkeepFix() )
{
StartGpsManager();
}
return; // The next point will be logged on next position update
}
Intent i = new Intent(this, GpsLoggingService.class);
i.putExtra("getnextpoint", true);
PendingIntent pi = PendingIntent.getService(this, 0, i, 0);
nextPointAlarmManager.cancel(pi);
// long realtime = SystemClock.elapsedRealtime();
long systime = System.currentTimeMillis();
long nextalarm = GetNextAlarmTime();
Utilities.LogDebug("Systime:" +String.valueOf(systime) + "; Got nextalarm time:" + String.valueOf(nextalarm));
// nextPointAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,
// realtime + nextalarm, pi);
PendingIntent pi = PendingIntent.getService(this, 0, i, PendingIntent.FLAG_UPDATE_CURRENT); // Last argument was 0
nextPointAlarmManager.cancel(pi); // Probably not needed as it will be cancelled by the 'set' method
Utilities.LogDebug("Old alarm cancelled, setting next alarm");
nextPointAlarmManager.set(AlarmManager.RTC_WAKEUP,
systime + nextalarm, pi);
Session.setWaitingForAlarm(true);
}
private void SetAlarmForNextPoint(int retryInterval)
@ -882,12 +972,14 @@ public class GpsLoggingService extends Service implements IActionListener
i.putExtra("getnextpoint", true);
PendingIntent pi = PendingIntent.getService(this, 0, i, 0);
PendingIntent pi = PendingIntent.getService(this, 0, i, PendingIntent.FLAG_UPDATE_CURRENT); // Last argument was 0
nextPointAlarmManager.cancel(pi);
nextPointAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,
SystemClock.elapsedRealtime() + retryInterval * 1000, pi);
Session.setWaitingForAlarm(true);
}
private void closeLoggers(){

121
GPSLogger/src/main/java/com/mendhak/gpslogger/GpsMainActivity.java

@ -20,6 +20,8 @@
package com.mendhak.gpslogger;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.ActivityManager.RunningServiceInfo;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.*;
@ -73,6 +75,8 @@ public class GpsMainActivity extends SherlockFragmentActivity implements OnCheck
private PrefsIO prefsio;
private final int DIALOG_CHOOSE_FILE = 103;
public final static String CONF_DATA = "CONF_DATA_STRING";
/**
* Provides a connection to the GPS Logging Service
*/
@ -81,6 +85,7 @@ public class GpsMainActivity extends SherlockFragmentActivity implements OnCheck
@Override
public void onServiceDisconnected(ComponentName name)
{
Utilities.LogDebug("Service disconnected");
loggingService = null;
}
@ -89,7 +94,7 @@ public class GpsMainActivity extends SherlockFragmentActivity implements OnCheck
{
loggingService = ((GpsLoggingService.GpsLoggingBinder) service).getService();
GpsLoggingService.SetServiceClient(GpsMainActivity.this);
Utilities.LogDebug("Service successfully connected");
if (Session.isStarted())
{
SetMainButtonChecked(true);
@ -114,18 +119,42 @@ public class GpsMainActivity extends SherlockFragmentActivity implements OnCheck
super.onCreate(savedInstanceState);
Utilities.LogInfo("GPSLogger started");
Utilities.LogInfo("GPSLogger activity created");
setContentView(R.layout.main_fragment);
// Moved to onResume to update the list of loggers
//GetPreferences();
Intent iin= getIntent();
Bundle ext = iin.getExtras();
String confImport = "";
StartAndBindService();
if(ext!=null)
{
confImport = ext.getString(CONF_DATA);
if(confImport!=null) Utilities.LogInfo("Got string to import configuration data");
else confImport="";
}
path = Environment.getExternalStorageDirectory() + File.separator + "GPSLogger";
prefsio=new PrefsIO(this, PreferenceManager.getDefaultSharedPreferences(this), "gpslogger", path);
this.registerReceiver(this.batteryInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
// serviceIntent = new Intent(this, GpsLoggingService.class);
if(confImport.length() > 1) prefsio.ImportString(confImport);
}
@Override
protected void onNewIntent(Intent iin)
{
Bundle ext = iin.getExtras();
String confImport = "";
if(ext!=null)
{
confImport = ext.getString(CONF_DATA);
if(confImport!=null) {
Utilities.LogInfo("Got string to import configuration data");
prefsio.ImportString(confImport);
}
}
}
@Override
@ -133,7 +162,6 @@ public class GpsMainActivity extends SherlockFragmentActivity implements OnCheck
{
Utilities.LogDebug("GpsMainActivity.onStart");
super.onStart();
StartAndBindService();
}
@Override
@ -292,10 +320,29 @@ public class GpsMainActivity extends SherlockFragmentActivity implements OnCheck
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if( (requestCode==prefsio.ACTIVITY_CHOOSE_FILE) && (resultCode == RESULT_OK) ) {
Uri uri = data.getData();
String str=uri.getPath();
prefsio.SetCurFileName(str);
prefsio.ImportFile();
Intent intent = new Intent(this, ConfImportActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.setData(uri);
startActivity(intent);
// String str=uri.getPath();
// prefsio.SetCurFileName(str);
// prefsio.ImportFile();
}
}
private boolean isBatteryLow() {
Intent intent = this.registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
int plugged= intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, 0);
if(plugged!=0) return false;
int level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, 0);
int scale = intent.getIntExtra(BatteryManager.EXTRA_SCALE, 100);
int percent = (level*100)/scale;
if(percent<=AppSettings.getCritBattLevel()) {
Utilities.LogDebug("Cannot start logging - battery level equal or below critical");
return true;
}
return false;
}
private BroadcastReceiver batteryInfoReceiver = new BroadcastReceiver() {
@ -315,7 +362,7 @@ public class GpsMainActivity extends SherlockFragmentActivity implements OnCheck
SetMainButtonChecked(false);
// ShowPreferencesSummary();
loggingService.stopSelf();
loggingService.SetStatus(getString(R.string.stopped));
loggingService.SetStatus(getString(R.string.stopped_low_batt));
}
}
}
@ -327,11 +374,27 @@ public class GpsMainActivity extends SherlockFragmentActivity implements OnCheck
{
Utilities.LogDebug("StartAndBindService - binding now");
serviceIntent = new Intent(this, GpsLoggingService.class);
// Start the service in case it isn't already running
startService(serviceIntent);
if(!isServiceRunning(GpsLoggingService.class))
{
// Start the service in case it isn't already running
Utilities.LogDebug("Trying to start service");
startService(serviceIntent);
Session.setBoundToService(false);
}
else {
Utilities.LogDebug("Seems that the service is already running");
if (Session.isBoundToService() && (loggingService != null)) return;
else {
Utilities.LogDebug("Seems that the service is running but not bound");
// StopAndUnbindServiceIfRequired();
}
}
// Now bind to service
bindService(serviceIntent, gpsServiceConnection, Context.BIND_AUTO_CREATE);
Session.setBoundToService(true);
Utilities.LogDebug("Trying to bind to service");
if(bindService(serviceIntent, gpsServiceConnection, Context.BIND_AUTO_CREATE)) {
Utilities.LogDebug("Successfully bound to service");
Session.setBoundToService(true);
}
}
/**
@ -347,7 +410,8 @@ public class GpsMainActivity extends SherlockFragmentActivity implements OnCheck
Session.setBoundToService(false);
}
if (!Session.isStarted())
// if (!Session.isStarted())
if(isServiceRunning(GpsLoggingService.class))
{
Utilities.LogDebug("StopServiceIfRequired - Stopping the service");
//serviceIntent = new Intent(this, GpsLoggingService.class);
@ -355,12 +419,22 @@ public class GpsMainActivity extends SherlockFragmentActivity implements OnCheck
}
}
private boolean isServiceRunning(Class<?> serviceClass) {
ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
if (serviceClass.getName().equals(service.service.getClassName())) {
return true;
}
}
return false;
}
@Override
protected void onPause()
{
Utilities.LogDebug("GpsMainActivity.onPause");
StopAndUnbindServiceIfRequired();
// StopAndUnbindServiceIfRequired();
super.onPause();
}
@ -382,13 +456,20 @@ public class GpsMainActivity extends SherlockFragmentActivity implements OnCheck
{
Utilities.LogDebug("GpsMainActivity.onCheckedChanged");
if (isChecked)
if (isChecked) // Start
{
GetPreferences();
loggingService.SetupAutoSendTimers();
loggingService.StartLogging();
if(!isBatteryLow()) {
loggingService.SetupAutoSendTimers();
loggingService.StartLogging();
}
else {
SetMainButtonChecked(false);
loggingService.SetStatus(getString(R.string.stopped_low_batt));
Toast.makeText(this, R.string.stopped_low_batt, Toast.LENGTH_LONG).show();
}
}
else
else // Stop
{
loggingService.StopLogging();
ShowPreferencesSummary();

6
GPSLogger/src/main/java/com/mendhak/gpslogger/GpsSettingsActivity.java

@ -410,7 +410,7 @@ public class GpsSettingsActivity extends SherlockPreferenceActivity
if (chkLog_opengts.isChecked() && !opengts_enabled)
{
startActivity(new Intent("com.mendhak.gpslogger.OPENGTS_SETUP"));
startActivity(new Intent("net.kataplop.gpslogger.OPENGTS_SETUP"));
}
return true;