forked from upstream-mirrors/OpenTracks
Code cleanup. Remove track.getMapId and track.getTableId.
This commit is contained in:
Binary file not shown.
@@ -68,9 +68,6 @@ public class SendDriveAsyncTask extends AbstractSendAsyncTask {
|
|||||||
@Override
|
@Override
|
||||||
protected void closeConnection() {}
|
protected void closeConnection() {}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void saveResult() {}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean performTask() {
|
protected boolean performTask() {
|
||||||
try {
|
try {
|
||||||
|
|||||||
+4
-8
@@ -88,9 +88,6 @@ public class SendFusionTablesAsyncTask extends AbstractSendAsyncTask {
|
|||||||
@Override
|
@Override
|
||||||
protected void closeConnection() {}
|
protected void closeConnection() {}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void saveResult() {}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean performTask() {
|
protected boolean performTask() {
|
||||||
try {
|
try {
|
||||||
@@ -121,7 +118,7 @@ public class SendFusionTablesAsyncTask extends AbstractSendAsyncTask {
|
|||||||
publishProgress(PROGRESS_SET_STYLE);
|
publishProgress(PROGRESS_SET_STYLE);
|
||||||
setStyle(fusiontables, tableId);
|
setStyle(fusiontables, tableId);
|
||||||
setTemplate(fusiontables, tableId);
|
setTemplate(fusiontables, tableId);
|
||||||
if (!setPermission(tableId)) {
|
if (!setPermission(track, tableId)) {
|
||||||
Log.d(TAG, "Cannot set permission for table " + tableId);
|
Log.d(TAG, "Cannot set permission for table " + tableId);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -138,9 +135,6 @@ public class SendFusionTablesAsyncTask extends AbstractSendAsyncTask {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
track.setTableId(tableId);
|
|
||||||
myTracksProviderUtils.updateTrack(track);
|
|
||||||
|
|
||||||
publishProgress(PROGRESS_COMPLETE);
|
publishProgress(PROGRESS_COMPLETE);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -200,7 +194,7 @@ public class SendFusionTablesAsyncTask extends AbstractSendAsyncTask {
|
|||||||
fusiontables.template().insert(tableId, template).execute();
|
fusiontables.template().insert(tableId, template).execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean setPermission(String tableId) throws IOException, GoogleAuthException {
|
private boolean setPermission(Track track, String tableId) throws IOException, GoogleAuthException {
|
||||||
boolean defaultTablePublic = PreferencesUtils.getBoolean(context,
|
boolean defaultTablePublic = PreferencesUtils.getBoolean(context,
|
||||||
R.string.export_google_fusion_tables_public_key,
|
R.string.export_google_fusion_tables_public_key,
|
||||||
PreferencesUtils.EXPORT_GOOGLE_FUSION_TABLES_PUBLIC_DEFAULT);
|
PreferencesUtils.EXPORT_GOOGLE_FUSION_TABLES_PUBLIC_DEFAULT);
|
||||||
@@ -218,6 +212,8 @@ public class SendFusionTablesAsyncTask extends AbstractSendAsyncTask {
|
|||||||
permission.setType("anyone");
|
permission.setType("anyone");
|
||||||
permission.setValue("");
|
permission.setValue("");
|
||||||
drive.permissions().insert(tableId, permission).execute();
|
drive.permissions().insert(tableId, permission).execute();
|
||||||
|
|
||||||
|
shareUrl = SendFusionTablesUtils.getMapUrl(track, tableId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-8
@@ -42,13 +42,11 @@ public class SendFusionTablesUtils {
|
|||||||
* Gets the url to visualize a fusion table on a map.
|
* Gets the url to visualize a fusion table on a map.
|
||||||
*
|
*
|
||||||
* @param track the track
|
* @param track the track
|
||||||
|
* @param tableId the table id
|
||||||
* @return the url.
|
* @return the url.
|
||||||
*/
|
*/
|
||||||
public static String getMapUrl(Track track) {
|
public static String getMapUrl(Track track, String tableId) {
|
||||||
if (track == null
|
if (track == null || track.getTripStatistics() == 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;
|
||||||
}
|
}
|
||||||
@@ -57,7 +55,7 @@ public class SendFusionTablesUtils {
|
|||||||
int z;
|
int z;
|
||||||
if (track.getNumberOfPoints() < 2) {
|
if (track.getNumberOfPoints() < 2) {
|
||||||
// Use Google's latitude and longitude
|
// Use Google's latitude and longitude
|
||||||
latE6 = 37.423 * 1.E6;
|
latE6 = 37.423 * 1.E6;
|
||||||
lonE6 = -122.084 * 1.E6;
|
lonE6 = -122.084 * 1.E6;
|
||||||
z = 2;
|
z = 2;
|
||||||
} else {
|
} else {
|
||||||
@@ -69,8 +67,7 @@ public class SendFusionTablesUtils {
|
|||||||
// We explicitly format with Locale.US because we need the latitude and
|
// We explicitly format with Locale.US because we need the latitude and
|
||||||
// longitude to be formatted in a locale-independent manner. Specifically,
|
// longitude to be formatted in a locale-independent manner. Specifically,
|
||||||
// we need the decimal separator to be a period rather than a comma.
|
// we need the decimal separator to be a period rather than a comma.
|
||||||
return String.format(
|
return String.format(Locale.US, MAP_URL, tableId, latE6 / 1.E6, lonE6 / 1.E6, z);
|
||||||
Locale.US, MAP_URL, track.getTableId(), latE6 / 1.E6, lonE6 / 1.E6, z);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -123,17 +123,6 @@ public class SendMapsAsyncTask extends AbstractSendAsyncTask {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void saveResult() {
|
|
||||||
Track track = myTracksProviderUtils.getTrack(trackId);
|
|
||||||
if (track == null) {
|
|
||||||
Log.d(TAG, "No track for " + trackId);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
track.setMapId(mapId);
|
|
||||||
myTracksProviderUtils.updateTrack(track);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean performTask() {
|
protected boolean performTask() {
|
||||||
// Reset the per upload states
|
// Reset the per upload states
|
||||||
@@ -222,6 +211,7 @@ public class SendMapsAsyncTask extends AbstractSendAsyncTask {
|
|||||||
+ context.getString(R.string.send_google_by_my_tracks, "", "");
|
+ context.getString(R.string.send_google_by_my_tracks, "", "");
|
||||||
mapId = SendMapsUtils.createNewMap(
|
mapId = SendMapsUtils.createNewMap(
|
||||||
track.getName(), description, defaultMapPublic, mapsClient, authToken);
|
track.getName(), description, defaultMapPublic, mapsClient, authToken);
|
||||||
|
shareUrl = MapsClient.buildMapUrl(mapId);
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
Log.d(TAG, "Unable to create a new map", e);
|
Log.d(TAG, "Unable to create a new map", e);
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -15,7 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.google.android.apps.mytracks.io.maps;
|
package com.google.android.apps.mytracks.io.maps;
|
||||||
|
|
||||||
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.gdata.maps.MapsClient;
|
import com.google.android.apps.mytracks.io.gdata.maps.MapsClient;
|
||||||
import com.google.android.apps.mytracks.io.gdata.maps.MapsFeature;
|
import com.google.android.apps.mytracks.io.gdata.maps.MapsFeature;
|
||||||
@@ -46,22 +45,6 @@ public class SendMapsUtils {
|
|||||||
|
|
||||||
private SendMapsUtils() {}
|
private SendMapsUtils() {}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the Google Maps url for a track.
|
|
||||||
*
|
|
||||||
* @param track the track
|
|
||||||
* @return the url if available.
|
|
||||||
*/
|
|
||||||
public static String getMapUrl(Track track) {
|
|
||||||
if (track == null
|
|
||||||
|| track.getMapId() == null
|
|
||||||
|| track.getMapId().length() == 0) {
|
|
||||||
Log.e(TAG, "Invalid track");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return MapsClient.buildMapUrl(track.getMapId());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new Google Map.
|
* Creates a new Google Map.
|
||||||
*
|
*
|
||||||
|
|||||||
-8
@@ -100,9 +100,6 @@ public abstract class AbstractSendAsyncTask extends AsyncTask<Void, Integer, Boo
|
|||||||
protected void onPostExecute(Boolean result) {
|
protected void onPostExecute(Boolean result) {
|
||||||
success = result;
|
success = result;
|
||||||
completed = true;
|
completed = true;
|
||||||
if (success) {
|
|
||||||
saveResult();
|
|
||||||
}
|
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
activity.onAsyncTaskCompleted(success, shareUrl);
|
activity.onAsyncTaskCompleted(success, shareUrl);
|
||||||
}
|
}
|
||||||
@@ -132,11 +129,6 @@ public abstract class AbstractSendAsyncTask extends AsyncTask<Void, Integer, Boo
|
|||||||
*/
|
*/
|
||||||
protected abstract void closeConnection();
|
protected abstract void closeConnection();
|
||||||
|
|
||||||
/**
|
|
||||||
* Saves any AsyncTask result.
|
|
||||||
*/
|
|
||||||
protected abstract void saveResult();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs the AsyncTask.
|
* Performs the AsyncTask.
|
||||||
*
|
*
|
||||||
|
|||||||
+1
-17
@@ -20,10 +20,7 @@ import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
|||||||
import com.google.android.apps.mytracks.content.Track;
|
import com.google.android.apps.mytracks.content.Track;
|
||||||
import com.google.android.apps.mytracks.fragments.ChooseActivityDialogFragment;
|
import com.google.android.apps.mytracks.fragments.ChooseActivityDialogFragment;
|
||||||
import com.google.android.apps.mytracks.fragments.ChooseActivityDialogFragment.ChooseActivityCaller;
|
import com.google.android.apps.mytracks.fragments.ChooseActivityDialogFragment.ChooseActivityCaller;
|
||||||
import com.google.android.apps.mytracks.io.fusiontables.SendFusionTablesUtils;
|
|
||||||
import com.google.android.apps.mytracks.io.maps.SendMapsUtils;
|
|
||||||
import com.google.android.apps.mytracks.util.IntentUtils;
|
import com.google.android.apps.mytracks.util.IntentUtils;
|
||||||
import com.google.android.apps.mytracks.util.PreferencesUtils;
|
|
||||||
import com.google.android.maps.mytracks.R;
|
import com.google.android.maps.mytracks.R;
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
|
|
||||||
@@ -74,19 +71,6 @@ public class UploadResultActivity extends FragmentActivity implements ChooseActi
|
|||||||
getSupportFragmentManager(), ChooseActivityDialogFragment.CHOOSE_ACTIVITY_DIALOG_TAG);
|
getSupportFragmentManager(), ChooseActivityDialogFragment.CHOOSE_ACTIVITY_DIALOG_TAG);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sendRequest.isSendMaps() && sendRequest.isMapsSuccess()) {
|
|
||||||
shareUrl = SendMapsUtils.getMapUrl(track);
|
|
||||||
}
|
|
||||||
if (shareUrl == null && sendRequest.isSendFusionTables()
|
|
||||||
&& sendRequest.isFusionTablesSuccess()) {
|
|
||||||
boolean defaultTablePublic = PreferencesUtils.getBoolean(this,
|
|
||||||
R.string.export_google_fusion_tables_public_key,
|
|
||||||
PreferencesUtils.EXPORT_GOOGLE_FUSION_TABLES_PUBLIC_DEFAULT);
|
|
||||||
if (defaultTablePublic) {
|
|
||||||
shareUrl = SendFusionTablesUtils.getMapUrl(track);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
showDialog(DIALOG_RESULT_ID);
|
showDialog(DIALOG_RESULT_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,7 +161,7 @@ public class UploadResultActivity extends FragmentActivity implements ChooseActi
|
|||||||
.setView(view);
|
.setView(view);
|
||||||
|
|
||||||
// Add a Share URL button if shareUrl exists
|
// Add a Share URL button if shareUrl exists
|
||||||
if (shareUrl != null) {
|
if (!hasError && shareUrl != null) {
|
||||||
builder.setNegativeButton(
|
builder.setNegativeButton(
|
||||||
R.string.share_track_share_url, new DialogInterface.OnClickListener() {
|
R.string.share_track_share_url, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+1
-18
@@ -18,8 +18,6 @@ package com.google.android.apps.mytracks.io.spreadsheets;
|
|||||||
|
|
||||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
||||||
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.maps.SendMapsUtils;
|
|
||||||
import com.google.android.apps.mytracks.io.sendtogoogle.AbstractSendAsyncTask;
|
import com.google.android.apps.mytracks.io.sendtogoogle.AbstractSendAsyncTask;
|
||||||
import com.google.android.apps.mytracks.io.sendtogoogle.SendToGoogleUtils;
|
import com.google.android.apps.mytracks.io.sendtogoogle.SendToGoogleUtils;
|
||||||
import com.google.android.apps.mytracks.io.sync.SyncUtils;
|
import com.google.android.apps.mytracks.io.sync.SyncUtils;
|
||||||
@@ -97,9 +95,6 @@ public class SendSpreadsheetsAsyncTask extends AbstractSendAsyncTask {
|
|||||||
@Override
|
@Override
|
||||||
protected void closeConnection() {}
|
protected void closeConnection() {}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void saveResult() {}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean performTask() {
|
protected boolean performTask() {
|
||||||
try {
|
try {
|
||||||
@@ -281,19 +276,7 @@ public class SendSpreadsheetsAsyncTask extends AbstractSendAsyncTask {
|
|||||||
row.getCustomElements().setValueLocal(
|
row.getCustomElements().setValueLocal(
|
||||||
"maxelevation", SendSpreadsheetsUtils.getElevation(tripStatistics.getMaxElevation(), metricUnits));
|
"maxelevation", SendSpreadsheetsUtils.getElevation(tripStatistics.getMaxElevation(), metricUnits));
|
||||||
row.getCustomElements().setValueLocal("elevationunit", elevationUnit);
|
row.getCustomElements().setValueLocal("elevationunit", elevationUnit);
|
||||||
|
|
||||||
String map = SendMapsUtils.getMapUrl(track);
|
|
||||||
if (map == null) {
|
|
||||||
map = context.getString(R.string.value_unknown);
|
|
||||||
}
|
|
||||||
row.getCustomElements().setValueLocal("map", map);
|
|
||||||
|
|
||||||
String fusionTable = SendFusionTablesUtils.getMapUrl(track);
|
|
||||||
if (fusionTable == null) {
|
|
||||||
fusionTable = context.getString(R.string.value_unknown);
|
|
||||||
}
|
|
||||||
row.getCustomElements().setValueLocal("fusiontable", fusionTable);
|
|
||||||
|
|
||||||
ListEntry result = spreadsheetService.insert(worksheetUrl, row);
|
ListEntry result = spreadsheetService.insert(worksheetUrl, row);
|
||||||
return result != null;
|
return result != null;
|
||||||
}
|
}
|
||||||
|
|||||||
-10
@@ -82,8 +82,6 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
|||||||
int elevationGainIndex = cursor.getColumnIndexOrThrow(TracksColumns.ELEVATIONGAIN);
|
int elevationGainIndex = cursor.getColumnIndexOrThrow(TracksColumns.ELEVATIONGAIN);
|
||||||
int minGradeIndex = cursor.getColumnIndexOrThrow(TracksColumns.MINGRADE);
|
int minGradeIndex = cursor.getColumnIndexOrThrow(TracksColumns.MINGRADE);
|
||||||
int maxGradeIndex = cursor.getColumnIndexOrThrow(TracksColumns.MAXGRADE);
|
int maxGradeIndex = cursor.getColumnIndexOrThrow(TracksColumns.MAXGRADE);
|
||||||
int mapIdIndex = cursor.getColumnIndexOrThrow(TracksColumns.MAPID);
|
|
||||||
int tableIdIndex = cursor.getColumnIndexOrThrow(TracksColumns.TABLEID);
|
|
||||||
int iconIndex = cursor.getColumnIndexOrThrow(TracksColumns.ICON);
|
int iconIndex = cursor.getColumnIndexOrThrow(TracksColumns.ICON);
|
||||||
int driveIdIndex = cursor.getColumnIndexOrThrow(TracksColumns.DRIVEID);
|
int driveIdIndex = cursor.getColumnIndexOrThrow(TracksColumns.DRIVEID);
|
||||||
int modifiedTimeIndex = cursor.getColumnIndexOrThrow(TracksColumns.MODIFIEDTIME);
|
int modifiedTimeIndex = cursor.getColumnIndexOrThrow(TracksColumns.MODIFIEDTIME);
|
||||||
@@ -154,12 +152,6 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
|||||||
if (!cursor.isNull(maxGradeIndex)) {
|
if (!cursor.isNull(maxGradeIndex)) {
|
||||||
tripStatistics.setMaxGrade(cursor.getFloat(maxGradeIndex));
|
tripStatistics.setMaxGrade(cursor.getFloat(maxGradeIndex));
|
||||||
}
|
}
|
||||||
if (!cursor.isNull(mapIdIndex)) {
|
|
||||||
track.setMapId(cursor.getString(mapIdIndex));
|
|
||||||
}
|
|
||||||
if (!cursor.isNull(tableIdIndex)) {
|
|
||||||
track.setTableId(cursor.getString(tableIdIndex));
|
|
||||||
}
|
|
||||||
if (!cursor.isNull(iconIndex)) {
|
if (!cursor.isNull(iconIndex)) {
|
||||||
track.setIcon(cursor.getString(iconIndex));
|
track.setIcon(cursor.getString(iconIndex));
|
||||||
}
|
}
|
||||||
@@ -319,8 +311,6 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
|||||||
values.put(TracksColumns.ELEVATIONGAIN, tripStatistics.getTotalElevationGain());
|
values.put(TracksColumns.ELEVATIONGAIN, tripStatistics.getTotalElevationGain());
|
||||||
values.put(TracksColumns.MINGRADE, tripStatistics.getMinGrade());
|
values.put(TracksColumns.MINGRADE, tripStatistics.getMinGrade());
|
||||||
values.put(TracksColumns.MAXGRADE, tripStatistics.getMaxGrade());
|
values.put(TracksColumns.MAXGRADE, tripStatistics.getMaxGrade());
|
||||||
values.put(TracksColumns.MAPID, track.getMapId());
|
|
||||||
values.put(TracksColumns.TABLEID, track.getTableId());
|
|
||||||
values.put(TracksColumns.ICON, track.getIcon());
|
values.put(TracksColumns.ICON, track.getIcon());
|
||||||
values.put(TracksColumns.DRIVEID, track.getDriveId());
|
values.put(TracksColumns.DRIVEID, track.getDriveId());
|
||||||
values.put(TracksColumns.MODIFIEDTIME, track.getModifiedTime());
|
values.put(TracksColumns.MODIFIEDTIME, track.getModifiedTime());
|
||||||
|
|||||||
@@ -44,8 +44,6 @@ public class Track implements Parcelable {
|
|||||||
* not loaded)
|
* not loaded)
|
||||||
*/
|
*/
|
||||||
private int numberOfPoints = 0;
|
private int numberOfPoints = 0;
|
||||||
private String mapId = "";
|
|
||||||
private String tableId = "";
|
|
||||||
private String icon = "";
|
private String icon = "";
|
||||||
private String driveId = "";
|
private String driveId = "";
|
||||||
private long modifiedTime = -1L;
|
private long modifiedTime = -1L;
|
||||||
@@ -67,8 +65,6 @@ public class Track implements Parcelable {
|
|||||||
startId = in.readLong();
|
startId = in.readLong();
|
||||||
stopId = in.readLong();
|
stopId = in.readLong();
|
||||||
numberOfPoints = in.readInt();
|
numberOfPoints = in.readInt();
|
||||||
mapId = in.readString();
|
|
||||||
tableId = in.readString();
|
|
||||||
icon = in.readString();
|
icon = in.readString();
|
||||||
driveId = in.readString();
|
driveId = in.readString();
|
||||||
modifiedTime = in.readLong();
|
modifiedTime = in.readLong();
|
||||||
@@ -98,8 +94,6 @@ public class Track implements Parcelable {
|
|||||||
dest.writeLong(startId);
|
dest.writeLong(startId);
|
||||||
dest.writeLong(stopId);
|
dest.writeLong(stopId);
|
||||||
dest.writeInt(numberOfPoints);
|
dest.writeInt(numberOfPoints);
|
||||||
dest.writeString(mapId);
|
|
||||||
dest.writeString(tableId);
|
|
||||||
dest.writeString(icon);
|
dest.writeString(icon);
|
||||||
dest.writeString(driveId);
|
dest.writeString(driveId);
|
||||||
dest.writeLong(modifiedTime);
|
dest.writeLong(modifiedTime);
|
||||||
@@ -180,22 +174,6 @@ public class Track implements Parcelable {
|
|||||||
this.numberOfPoints = numberOfPoints;
|
this.numberOfPoints = numberOfPoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMapId() {
|
|
||||||
return mapId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMapId(String mapId) {
|
|
||||||
this.mapId = mapId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTableId() {
|
|
||||||
return tableId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTableId(String tableId) {
|
|
||||||
this.tableId = tableId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getIcon() {
|
public String getIcon() {
|
||||||
return icon;
|
return icon;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-17
@@ -35,19 +35,7 @@ public class SendFusionTablesUtilsTest extends TestCase {
|
|||||||
* Tests {@link SendFusionTablesUtils#getMapUrl(Track)} with null track.
|
* Tests {@link SendFusionTablesUtils#getMapUrl(Track)} with null track.
|
||||||
*/
|
*/
|
||||||
public void testGetMapUrl_null_track() {
|
public void testGetMapUrl_null_track() {
|
||||||
assertEquals(null, SendFusionTablesUtils.getMapUrl(null));
|
assertEquals(null, SendFusionTablesUtils.getMapUrl(null, "123"));
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests {@link SendFusionTablesUtils#getMapUrl(Track)} with null table id.
|
|
||||||
*/
|
|
||||||
public void testGetMapUrl_null_table_id() {
|
|
||||||
Track track = new Track();
|
|
||||||
TripStatistics stats = new TripStatistics();
|
|
||||||
stats.setBounds((int) 100.E6, (int) 10.E6, (int) 50.E6, (int) 5.E6);
|
|
||||||
track.setTripStatistics(stats);
|
|
||||||
track.setTableId(null);
|
|
||||||
assertEquals(null, SendFusionTablesUtils.getMapUrl(track));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -56,8 +44,7 @@ public class SendFusionTablesUtilsTest extends TestCase {
|
|||||||
public void testGetMapUrl_null_stats() {
|
public void testGetMapUrl_null_stats() {
|
||||||
Track track = new Track();
|
Track track = new Track();
|
||||||
track.setTripStatistics(null);
|
track.setTripStatistics(null);
|
||||||
track.setTableId("123");
|
assertEquals(null, SendFusionTablesUtils.getMapUrl(track, "123"));
|
||||||
assertEquals(null, SendFusionTablesUtils.getMapUrl(track));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -69,11 +56,10 @@ public class SendFusionTablesUtilsTest extends TestCase {
|
|||||||
TripStatistics stats = new TripStatistics();
|
TripStatistics stats = new TripStatistics();
|
||||||
stats.setBounds((int) 100.E6, (int) 10.E6, (int) 50.E6, (int) 5.E6);
|
stats.setBounds((int) 100.E6, (int) 10.E6, (int) 50.E6, (int) 5.E6);
|
||||||
track.setTripStatistics(stats);
|
track.setTripStatistics(stats);
|
||||||
track.setTableId("123");
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"https://www.google.com/fusiontables/embedviz?"
|
"https://www.google.com/fusiontables/embedviz?"
|
||||||
+ "viz=MAP&q=select+col0,+col1,+col2,+col3+from+123+&h=false&lat=7.500000&lng=75.000000"
|
+ "viz=MAP&q=select+col0,+col1,+col2,+col3+from+123+&h=false&lat=7.500000&lng=75.000000"
|
||||||
+ "&z=15&t=1&l=col2", SendFusionTablesUtils.getMapUrl(track));
|
+ "&z=15&t=1&l=col2", SendFusionTablesUtils.getMapUrl(track, "123"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -89,23 +89,6 @@ public class SendMapsAsyncTaskTest extends AndroidTestCase {
|
|||||||
AndroidMock.expect(sendMapsActivityMock.getApplicationContext()).andReturn(getContext());
|
AndroidMock.expect(sendMapsActivityMock.getApplicationContext()).andReturn(getContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests the method {@link SendMapsAsyncTask#saveResult()}and makes sure the
|
|
||||||
* track is updated.
|
|
||||||
*/
|
|
||||||
public void testSaveResult() {
|
|
||||||
Track track = TrackStubUtils.createTrack(1);
|
|
||||||
track.setMapId(null);
|
|
||||||
AndroidMock.expect(myTracksProviderUtilsMock.getTrack(TRACK_ID)).andReturn(track);
|
|
||||||
myTracksProviderUtilsMock.updateTrack(track);
|
|
||||||
|
|
||||||
AndroidMock.replay(sendMapsActivityMock, myTracksProviderUtilsMock);
|
|
||||||
SendMapsAsyncTask sendMapsAsyncTask = new SendMapsAsyncTask(sendMapsActivityMock,
|
|
||||||
sendRequest.getTrackId(), sendRequest.getAccount(), myTracksProviderUtilsMock);
|
|
||||||
sendMapsAsyncTask.saveResult();
|
|
||||||
AndroidMock.verify(sendMapsActivityMock, myTracksProviderUtilsMock);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests {@link SendMapsAsyncTask#fetchSendMapId(Track)} when chooseMapId is
|
* Tests {@link SendMapsAsyncTask#fetchSendMapId(Track)} when chooseMapId is
|
||||||
* null and makes sure it returns false.
|
* null and makes sure it returns false.
|
||||||
|
|||||||
@@ -15,7 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.google.android.apps.mytracks.io.maps;
|
package com.google.android.apps.mytracks.io.maps;
|
||||||
|
|
||||||
import com.google.android.apps.mytracks.content.Track;
|
|
||||||
import com.google.android.apps.mytracks.io.gdata.maps.MapsFeature;
|
import com.google.android.apps.mytracks.io.gdata.maps.MapsFeature;
|
||||||
|
|
||||||
import android.location.Location;
|
import android.location.Location;
|
||||||
@@ -31,31 +30,6 @@ import junit.framework.TestCase;
|
|||||||
*/
|
*/
|
||||||
public class SendMapsUtilsTest extends TestCase {
|
public class SendMapsUtilsTest extends TestCase {
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests {@link SendMapsUtils#getMapUrl(Track)} with null track.
|
|
||||||
*/
|
|
||||||
public void testGetMapUrl_null_track() {
|
|
||||||
assertEquals(null, SendMapsUtils.getMapUrl(null));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests {@link SendMapsUtils#getMapUrl(Track)} with null map id.
|
|
||||||
*/
|
|
||||||
public void testGetMapUrl_null_map_id() {
|
|
||||||
Track track = new Track();
|
|
||||||
track.setMapId(null);
|
|
||||||
assertEquals(null, SendMapsUtils.getMapUrl(track));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests {@link SendMapsUtils#getMapUrl(Track)} with a valid track.
|
|
||||||
*/
|
|
||||||
public void testGetMapUrl_valid_track() {
|
|
||||||
Track track = new Track();
|
|
||||||
track.setMapId("123");
|
|
||||||
assertEquals("https://maps.google.com/maps/ms?msa=0&msid=123", SendMapsUtils.getMapUrl(track));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test {@link SendMapsUtils#buildMapsMarkerFeature(String, String, String,
|
* Test {@link SendMapsUtils#buildMapsMarkerFeature(String, String, String,
|
||||||
* Location)} with a title.
|
* Location)} with a title.
|
||||||
|
|||||||
Reference in New Issue
Block a user