diff --git a/MyTracks/AndroidManifest.xml b/MyTracks/AndroidManifest.xml index dbc796445..25bdf9c10 100755 --- a/MyTracks/AndroidManifest.xml +++ b/MyTracks/AndroidManifest.xml @@ -56,11 +56,6 @@ limitations under the License. android:label="MyTracks" android:exported="false" /> - - @@ -157,12 +152,11 @@ limitations under the License. - - --> - + diff --git a/MyTracks/res/layout/list.xml b/MyTracks/res/layout/list.xml deleted file mode 100644 index 33567b8d2..000000000 --- a/MyTracks/res/layout/list.xml +++ /dev/null @@ -1,103 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/MyTracks/res/values-ca/strings.xml b/MyTracks/res/values-ca/strings.xml index b5b58e5aa..b7b3376b1 100644 --- a/MyTracks/res/values-ca/strings.xml +++ b/MyTracks/res/values-ca/strings.xml @@ -104,6 +104,9 @@ limitations under the License. Fet Punt de referència Cancel·la + Tanca + Edita + Desa (Inici) @@ -241,27 +244,6 @@ limitations under the License. Satèl·lits GPS - - Seleccioneu un mapa del vostre compte: - Crea un mapa nou... - Envia a Google My Maps - S\'estan carregant els mapes... - No s\'han pogut carregar els vostres mapes en aquest moment - Selecciona aquest mapa - Edita els detalls del mapa - Comparteix el mapa amb amics - Comparteix la ruta amb amics - Elimina el mapa del vostre compte - Títol del mapa: - Descripció del mapa: - Fes que aquest mapa i els seus continguts apareguen als resultats de cerca - No permetis que aquest mapa ni els seus continguts es mostrin als resultats de cerca, tot i que sí es podrà visualitzar per altres amb l\'adreça URL directa - Aquest mapa i els seus continguts es mostraran als resultats de cerca - Ni els mapes ni els seus continguts es mostraran als resultats de cerca, però podran visualitzar-se per altres a través d\'un enllaç directe. - Tanca - Edita - Desa - M\'agradaria compartir un mapa amb tu Crec que estaràs interessat en aquest mapa: @@ -271,6 +253,7 @@ limitations under the License. Crec que estaràs interessat en aquesta ruta. Per verue aquesta ruta fes servir Google Earth o altre programari de mapes. + Comparteix la ruta amb amics Públic diff --git a/MyTracks/res/values-de/strings.xml b/MyTracks/res/values-de/strings.xml index af7ebd1e4..7f4afe125 100644 --- a/MyTracks/res/values-de/strings.xml +++ b/MyTracks/res/values-de/strings.xml @@ -97,6 +97,8 @@ limitations under the License. Erfolgreich Wegpunkt Abbrechen + Bearbeiten + Sichern (Anfang) @@ -202,6 +204,11 @@ limitations under the License. %s. Track mit Freunden teilen + + Öffentlich + Nicht in Suchergebnissen enthalten. + Du hast noch keine Karten. + Durchschnitt in Bew. diff --git a/MyTracks/res/values-es/strings.xml b/MyTracks/res/values-es/strings.xml index 4cc57ef0a..7f0ec7670 100644 --- a/MyTracks/res/values-es/strings.xml +++ b/MyTracks/res/values-es/strings.xml @@ -207,6 +207,10 @@ limitations under the License. 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. diff --git a/MyTracks/res/values-fr/strings.xml b/MyTracks/res/values-fr/strings.xml index 432080c7d..bf588b041 100644 --- a/MyTracks/res/values-fr/strings.xml +++ b/MyTracks/res/values-fr/strings.xml @@ -100,6 +100,9 @@ limitations under the License. Erreur Point de passage Annuler + Fermer + Modifier + Enregistrer (Début) @@ -194,28 +197,8 @@ limitations under the License. Satellites GPS - - Choisissez une carte de votre compte : - Création d\'une nouvelle carte en cours... - Envoyer à Google Mes cartes - Chargements de vos cartes... - Vos cartes n\'ont pu être chargées - Sélectionnez la carte - Consulter les détails de la carte - Partager. - Partager des parcours. - Supprimer la carte de votre compte. - Titre de la carte : - Description de la carte : - Rendre cette carte et son contenu visibles dans les résultats de recherche. - Ne pas inclure cette carte et sont contenu dans les résultats de recherche. Ils seront cependant consultables par d\'autres utilisateurs en utilisant l\'adresse URL exacte - Cette carte et son contenu seront visibles dans les résultats de recherche - Ni cette carte, ni son contenu seront visible dans les résultats de recherche, mais ils seront consultables en utilisant l\'adresse URL exacte - Fermer - Modifier - Enregistrer - + Partager. Je voudrais partager ma carte avec vous Je pense que cette carte vous intéressera : @@ -224,6 +207,7 @@ limitations under the License. Je pense que ce parcours vous intéressera. Pour voir ce parcours, utilisez Google Earth ou tout autre logiciel de cartographie. + Partager des parcours. Carte non listée diff --git a/MyTracks/res/values-it/strings.xml b/MyTracks/res/values-it/strings.xml index 6f187880a..0deba74fe 100644 --- a/MyTracks/res/values-it/strings.xml +++ b/MyTracks/res/values-it/strings.xml @@ -104,6 +104,9 @@ limitations under the License. Successo Punto di passaggio Annulla + Chiudi + Modifica + Salva (Inizio) @@ -200,27 +203,6 @@ limitations under the License. Satelliti GPS - - Scegli una mappa dal tuo account: - Crea una nuova mappa... - Invia a «Le mie mappe» di Google - Caricamento mappe in corso... - Le tue mappe non possono momentaneamente essere caricate! - Scegli questa mappa - Modifica dettagli della mappa - Condividi la mappa con amici - Condividi il percorso con amici - Elimina la mappa dal tuo account - Titolo della mappa: - Descrizione della mappa: - Rendi questa mappa e il suo contenuto visibili fra i risultati di ricerche - Rendi questa mappa e il suo contenuto invisibili fra i risultati di ricerche. Resteranno comunque visibili ad altri utilizzando l\'indirizzo URL esatto - Questa mappa e il suo contenuto saranno visibili fra i risultati di ricerche - Né questa mappa né il suo contenuto saranno visibili in risultati di ricerche, ma saranno comunque visibili ad altri tramite un link diretto. - Chiudi - Modifica - Salva - Vorrei condividere una mappa con te Credo che questa mappa potrebbe interessarti: @@ -230,6 +212,7 @@ limitations under the License. Credo che questo percorso potrebbe interessarti. Per vedere questo percorso, usa Google Earth o un altro software di cartografia. + Condividi il percorso con amici Pubblica diff --git a/MyTracks/res/values-ja/strings.xml b/MyTracks/res/values-ja/strings.xml index 52e4b9918..9f80638dc 100644 --- a/MyTracks/res/values-ja/strings.xml +++ b/MyTracks/res/values-ja/strings.xml @@ -102,6 +102,9 @@ limitations under the License. 成功 ウェイポイント キャンセル + 閉じる + 編集 + 保存 (開始) @@ -201,29 +204,6 @@ limitations under the License. GPS衛星 - - ご使用のアカウントからのマップ選択: - 新規マップ... - Googleマイマップへの送信 - マップの読み込み中... - マップを読み込めませんでした! - このマップを選択 - マップ詳細の編集 - マップの共有 - トラックの共有 - アカウントからマップの削除 - マップタイトル: - マップ説明: - - - このマップとコンテンツを検索結果に表示させる - このマップとコンテンツはどちらも検索結果に表示させない(直接URLで他の方が見ることは可能) - このマップとコンテンツは検索結果に表示されます - このマップとコンテンツはどちらも検索結果に表示されませんが,直接リンクで他の方が見ることができます. - 閉じる - 編集 - 保存 - マップを共有したいと思います このマップに興味を持って頂けると思います: @@ -233,6 +213,7 @@ limitations under the License. このトラックに興味を持って頂けると思います. このトラックを閲覧するには,Google Earthまたは他のマッピングソフトウェアが必要です. + トラックの共有 公開 diff --git a/MyTracks/res/values-pl/strings.xml b/MyTracks/res/values-pl/strings.xml index 0d9ceeafe..762a867cb 100644 --- a/MyTracks/res/values-pl/strings.xml +++ b/MyTracks/res/values-pl/strings.xml @@ -103,6 +103,9 @@ limitations under the License. Powodzenie Punkt orientacyjny Anuluj + Zamknij + Edytuj + Zapisz (Początek) @@ -233,27 +236,6 @@ limitations under the License. Satelity GPS - - Wybierz mapę z twojego konta: - Utwórz nową mapę... - Wyślij do Moich Map Google - Wczytywanie map... - Nie można wczytać twoich map! - Wybierz tę mapę - Edytuj szczegóły mapy - Podziel się mapą z przyjaciółmi - Podziel się trasą z przyjaciółmi - Usuń mapę z twojego konta - Tytuł mapy: - Opis mapy: - Pokazuj tę pamę i jej zawartość w wynikach wyszukiwania - Nie pokazuj tej mapy i jej zawartości w wynikach wyszukiwania. Dostęp do mapy będzie ciągle możliwy poprzez odnośnik - Ta mapa i jej zawartość będzie dostępna w wynikach wyszukiwania - Mapa i jej zawartość nie będzie dostępna w wynikach wyszukiwania, ale będzie dostępna przez bezpośredni odnośnik - Zamknij - Edytuj - Zapisz - Chciałbym się z Tobą podzielić mapą Myślę, że może Cię zainteresować ta mapa: @@ -263,6 +245,7 @@ limitations under the License. Myślę, że może Cię zainteresować ta trasa. Trasę możesz obejrzeć w Google Earth lub innym programie do obsługi map. + Podziel się trasą z przyjaciółmi Publiczna diff --git a/MyTracks/res/values-pt-rBR/strings.xml b/MyTracks/res/values-pt-rBR/strings.xml index ec0437cdf..e3ecbfa89 100644 --- a/MyTracks/res/values-pt-rBR/strings.xml +++ b/MyTracks/res/values-pt-rBR/strings.xml @@ -101,6 +101,9 @@ limitations under the License. Successo Ponto de passagem Cancelar + Fechar + Editar + Salvar (Início) @@ -184,27 +187,6 @@ limitations under the License. Satélites de GPS - - Escolha um mapa da sua conta: - Criar novo mapa... - Enviar para o Google Meus Mapas - Carregando mapas... - Seus mapas não puderam ser carregados neste momento! - Selecionar este Mapa - Editar detalhes do mapa - Compartilhar mapa com amigos - Compartilhar caminho com amigos - Apagar mapa da sua conta - Título do Mapa: - Descrição do Mapa: - Fazer com que o conteúdo deste mapa apareça em resultados de buscas - Não permitir que este mapa ou seu conteúdo apareçam em resultados de buscas, porém ele ainda pode ser visto por sua URL direta - Este mapa e seu conteúdo vão aparecer em resultados de buscas - Nem este mapa nem seu conteúdo vão aparecer em resultados de buscas, porém outras pessoas ainda podem vê-los se obtiverem sua URL direta - Fechar - Editar - Salvar - Eu gostaria de compartilhar um mapa com você Eu acredito que você pode se interessar por este mapa: @@ -214,6 +196,7 @@ limitations under the License. Eu acredito que você pode se interesasr por este caminho. Para visualizar este caminho, use o Google Earth ou outro software de mapas. + Compartilhar caminho com amigos Público diff --git a/MyTracks/res/values-sv/strings.xml b/MyTracks/res/values-sv/strings.xml index 202e071cb..4cefa2706 100644 --- a/MyTracks/res/values-sv/strings.xml +++ b/MyTracks/res/values-sv/strings.xml @@ -103,6 +103,9 @@ limitations under the License. Lyckades Positionsmärke Avbryt + Stäng + Ändra + Spara (Start) @@ -202,27 +205,6 @@ limitations under the License. GPS-satelliter - - Välj en karta från ditt konto: - Skapa en ny karta... - Skicka till Google Mina Kartor - Laddar kartor... - Dina kartor kunde inte laddas just nu! - Välj den här kartan - Ändra kartdetaljer - Dela kartan med vänner - Dela spår med vänner - Ta bort kartan från ditt konto - Karttitel: - Kartbeskrivning: - Gör så att kartan och dess innehåll visas i sökresultat - Låt inte kartan och dess innehåll visas i sökresultat, men de kan ändå ses av andra genom en direktlänk - Kartan och dess innehåll kommer att visas i sökresultat - Varken kartan eller dess innehåll visas i sökresultat, men de kan ändå ses av andra genom en direktlänk - Stäng - Ändra - Spara - Jag vill dela en karta med dig Jag tror att du skulle vara intresserad av den här kartan: @@ -232,6 +214,7 @@ limitations under the License. Jag tror att du skulle vara intresserad av det här spåret. För att se det här spåret använd Google Earth eller något annat kartprogram. + Dela spår med vänner Publik diff --git a/MyTracks/res/values-zh-rCN/strings.xml b/MyTracks/res/values-zh-rCN/strings.xml index 2f9a1c05b..72c2576e9 100644 --- a/MyTracks/res/values-zh-rCN/strings.xml +++ b/MyTracks/res/values-zh-rCN/strings.xml @@ -106,6 +106,9 @@ limitations under the License. 成功 路点 取消 + 关闭 + 编辑 + 保存 (开始) @@ -239,27 +242,6 @@ limitations under the License. GPS 卫星 - - 从你的帐户里选择地图: - 创建新地图... - 发送到 Google My Maps - 载入地图中... - 现在无法载入你的地图! - 选择此地图 - 编辑地图详细信息 - 与朋友分享地图 - 与朋友分享轨迹 - 删除你帐号下的此地图 - 地图标题: - 地图描述: - 允许此地图及其内容出现在搜索结果中 - 不允许地图及其内容出现在搜索结果中, 但它的内容依然可以通过网址直接访问 - 此地图及其内容会出现在搜索结果中 - 此地图及其内容不会出现在搜索结果中, 但它的内容依然可以通过网址直接访问 - 关闭 - 编辑 - 保存 - 我想与你分享一张地图 我想你可能会对这个地图感兴趣: @@ -269,6 +251,7 @@ limitations under the License. 我想你可能会对这条轨迹感兴趣. 请用 Google Earth 或其它地图软件查看此轨迹. + 与朋友分享轨迹 公开 diff --git a/MyTracks/res/values/strings.xml b/MyTracks/res/values/strings.xml index 1bcf74330..3665c56b5 100644 --- a/MyTracks/res/values/strings.xml +++ b/MyTracks/res/values/strings.xml @@ -106,6 +106,9 @@ limitations under the License. Success Waypoint Cancel + Close + Edit + Save (Start) diff --git a/MyTracks/src/com/google/android/apps/mytracks/DialogManager.java b/MyTracks/src/com/google/android/apps/mytracks/DialogManager.java index 84992631b..e8512ac3b 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/DialogManager.java +++ b/MyTracks/src/com/google/android/apps/mytracks/DialogManager.java @@ -85,12 +85,12 @@ 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) { + builder.setNeutralButton(activity.getString(R.string.share_track), + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { activity.shareLinkToFusionTable(activity.sendToTrackId); dialog.dismiss(); - } + } }); sendToGoogleResultDialog = builder.create(); return sendToGoogleResultDialog; diff --git a/MyTracks/src/com/google/android/apps/mytracks/MyTracks.java b/MyTracks/src/com/google/android/apps/mytracks/MyTracks.java index 6979e9b0a..83750d600 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/MyTracks.java +++ b/MyTracks/src/com/google/android/apps/mytracks/MyTracks.java @@ -52,9 +52,6 @@ import android.content.Intent; import android.content.ServiceConnection; import android.content.SharedPreferences; import android.content.SharedPreferences.OnSharedPreferenceChangeListener; -import android.content.pm.PackageInfo; -import android.content.pm.PackageManager; -import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.Resources; import android.location.Location; import android.location.LocationManager; @@ -213,23 +210,6 @@ public class MyTracks extends TabActivity implements OnTouchListener, return instance; } - /** - * Get the My Tracks version from the manifest. - * - * @return the version, or an empty string in case of failure. - */ - public static String getMyTracksVersion(Context context) { - try { - PackageInfo pi = context.getPackageManager().getPackageInfo( - "com.google.android.maps.mytracks", - PackageManager.GET_META_DATA); - return pi.versionName; - } catch (NameNotFoundException e) { - Log.w(MyTracksConstants.TAG, "Failed to get version info.", e); - return ""; - } - } - /** * Checks whether we have a track recording session in progress. * In some cases, when the service has crashed or has been restarted @@ -661,7 +641,7 @@ public class MyTracks extends TabActivity implements OnTouchListener, if (selectedTrack.getTableId().length() > 0) { shareLinkToFusionTable(selectedTrackId); } else { - shareRequested = true; + shareRequested = true; dialogManager.showDialogSafely(DIALOG_SEND_TO_GOOGLE); } } @@ -1112,8 +1092,7 @@ public class MyTracks extends TabActivity implements OnTouchListener, dialogManager.showDialogSafely(DIALOG_PROGRESS); if (sendToGoogleDialog.getSendToFusionTables()) { setProgressValue(0); - setProgressMessage( - R.string.progress_message_authenticating_fusiontables); + setProgressMessage(R.string.progress_message_authenticating_fusiontables); authenticate(new Intent(), MyTracksConstants.SEND_TO_GOOGLE, SendToFusionTables.SERVICE_ID); } else { @@ -1235,10 +1214,10 @@ public class MyTracks extends TabActivity implements OnTouchListener, * Notifies that uploading to fusion tables is finished. */ private void handleFusionTablesFinish(long trackId) { - if (shareRequested && sendToFusionTablesSuccess) { + if (shareRequested && sendToFusionTablesSuccess) { // Just share - Toast.makeText(this, getFusionTablesResultMessage(), Toast.LENGTH_LONG).show(); - shareLinkToFusionTable(trackId); + Toast.makeText(this, getFusionTablesResultMessage(), Toast.LENGTH_LONG).show(); + shareLinkToFusionTable(trackId); } else { dialogManager.showDialogSafely(DialogManager.DIALOG_SEND_TO_GOOGLE_RESULT); } diff --git a/MyTracks/src/com/google/android/apps/mytracks/WelcomeActivity.java b/MyTracks/src/com/google/android/apps/mytracks/WelcomeActivity.java index 4da2b0807..0acf875fc 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/WelcomeActivity.java +++ b/MyTracks/src/com/google/android/apps/mytracks/WelcomeActivity.java @@ -15,6 +15,7 @@ */ package com.google.android.apps.mytracks; +import com.google.android.apps.mytracks.util.MyTracksUtils; import com.google.android.maps.mytracks.R; import android.app.Activity; @@ -74,6 +75,6 @@ public class WelcomeActivity extends Activity { AlertDialog dialog = builder.create(); dialog.show(); ((TextView) dialog.findViewById(R.id.about_version_register)). - setText(MyTracks.getMyTracksVersion(this)); + setText(MyTracksUtils.getMyTracksVersion(this)); } } diff --git a/MyTracks/src/com/google/android/apps/mytracks/content/MyTracksProvider.java b/MyTracks/src/com/google/android/apps/mytracks/content/MyTracksProvider.java index 8dba09e61..a9689e72f 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/content/MyTracksProvider.java +++ b/MyTracks/src/com/google/android/apps/mytracks/content/MyTracksProvider.java @@ -144,15 +144,13 @@ public class MyTracksProvider extends ContentProvider { db.execSQL("DROP TABLE IF EXISTS " + WAYPOINTS_TABLE); onCreate(db); } else { + Log.w(TAG, "Upgrading database from version " + oldVersion + " to " + + newVersion + ", adding sensor column."); if (oldVersion == 17) { - Log.w(TAG, "Upgrading database from version " + oldVersion + " to " - + newVersion + ", adding sensor column."); db.execSQL("ALTER TABLE " + TRACKPOINTS_TABLE + " ADD " + TrackPointsColumns.SENSOR + " BLOB"); }; if (oldVersion >= 17) { - Log.w(TAG, "Upgrading database from version " + oldVersion + " to " - + newVersion + ", adding tableid column."); db.execSQL("ALTER TABLE " + TRACKS_TABLE + " ADD " + TracksColumns.TABLEID + " STRING"); } diff --git a/MyTracks/src/com/google/android/apps/mytracks/io/SendToDocs.java b/MyTracks/src/com/google/android/apps/mytracks/io/SendToDocs.java index c2d85b758..d72027a33 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/io/SendToDocs.java +++ b/MyTracks/src/com/google/android/apps/mytracks/io/SendToDocs.java @@ -329,8 +329,8 @@ public class SendToDocs { break; } } - } catch (ParseException e) { - throw new GDataWrapper.ParseException(); + } catch (ParseException e) { + throw new GDataWrapper.ParseException(e); } catch (HttpException e) { throw new GDataWrapper.HttpException(e.getStatusCode(), e.getMessage()); } @@ -346,27 +346,27 @@ public class SendToDocs { throws GDataWrapper.AuthenticationException, IOException, GDataWrapper.ParseException { String uri = String.format(DOCS_WORKSHEETS_URL_FORMAT, spreadSheetId); GDataParser sheetParser; - try { - sheetParser = ((SpreadsheetsClient) client).getParserForWorksheetsFeed(uri, - wiseAuth.getAuthToken()); - sheetParser.init(); - if (!sheetParser.hasMoreData()) { - Log.i(MyTracksConstants.TAG, "Found no worksheets"); - return; // failure - } + try { + sheetParser = ((SpreadsheetsClient) client).getParserForWorksheetsFeed(uri, + wiseAuth.getAuthToken()); + sheetParser.init(); + if (!sheetParser.hasMoreData()) { + Log.i(MyTracksConstants.TAG, "Found no worksheets"); + return; // failure + } - // just grab the first. - WorksheetEntry worksheetEntry = - (WorksheetEntry) sheetParser.readNextEntry(new WorksheetEntry()); + // just grab the first. + WorksheetEntry worksheetEntry = + (WorksheetEntry) sheetParser.readNextEntry(new WorksheetEntry()); - int lastSlash = worksheetEntry.getId().lastIndexOf('/'); - workSheetId = worksheetEntry.getId().substring(lastSlash + 1); + int lastSlash = worksheetEntry.getId().lastIndexOf('/'); + workSheetId = worksheetEntry.getId().substring(lastSlash + 1); - } catch (AuthenticationException e) { - throw new GDataWrapper.AuthenticationException(); - } catch (ParseException e) { - throw new GDataWrapper.ParseException(); - } + } catch (AuthenticationException e) { + throw new GDataWrapper.AuthenticationException(e); + } catch (ParseException e) { + throw new GDataWrapper.ParseException(e); + } } }); } 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 3a354a115..b0b62be0e 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/io/SendToFusionTables.java +++ b/MyTracks/src/com/google/android/apps/mytracks/io/SendToFusionTables.java @@ -15,7 +15,6 @@ */ package com.google.android.apps.mytracks.io; -import com.google.android.apps.mytracks.MyTracks; import com.google.android.apps.mytracks.MyTracksConstants; import com.google.android.apps.mytracks.MyTracksSettings; import com.google.android.apps.mytracks.ProgressIndicator; @@ -60,18 +59,21 @@ import java.util.Vector; */ public class SendToFusionTables implements Runnable { + /** + * Listener invoked when sending to fusion tables completes. + */ public interface OnSendCompletedListener { void onSendCompleted(String tableId, boolean success, int statusMessage); } - /** The GData service id for Fusion Tables. */ + /** The GData service id for Fusion Tables. */ public static final String SERVICE_ID = "fusiontables"; /** The path for viewing a map visualization of a table. */ private static final String FUSIONTABLES_MAP = - "http://www.google.com/fusiontables/embedviz?" + - "viz=MAP&q=select+col0,+col1,+col2,+col3+from+%s+&h=false&" + - "lat=%f&lng=%f&z=%d&t=1&l=col2"; + "http://www.google.com/fusiontables/embedviz?" + + "viz=MAP&q=select+col0,+col1,+col2,+col3+from+%s+&h=false&" + + "lat=%f&lng=%f&z=%d&t=1&l=col2"; /** Standard base feed url for Fusion Tables. */ private static final String FUSIONTABLES_BASE_FEED_URL = @@ -79,6 +81,8 @@ public class SendToFusionTables implements Runnable { private static final int MAX_POINTS_PER_UPLOAD = 2048; + private static final String GDATA_VERSION = "2"; + private final Activity context; private final AuthManager auth; private final long trackId; @@ -97,6 +101,10 @@ public class SendToFusionTables implements Runnable { private HttpTransport transport; private String tableId; + private static String MARKER_TYPE_START = "large_green"; + private static String MARKER_TYPE_END = "large_red"; + private static String MARKER_TYPE_WAYPOINT = "large_yellow"; + public SendToFusionTables(Activity context, AuthManager auth, long trackId, ProgressIndicator progressIndicator, OnSendCompletedListener onCompletion) { @@ -109,8 +117,8 @@ public class SendToFusionTables implements Runnable { this.providerUtils = MyTracksProviderUtils.Factory.get(context); transport = GoogleTransport.create(); GoogleHeaders headers = (GoogleHeaders) transport.defaultHeaders; - headers.setApplicationName("Google-MyTracks-" + MyTracks.getMyTracksVersion(context)); - headers.gdataVersion = "2"; + headers.setApplicationName("Google-MyTracks-" + MyTracksUtils.getMyTracksVersion(context)); + headers.gdataVersion = GDATA_VERSION; } @Override @@ -121,11 +129,11 @@ public class SendToFusionTables implements Runnable { public static String getMapVisualizationUrl(Track track) { // 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; + 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(), latE6 / 1.E6, lonE6 / 1.E6, z); + return String.format(FUSIONTABLES_MAP, track.getTableId(), latE6 / 1.E6, lonE6 / 1.E6, z); } private void doUpload() { @@ -191,17 +199,17 @@ public class SendToFusionTables implements Runnable { * @return the values formatted as: ('value1','value2',...,'value_n'). */ private static String values(String... values) { - StringBuilder builder = new StringBuilder("("); - for (int i = 0; i < values.length; i++) { - builder.append('\''); - builder.append(values[i].replaceAll("'", "xxx")); + StringBuilder builder = new StringBuilder("("); + for (int i = 0; i < values.length; i++) { + if (i > 0) { + builder.append(','); + } builder.append('\''); - if (i < values.length - 1) { - builder.append(','); - } - } - builder.append(')'); - return builder.toString(); + builder.append(values[i].replaceAll("'", "''")); + builder.append('\''); + } + builder.append(')'); + return builder.toString(); } /** @@ -213,7 +221,7 @@ public class SendToFusionTables implements Runnable { * @return true in case of success. */ private boolean createNewPoint(String name, String description, Location location, - String marker) { + String marker) { Log.d(MyTracksConstants.TAG, "Creating a new row with a point."); String query = "INSERT INTO " + tableId + " (name,description,geometry,marker) VALUES " + values(name, description, getKmlPoint(location), marker); @@ -229,8 +237,8 @@ public class SendToFusionTables implements Runnable { private boolean createNewLineString(Track track) { Log.d(MyTracksConstants.TAG, "Creating a new row with a point."); String query = "INSERT INTO " + tableId - + " (name,description,geometry) VALUES " - + values(track.getName(), track.getDescription(), getKmlLineString(track)); + + " (name,description,geometry) VALUES " + + values(track.getName(), track.getDescription(), getKmlLineString(track)); return runUpdate(query); } @@ -248,25 +256,25 @@ public class SendToFusionTables implements Runnable { Log.w(MyTracksConstants.TAG, "Unable to get any points to upload"); return false; } - + totalLocationsRead = 0; totalLocationsPrepared = 0; totalLocationsUploaded = 0; totalLocations = locationsCursor.getCount(); totalSegmentsUploaded = 0; - + // 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, - "Using elevation sampling factor: " + elevationSamplingFrequency - + " on " + totalLocations); + "Using elevation sampling factor: " + elevationSamplingFrequency + + " on " + totalLocations); double totalDistance = 0; - + Vector distances = new Vector(); Vector elevations = new Vector(); DoubleBuffer elevationBuffer = new DoubleBuffer(MyTracksConstants.ELEVATION_SMOOTHING_FACTOR); - + List locations = new ArrayList(MAX_POINTS_PER_UPLOAD); progressIndicator.setProgressMessage(R.string.progress_message_reading_track); Location lastLocation = null; @@ -274,16 +282,16 @@ public class SendToFusionTables implements Runnable { if (totalLocationsRead % 100 == 0) { updateProgress(); } - + Location loc = providerUtils.createLocation(locationsCursor); locations.add(loc); - + if (totalLocationsRead == 0) { // Put a marker at the first point of the first valid segment: - String name = track.getName() + " " + context.getString(R.string.start); - createNewPoint(name, "", loc, "large_green"); + String name = track.getName() + " " + context.getString(R.string.start); + createNewPoint(name, "", loc, MARKER_TYPE_START); } - + // Add to the elevation profile. if (loc != null && MyTracksUtils.isValidLocation(loc)) { // All points go into the smoothing buffer... @@ -293,43 +301,41 @@ public class SendToFusionTables implements Runnable { double dist = lastLocation.distanceTo(loc); totalDistance += dist; } - + // ...but only a few points are really used to keep the url short. if (totalLocationsRead % elevationSamplingFrequency == 0) { distances.add(totalDistance); elevations.add(elevationBuffer.getAverage()); } } - + // If the location was not valid, it's a segment split, so make sure the // distance between the previous segment and the new one is not accounted // for in the next iteration. lastLocation = loc; - + // Every now and then, upload the accumulated points - if (totalLocationsRead % MAX_POINTS_PER_UPLOAD - == MAX_POINTS_PER_UPLOAD - 1) { + if (totalLocationsRead % MAX_POINTS_PER_UPLOAD == MAX_POINTS_PER_UPLOAD - 1) { if (!prepareAndUploadPoints(track, locations)) { return false; } } - + totalLocationsRead++; } while (locationsCursor.moveToNext()); - + // Do a final upload with what's left if (!prepareAndUploadPoints(track, locations)) { return false; } - + // Put an end marker at the last point of the last valid segment: if (lastLocation != null) { track.setDescription("

" + originalDescription + "

" - + stringUtils.generateTrackDescription( - track, distances, elevations) + + stringUtils.generateTrackDescription(track, distances, elevations) + "

"); - String name = track.getName() + " " + context.getString(R.string.end); - return createNewPoint(name, track.getDescription(), lastLocation, "large_red"); + String name = track.getName() + " " + context.getString(R.string.end); + return createNewPoint(name, track.getDescription(), lastLocation, MARKER_TYPE_END); } return true; @@ -337,7 +343,7 @@ public class SendToFusionTables implements Runnable { locationsCursor.close(); } } - + /** * Appends the given location to the string in the format: * longitude,latitude[,altitude] @@ -346,14 +352,14 @@ public class SendToFusionTables implements Runnable { * @param builder the string builder to use */ private void appendCoordinate(Location location, StringBuilder builder) { - builder - .append(location.getLongitude()) - .append(",") - .append(location.getLatitude()); - if (location.hasAltitude()) { - builder.append(","); - builder.append(location.getAltitude()); - } + builder + .append(location.getLongitude()) + .append(",") + .append(location.getLatitude()); + if (location.hasAltitude()) { + builder.append(","); + builder.append(location.getAltitude()); + } } /** @@ -376,29 +382,29 @@ public class SendToFusionTables implements Runnable { * @return the kml. */ private String getKmlLineString(Track track) { - StringBuilder builder = new StringBuilder(""); - for (Location location : track.getLocations()) { - appendCoordinate(location, builder); - builder.append(' '); - } - builder.append(""); - return builder.toString(); + StringBuilder builder = new StringBuilder(""); + for (Location location : track.getLocations()) { + appendCoordinate(location, builder); + builder.append(' '); + } + builder.append(""); + return builder.toString(); } private boolean prepareAndUploadPoints(Track track, List locations) { progressIndicator.setProgressMessage(R.string.progress_message_preparing_track); updateProgress(); - + int numLocations = locations.size(); if (numLocations < 2) { Log.d(MyTracksConstants.TAG, "Not preparing/uploading too few points"); totalLocationsUploaded += numLocations; return true; } - + // Prepare/pre-process the points ArrayList splitTracks = prepareLocations(track, locations); - + // Start uploading them progressIndicator.setProgressMessage(R.string.progress_message_sending_fusiontables); for (Track splitTrack : splitTracks) { @@ -411,7 +417,7 @@ public class SendToFusionTables implements Runnable { Log.d(MyTracksConstants.TAG, "SendToFusionTables: Prepared feature for upload w/ " + splitTrack.getLocations().size() + " points."); - + // Transmit tracks via GData feed: // ------------------------------- Log.d(MyTracksConstants.TAG, @@ -421,7 +427,7 @@ public class SendToFusionTables implements Runnable { return false; } } - + locations.clear(); totalLocationsUploaded += numLocations; updateProgress(); @@ -439,7 +445,7 @@ public class SendToFusionTables implements Runnable { private ArrayList prepareLocations( Track track, Iterable locations) { ArrayList splitTracks = new ArrayList(); - + // Create segments from each full track: Track segment = new Track(); TripStatistics segmentStats = segment.getStatistics(); @@ -458,11 +464,11 @@ public class SendToFusionTables implements Runnable { if (loc.getLatitude() > 90) { startNewTrackSegment = true; } - + if (startNewTrackSegment) { // Close up the last segment. prepareTrackSegment(segment, splitTracks); - + Log.d(MyTracksConstants.TAG, "MyTracksSendToFusionTables: Starting new track segment..."); startNewTrackSegment = false; @@ -472,7 +478,7 @@ public class SendToFusionTables implements Runnable { segment.setDescription(/* track.getDescription() */ ""); segment.setCategory(track.getCategory()); } - + if (loc.getLatitude() <= 90) { segment.addLocation(loc); if (segmentStats.getStartTime() < 0) { @@ -481,9 +487,9 @@ public class SendToFusionTables implements Runnable { } totalLocationsPrepared++; } - + prepareTrackSegment(segment, splitTracks); - + return splitTracks; } @@ -506,13 +512,13 @@ public class SendToFusionTables implements Runnable { && segment.getLocations().size() > 0) { segmentStats.setStopTime(segment.getLocations().size() - 1); } - + /* * Decimate to 2 meter precision. Fusion tables doesn't like too many * points: */ MyTracksUtils.decimate(segment, 2.0); - + /* If the track still has > 2500 points, split it in pieces: */ final int maxPoints = 2500; if (segment.getLocations().size() > maxPoints) { @@ -557,7 +563,7 @@ public class SendToFusionTables implements Runnable { Waypoint wpt = providerUtils.createWaypoint(c); Log.d(MyTracksConstants.TAG, "SendToFusionTables: Creating waypoint."); success = createNewPoint(wpt.getName(), wpt.getDescription(), wpt.getLocation(), - "large_yellow"); + MARKER_TYPE_WAYPOINT); if (!success) { break; } @@ -611,20 +617,20 @@ public class SendToFusionTables implements Runnable { HttpResponse response = request.execute(); boolean success = response.isSuccessStatusCode; if (success) { - byte[] result = new byte[1024]; - response.getContent().read(result); - String s = Strings.fromBytesUtf8(result); - String[] lines = s.split(Strings.LINE_SEPARATOR); - if (lines[0].equals("tableid")) { - tableId = lines[1]; - Log.d(MyTracksConstants.TAG, "tableId = " + tableId); - } else { - Log.w(MyTracksConstants.TAG, "Unrecognized response: " + lines[0]); - } + byte[] result = new byte[1024]; + response.getContent().read(result); + String s = Strings.fromBytesUtf8(result); + String[] lines = s.split(Strings.LINE_SEPARATOR); + if (lines[0].equals("tableid")) { + tableId = lines[1]; + Log.d(MyTracksConstants.TAG, "tableId = " + tableId); + } else { + Log.w(MyTracksConstants.TAG, "Unrecognized response: " + lines[0]); + } } else { - Log.d(MyTracksConstants.TAG, "Query failed: " + response.statusMessage + " (" + - response.statusCode + ")"); - throw new GDataWrapper.HttpException(response.statusCode, response.statusMessage); + Log.d(MyTracksConstants.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/backup/BackupColumns.java b/MyTracks/src/com/google/android/apps/mytracks/io/backup/BackupColumns.java index 9fb3f739a..96de8cfa2 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/io/backup/BackupColumns.java +++ b/MyTracks/src/com/google/android/apps/mytracks/io/backup/BackupColumns.java @@ -37,13 +37,15 @@ public class BackupColumns { TracksColumns.MOVINGTIME, TracksColumns.AVGSPEED, TracksColumns.AVGMOVINGSPEED, TracksColumns.MAXSPEED, TracksColumns.MINELEVATION, TracksColumns.MAXELEVATION, TracksColumns.ELEVATIONGAIN, TracksColumns.MINGRADE, TracksColumns.MAXGRADE, - TracksColumns.MINLAT, TracksColumns.MAXLAT, TracksColumns.MINLON, TracksColumns.MAXLON }; + TracksColumns.MINLAT, TracksColumns.MAXLAT, TracksColumns.MINLON, TracksColumns.MAXLON, + TracksColumns.MAPID, TracksColumns.TABLEID}; public static final byte[] TRACKS_BACKUP_COLUMN_TYPES = { LONG_TYPE_ID, STRING_TYPE_ID, STRING_TYPE_ID, STRING_TYPE_ID, LONG_TYPE_ID, LONG_TYPE_ID, LONG_TYPE_ID, LONG_TYPE_ID, INT_TYPE_ID, FLOAT_TYPE_ID, LONG_TYPE_ID, LONG_TYPE_ID, FLOAT_TYPE_ID, FLOAT_TYPE_ID, FLOAT_TYPE_ID, FLOAT_TYPE_ID, FLOAT_TYPE_ID, FLOAT_TYPE_ID, FLOAT_TYPE_ID, - FLOAT_TYPE_ID, INT_TYPE_ID, INT_TYPE_ID, INT_TYPE_ID, INT_TYPE_ID }; + FLOAT_TYPE_ID, INT_TYPE_ID, INT_TYPE_ID, INT_TYPE_ID, INT_TYPE_ID, STRING_TYPE_ID, + STRING_TYPE_ID}; public static final String[] WAYPOINTS_BACKUP_COLUMNS = { WaypointsColumns._ID, WaypointsColumns.TRACKID, WaypointsColumns.NAME, 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 d1370ad2f..48de71ebe 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 @@ -39,33 +39,54 @@ import java.util.concurrent.TimeoutException; */ public class GDataWrapper { - public static class AuthenticationException extends Exception { - private static final long serialVersionUID = 1L; + public static class AuthenticationException extends Exception { + private Exception exception; + private static final long serialVersionUID = 1L; + public AuthenticationException(Exception caught) { + this.exception = caught; + } + public Exception getException() { + return exception; + } }; - public static class ParseException extends Exception { - private static final long serialVersionUID = 1L; + public static class ParseException extends Exception { + private Exception exception; + private static final long serialVersionUID = 1L; + public ParseException(Exception caught) { + this.exception = caught; + } + public Exception getException() { + return exception; + } }; public static class ConflictDetectedException extends Exception { - private static final long serialVersionUID = 1L; + private Exception exception; + private static final long serialVersionUID = 1L; + public ConflictDetectedException(Exception caught) { + this.exception = caught; + } + public Exception getException() { + return exception; + } }; - public static class HttpException extends Exception { - private static final long serialVersionUID = 1L; - private int statusCode; - private String statusMessage; - public HttpException(int statusCode, String statusMessage) { - super(); - this.statusCode = statusCode; - this.statusMessage = statusMessage; - } - public int getStatusCode() { - return statusCode; - } - public String getStatusMessage() { - return statusMessage; - } + public static class HttpException extends Exception { + private static final long serialVersionUID = 1L; + private int statusCode; + private String statusMessage; + public HttpException(int statusCode, String statusMessage) { + super(); + this.statusCode = statusCode; + this.statusMessage = statusMessage; + } + public int getStatusCode() { + return statusCode; + } + public String getStatusMessage() { + return statusMessage; + } }; /** diff --git a/MyTracks/src/com/google/android/apps/mytracks/util/MyTracksUtils.java b/MyTracks/src/com/google/android/apps/mytracks/util/MyTracksUtils.java index 71caa003c..4d83ba992 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/util/MyTracksUtils.java +++ b/MyTracks/src/com/google/android/apps/mytracks/util/MyTracksUtils.java @@ -21,6 +21,10 @@ import com.google.android.apps.mytracks.stats.TripStatistics; import com.google.android.maps.GeoPoint; +import android.content.Context; +import android.content.pm.PackageInfo; +import android.content.pm.PackageManager; +import android.content.pm.PackageManager.NameNotFoundException; import android.location.Location; import android.util.Log; @@ -246,6 +250,23 @@ public class MyTracksUtils { (int) (location.getLongitude() * 1E6)); } + /** + * Get the My Tracks version from the manifest. + * + * @return the version, or an empty string in case of failure. + */ + public static String getMyTracksVersion(Context context) { + try { + PackageInfo pi = context.getPackageManager().getPackageInfo( + "com.google.android.maps.mytracks", + PackageManager.GET_META_DATA); + return pi.versionName; + } catch (NameNotFoundException e) { + Log.w(MyTracksConstants.TAG, "Failed to get version info.", e); + return ""; + } + } + /** * This is a utility class w/ only static memebers. */