Fixing the fixes for localization and track importing.

Fixes issue 462
Fixes issue 559
Fixes issue 540
This commit is contained in:
Rodrigo Damazio
2011-09-11 08:16:58 -03:00
parent 79c2cf90cf
commit eb6cdd0fc0
3 changed files with 31 additions and 17 deletions
@@ -61,8 +61,8 @@ public class ImportAllTracks {
Log.i(Constants.TAG, "ImportAllTracks: Starting"); Log.i(Constants.TAG, "ImportAllTracks: Starting");
fileUtils = new FileUtils(); fileUtils = new FileUtils();
gpxPath = fileUtils.buildExternalDirectoryPath("gpx"); gpxPath = fileUtils.buildExternalDirectoryPath("gpx");
this.activity.runOnUiThread(runner);
//new Thread(runner).start(); new Thread(runner).start();
} }
private final Runnable runner = new Runnable() { private final Runnable runner = new Runnable() {
@@ -95,6 +95,15 @@ public class ImportAllTracks {
Log.i(Constants.TAG, "ImportAllTracks: Releasing wake lock."); Log.i(Constants.TAG, "ImportAllTracks: Releasing wake lock.");
} }
activity.runOnUiThread(new Thread() {
@Override
public void run() {
showDoneDialog();
}
});
}
private void showDoneDialog() {
Log.i(Constants.TAG, "ImportAllTracks: Done"); Log.i(Constants.TAG, "ImportAllTracks: Done");
AlertDialog.Builder builder = new AlertDialog.Builder(activity); AlertDialog.Builder builder = new AlertDialog.Builder(activity);
if (gpxFileCount == 0) { if (gpxFileCount == 0) {
@@ -287,11 +287,13 @@ public class DocsHelper {
String elevationUnit = context.getString(metricUnits ? String elevationUnit = context.getString(metricUnits ?
R.string.meter : R.string.feet); R.string.meter : R.string.feet);
DateFormat trackDateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
// Prepare the Post-Text we are going to send. // Prepare the Post-Text we are going to send.
DocsTagBuilder tagBuilder = new DocsTagBuilder(metricUnits) DocsTagBuilder tagBuilder = new DocsTagBuilder(metricUnits)
.append("name", track.getName()) .append("name", track.getName())
.append("description", track.getDescription()) .append("description", track.getDescription())
.append("date", DateFormat.getDateTimeInstance(DateFormat.SHORT,DateFormat.SHORT).format(new Date(stats.getStartTime()))) .append("date", trackDateFormat.format(new Date(stats.getStartTime())))
.append("totaltime", StringUtils.formatTimeAlwaysShowingHours( .append("totaltime", StringUtils.formatTimeAlwaysShowingHours(
stats.getTotalTime())) stats.getTotalTime()))
.append("movingtime", StringUtils.formatTimeAlwaysShowingHours( .append("movingtime", StringUtils.formatTimeAlwaysShowingHours(
@@ -18,7 +18,10 @@ package com.google.android.apps.mytracks.io.docs;
import com.google.android.apps.mytracks.util.StringUtils; import com.google.android.apps.mytracks.util.StringUtils;
import com.google.android.apps.mytracks.util.UnitConversions; import com.google.android.apps.mytracks.util.UnitConversions;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.NumberFormat; import java.text.NumberFormat;
import java.util.Locale;
/** /**
* <p>This class builds a string of XML tags used to talk to Docs using GData. * <p>This class builds a string of XML tags used to talk to Docs using GData.
@@ -42,12 +45,12 @@ import java.text.NumberFormat;
* @author Matthew Simmons * @author Matthew Simmons
*/ */
class DocsTagBuilder { class DocsTagBuilder {
// TODO(simmonmt): These formats aren't I18N-compatible. Not everyone uses private static final DecimalFormatSymbols FORMAT_SYMBOLS =
// commas for thousands and dots for the decimal point. DecimalFormatSymbols.getInstance(Locale.ENGLISH);
private static final NumberFormat LARGE_UNIT_FORMAT = private static final NumberFormat LARGE_UNIT_FORMAT =
NumberFormat.getNumberInstance(); new DecimalFormat("#,###,###.00", FORMAT_SYMBOLS);
private static final NumberFormat SMALL_UNIT_FORMAT = private static final NumberFormat SMALL_UNIT_FORMAT =
NumberFormat.getNumberInstance(); new DecimalFormat("###,###", FORMAT_SYMBOLS);
protected final boolean metricUnits; protected final boolean metricUnits;
protected final StringBuilder stringBuilder; protected final StringBuilder stringBuilder;
@@ -58,7 +61,7 @@ class DocsTagBuilder {
*/ */
DocsTagBuilder(boolean metricUnits) { DocsTagBuilder(boolean metricUnits) {
this.metricUnits = metricUnits; this.metricUnits = metricUnits;
stringBuilder = new StringBuilder(); this.stringBuilder = new StringBuilder();
} }
/** Appends a tag containing a string value */ /** Appends a tag containing a string value */