diff --git a/MyTracks/.classpath b/MyTracks/.classpath index 3bc91a041..0734acf85 100644 --- a/MyTracks/.classpath +++ b/MyTracks/.classpath @@ -6,9 +6,8 @@ + + - - - diff --git a/MyTracks/res/values-de/strings.xml b/MyTracks/res/values-de/strings.xml index fae146410..af7ebd1e4 100644 --- a/MyTracks/res/values-de/strings.xml +++ b/MyTracks/res/values-de/strings.xml @@ -33,7 +33,7 @@ limitations under the License. Es wurde kein \'Location Manager\' auf diesem Gerät gefunden. Konnte keinen GPS-Empfänger auf diesem Gerät finden. - Beim Senden Ihres Tracks an Google My Maps ist ein Fehler aufgetreten. Bitte versuchen Sie es später nochmal. + Beim Senden Ihres Tracks an Google Fusion Tables ist ein Fehler aufgetreten. Bitte versuchen Sie es später nochmal. Beim Senden Ihres Tracks an Google Docs ist ein Fehler aufgetreten. Bitte versuchen Sie es später nochmal. Aufzeichnen fehlgeschlagen. Bitte versuchen Sie es nochmal. Anhalten unmöglich. Bitte versuchen Sie es nochmal. @@ -48,7 +48,7 @@ limitations under the License. Warten auf ein besseres GPS-Signal. Bitte stellen Sie sicher, dass der Himmel sichtbar ist. Ein neuer Track wird aufgezeichnet. Die Aufzeichnung wurde beendet. - Eine neue Karte wurde auf maps.google.com erstellt. + Eine neue Tabelle wurde auf google.com/fusiontables erstellt. Ihr Track wurde auf maps.google.com gespeichert. Ihr Track wurde in einer neuen Tabelle bei docs.google.com gespeichert. Ihr Track wurde an docs.google.com gesendet. @@ -63,11 +63,11 @@ limitations under the License. Ihr GPS-Track wird an Google gesendet. Lese Track Bereite Track vor - Anmelden bei Google Maps + Anmelden bei Google Fusion Tables Anmelden bei Google Docs Track an Google Docs senden - Track an Google Maps senden - Neue \'Meine Karte\' erstellen + Track an Google Fusion Tables senden + Neue \'Fusion Tabelle\' erstellen Importiere GPS-Track. Das dauert ein wenig. Schreibe Datei auf SD-Karte. Das dauert ein wenig. Aktualisiere Trackstatistik @@ -78,8 +78,7 @@ limitations under the License. Dieser Track und seine Wegpunkte werden endgültig von diesem Gerät gelöscht. Dieser Wegpunkt wird endgültig von diesem Gerät gelöscht. - - Neue Karte + Punkte @@ -120,7 +119,7 @@ limitations under the License. Alle Tracks: Dieser Track Mit Freunden teilen… - Ein Link zur Google MyMaps-Karte + Ein Link zur Google Fusion Tables-Karte Eine GPX-Datei Eine KML-Datei Karte zurücksetzen. @@ -202,9 +201,6 @@ limitations under the License. %s. Track mit Freunden teilen - Öffentlich - Nicht in Suchergebnissen enthalten. - Du hast noch keine Karten. @@ -289,8 +285,6 @@ limitations under the License. Senden an… Jetzt senden - Neue Karte erstellen - Eine Karte auswählen Trackstatistik senden Statistik und Punkte senden diff --git a/MyTracks/res/values-es/strings.xml b/MyTracks/res/values-es/strings.xml index 01a1d4370..4cc57ef0a 100644 --- a/MyTracks/res/values-es/strings.xml +++ b/MyTracks/res/values-es/strings.xml @@ -193,29 +193,10 @@ limitations under the License. Satélites GPS - - - Elija un mapa de su cuenta: - Crear mapa nuevo... - Enviar a Google My Maps - Cargando mapas... - Sus mapas no pudieron ser cargados en este momento! - Seleccione este mapa - Editar detalles del mapa - Compartir mapa con amigos Compartir recorrido con amigos - Borrar mapa de su cuenta - Título del mapa: - Descripción del mapa: - Permitir que este mapa y su contenido sean mostrados en resultados de búsqueda - No permitir que este mapa y su contenido sean mostrados en resultados de búsqueda, pero permitir acceso directo mediante su URL - Este mapa y su contenido serán mostrados en resultados de búsqueda - No mostrar ni este mapa ni sus contenidos en resultados de búsqueda, pero permitir acceso directo mediante su URL - Cerrar - Editar - Guardar + Compartir mapa con amigos Me gustaría compartir un mapa contigo Creo que este mapa pudiera interesarte: @@ -224,11 +205,8 @@ limitations under the License. Creo que este recorrido pudiera interesarte. Para ver este recorrido usa Google Earth o algún otro software de mapeo. + Compartir recorrido con amigos - - Público - No listado - Aún no tienes ningún mapa. @@ -314,8 +292,6 @@ limitations under the License. Enviar a... Enviar ahora - Crear un nuevo mapa - Escoja un mapa existente Enviar estadísticas de recorrido Enviar estadísticas y puntos diff --git a/MyTracks/res/values/strings.xml b/MyTracks/res/values/strings.xml index df5cd5a38..1bcf74330 100644 --- a/MyTracks/res/values/strings.xml +++ b/MyTracks/res/values/strings.xml @@ -86,7 +86,6 @@ limitations under the License. Created by My Tracks on Android. Created by <a href=\'http://mytracks.appspot.com\'>My Tracks</a> on Android. - New table Points @@ -134,7 +133,7 @@ limitations under the License. All Tracks: This Track Share with Friends... - A link to Google Fusion Tables + A link to Google Fusion Tables A GPX file A KML file A CSV file @@ -250,8 +249,8 @@ limitations under the License. I think you might be interested in this track: %s - I would like to share a track with you - I think you might be interested in this track. + I would like to share a track with you + I think you might be interested in this track. To view this track use Google Earth or other mapping software. Share track with friends diff --git a/MyTracks/src/com/google/android/apps/mytracks/DialogManager.java b/MyTracks/src/com/google/android/apps/mytracks/DialogManager.java index 1413bd1b6..84992631b 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/DialogManager.java +++ b/MyTracks/src/com/google/android/apps/mytracks/DialogManager.java @@ -20,6 +20,7 @@ import com.google.android.maps.mytracks.R; import android.app.AlertDialog; import android.app.Dialog; import android.app.ProgressDialog; +import android.content.DialogInterface; import android.os.Bundle; import android.util.Log; import android.view.View; @@ -84,6 +85,13 @@ public class DialogManager { builder.setTitle("Title"); builder.setMessage("Message"); builder.setPositiveButton(activity.getString(R.string.ok), null); + builder.setNeutralButton(activity.getString(R.string.share_map), + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { + activity.shareLinkToFusionTable(activity.sendToTrackId); + dialog.dismiss(); + } + }); sendToGoogleResultDialog = builder.create(); return sendToGoogleResultDialog; case DIALOG_WRITE_PROGRESS: diff --git a/MyTracks/src/com/google/android/apps/mytracks/MyTracks.java b/MyTracks/src/com/google/android/apps/mytracks/MyTracks.java index d30db091f..6979e9b0a 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/MyTracks.java +++ b/MyTracks/src/com/google/android/apps/mytracks/MyTracks.java @@ -126,6 +126,7 @@ public class MyTracks extends TabActivity implements OnTouchListener, * Used by SendToGoogleResultDialog. */ + public long sendToTrackId = -1; public boolean sendToFusionTablesSuccess = false; public boolean sendToDocsSuccess = false; public String sendToFusionTablesTableId; @@ -150,6 +151,11 @@ public class MyTracks extends TabActivity implements OnTouchListener, */ private long selectedTrackId = -1; + /** + * Does the user want to share the current track. + */ + private boolean shareRequested = false; + /** * Utilities to deal with the database. */ @@ -549,6 +555,7 @@ public class MyTracks extends TabActivity implements OnTouchListener, setProgressValue(50); setProgressMessage(R.string.progress_message_sending_docs); final long trackId = results.getLongExtra("trackid", selectedTrackId); + sendToTrackId = trackId; final SendToDocs sender = new SendToDocs(this, authMap.get("wise"), authMap.get("writely"), trackId); Runnable onCompletion = new Runnable() { @@ -559,7 +566,7 @@ public class MyTracks extends TabActivity implements OnTouchListener, public void run() { sendToDocsMessage = sender.getStatusMessage(); sendToDocsSuccess = sender.wasSuccess(); - handleFusionTablesFinish(); + handleFusionTablesFinish(trackId); } }); } @@ -572,6 +579,7 @@ public class MyTracks extends TabActivity implements OnTouchListener, break; } case MyTracksConstants.SEND_TO_GOOGLE_DIALOG: { + shareRequested = false; dialogManager.showDialogSafely(DIALOG_SEND_TO_GOOGLE); break; } @@ -609,12 +617,13 @@ public class MyTracks extends TabActivity implements OnTouchListener, dialogManager.dismissDialogSafely(DIALOG_PROGRESS); runOnUiThread(new Runnable() { public void run() { - handleFusionTablesFinish(); + handleFusionTablesFinish(trackId); } }); } } }; + sendToTrackId = trackId; final SendToFusionTables sender = new SendToFusionTables(this, auth, trackId, this/*progressIndicator*/, onCompletion); @@ -650,8 +659,9 @@ public class MyTracks extends TabActivity implements OnTouchListener, Track selectedTrack = providerUtils.getTrack(selectedTrackId); if (selectedTrack != null) { if (selectedTrack.getTableId().length() > 0) { - shareLinkToFusionTable(selectedTrack); + shareLinkToFusionTable(selectedTrackId); } else { + shareRequested = true; dialogManager.showDialogSafely(DIALOG_SEND_TO_GOOGLE); } } @@ -793,7 +803,7 @@ public class MyTracks extends TabActivity implements OnTouchListener, * Shares a link to a fusion table via external app (email, gmail, ...) * A chooser with apps that support text/plain will be shown to the user. */ - public void shareLinkToFusionTable(Track track) { + public void shareLinkToFusionTable(long trackId) { Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("text/plain"); shareIntent.putExtra(Intent.EXTRA_SUBJECT, @@ -805,12 +815,13 @@ public class MyTracks extends TabActivity implements OnTouchListener, getString(R.string.share_url_only_key), false); } + Track track = providerUtils.getTrack(trackId); String url = SendToFusionTables.getMapVisualizationUrl(track); String msg = shareUrlOnly ? url : String.format( getResources().getText(R.string.share_map_body_format).toString(), url); shareIntent.putExtra(Intent.EXTRA_TEXT, msg); startActivity(Intent.createChooser(shareIntent, - getResources().getText(R.string.share_map_subject).toString())); + getResources().getText(R.string.share_map).toString())); } /** @@ -1223,9 +1234,14 @@ public class MyTracks extends TabActivity implements OnTouchListener, /** * Notifies that uploading to fusion tables is finished. */ - private void handleFusionTablesFinish() { - dialogManager.showDialogSafely( - DialogManager.DIALOG_SEND_TO_GOOGLE_RESULT); + private void handleFusionTablesFinish(long trackId) { + if (shareRequested && sendToFusionTablesSuccess) { + // Just share + Toast.makeText(this, getFusionTablesResultMessage(), Toast.LENGTH_LONG).show(); + shareLinkToFusionTable(trackId); + } else { + dialogManager.showDialogSafely(DialogManager.DIALOG_SEND_TO_GOOGLE_RESULT); + } } public String getFusionTablesResultMessage() { diff --git a/MyTracks/src/com/google/android/apps/mytracks/MyTracksMap.java b/MyTracks/src/com/google/android/apps/mytracks/MyTracksMap.java index af000e7b1..758c0f550 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/MyTracksMap.java +++ b/MyTracks/src/com/google/android/apps/mytracks/MyTracksMap.java @@ -789,7 +789,7 @@ public class MyTracksMap extends MapActivity SubMenu share = menu.addSubMenu(0, MyTracksConstants.MENU_SHARE, 0, R.string.tracklist_share_track); share.add(0, MyTracksConstants.MENU_SHARE_LINK, 0, - R.string.tracklist_share_link); + R.string.tracklist_share_linkfusion); share.add(0, MyTracksConstants.MENU_SHARE_GPX_FILE, 0, R.string.tracklist_share_gpx_file); share.add(0, MyTracksConstants.MENU_SHARE_KML_FILE, 0, diff --git a/MyTracks/src/com/google/android/apps/mytracks/SendToGoogleDialog.java b/MyTracks/src/com/google/android/apps/mytracks/SendToGoogleDialog.java index 3364513d7..f39be1d84 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/SendToGoogleDialog.java +++ b/MyTracks/src/com/google/android/apps/mytracks/SendToGoogleDialog.java @@ -29,7 +29,6 @@ import android.widget.CheckBox; import android.widget.CompoundButton; import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.RadioButton; -import android.widget.RadioGroup; /** * A dialog where the user can choose where to send the tracks to, i.e. diff --git a/MyTracks/src/com/google/android/apps/mytracks/WelcomeActivity.java b/MyTracks/src/com/google/android/apps/mytracks/WelcomeActivity.java index cbe717f28..4da2b0807 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/WelcomeActivity.java +++ b/MyTracks/src/com/google/android/apps/mytracks/WelcomeActivity.java @@ -19,11 +19,7 @@ import com.google.android.maps.mytracks.R; import android.app.Activity; import android.app.AlertDialog; -import android.content.pm.PackageInfo; -import android.content.pm.PackageManager; -import android.content.pm.PackageManager.NameNotFoundException; import android.os.Bundle; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; diff --git a/MyTracks/src/com/google/android/apps/mytracks/io/SendToFusionTables.java b/MyTracks/src/com/google/android/apps/mytracks/io/SendToFusionTables.java index 578128de3..3a354a115 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/io/SendToFusionTables.java +++ b/MyTracks/src/com/google/android/apps/mytracks/io/SendToFusionTables.java @@ -36,6 +36,7 @@ import com.google.api.client.http.GenericUrl; import com.google.api.client.http.HttpRequest; import com.google.api.client.http.HttpResponse; import com.google.api.client.http.HttpTransport; +import com.google.api.client.http.InputStreamContent; import com.google.api.client.util.Strings; import android.app.Activity; @@ -44,6 +45,7 @@ import android.database.Cursor; import android.location.Location; import android.util.Log; +import java.io.ByteArrayInputStream; import java.io.IOException; import java.net.URLEncoder; import java.util.ArrayList; @@ -65,9 +67,6 @@ public class SendToFusionTables implements Runnable { /** The GData service id for Fusion Tables. */ public static final String SERVICE_ID = "fusiontables"; - /** The base url for viewing a fusion table. */ - public static final String FUSIONTABLES_TABLE_URL = "http://www.google.com/fusiontables"; - /** The path for viewing a map visualization of a table. */ private static final String FUSIONTABLES_MAP = "http://www.google.com/fusiontables/embedviz?" + @@ -121,12 +120,12 @@ public class SendToFusionTables implements Runnable { } public static String getMapVisualizationUrl(Track track) { - // TODO(leifhendrik): Determine correct bounding box and zoom level. - Location start = track.getLocations().get(0); - double lat = start != null ? start.getLatitude() : 37.0; - double lng = start != null ? start.getLongitude() : -121.0; + // TODO(leifhendrik): Determine correct bounding box and zoom level that will show the entire track. + TripStatistics stats = track.getStatistics(); + double latE6 = stats.getBottom() + (stats.getTop() - stats.getBottom()) / 2; + double lonE6 = stats.getLeft() + (stats.getRight() - stats.getLeft()) / 2; int z = 15; - return String.format(FUSIONTABLES_MAP, track.getTableId(), lat, lng, z); + return String.format(FUSIONTABLES_MAP, track.getTableId(), latE6 / 1.E6, lonE6 / 1.E6, z); } private void doUpload() { @@ -281,7 +280,8 @@ public class SendToFusionTables implements Runnable { if (totalLocationsRead == 0) { // Put a marker at the first point of the first valid segment: - createNewPoint(track.getName(), track.getDescription(), loc, "large_green"); + String name = track.getName() + " " + context.getString(R.string.start); + createNewPoint(name, "", loc, "large_green"); } // Add to the elevation profile. @@ -328,9 +328,10 @@ public class SendToFusionTables implements Runnable { + stringUtils.generateTrackDescription( track, distances, elevations) + "

"); - return createNewPoint(track.getName(), track.getDescription(), lastLocation, "large_red"); + String name = track.getName() + " " + context.getString(R.string.end); + return createNewPoint(name, track.getDescription(), lastLocation, "large_red"); } - + return true; } finally { locationsCursor.close(); @@ -600,14 +601,13 @@ public class SendToFusionTables implements Runnable { throws IOException, GDataWrapper.ParseException, GDataWrapper.HttpException { HttpRequest request = transport.buildPostRequest(); request.headers.contentType = "application/x-www-form-urlencoded"; - String sql = "sql=" + URLEncoder.encode(query, "UTF-8"); - GenericUrl url = new GenericUrl(FUSIONTABLES_BASE_FEED_URL + "?" + sql); + GenericUrl url = new GenericUrl(FUSIONTABLES_BASE_FEED_URL); request.url = url; - //OutputStream outputStream = new ByteArrayOutputStream(); - //outputStream.write(Strings.toBytesUtf8(sql)); - //outputStream.flush(); - //request.content.writeTo(outputStream); - Log.d(MyTracksConstants.TAG, "Running update query: " + url.toString()); + InputStreamContent isc = new InputStreamContent(); + String sql = "sql=" + URLEncoder.encode(query, "UTF-8"); + isc.inputStream = new ByteArrayInputStream(Strings.toBytesUtf8(sql)); + request.content = isc; + Log.d(MyTracksConstants.TAG, "Running update query " + url.toString() + ": " + sql); HttpResponse response = request.execute(); boolean success = response.isSuccessStatusCode; if (success) {