correctly use the <Cadence> tag for biking related activities

This commit is contained in:
ml1050
2012-02-12 18:47:50 +01:00
parent 13f5c0e685
commit ceb0e68b2a
@@ -21,6 +21,7 @@ import com.google.android.apps.mytracks.content.Sensor.SensorDataSet;
import com.google.android.apps.mytracks.content.Track; import com.google.android.apps.mytracks.content.Track;
import com.google.android.apps.mytracks.content.Waypoint; import com.google.android.apps.mytracks.content.Waypoint;
import com.google.android.apps.mytracks.io.file.TrackWriterFactory.TrackFileFormat; import com.google.android.apps.mytracks.io.file.TrackWriterFactory.TrackFileFormat;
import com.google.android.apps.mytracks.lib.R;
import com.google.android.apps.mytracks.util.FileUtils; import com.google.android.apps.mytracks.util.FileUtils;
import com.google.android.apps.mytracks.util.SystemUtils; import com.google.android.apps.mytracks.util.SystemUtils;
@@ -47,6 +48,23 @@ import java.util.Locale;
*/ */
public class TcxTrackWriter implements TrackFormatWriter { public class TcxTrackWriter implements TrackFormatWriter {
// "Biking" related string IDs
private static final int TCX_SPORT_BIKING_IDS[] = {
R.string.activity_type_cycling,
R.string.activity_type_dirt_bike,
R.string.activity_type_mountain_biking,
R.string.activity_type_road_biking,
R.string.activity_type_track_cycling,
};
// "Running" related string IDs
private static final int TCX_SPORT_RUNNING_IDS[] = {
R.string.activity_type_running,
R.string.activity_type_speed_walking,
R.string.activity_type_street_running,
R.string.activity_type_track_running,
R.string.activity_type_trail_running,
R.string.activity_type_walking,
};
// These are the only sports allowed by the TCX v2 specification for fields // These are the only sports allowed by the TCX v2 specification for fields
// of type Sport_t. // of type Sport_t.
private static final String TCX_SPORT_BIKING = "Biking"; private static final String TCX_SPORT_BIKING = "Biking";
@@ -302,6 +320,19 @@ public class TcxTrackWriter implements TrackFormatWriter {
private String categoryToTcxSport(String category) { private String categoryToTcxSport(String category) {
category = category.trim(); category = category.trim();
// category is possibly localised here, so compare it to localised string resources
for (int i : TCX_SPORT_RUNNING_IDS) {
if (category.equalsIgnoreCase(context.getResources().getString(i))) {
return TCX_SPORT_RUNNING;
}
}
for (int i : TCX_SPORT_BIKING_IDS) {
if (category.equalsIgnoreCase(context.getResources().getString(i))) {
return TCX_SPORT_BIKING;
}
}
if (category.equalsIgnoreCase(TCX_SPORT_RUNNING)) { if (category.equalsIgnoreCase(TCX_SPORT_RUNNING)) {
return TCX_SPORT_RUNNING; return TCX_SPORT_RUNNING;
} else if (category.equalsIgnoreCase(TCX_SPORT_BIKING)) { } else if (category.equalsIgnoreCase(TCX_SPORT_BIKING)) {