forked from upstream-mirrors/OpenTracks
Merge heads
This commit is contained in:
Binary file not shown.
@@ -124,8 +124,6 @@ public abstract class Constants {
|
|||||||
public static final String
|
public static final String
|
||||||
RESUME_TRACK_EXTRA_NAME = "com.google.android.apps.mytracks.RESUME_TRACK";
|
RESUME_TRACK_EXTRA_NAME = "com.google.android.apps.mytracks.RESUME_TRACK";
|
||||||
|
|
||||||
public static final String MAPSHOP_BASE_URL = "https://maps.google.com/maps/ms";
|
|
||||||
|
|
||||||
public static final String SETTINGS_NAME = "SettingsActivity";
|
public static final String SETTINGS_NAME = "SettingsActivity";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+7
-2
@@ -33,14 +33,19 @@ import android.support.v4.app.DialogFragment;
|
|||||||
public class DeleteAllTrackDialogFragment extends DialogFragment {
|
public class DeleteAllTrackDialogFragment extends DialogFragment {
|
||||||
|
|
||||||
public static final String DELETE_ALL_TRACK_DIALOG_TAG = "deleteAllTrackDialog";
|
public static final String DELETE_ALL_TRACK_DIALOG_TAG = "deleteAllTrackDialog";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
return DialogUtils.createConfirmationDialog(getActivity(),
|
return DialogUtils.createConfirmationDialog(getActivity(),
|
||||||
R.string.track_list_delete_all_confirm_message, new DialogInterface.OnClickListener() {
|
R.string.track_list_delete_all_confirm_message, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
MyTracksProviderUtils.Factory.get(getActivity()).deleteAllTracks();
|
new Thread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
MyTracksProviderUtils.Factory.get(getActivity()).deleteAllTracks();
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-2
@@ -56,8 +56,14 @@ public class DeleteOneMarkerDialogFragment extends DialogFragment {
|
|||||||
R.string.marker_delete_one_marker_confirm_message, new DialogInterface.OnClickListener() {
|
R.string.marker_delete_one_marker_confirm_message, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
MyTracksProviderUtils.Factory.get(getActivity()).deleteWaypoint(
|
new Thread(new Runnable() {
|
||||||
getArguments().getLong(KEY_MARKER_ID), new DescriptionGeneratorImpl(getActivity()));
|
@Override
|
||||||
|
public void run() {
|
||||||
|
MyTracksProviderUtils.Factory.get(getActivity()).deleteWaypoint(
|
||||||
|
getArguments().getLong(KEY_MARKER_ID),
|
||||||
|
new DescriptionGeneratorImpl(getActivity()));
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
Intent intent = IntentUtils.newIntent(getActivity(), MarkerListActivity.class)
|
Intent intent = IntentUtils.newIntent(getActivity(), MarkerListActivity.class)
|
||||||
.putExtra(MarkerListActivity.EXTRA_TRACK_ID, getArguments().getLong(KEY_TRACK_ID));
|
.putExtra(MarkerListActivity.EXTRA_TRACK_ID, getArguments().getLong(KEY_TRACK_ID));
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
|
|||||||
+8
-3
@@ -79,13 +79,18 @@ public class DeleteOneTrackDialogFragment extends DialogFragment {
|
|||||||
R.string.track_detail_delete_confirm_message, new DialogInterface.OnClickListener() {
|
R.string.track_detail_delete_confirm_message, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
long trackId = getArguments().getLong(KEY_TRACK_ID);
|
final long trackId = getArguments().getLong(KEY_TRACK_ID);
|
||||||
Context context = getActivity();
|
final Context context = getActivity();
|
||||||
if (trackId == PreferencesUtils.getLong(context, R.string.recording_track_id_key)) {
|
if (trackId == PreferencesUtils.getLong(context, R.string.recording_track_id_key)) {
|
||||||
TrackRecordingServiceConnectionUtils.stop(
|
TrackRecordingServiceConnectionUtils.stop(
|
||||||
context, caller.getTrackRecordingServiceConnection(), false);
|
context, caller.getTrackRecordingServiceConnection(), false);
|
||||||
}
|
}
|
||||||
MyTracksProviderUtils.Factory.get(context).deleteTrack(trackId);
|
new Thread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
MyTracksProviderUtils.Factory.get(context).deleteTrack(trackId);
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
Intent intent = IntentUtils.newIntent(context, TrackListActivity.class);
|
Intent intent = IntentUtils.newIntent(context, TrackListActivity.class);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
// Close the activity since its content can change after delete
|
// Close the activity since its content can change after delete
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ import android.content.Context;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AsyncTask to send a track to Google Docs.
|
* AsyncTask to send a track to Google Docs.
|
||||||
@@ -127,6 +129,13 @@ public class SendDocsAsyncTask extends AbstractSendAsyncTask {
|
|||||||
if (track.getCategory() != null && !track.getCategory().equals("")) {
|
if (track.getCategory() != null && !track.getCategory().equals("")) {
|
||||||
title += "-" + track.getCategory();
|
title += "-" + track.getCategory();
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
title = URLEncoder.encode(title, "UTF-8");
|
||||||
|
title = title.replace('+', ' ');
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
Log.d(TAG, "No UTF-8 encoding", e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Get the spreadsheet ID
|
// Get the spreadsheet ID
|
||||||
publishProgress(PROGRESS_GET_SPREADSHEET_ID);
|
publishProgress(PROGRESS_GET_SPREADSHEET_ID);
|
||||||
@@ -259,7 +268,8 @@ public class SendDocsAsyncTask extends AbstractSendAsyncTask {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
spreadsheetId = SendDocsUtils.createSpreadsheet(spreadsheetTitle, documentsAuthToken, context);
|
spreadsheetId = SendDocsUtils.createSpreadsheet(
|
||||||
|
spreadsheetTitle, documentsAuthToken, context);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.d(TAG, "Unable to create spreadsheet", e);
|
Log.d(TAG, "Unable to create spreadsheet", e);
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -15,11 +15,12 @@
|
|||||||
*/
|
*/
|
||||||
package com.google.android.apps.mytracks.io.docs;
|
package com.google.android.apps.mytracks.io.docs;
|
||||||
|
|
||||||
import com.google.android.apps.mytracks.Constants;
|
|
||||||
import com.google.android.apps.mytracks.content.Track;
|
import com.google.android.apps.mytracks.content.Track;
|
||||||
|
import com.google.android.apps.mytracks.io.fusiontables.SendFusionTablesUtils;
|
||||||
import com.google.android.apps.mytracks.io.gdata.docs.DocumentsClient;
|
import com.google.android.apps.mytracks.io.gdata.docs.DocumentsClient;
|
||||||
import com.google.android.apps.mytracks.io.gdata.docs.SpreadsheetsClient;
|
import com.google.android.apps.mytracks.io.gdata.docs.SpreadsheetsClient;
|
||||||
import com.google.android.apps.mytracks.io.gdata.docs.SpreadsheetsClient.WorksheetEntry;
|
import com.google.android.apps.mytracks.io.gdata.docs.SpreadsheetsClient.WorksheetEntry;
|
||||||
|
import com.google.android.apps.mytracks.io.maps.SendMapsUtils;
|
||||||
import com.google.android.apps.mytracks.stats.TripStatistics;
|
import com.google.android.apps.mytracks.stats.TripStatistics;
|
||||||
import com.google.android.apps.mytracks.util.PreferencesUtils;
|
import com.google.android.apps.mytracks.util.PreferencesUtils;
|
||||||
import com.google.android.apps.mytracks.util.ResourceUtils;
|
import com.google.android.apps.mytracks.util.ResourceUtils;
|
||||||
@@ -311,10 +312,17 @@ public class SendDocsUtils {
|
|||||||
appendTag(builder, "maxelevation", getElevation(stats.getMaxElevation(), metricUnits));
|
appendTag(builder, "maxelevation", getElevation(stats.getMaxElevation(), metricUnits));
|
||||||
appendTag(builder, "elevationunit", elevationUnit);
|
appendTag(builder, "elevationunit", elevationUnit);
|
||||||
|
|
||||||
if (track.getMapId().length() > 0) {
|
String map = SendMapsUtils.getMapUrl(track);
|
||||||
appendTag(builder, "map", String.format(
|
if (map == null) {
|
||||||
Locale.US, "%s?msa=0&msid=%s", Constants.MAPSHOP_BASE_URL, track.getMapId()));
|
map = context.getString(R.string.value_unknown);
|
||||||
}
|
}
|
||||||
|
appendTag(builder, "map", map);
|
||||||
|
|
||||||
|
String fusionTable = SendFusionTablesUtils.getMapUrl(track);
|
||||||
|
if (fusionTable == null) {
|
||||||
|
fusionTable = context.getString(R.string.value_unknown);
|
||||||
|
}
|
||||||
|
appendTag(builder, "fusiontable", fusionTable);
|
||||||
|
|
||||||
builder.append("</entry>");
|
builder.append("</entry>");
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
|
|||||||
+2
-3
@@ -277,9 +277,8 @@ public class SendFusionTablesAsyncTask extends AbstractSendAsyncTask {
|
|||||||
distances.add(tripStatisticsBuilder.getStatistics().getTotalDistance());
|
distances.add(tripStatisticsBuilder.getStatistics().getTotalDistance());
|
||||||
elevations.add(elevationBuffer.getAverage());
|
elevations.add(elevationBuffer.getAverage());
|
||||||
DescriptionGenerator descriptionGenerator = new DescriptionGeneratorImpl(context);
|
DescriptionGenerator descriptionGenerator = new DescriptionGeneratorImpl(context);
|
||||||
track.setDescription("<p>" + track.getDescription() + "</p><p>"
|
track.setDescription(
|
||||||
+ descriptionGenerator.generateTrackDescription(track, distances, elevations, true)
|
descriptionGenerator.generateTrackDescription(track, distances, elevations, true));
|
||||||
+ "</p>");
|
|
||||||
String name = context.getString(R.string.marker_label_end, track.getName());
|
String name = context.getString(R.string.marker_label_end, track.getName());
|
||||||
if (!createNewPoint(name, track.getDescription(), lastLocation, MARKER_TYPE_END)) {
|
if (!createNewPoint(name, track.getDescription(), lastLocation, MARKER_TYPE_END)) {
|
||||||
Log.d(TAG, "Unable to create the end marker");
|
Log.d(TAG, "Unable to create the end marker");
|
||||||
|
|||||||
+4
-1
@@ -52,7 +52,10 @@ public class SendFusionTablesUtils {
|
|||||||
* @return the url.
|
* @return the url.
|
||||||
*/
|
*/
|
||||||
public static String getMapUrl(Track track) {
|
public static String getMapUrl(Track track) {
|
||||||
if (track == null || track.getTripStatistics() == null || track.getTableId() == null) {
|
if (track == null
|
||||||
|
|| track.getTripStatistics() == null
|
||||||
|
|| track.getTableId() == null
|
||||||
|
|| track.getTableId().length() == 0) {
|
||||||
Log.e(TAG, "Invalid track");
|
Log.e(TAG, "Invalid track");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,11 +54,12 @@ public class SendMapsUtils {
|
|||||||
* @return the url if available.
|
* @return the url if available.
|
||||||
*/
|
*/
|
||||||
public static String getMapUrl(Track track) {
|
public static String getMapUrl(Track track) {
|
||||||
if (track == null || track.getMapId() == null) {
|
if (track == null
|
||||||
|
|| track.getMapId() == null
|
||||||
|
|| track.getMapId().length() == 0) {
|
||||||
Log.e(TAG, "Invalid track");
|
Log.e(TAG, "Invalid track");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return MapsClient.buildMapUrl(track.getMapId());
|
return MapsClient.buildMapUrl(track.getMapId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user