forked from upstream-mirrors/OpenTracks
Code cleanup. Remove track.getMapId and track.getTableId.
This commit is contained in:
@@ -68,9 +68,6 @@ public class SendDriveAsyncTask extends AbstractSendAsyncTask {
|
||||
@Override
|
||||
protected void closeConnection() {}
|
||||
|
||||
@Override
|
||||
protected void saveResult() {}
|
||||
|
||||
@Override
|
||||
protected boolean performTask() {
|
||||
try {
|
||||
|
||||
+4
-8
@@ -88,9 +88,6 @@ public class SendFusionTablesAsyncTask extends AbstractSendAsyncTask {
|
||||
@Override
|
||||
protected void closeConnection() {}
|
||||
|
||||
@Override
|
||||
protected void saveResult() {}
|
||||
|
||||
@Override
|
||||
protected boolean performTask() {
|
||||
try {
|
||||
@@ -121,7 +118,7 @@ public class SendFusionTablesAsyncTask extends AbstractSendAsyncTask {
|
||||
publishProgress(PROGRESS_SET_STYLE);
|
||||
setStyle(fusiontables, tableId);
|
||||
setTemplate(fusiontables, tableId);
|
||||
if (!setPermission(tableId)) {
|
||||
if (!setPermission(track, tableId)) {
|
||||
Log.d(TAG, "Cannot set permission for table " + tableId);
|
||||
return false;
|
||||
}
|
||||
@@ -138,9 +135,6 @@ public class SendFusionTablesAsyncTask extends AbstractSendAsyncTask {
|
||||
return false;
|
||||
}
|
||||
|
||||
track.setTableId(tableId);
|
||||
myTracksProviderUtils.updateTrack(track);
|
||||
|
||||
publishProgress(PROGRESS_COMPLETE);
|
||||
return true;
|
||||
|
||||
@@ -200,7 +194,7 @@ public class SendFusionTablesAsyncTask extends AbstractSendAsyncTask {
|
||||
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,
|
||||
R.string.export_google_fusion_tables_public_key,
|
||||
PreferencesUtils.EXPORT_GOOGLE_FUSION_TABLES_PUBLIC_DEFAULT);
|
||||
@@ -218,6 +212,8 @@ public class SendFusionTablesAsyncTask extends AbstractSendAsyncTask {
|
||||
permission.setType("anyone");
|
||||
permission.setValue("");
|
||||
drive.permissions().insert(tableId, permission).execute();
|
||||
|
||||
shareUrl = SendFusionTablesUtils.getMapUrl(track, tableId);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+5
-8
@@ -42,13 +42,11 @@ public class SendFusionTablesUtils {
|
||||
* Gets the url to visualize a fusion table on a map.
|
||||
*
|
||||
* @param track the track
|
||||
* @param tableId the table id
|
||||
* @return the url.
|
||||
*/
|
||||
public static String getMapUrl(Track track) {
|
||||
if (track == null
|
||||
|| track.getTripStatistics() == null
|
||||
|| track.getTableId() == null
|
||||
|| track.getTableId().length() == 0) {
|
||||
public static String getMapUrl(Track track, String tableId) {
|
||||
if (track == null || track.getTripStatistics() == null) {
|
||||
Log.e(TAG, "Invalid track");
|
||||
return null;
|
||||
}
|
||||
@@ -57,7 +55,7 @@ public class SendFusionTablesUtils {
|
||||
int z;
|
||||
if (track.getNumberOfPoints() < 2) {
|
||||
// Use Google's latitude and longitude
|
||||
latE6 = 37.423 * 1.E6;
|
||||
latE6 = 37.423 * 1.E6;
|
||||
lonE6 = -122.084 * 1.E6;
|
||||
z = 2;
|
||||
} else {
|
||||
@@ -69,8 +67,7 @@ public class SendFusionTablesUtils {
|
||||
// We explicitly format with Locale.US because we need the latitude and
|
||||
// longitude to be formatted in a locale-independent manner. Specifically,
|
||||
// we need the decimal separator to be a period rather than a comma.
|
||||
return String.format(
|
||||
Locale.US, MAP_URL, track.getTableId(), latE6 / 1.E6, lonE6 / 1.E6, z);
|
||||
return String.format(Locale.US, MAP_URL, tableId, 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
|
||||
protected boolean performTask() {
|
||||
// Reset the per upload states
|
||||
@@ -222,6 +211,7 @@ public class SendMapsAsyncTask extends AbstractSendAsyncTask {
|
||||
+ context.getString(R.string.send_google_by_my_tracks, "", "");
|
||||
mapId = SendMapsUtils.createNewMap(
|
||||
track.getName(), description, defaultMapPublic, mapsClient, authToken);
|
||||
shareUrl = MapsClient.buildMapUrl(mapId);
|
||||
} catch (ParseException e) {
|
||||
Log.d(TAG, "Unable to create a new map", e);
|
||||
return false;
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
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.io.gdata.maps.MapsClient;
|
||||
import com.google.android.apps.mytracks.io.gdata.maps.MapsFeature;
|
||||
@@ -46,22 +45,6 @@ public class 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.
|
||||
*
|
||||
|
||||
-8
@@ -100,9 +100,6 @@ public abstract class AbstractSendAsyncTask extends AsyncTask<Void, Integer, Boo
|
||||
protected void onPostExecute(Boolean result) {
|
||||
success = result;
|
||||
completed = true;
|
||||
if (success) {
|
||||
saveResult();
|
||||
}
|
||||
if (activity != null) {
|
||||
activity.onAsyncTaskCompleted(success, shareUrl);
|
||||
}
|
||||
@@ -132,11 +129,6 @@ public abstract class AbstractSendAsyncTask extends AsyncTask<Void, Integer, Boo
|
||||
*/
|
||||
protected abstract void closeConnection();
|
||||
|
||||
/**
|
||||
* Saves any AsyncTask result.
|
||||
*/
|
||||
protected abstract void saveResult();
|
||||
|
||||
/**
|
||||
* 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.fragments.ChooseActivityDialogFragment;
|
||||
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.PreferencesUtils;
|
||||
import com.google.android.maps.mytracks.R;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
|
||||
@@ -74,19 +71,6 @@ public class UploadResultActivity extends FragmentActivity implements ChooseActi
|
||||
getSupportFragmentManager(), ChooseActivityDialogFragment.CHOOSE_ACTIVITY_DIALOG_TAG);
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -177,7 +161,7 @@ public class UploadResultActivity extends FragmentActivity implements ChooseActi
|
||||
.setView(view);
|
||||
|
||||
// Add a Share URL button if shareUrl exists
|
||||
if (shareUrl != null) {
|
||||
if (!hasError && shareUrl != null) {
|
||||
builder.setNegativeButton(
|
||||
R.string.share_track_share_url, new DialogInterface.OnClickListener() {
|
||||
@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.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.SendToGoogleUtils;
|
||||
import com.google.android.apps.mytracks.io.sync.SyncUtils;
|
||||
@@ -97,9 +95,6 @@ public class SendSpreadsheetsAsyncTask extends AbstractSendAsyncTask {
|
||||
@Override
|
||||
protected void closeConnection() {}
|
||||
|
||||
@Override
|
||||
protected void saveResult() {}
|
||||
|
||||
@Override
|
||||
protected boolean performTask() {
|
||||
try {
|
||||
@@ -281,19 +276,7 @@ public class SendSpreadsheetsAsyncTask extends AbstractSendAsyncTask {
|
||||
row.getCustomElements().setValueLocal(
|
||||
"maxelevation", SendSpreadsheetsUtils.getElevation(tripStatistics.getMaxElevation(), metricUnits));
|
||||
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);
|
||||
return result != null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user