() {
@Override
public void query(HttpTransport client)
@@ -672,7 +671,7 @@ public class SendToFusionTables implements Runnable {
isc.inputStream = new ByteArrayInputStream(Strings.toBytesUtf8(sql));
request.content = isc;
- Log.d(MyTracksConstants.TAG, "Running update query " + url.toString() + ": " + sql);
+ Log.d(Constants.TAG, "Running update query " + url.toString() + ": " + sql);
HttpResponse response;
try {
response = request.execute();
@@ -687,12 +686,12 @@ public class SendToFusionTables implements Runnable {
String[] lines = s.split(Strings.LINE_SEPARATOR);
if (lines[0].equals("tableid")) {
tableId = lines[1];
- Log.d(MyTracksConstants.TAG, "tableId = " + tableId);
+ Log.d(Constants.TAG, "tableId = " + tableId);
} else {
- Log.w(MyTracksConstants.TAG, "Unrecognized response: " + lines[0]);
+ Log.w(Constants.TAG, "Unrecognized response: " + lines[0]);
}
} else {
- Log.d(MyTracksConstants.TAG, "Query failed: " + response.statusMessage + " (" +
+ Log.d(Constants.TAG, "Query failed: " + response.statusMessage + " (" +
response.statusCode + ")");
throw new GDataWrapper.HttpException(response.statusCode, response.statusMessage);
}
diff --git a/MyTracks/src/com/google/android/apps/mytracks/io/SendToMyMaps.java b/MyTracks/src/com/google/android/apps/mytracks/io/SendToMyMaps.java
index 542606426..4145f3a6f 100644
--- a/MyTracks/src/com/google/android/apps/mytracks/io/SendToMyMaps.java
+++ b/MyTracks/src/com/google/android/apps/mytracks/io/SendToMyMaps.java
@@ -15,14 +15,14 @@
*/
package com.google.android.apps.mytracks.io;
-import com.google.android.apps.mytracks.MyTracksConstants;
+import static com.google.android.apps.mytracks.Constants.TAG;
+import com.google.android.apps.mytracks.Constants;
import com.google.android.apps.mytracks.MyTracksSettings;
import com.google.android.apps.mytracks.ProgressIndicator;
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
import com.google.android.apps.mytracks.content.Track;
import com.google.android.apps.mytracks.content.Waypoint;
import com.google.android.apps.mytracks.io.mymaps.MapsFacade;
-import com.google.android.apps.mytracks.io.mymaps.MapsFacade.WaypointData;
import com.google.android.apps.mytracks.stats.DoubleBuffer;
import com.google.android.apps.mytracks.stats.TripStatistics;
import com.google.android.apps.mytracks.util.MyTracksUtils;
@@ -93,7 +93,7 @@ public class SendToMyMaps implements Runnable {
@Override
public void run() {
- Log.d(MyTracksConstants.TAG, "Sending to MyMaps: trackId = " + trackId);
+ Log.d(TAG, "Sending to MyMaps: trackId = " + trackId);
doUpload();
}
@@ -111,7 +111,7 @@ public class SendToMyMaps implements Runnable {
track.setDescription("" + track.getDescription() + "
"
+ stringUtils.generateTrackDescription(track, null, null) + "
");
- mapsClient = MyMapsFactory.newMapsClient(context, auth);
+ mapsClient = new MapsFacade(context, auth);
// Create a new map if necessary:
boolean isNewMap = mapId.equals(NEW_MAP_ID);
@@ -142,17 +142,16 @@ public class SendToMyMaps implements Runnable {
if (success) {
Cursor c = providerUtils.getWaypointsCursor(
track.getId(), 0,
- MyTracksConstants.MAX_LOADED_WAYPOINTS_POINTS);
+ Constants.MAX_LOADED_WAYPOINTS_POINTS);
if (c != null) {
try {
if (c.getCount() > 1 && c.moveToFirst()) {
// This will skip the 1st waypoint (it carries the stats for the
// last segment).
- ArrayList waypoints = new ArrayList(c.getCount() - 1);
+ ArrayList waypoints = new ArrayList(c.getCount() - 1);
while (c.moveToNext()) {
Waypoint wpt = providerUtils.createWaypoint(c);
- waypoints.add(new WaypointData(
- wpt.getName(), wpt.getDescription(), wpt.getIcon(), wpt.getLocation()));
+ waypoints.add(wpt);
}
success = mapsClient.uploadWaypoints(mapId, waypoints);
@@ -165,8 +164,7 @@ public class SendToMyMaps implements Runnable {
}
if (!success) {
- Log.w(MyTracksConstants.TAG,
- "SendToMyMaps: upload waypoints failed.");
+ Log.w(TAG, "SendToMyMaps: upload waypoints failed.");
}
}
@@ -175,7 +173,7 @@ public class SendToMyMaps implements Runnable {
? R.string.status_new_mymap_has_been_created
: R.string.status_tracks_have_been_uploaded;
}
- Log.d(MyTracksConstants.TAG, "SendToMyMaps: Done: " + success);
+ Log.d(TAG, "SendToMyMaps: Done: " + success);
progressIndicator.setProgressValue(100);
} finally {
if (mapsClient != null) {
@@ -210,7 +208,7 @@ public class SendToMyMaps implements Runnable {
providerUtils.getLocationsCursor(track.getId(), 0, -1, false);
try {
if (!locationsCursor.moveToFirst()) {
- Log.w(MyTracksConstants.TAG, "Unable to get any points to upload");
+ Log.w(TAG, "Unable to get any points to upload");
return false;
}
@@ -223,7 +221,7 @@ public class SendToMyMaps implements Runnable {
// Limit the number of elevation readings. Ideally we would want around 250.
int elevationSamplingFrequency =
Math.max(1, (int) (totalLocations / 250.0));
- Log.d(MyTracksConstants.TAG,
+ Log.d(TAG,
"Using elevation sampling factor: " + elevationSamplingFrequency
+ " on " + totalLocations);
double totalDistance = 0;
@@ -231,7 +229,7 @@ public class SendToMyMaps implements Runnable {
Vector distances = new Vector();
Vector elevations = new Vector();
DoubleBuffer elevationBuffer =
- new DoubleBuffer(MyTracksConstants.ELEVATION_SMOOTHING_FACTOR);
+ new DoubleBuffer(Constants.ELEVATION_SMOOTHING_FACTOR);
List locations = new ArrayList(MAX_POINTS_PER_UPLOAD);
progressIndicator.setProgressMessage(
@@ -312,7 +310,7 @@ public class SendToMyMaps implements Runnable {
int numLocations = locations.size();
if (numLocations < 2) {
- Log.d(MyTracksConstants.TAG, "Not preparing/uploading too few points");
+ Log.d(TAG, "Not preparing/uploading too few points");
totalLocationsUploaded += numLocations;
return true;
}
@@ -330,16 +328,16 @@ public class SendToMyMaps implements Runnable {
context.getString(R.string.part), totalSegmentsUploaded));
}
totalSegmentsUploaded++;
- Log.d(MyTracksConstants.TAG,
+ Log.d(TAG,
"SendToMyMaps: Prepared feature for upload w/ "
+ splitTrack.getLocations().size() + " points.");
// Transmit tracks via GData feed:
// -------------------------------
- Log.d(MyTracksConstants.TAG,
+ Log.d(TAG,
"SendToMyMaps: Uploading to map " + mapId + " w/ auth " + auth);
if (!mapsClient.uploadTrackPoints(mapId, splitTrack.getName(), splitTrack.getLocations())) {
- Log.e(MyTracksConstants.TAG, "Uploading failed");
+ Log.e(TAG, "Uploading failed");
return false;
}
}
@@ -385,7 +383,7 @@ public class SendToMyMaps implements Runnable {
// Close up the last segment.
prepareTrackSegment(segment, splitTracks);
- Log.d(MyTracksConstants.TAG,
+ Log.d(TAG,
"MyTracksSendToMyMaps: Starting new track segment...");
startNewTrackSegment = false;
segment = new Track();
diff --git a/MyTracks/src/com/google/android/apps/mytracks/io/TcxTrackWriter.java b/MyTracks/src/com/google/android/apps/mytracks/io/TcxTrackWriter.java
index dfd3513ad..cf965b4c6 100644
--- a/MyTracks/src/com/google/android/apps/mytracks/io/TcxTrackWriter.java
+++ b/MyTracks/src/com/google/android/apps/mytracks/io/TcxTrackWriter.java
@@ -1,12 +1,12 @@
/*
* Copyright 2010 Google Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -17,11 +17,13 @@ package com.google.android.apps.mytracks.io;
import com.google.android.apps.mytracks.content.MyTracksLocation;
import com.google.android.apps.mytracks.content.Sensor;
+import com.google.android.apps.mytracks.content.Sensor.SensorDataSet;
import com.google.android.apps.mytracks.content.Track;
import com.google.android.apps.mytracks.content.Waypoint;
-import com.google.android.apps.mytracks.content.Sensor.SensorDataSet;
import com.google.android.apps.mytracks.io.TrackWriterFactory.TrackFileFormat;
+import com.google.android.apps.mytracks.util.MyTracksUtils;
+import android.content.Context;
import android.location.Location;
import android.os.Build;
@@ -30,6 +32,7 @@ import java.io.PrintWriter;
import java.nio.charset.Charset;
import java.text.SimpleDateFormat;
import java.util.Date;
+import java.util.Locale;
import java.util.TimeZone;
/**
@@ -37,20 +40,35 @@ import java.util.TimeZone;
* As defined by:
* http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2
*
+ * The TCX file written by this class has been verified as compatible with
+ * Garmin Training Center 3.5.3.
+ *
* @author Sandor Dornbush
*/
public class TcxTrackWriter implements TrackFormatWriter {
+ protected static final String TIMESTAMP_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'";
+
+ // These are the only sports allowed by the TCX v2 specification for fields
+ // of type Sport_t.
+ private static final String TCX_SPORT_BIKING = "Biking";
+ private static final String TCX_SPORT_RUNNING = "Running";
+ private static final String TCX_SPORT_OTHER = "Other";
+
+ // Values for fields of type Build_t/Type.
+ private static final String TCX_TYPE_RELEASE = "Release";
+ private static final String TCX_TYPE_INTERNAL = "Internal";
+
+ private final SimpleDateFormat timestampFormatter;
+ private final Context context;
private PrintWriter pw = null;
private Track track;
- static final SimpleDateFormat TIMESTAMP_FORMAT =
- new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
- static {
- TIMESTAMP_FORMAT.setTimeZone(TimeZone.getTimeZone("UTC"));
- }
+ public TcxTrackWriter(Context context) {
+ this.context = context;
- public TcxTrackWriter() {
+ timestampFormatter = new SimpleDateFormat(TIMESTAMP_FORMAT);
+ timestampFormatter.setTimeZone(TimeZone.getTimeZone("UTC"));
}
@Override
@@ -93,16 +111,13 @@ public class TcxTrackWriter implements TrackFormatWriter {
if (pw == null) {
return;
}
+
+ String startTime = timestampFormatter.format(track.getStatistics().getStartTime());
+
pw.println(" ");
- pw.print(" ");
- pw.print(" ");
- pw.print(TIMESTAMP_FORMAT.format(track.getStatistics().getStartTime()));
- pw.println("");
- pw.println(" ");
+ pw.format(" \n", categoryToTcxSport(track.getCategory()));
+ pw.format(" %s\n", startTime);
+ pw.format(" \n", startTime);
pw.print(" ");
pw.print(track.getStatistics().getTotalTime() / 1000);
pw.println("");
@@ -113,7 +128,7 @@ public class TcxTrackWriter implements TrackFormatWriter {
// Calories are a required element just put in 0.
pw.print("0");
pw.println("Active");
- pw.println("Manual)");
+ pw.println("Manual");
}
@Override
@@ -130,7 +145,7 @@ public class TcxTrackWriter implements TrackFormatWriter {
}
pw.println(" ");
Date d = new Date(location.getTime());
- pw.println(" ");
+ pw.println(" ");
pw.println(" ");
pw.print(" ");
@@ -194,10 +209,18 @@ public class TcxTrackWriter implements TrackFormatWriter {
}
pw.println(" ");
pw.print(" ");
- pw.print("");
- pw.print(Build.MODEL);
- pw.print("");
- pw.println(")");
+ pw.format("%s\n", Build.MODEL);
+
+ // The following code is correct. ID is inconsistently capitalized in the
+ // TCX schema.
+ pw.println("0");
+ pw.println("0");
+
+ pw.println("");
+ pw.println("0");
+ pw.println("0");
+ pw.println("");
+ pw.println("");
pw.println(" ");
pw.println(" ");
}
@@ -207,8 +230,31 @@ public class TcxTrackWriter implements TrackFormatWriter {
if (pw == null) {
return;
}
- pw.print(" ");
- pw.print("My Tracks by Google");
+ pw.println(" ");
+
+ // We put the version in the name because there isn't a better place for
+ // it. The TCX schema tightly defined the Version tag, so we can't put it
+ // there. They've similarly constrained the PartNumber tag, so it can't go
+ // there either.
+ pw.format("My Tracks %s by Google\n", MyTracksUtils.getMyTracksVersion(context));
+
+ pw.println("");
+
+ // The TCX spec for the Version tag is too strict to allow us to use our
+ // user-visible version number, so we use our version code instead. We
+ // also set the minor version to 1 if this is a development build to
+ // signify that this build is newer than the one associated with the
+ // version code given in VersionMajor.
+ pw.println("");
+ pw.format("%d\n", MyTracksUtils.getMyTracksVersion(context));
+ pw.format("%d\n", MyTracksUtils.isRelease(context) ? 0 : 1);
+ pw.println("");
+
+ pw.format("%s\n", MyTracksUtils.isRelease(context) ? TCX_TYPE_RELEASE
+ : TCX_TYPE_INTERNAL);
+ pw.println("");
+ pw.format("%s\n", Locale.getDefault().getLanguage());
+ pw.println("000-00000-00");
pw.println("");
pw.println("");
}
@@ -217,4 +263,15 @@ public class TcxTrackWriter implements TrackFormatWriter {
public void writeWaypoint(Waypoint waypoint) {
// TODO Write out the waypoints somewhere.
}
+
+ private String categoryToTcxSport(String category) {
+ category = category.trim();
+ if (category.equalsIgnoreCase(TCX_SPORT_RUNNING)) {
+ return TCX_SPORT_RUNNING;
+ } else if (category.equalsIgnoreCase(TCX_SPORT_BIKING)) {
+ return TCX_SPORT_BIKING;
+ } else {
+ return TCX_SPORT_OTHER;
+ }
+ }
}
diff --git a/MyTracks/src/com/google/android/apps/mytracks/io/TrackWriter.java b/MyTracks/src/com/google/android/apps/mytracks/io/TrackWriter.java
index 26fb19f87..c18788572 100644
--- a/MyTracks/src/com/google/android/apps/mytracks/io/TrackWriter.java
+++ b/MyTracks/src/com/google/android/apps/mytracks/io/TrackWriter.java
@@ -15,7 +15,7 @@
*/
package com.google.android.apps.mytracks.io;
-import com.google.android.apps.mytracks.MyTracksConstants;
+import com.google.android.apps.mytracks.Constants;
import com.google.android.apps.mytracks.content.MyTracksLocation;
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
import com.google.android.apps.mytracks.content.Track;
@@ -160,16 +160,16 @@ public class TrackWriter {
String fileName = fileUtils.buildUniqueFileName(
directory, track.getName(), writer.getExtension());
if (fileName == null) {
- Log.e(MyTracksConstants.TAG,
+ Log.e(Constants.TAG,
"Unable to get a unique filename for " + fileName);
return false;
}
- Log.i(MyTracksConstants.TAG, "Writing track to: " + fileName);
+ Log.i(Constants.TAG, "Writing track to: " + fileName);
try {
writer.prepare(track, newOutputStream(fileName));
} catch (FileNotFoundException e) {
- Log.e(MyTracksConstants.TAG, "Failed to open output file.", e);
+ Log.e(Constants.TAG, "Failed to open output file.", e);
errorMessage = R.string.io_write_failed;
return false;
}
@@ -187,12 +187,12 @@ public class TrackWriter {
}
if (!fileUtils.isSdCardAvailable()) {
- Log.i(MyTracksConstants.TAG, "Could not find SD card.");
+ Log.i(Constants.TAG, "Could not find SD card.");
errorMessage = R.string.io_no_external_storage_found;
return false;
}
if (!fileUtils.ensureDirectoryExists(directory)) {
- Log.i(MyTracksConstants.TAG, "Could not create export directory.");
+ Log.i(Constants.TAG, "Could not create export directory.");
errorMessage = R.string.io_create_dir_failed;
return false;
}
@@ -230,7 +230,7 @@ public class TrackWriter {
// same time.
Cursor cursor = null;
cursor = providerUtils.getWaypointsCursor(trackId, 0,
- MyTracksConstants.MAX_LOADED_WAYPOINTS_POINTS);
+ Constants.MAX_LOADED_WAYPOINTS_POINTS);
if (cursor != null) {
try {
if (cursor.moveToFirst()) {
@@ -253,14 +253,14 @@ public class TrackWriter {
* Does the actual work of writing the track to the now open file.
*/
void writeDocument() {
- Log.d(MyTracksConstants.TAG, "Started writing track.");
+ Log.d(Constants.TAG, "Started writing track.");
writer.writeHeader();
writeWaypoints(track.getId());
writeLocations();
writer.writeFooter();
writer.close();
success = true;
- Log.d(MyTracksConstants.TAG, "Done writing track.");
+ Log.d(Constants.TAG, "Done writing track.");
errorMessage = R.string.io_write_finished;
}
@@ -296,7 +296,7 @@ public class TrackWriter {
locationFactory);
try {
if (!it.hasNext()) {
- Log.w(MyTracksConstants.TAG, "Unable to get any points to write");
+ Log.w(Constants.TAG, "Unable to get any points to write");
return;
}
while (it.hasNext()) {
diff --git a/MyTracks/src/com/google/android/apps/mytracks/io/TrackWriterFactory.java b/MyTracks/src/com/google/android/apps/mytracks/io/TrackWriterFactory.java
index 55261f8a5..785454b0b 100644
--- a/MyTracks/src/com/google/android/apps/mytracks/io/TrackWriterFactory.java
+++ b/MyTracks/src/com/google/android/apps/mytracks/io/TrackWriterFactory.java
@@ -1,12 +1,12 @@
/*
* Copyright 2010 Google Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -53,7 +53,7 @@ public class TrackWriterFactory {
TCX {
@Override
public TrackFormatWriter newFormatWriter(Context context) {
- return new TcxTrackWriter();
+ return new TcxTrackWriter(context);
}
};
diff --git a/MyTracks/src/com/google/android/apps/mytracks/io/backup/BackupActivityHelper.java b/MyTracks/src/com/google/android/apps/mytracks/io/backup/BackupActivityHelper.java
index e66cd29d8..0de343479 100644
--- a/MyTracks/src/com/google/android/apps/mytracks/io/backup/BackupActivityHelper.java
+++ b/MyTracks/src/com/google/android/apps/mytracks/io/backup/BackupActivityHelper.java
@@ -16,7 +16,7 @@
package com.google.android.apps.mytracks.io.backup;
import com.google.android.apps.mytracks.MyTracks;
-import com.google.android.apps.mytracks.MyTracksConstants;
+import com.google.android.apps.mytracks.Constants;
import com.google.android.apps.mytracks.util.FileUtils;
import com.google.android.maps.mytracks.R;
@@ -97,7 +97,7 @@ public class BackupActivityHelper {
backup.writeToDefaultFile();
showToast(R.string.io_write_finished);
} catch (IOException e) {
- Log.e(MyTracksConstants.TAG, "Failed to write backup", e);
+ Log.e(Constants.TAG, "Failed to write backup", e);
showToast(R.string.io_write_failed);
} finally {
dismissDialog(progressDialog);
@@ -199,7 +199,7 @@ public class BackupActivityHelper {
backup.restoreFromDate(date);
showToast(R.string.io_read_finished);
} catch (IOException e) {
- Log.e(MyTracksConstants.TAG, "Failed to restore backup", e);
+ Log.e(Constants.TAG, "Failed to restore backup", e);
showToast(R.string.io_read_failed);
} finally {
dismissDialog(progressDialog);
diff --git a/MyTracks/src/com/google/android/apps/mytracks/io/backup/ExternalFileBackup.java b/MyTracks/src/com/google/android/apps/mytracks/io/backup/ExternalFileBackup.java
index cc346e2f7..cde8c1954 100644
--- a/MyTracks/src/com/google/android/apps/mytracks/io/backup/ExternalFileBackup.java
+++ b/MyTracks/src/com/google/android/apps/mytracks/io/backup/ExternalFileBackup.java
@@ -15,7 +15,7 @@
*/
package com.google.android.apps.mytracks.io.backup;
-import com.google.android.apps.mytracks.MyTracksConstants;
+import com.google.android.apps.mytracks.Constants;
import com.google.android.apps.mytracks.MyTracksSettings;
import com.google.android.apps.mytracks.content.TrackPointsColumns;
import com.google.android.apps.mytracks.content.TracksColumns;
@@ -88,7 +88,7 @@ class ExternalFileBackup {
private File getBackupsDirectory(boolean create) {
String dirName = fileUtils.buildExternalDirectoryPath(BACKUPS_SUBDIR);
final File dir = new File(dirName);
- Log.d(MyTracksConstants.TAG, "Dir: " + dir.getAbsolutePath());
+ Log.d(Constants.TAG, "Dir: " + dir.getAbsolutePath());
if (create) {
// Try to create - if that fails, return null
return fileUtils.ensureDirectoryExists(dir) ? dir : null;
@@ -147,7 +147,7 @@ class ExternalFileBackup {
* Synchronously writes a backup to the given file.
*/
private void writeToFile(File outputFile) throws IOException {
- Log.d(MyTracksConstants.TAG,
+ Log.d(Constants.TAG,
"Writing backup to file " + outputFile.getAbsolutePath());
// Create all the auxiliary classes that will do the writing
@@ -219,7 +219,7 @@ class ExternalFileBackup {
* Synchronously restores the backup from the given file.
*/
private void restoreFromFile(File inputFile) throws IOException {
- Log.d(MyTracksConstants.TAG,
+ Log.d(Constants.TAG,
"Restoring from file " + inputFile.getAbsolutePath());
PreferenceBackupHelper preferencesHelper = new PreferenceBackupHelper();
diff --git a/MyTracks/src/com/google/android/apps/mytracks/io/backup/MyTracksBackupAgent.java b/MyTracks/src/com/google/android/apps/mytracks/io/backup/MyTracksBackupAgent.java
index f9bb2f352..729e0125f 100644
--- a/MyTracks/src/com/google/android/apps/mytracks/io/backup/MyTracksBackupAgent.java
+++ b/MyTracks/src/com/google/android/apps/mytracks/io/backup/MyTracksBackupAgent.java
@@ -15,7 +15,7 @@
*/
package com.google.android.apps.mytracks.io.backup;
-import com.google.android.apps.mytracks.MyTracksConstants;
+import com.google.android.apps.mytracks.Constants;
import com.google.android.apps.mytracks.MyTracksSettings;
import android.app.backup.BackupAgent;
@@ -40,12 +40,12 @@ public class MyTracksBackupAgent extends BackupAgent {
@Override
public void onBackup(ParcelFileDescriptor oldState, BackupDataOutput data,
ParcelFileDescriptor newState) throws IOException {
- Log.i(MyTracksConstants.TAG, "Performing backup");
+ Log.i(Constants.TAG, "Performing backup");
SharedPreferences preferences = this.getSharedPreferences(
MyTracksSettings.SETTINGS_NAME, 0);
backupPreferences(data, preferences);
- Log.i(MyTracksConstants.TAG, "Backup complete");
+ Log.i(Constants.TAG, "Backup complete");
}
private void backupPreferences(BackupDataOutput data,
@@ -63,18 +63,18 @@ public class MyTracksBackupAgent extends BackupAgent {
@Override
public void onRestore(BackupDataInput data, int appVersionCode,
ParcelFileDescriptor newState) throws IOException {
- Log.i(MyTracksConstants.TAG, "Restoring from backup");
+ Log.i(Constants.TAG, "Restoring from backup");
while (data.readNextHeader()) {
String key = data.getKey();
- Log.d(MyTracksConstants.TAG, "Restoring entity " + key);
+ Log.d(Constants.TAG, "Restoring entity " + key);
if (key.equals(PREFERENCES_ENTITY)) {
restorePreferences(data);
} else {
- Log.e(MyTracksConstants.TAG, "Found unknown backup entity: " + key);
+ Log.e(Constants.TAG, "Found unknown backup entity: " + key);
data.skipEntityData();
}
}
- Log.i(MyTracksConstants.TAG, "Done restoring from backup");
+ Log.i(Constants.TAG, "Done restoring from backup");
}
/**
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 e46a2573d..ce9752f39 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
@@ -15,7 +15,7 @@
*/
package com.google.android.apps.mytracks.io.docs;
-import com.google.android.apps.mytracks.MyTracksConstants;
+import com.google.android.apps.mytracks.Constants;
import com.google.android.apps.mytracks.content.Track;
import com.google.android.apps.mytracks.io.AuthManager;
import com.google.android.apps.mytracks.io.gdata.GDataWrapper;
@@ -144,7 +144,7 @@ public class DocsHelper {
String id = result.substring(
idStringStart + DOCS_SPREADSHEET_URL.length(), idTagCloseIndex);
- Log.i(MyTracksConstants.TAG, "Created new spreadsheet: " + id);
+ Log.i(Constants.TAG, "Created new spreadsheet: " + id);
idSaver.set(id);
}});
@@ -184,7 +184,7 @@ public class DocsHelper {
while (listParser.hasMoreData()) {
Entry entry = listParser.readNextEntry(null);
String entryTitle = entry.getTitle();
- Log.i(MyTracksConstants.TAG, "Found docs entry: " + entryTitle);
+ Log.i(Constants.TAG, "Found docs entry: " + entryTitle);
if (entryTitle.equals(title)) {
String entryId = entry.getId();
int lastSlash = entryId.lastIndexOf('/');
@@ -233,7 +233,7 @@ public class DocsHelper {
trixWrapper.getAuthManager().getAuthToken());
sheetParser.init();
if (!sheetParser.hasMoreData()) {
- Log.i(MyTracksConstants.TAG, "Found no worksheets");
+ Log.i(Constants.TAG, "Found no worksheets");
return;
}
@@ -308,7 +308,7 @@ public class DocsHelper {
if (track.getMapId().length() > 0) {
tagBuilder.append("map", String.format("%s?msa=0&msid=%s",
- MyTracksConstants.MAPSHOP_BASE_URL, track.getMapId()));
+ Constants.MAPSHOP_BASE_URL, track.getMapId()));
}
String postText = new StringBuilder()
@@ -319,14 +319,14 @@ public class DocsHelper {
.append("")
.toString();
- Log.i(MyTracksConstants.TAG,
+ Log.i(Constants.TAG,
"Inserting at: " + spreadsheetId + " => " + worksheetUri);
- Log.i(MyTracksConstants.TAG, postText);
+ Log.i(Constants.TAG, postText);
writeRowData(trixAuth, worksheetUri, postText);
- Log.i(MyTracksConstants.TAG, "Post finished.");
+ Log.i(Constants.TAG, "Post finished.");
}
/**
@@ -358,7 +358,7 @@ public class DocsHelper {
String line;
while ((line = rd.readLine()) != null) {
// Process line.
- Log.i(MyTracksConstants.TAG, "r: " + line);
+ Log.i(Constants.TAG, "r: " + line);
}
wr.close();
rd.close();
diff --git a/MyTracks/src/com/google/android/apps/mytracks/io/gdata/GDataClientFactory.java b/MyTracks/src/com/google/android/apps/mytracks/io/gdata/GDataClientFactory.java
index 15dd588d0..a0a717bb1 100644
--- a/MyTracks/src/com/google/android/apps/mytracks/io/gdata/GDataClientFactory.java
+++ b/MyTracks/src/com/google/android/apps/mytracks/io/gdata/GDataClientFactory.java
@@ -15,7 +15,7 @@
*/
package com.google.android.apps.mytracks.io.gdata;
-import com.google.android.apps.mytracks.MyTracksConstants;
+import com.google.android.apps.mytracks.Constants;
import com.google.wireless.gdata.client.GDataClient;
import android.content.Context;
@@ -43,7 +43,7 @@ public class GDataClientFactory {
} catch (LinkageError e) {
// On all other platforms use the client implementation packaged in the
// apk.
- Log.i(MyTracksConstants.TAG, "Using mytracks AndroidGDataClient.", e);
+ Log.i(Constants.TAG, "Using mytracks AndroidGDataClient.", e);
return new com.google.android.apps.mytracks.io.gdata.AndroidGDataClient();
}
}
diff --git a/MyTracks/src/com/google/android/apps/mytracks/io/gdata/GDataWrapper.java b/MyTracks/src/com/google/android/apps/mytracks/io/gdata/GDataWrapper.java
index 75626c825..e26cbf947 100644
--- a/MyTracks/src/com/google/android/apps/mytracks/io/gdata/GDataWrapper.java
+++ b/MyTracks/src/com/google/android/apps/mytracks/io/gdata/GDataWrapper.java
@@ -15,7 +15,7 @@
*/
package com.google.android.apps.mytracks.io.gdata;
-import com.google.android.apps.mytracks.MyTracksConstants;
+import com.google.android.apps.mytracks.Constants;
import com.google.android.apps.mytracks.io.AuthManager;
import android.util.Log;
@@ -173,14 +173,14 @@ public class GDataWrapper {
return true;
}
- Log.d(MyTracksConstants.TAG, "GData error encountered: " + errorMessage);
+ Log.d(Constants.TAG, "GData error encountered: " + errorMessage);
if (errorType == ERROR_AUTH && auth != null) {
if (!retryOnAuthFailure || !invalidateAndRefreshAuthToken()) {
return false;
}
}
- Log.d(MyTracksConstants.TAG, "retrying function/query");
+ Log.d(Constants.TAG, "retrying function/query");
}
return false;
}
@@ -206,11 +206,11 @@ public class GDataWrapper {
errorMessage = null;
} catch (AuthenticationException e) {
- Log.e(MyTracksConstants.TAG, "AuthenticationException", e);
+ Log.e(Constants.TAG, "AuthenticationException", e);
errorType = ERROR_AUTH;
errorMessage = e.getMessage();
} catch (HttpException e) {
- Log.e(MyTracksConstants.TAG,
+ Log.e(Constants.TAG,
"HttpException, code " + e.getStatusCode() + " message " + e.getMessage(), e);
errorMessage = e.getMessage();
if (e.getStatusCode() == 401) {
@@ -219,11 +219,11 @@ public class GDataWrapper {
errorType = ERROR_CONNECTION;
}
} catch (FileNotFoundException e) {
- Log.e(MyTracksConstants.TAG, "Exception", e);
+ Log.e(Constants.TAG, "Exception", e);
errorType = ERROR_AUTH;
errorMessage = e.getMessage();
} catch (IOException e) {
- Log.e(MyTracksConstants.TAG, "Exception", e);
+ Log.e(Constants.TAG, "Exception", e);
errorMessage = e.getMessage();
if (errorMessage != null && errorMessage.contains("503")) {
errorType = ERROR_INTERNAL;
@@ -231,11 +231,11 @@ public class GDataWrapper {
errorType = ERROR_CONNECTION;
}
} catch (ParseException e) {
- Log.e(MyTracksConstants.TAG, "Exception", e);
+ Log.e(Constants.TAG, "Exception", e);
errorType = ERROR_LOCAL;
errorMessage = e.getMessage();
} catch (ConflictDetectedException e) {
- Log.e(MyTracksConstants.TAG, "Exception", e);
+ Log.e(Constants.TAG, "Exception", e);
errorType = ERROR_CONFLICT;
errorMessage = e.getMessage();
}
@@ -249,7 +249,7 @@ public class GDataWrapper {
* times out.
*/
private boolean invalidateAndRefreshAuthToken() {
- Log.d(MyTracksConstants.TAG, "Retrying due to auth failure");
+ Log.d(Constants.TAG, "Retrying due to auth failure");
// This FutureTask doesn't do anything -- it exists simply to be
// blocked upon using get().
FutureTask> whenFinishedFuture = new FutureTask