diff --git a/.hgignore b/.hgignore
index ffa8823b5..8bd036659 100644
--- a/.hgignore
+++ b/.hgignore
@@ -4,7 +4,7 @@ syntax:glob
*/gen/**
*/proguard/**
.metadata
-MyTracksTest/annotations.log
+MyTracksTest/AnnotationProcessor.log
**/*.pyc
**/*.pyo
syntax: glob
diff --git a/MyTracks/src/com/google/android/apps/mytracks/io/docs/DocsHelper.java b/MyTracks/src/com/google/android/apps/mytracks/io/docs/DocsHelper.java
index 101fd9256..f423e85c8 100644
--- a/MyTracks/src/com/google/android/apps/mytracks/io/docs/DocsHelper.java
+++ b/MyTracks/src/com/google/android/apps/mytracks/io/docs/DocsHelper.java
@@ -275,7 +275,6 @@ public class DocsHelper {
public void addTrackRow(Context context, AuthManager trixAuth,
String spreadsheetId, String worksheetId, Track track,
boolean metricUnits) throws IOException {
-
String worksheetUri = String.format(DOCS_SPREADSHEET_URL_FORMAT,
spreadsheetId, worksheetId);
TripStatistics stats = track.getStatistics();
@@ -287,16 +286,11 @@ public class DocsHelper {
String elevationUnit = context.getString(metricUnits ?
R.string.meter : R.string.feet);
- java.text.DateFormat dateFormat = DateFormat.getDateFormat(context);
- java.text.DateFormat timeFormat = DateFormat.getTimeFormat(context);
- Date startTime = new Date(stats.getStartTime());
- String dateString = dateFormat.format(startTime) + " " + timeFormat.format(startTime);
-
// Prepare the Post-Text we are going to send.
DocsTagBuilder tagBuilder = new DocsTagBuilder(metricUnits)
.append("name", track.getName())
.append("description", track.getDescription())
- .append("date", dateString)
+ .append("date", getDisplayDate(context, stats.getStartTime()))
.append("totaltime", StringUtils.formatTimeAlwaysShowingHours(
stats.getTotalTime()))
.append("movingtime", StringUtils.formatTimeAlwaysShowingHours(
@@ -336,6 +330,21 @@ public class DocsHelper {
Log.i(Constants.TAG, "Post finished.");
}
+ /**
+ * Gets the display string for a time based on the phone's setting.
+ *
+ * @param context the context to obtain the phone's setting.
+ * @param time the time
+ * @return the display string of the time
+ */
+ protected String getDisplayDate(Context context, long time) {
+ java.text.DateFormat dateFormat = DateFormat.getDateFormat(context);
+ java.text.DateFormat timeFormat = DateFormat.getTimeFormat(context);
+ Date startTime = new Date(time);
+ String dateString = dateFormat.format(startTime) + " " + timeFormat.format(startTime);
+ return dateString;
+ }
+
/**
* Writes spreadsheet row data to the indicated worksheet.
*
diff --git a/MyTracksTest/.classpath b/MyTracksTest/.classpath
index e7b9e07b8..ac429b1c3 100644
--- a/MyTracksTest/.classpath
+++ b/MyTracksTest/.classpath
@@ -3,12 +3,12 @@
-
+
diff --git a/MyTracksTest/.factorypath b/MyTracksTest/.factorypath
index 75ad648ce..5eaac6ca6 100644
--- a/MyTracksTest/.factorypath
+++ b/MyTracksTest/.factorypath
@@ -1,6 +1,7 @@
-
-
-
+
+
+
+
diff --git a/MyTracksTest/.settings/org.eclipse.jdt.apt.core.prefs b/MyTracksTest/.settings/org.eclipse.jdt.apt.core.prefs
index ac3541cd4..527bacd02 100644
--- a/MyTracksTest/.settings/org.eclipse.jdt.apt.core.prefs
+++ b/MyTracksTest/.settings/org.eclipse.jdt.apt.core.prefs
@@ -1,7 +1,7 @@
-#Mon Nov 01 02:42:03 BRST 2010
+#Tue Oct 25 14:08:44 PDT 2011
eclipse.preferences.version=1
org.eclipse.jdt.apt.aptEnabled=true
org.eclipse.jdt.apt.genSrcDir=.apt_generated
-org.eclipse.jdt.apt.processorOptions/bin_dir=%PROJECT.DIR%/bin
-org.eclipse.jdt.apt.processorOptions/logfile=%PROJECT.DIR%/annotations.log
+org.eclipse.jdt.apt.processorOptions/bin_dir=%PROJECT.DIR%/bin/classes
+org.eclipse.jdt.apt.processorOptions/logfile=%PROJECT.DIR%/AnnotationProcessor.log
org.eclipse.jdt.apt.reconcileEnabled=false
diff --git a/MyTracksTest/src/com/google/android/apps/mytracks/io/docs/DocsHelper_AddTrackRowTest.java b/MyTracksTest/src/com/google/android/apps/mytracks/io/docs/DocsHelper_AddTrackRowTest.java
index 7400bcf11..996f77ef5 100644
--- a/MyTracksTest/src/com/google/android/apps/mytracks/io/docs/DocsHelper_AddTrackRowTest.java
+++ b/MyTracksTest/src/com/google/android/apps/mytracks/io/docs/DocsHelper_AddTrackRowTest.java
@@ -40,7 +40,8 @@ import junit.framework.TestCase;
*/
public class DocsHelper_AddTrackRowTest extends TestCase {
private static final long TIME = 1288721514000L;
-
+ private static final DateFormat DATE_FORMAT = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
+
private static class StringWritingDocsHelper extends DocsHelper {
String writtenSheetUri = null;
String writtenData = null;
@@ -52,18 +53,22 @@ public class DocsHelper_AddTrackRowTest extends TestCase {
writtenData = postText;
}
}
-
+
public void testAddTrackRow_imperial() throws Exception {
- StringWritingDocsHelper docsHelper = new StringWritingDocsHelper();
+ StringWritingDocsHelper docsHelper = new StringWritingDocsHelper() {
+ @Override
+ protected String getDisplayDate(Context context, long time) {
+ return DATE_FORMAT.format(new Date(TIME));
+ }
+ };
addTrackRow(docsHelper, false);
-
- DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
+
String expectedData =
""
+ ""
+ ""
- + ""
+ + ""
+ ""
+ ""
+ ""
@@ -89,7 +94,12 @@ public class DocsHelper_AddTrackRowTest extends TestCase {
}
public void testAddTrackRow_metric() throws Exception {
- StringWritingDocsHelper docsHelper = new StringWritingDocsHelper();
+ StringWritingDocsHelper docsHelper = new StringWritingDocsHelper() {
+ @Override
+ protected String getDisplayDate(Context context, long time) {
+ return DATE_FORMAT.format(new Date(TIME));
+ }
+ };
addTrackRow(docsHelper, true);
// The imperial test verifies that the tags come out in the proper order,
diff --git a/SignalStrengthSamplerTest/.classpath b/SignalStrengthSamplerTest/.classpath
index ea6042d8c..1af117a86 100644
--- a/SignalStrengthSamplerTest/.classpath
+++ b/SignalStrengthSamplerTest/.classpath
@@ -3,7 +3,7 @@
-
+
diff --git a/SignalStrengthSamplerTest/libs/AndroidMockGenerator.jar b/SignalStrengthSamplerTest/libs/AndroidMockGenerator.jar
new file mode 100644
index 000000000..ef8b3612c
Binary files /dev/null and b/SignalStrengthSamplerTest/libs/AndroidMockGenerator.jar differ