Rename to Google Spreadsheets.

This commit is contained in:
Jimmy Shih
2013-02-12 17:38:26 -08:00
parent c93b487483
commit 4f8e8adc23
30 changed files with 277 additions and 272 deletions
@@ -16,7 +16,6 @@
package com.google.android.apps.mytracks.io.drive;
import com.google.android.apps.mytracks.io.docs.SendDocsActivity;
import com.google.android.apps.mytracks.io.fusiontables.SendFusionTablesActivity;
import com.google.android.apps.mytracks.io.maps.ChooseMapActivity;
import com.google.android.apps.mytracks.io.maps.SendMapsActivity;
@@ -24,6 +23,7 @@ import com.google.android.apps.mytracks.io.sendtogoogle.AbstractSendActivity;
import com.google.android.apps.mytracks.io.sendtogoogle.AbstractSendAsyncTask;
import com.google.android.apps.mytracks.io.sendtogoogle.SendRequest;
import com.google.android.apps.mytracks.io.sendtogoogle.UploadResultActivity;
import com.google.android.apps.mytracks.io.spreadsheets.SendSpreadsheetsActivity;
import com.google.android.apps.mytracks.util.IntentUtils;
import com.google.android.maps.mytracks.R;
@@ -65,8 +65,8 @@ public class SendDriveActivity extends AbstractSendActivity {
return sendRequest.isNewMap() ? SendMapsActivity.class : ChooseMapActivity.class;
} else if (sendRequest.isSendFusionTables()) {
return SendFusionTablesActivity.class;
} else if (sendRequest.isSendDocs()) {
return SendDocsActivity.class;
} else if (sendRequest.isSendSpreadsheets()) {
return SendSpreadsheetsActivity.class;
} else {
return UploadResultActivity.class;
}
@@ -16,11 +16,11 @@
package com.google.android.apps.mytracks.io.fusiontables;
import com.google.android.apps.mytracks.io.docs.SendDocsActivity;
import com.google.android.apps.mytracks.io.sendtogoogle.AbstractSendActivity;
import com.google.android.apps.mytracks.io.sendtogoogle.AbstractSendAsyncTask;
import com.google.android.apps.mytracks.io.sendtogoogle.SendRequest;
import com.google.android.apps.mytracks.io.sendtogoogle.UploadResultActivity;
import com.google.android.apps.mytracks.io.spreadsheets.SendSpreadsheetsActivity;
import com.google.android.apps.mytracks.util.IntentUtils;
import com.google.android.maps.mytracks.R;
import com.google.common.annotations.VisibleForTesting;
@@ -59,8 +59,8 @@ public class SendFusionTablesActivity extends AbstractSendActivity {
if (isCancel) {
return UploadResultActivity.class;
} else {
if (request.isSendDocs()) {
return SendDocsActivity.class;
if (request.isSendSpreadsheets()) {
return SendSpreadsheetsActivity.class;
} else {
return UploadResultActivity.class;
}
@@ -15,12 +15,12 @@
*/
package com.google.android.apps.mytracks.io.maps;
import com.google.android.apps.mytracks.io.docs.SendDocsActivity;
import com.google.android.apps.mytracks.io.fusiontables.SendFusionTablesActivity;
import com.google.android.apps.mytracks.io.sendtogoogle.AbstractSendActivity;
import com.google.android.apps.mytracks.io.sendtogoogle.AbstractSendAsyncTask;
import com.google.android.apps.mytracks.io.sendtogoogle.SendRequest;
import com.google.android.apps.mytracks.io.sendtogoogle.UploadResultActivity;
import com.google.android.apps.mytracks.io.spreadsheets.SendSpreadsheetsActivity;
import com.google.android.apps.mytracks.util.IntentUtils;
import com.google.android.maps.mytracks.R;
import com.google.common.annotations.VisibleForTesting;
@@ -62,8 +62,8 @@ public class SendMapsActivity extends AbstractSendActivity {
} else {
if (request.isSendFusionTables()) {
return SendFusionTablesActivity.class;
} else if (request.isSendDocs()) {
return SendDocsActivity.class;
} else if (request.isSendSpreadsheets()) {
return SendSpreadsheetsActivity.class;
} else {
return UploadResultActivity.class;
}
@@ -17,12 +17,12 @@
package com.google.android.apps.mytracks.io.sendtogoogle;
import com.google.android.apps.mytracks.Constants;
import com.google.android.apps.mytracks.io.docs.SendDocsActivity;
import com.google.android.apps.mytracks.io.drive.SendDriveActivity;
import com.google.android.apps.mytracks.io.fusiontables.SendFusionTablesActivity;
import com.google.android.apps.mytracks.io.gdata.maps.MapsConstants;
import com.google.android.apps.mytracks.io.maps.ChooseMapActivity;
import com.google.android.apps.mytracks.io.maps.SendMapsActivity;
import com.google.android.apps.mytracks.io.spreadsheets.SendSpreadsheetsActivity;
import com.google.android.apps.mytracks.util.IntentUtils;
import com.google.android.apps.mytracks.util.PreferencesUtils;
import com.google.android.maps.mytracks.R;
@@ -185,7 +185,7 @@ public class AccountChooserActivity extends Activity {
needDrivePermission = defaultTablePublic && sendRequest.isSendFusionTables();
}
if (!needDrivePermission) {
needDrivePermission = sendRequest.isSendDocs();
needDrivePermission = sendRequest.isSendSpreadsheets();
}
if (needDrivePermission) {
@@ -214,7 +214,7 @@ public class AccountChooserActivity extends Activity {
* Checks the Spreadsheet permission.
*/
private void checkSpreadsheetPermission() {
if (sendRequest.isSendDocs()) {
if (sendRequest.isSendSpreadsheets()) {
SendToGoogleUtils.checkPermissionByActivity(this, sendRequest.getAccount().name,
SendToGoogleUtils.SPREADSHEET_SCOPE,
SendToGoogleUtils.SPREADSHEET_PERMISSION_REQUEST_CODE, spreadsheetsCallback);
@@ -312,15 +312,17 @@ public class AccountChooserActivity extends Activity {
/**
* Starts the next activity. If
* <p>
* sendDrive -> {@link SendDriveActivity}
* <p>
* sendMaps and newMap -> {@link SendMapsActivity}
* <p>
* sendMaps and !newMap -> {@link ChooseMapActivity}
* <p>
* !sendMaps && sendFusionTables -> {@link SendFusionTablesActivity}
* <p>
* !sendMaps && !sendFusionTables && sendDocs -> {@link SendDocsActivity}
* !sendMaps && !sendFusionTables && sendSpreadsheets -> {@link SendSpreadsheetsActivity}
* <p>
* !sendMaps && !sendFusionTables && !sendDocs -> {@link UploadResultActivity}
* !sendMaps && !sendFusionTables && !sendSpreadsheets -> {@link UploadResultActivity}
*/
private void startNextActivity() {
Class<?> next;
@@ -330,8 +332,8 @@ public class AccountChooserActivity extends Activity {
next = sendRequest.isNewMap() ? SendMapsActivity.class : ChooseMapActivity.class;
} else if (sendRequest.isSendFusionTables()) {
next = SendFusionTablesActivity.class;
} else if (sendRequest.isSendDocs()) {
next = SendDocsActivity.class;
} else if (sendRequest.isSendSpreadsheets()) {
next = SendSpreadsheetsActivity.class;
} else {
next = UploadResultActivity.class;
}
@@ -22,7 +22,7 @@ import android.os.Parcelable;
/**
* Send request states for sending a track to Google Maps, Google Fusion Tables,
* and Google Docs.
* and Google Spreadsheets.
*
* @author Jimmy Shih
*/
@@ -37,13 +37,13 @@ public class SendRequest implements Parcelable {
private boolean sendDrive = false;
private boolean sendMaps = false;
private boolean sendFusionTables = false;
private boolean sendDocs = false;
private boolean sendSpreadsheets = false;
private boolean newMap = false;
private Account account = null;
private String mapId = null;
private boolean driveSuccess = false;
private boolean mapsSuccess = false;
private boolean docsSuccess = false;
private boolean spreadsheetsSuccess = false;
private boolean fusionTablesSuccess = false;
/**
@@ -162,20 +162,20 @@ public class SendRequest implements Parcelable {
}
/**
* True if the user has selected the send to Google Docs option.
* True if the user has selected the send to Google Spreadsheets option.
*/
public boolean isSendDocs() {
return sendDocs;
public boolean isSendSpreadsheets() {
return sendSpreadsheets;
}
/**
* Sets the send to Google Docs option.
* Sets the send to Google Spreadsheets option.
*
* @param sendDocs true if the user has selected the send to Google Docs
* option
* @param sendSpreadsheets true if the user has selected the send to Google
* Spreadsheets option
*/
public void setSendDocs(boolean sendDocs) {
this.sendDocs = sendDocs;
public void setSendSpreadsheets(boolean sendSpreadsheets) {
this.sendSpreadsheets = sendSpreadsheets;
}
/**
@@ -277,19 +277,20 @@ public class SendRequest implements Parcelable {
}
/**
* True if sending to Google Docs is success.
* True if sending to Google Spreadsheets is success.
*/
public boolean isDocsSuccess() {
return docsSuccess;
public boolean isSpreadsheetsSuccess() {
return spreadsheetsSuccess;
}
/**
* Sets the Google Docs result.
* Sets the Google Spreadsheets result.
*
* @param docsSuccess true if sending to Google Docs is success
* @param spreadsheetsSuccess true if sending to Google Spreadsheets is
* success
*/
public void setDocsSuccess(boolean docsSuccess) {
this.docsSuccess = docsSuccess;
public void setSpreadsheetSuccess(boolean spreadsheetsSuccess) {
this.spreadsheetsSuccess = spreadsheetsSuccess;
}
private SendRequest(Parcel in) {
@@ -300,14 +301,14 @@ public class SendRequest implements Parcelable {
sendDrive = in.readByte() == 1;
sendMaps = in.readByte() == 1;
sendFusionTables = in.readByte() == 1;
sendDocs = in.readByte() == 1;
sendSpreadsheets = in.readByte() == 1;
newMap = in.readByte() == 1;
account = in.readParcelable(null);
mapId = in.readString();
driveSuccess = in.readByte() == 1;
mapsSuccess = in.readByte() == 1;
fusionTablesSuccess = in.readByte() == 1;
docsSuccess = in.readByte() == 1;
spreadsheetsSuccess = in.readByte() == 1;
}
@Override
@@ -324,14 +325,14 @@ public class SendRequest implements Parcelable {
out.writeByte((byte) (sendDrive ? 1 : 0));
out.writeByte((byte) (sendMaps ? 1 : 0));
out.writeByte((byte) (sendFusionTables ? 1 : 0));
out.writeByte((byte) (sendDocs ? 1 : 0));
out.writeByte((byte) (sendSpreadsheets ? 1 : 0));
out.writeByte((byte) (newMap ? 1 : 0));
out.writeParcelable(account, 0);
out.writeString(mapId);
out.writeByte((byte) (driveSuccess ? 1 : 0));
out.writeByte((byte) (mapsSuccess ? 1 : 0));
out.writeByte((byte) (fusionTablesSuccess ? 1 : 0));
out.writeByte((byte) (docsSuccess ? 1 : 0));
out.writeByte((byte) (spreadsheetsSuccess ? 1 : 0));
}
public static final Parcelable.Creator<SendRequest>
@@ -67,7 +67,7 @@ public class UploadResultActivity extends FragmentActivity {
finish();
return;
}
if (sendRequest.isSendMaps() && sendRequest.isMapsSuccess()) {
shareUrl = SendMapsUtils.getMapUrl(track);
if (sendRequest.getSharingAppPackageName() != null) {
@@ -80,9 +80,8 @@ public class UploadResultActivity extends FragmentActivity {
}
if (shareUrl == null && sendRequest.isSendFusionTables()
&& sendRequest.isFusionTablesSuccess()) {
boolean defaultTablePublic = PreferencesUtils.getBoolean(this,
R.string.default_table_public_key,
PreferencesUtils.DEFAULT_TABLE_PUBLIC_DEFAULT);
boolean defaultTablePublic = PreferencesUtils.getBoolean(
this, R.string.default_table_public_key, PreferencesUtils.DEFAULT_TABLE_PUBLIC_DEFAULT);
if (defaultTablePublic) {
shareUrl = SendFusionTablesUtils.getMapUrl(track);
}
@@ -101,13 +100,15 @@ public class UploadResultActivity extends FragmentActivity {
LinearLayout mapsResult = (LinearLayout) view.findViewById(R.id.upload_result_maps_result);
LinearLayout fusionTablesResult = (LinearLayout) view.findViewById(
R.id.upload_result_fusion_tables_result);
LinearLayout docsResult = (LinearLayout) view.findViewById(R.id.upload_result_docs_result);
LinearLayout spreadsheetsResult = (LinearLayout) view.findViewById(
R.id.upload_result_spreadsheets_result);
ImageView driveResultIcon = (ImageView) view.findViewById(R.id.upload_result_drive_result_icon);
ImageView mapsResultIcon = (ImageView) view.findViewById(R.id.upload_result_maps_result_icon);
ImageView fusionTablesResultIcon = (ImageView) view.findViewById(
R.id.upload_result_fusion_tables_result_icon);
ImageView docsResultIcon = (ImageView) view.findViewById(R.id.upload_result_docs_result_icon);
ImageView spreadsheetsResultIcon = (ImageView) view.findViewById(
R.id.upload_result_spreadsheets_result_icon);
TextView successFooter = (TextView) view.findViewById(R.id.upload_result_success_footer);
TextView errorFooter = (TextView) view.findViewById(R.id.upload_result_error_footer);
@@ -122,7 +123,7 @@ public class UploadResultActivity extends FragmentActivity {
hasError = true;
}
}
if (!sendRequest.isSendMaps()) {
mapsResult.setVisibility(View.GONE);
} else {
@@ -143,12 +144,12 @@ public class UploadResultActivity extends FragmentActivity {
}
}
if (!sendRequest.isSendDocs()) {
docsResult.setVisibility(View.GONE);
if (!sendRequest.isSendSpreadsheets()) {
spreadsheetsResult.setVisibility(View.GONE);
} else {
if (!sendRequest.isDocsSuccess()) {
docsResultIcon.setImageResource(R.drawable.failure);
docsResultIcon.setContentDescription(getString(R.string.generic_error_title));
if (!sendRequest.isSpreadsheetsSuccess()) {
spreadsheetsResultIcon.setImageResource(R.drawable.failure);
spreadsheetsResultIcon.setContentDescription(getString(R.string.generic_error_title));
hasError = true;
}
}
@@ -159,22 +160,19 @@ public class UploadResultActivity extends FragmentActivity {
errorFooter.setVisibility(View.GONE);
}
AlertDialog.Builder builder = new AlertDialog.Builder(this)
.setCancelable(true)
AlertDialog.Builder builder = new AlertDialog.Builder(this).setCancelable(true)
.setIcon(hasError ? android.R.drawable.ic_dialog_alert : android.R.drawable.ic_dialog_info)
.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
finish();
}
})
.setPositiveButton(R.string.generic_ok, new DialogInterface.OnClickListener() {
}).setPositiveButton(R.string.generic_ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
finish();
}
})
.setTitle(hasError ? R.string.generic_error_title : R.string.generic_success_title)
}).setTitle(hasError ? R.string.generic_error_title : R.string.generic_success_title)
.setView(view);
// Add a Share URL button if shareUrl exists
@@ -13,7 +13,8 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.android.apps.mytracks.io.docs;
package com.google.android.apps.mytracks.io.spreadsheets;
import com.google.android.apps.mytracks.io.sendtogoogle.AbstractSendActivity;
import com.google.android.apps.mytracks.io.sendtogoogle.AbstractSendAsyncTask;
@@ -25,25 +26,25 @@ import com.google.android.maps.mytracks.R;
import android.content.Intent;
/**
* An activity to send a track to Google Docs.
* An activity to send a track to Google Spreadsheet.
*
* @author Jimmy Shih
*/
public class SendDocsActivity extends AbstractSendActivity {
public class SendSpreadsheetsActivity extends AbstractSendActivity {
@Override
protected AbstractSendAsyncTask createAsyncTask() {
return new SendDocsAsyncTask(this, sendRequest.getTrackId(), sendRequest.getAccount());
return new SendSpreadsheetsAsyncTask(this, sendRequest.getTrackId(), sendRequest.getAccount());
}
@Override
protected String getServiceName() {
return getString(R.string.send_google_docs);
return getString(R.string.send_google_spreadsheets);
}
@Override
protected void startNextActivity(boolean success, boolean isCancel) {
sendRequest.setDocsSuccess(success);
sendRequest.setSpreadsheetSuccess(success);
Intent intent = IntentUtils.newIntent(this, UploadResultActivity.class)
.putExtra(SendRequest.SEND_REQUEST_KEY, sendRequest);
startActivity(intent);
@@ -14,7 +14,7 @@
* the License.
*/
package com.google.android.apps.mytracks.io.docs;
package com.google.android.apps.mytracks.io.spreadsheets;
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
import com.google.android.apps.mytracks.content.Track;
@@ -55,13 +55,13 @@ import java.util.List;
import java.util.Locale;
/**
* AsyncTask to send a track to Google Docs.
* AsyncTask to send a track to Google Spreadsheet.
*
* @author Jimmy Shih
*/
public class SendDocsAsyncTask extends AbstractSendAsyncTask {
public class SendSpreadsheetsAsyncTask extends AbstractSendAsyncTask {
private static final String TAG = SendDocsAsyncTask.class.getSimpleName();
private static final String TAG = SendSpreadsheetsAsyncTask.class.getSimpleName();
private static final String
GOOGLE_SPREADSHEET_MIME_TYPE = "application/vnd.google-apps.spreadsheet";
private static final String
@@ -82,7 +82,7 @@ public class SendDocsAsyncTask extends AbstractSendAsyncTask {
private final Context context;
private final MyTracksProviderUtils myTracksProviderUtils;
public SendDocsAsyncTask(SendDocsActivity activity, long trackId, Account account) {
public SendSpreadsheetsAsyncTask(SendSpreadsheetsActivity activity, long trackId, Account account) {
super(activity);
this.trackId = trackId;
this.account = account;
@@ -262,21 +262,21 @@ public class SendDocsAsyncTask extends AbstractSendAsyncTask {
row.getCustomElements().setValueLocal(
"movingtime", StringUtils.formatElapsedTimeWithHour(tripStatistics.getMovingTime()));
row.getCustomElements().setValueLocal(
"distance", SendDocsUtils.getDistance(tripStatistics.getTotalDistance(), metricUnits));
"distance", SendSpreadsheetsUtils.getDistance(tripStatistics.getTotalDistance(), metricUnits));
row.getCustomElements().setValueLocal("distanceunit", distanceUnit);
row.getCustomElements().setValueLocal(
"averagespeed", SendDocsUtils.getSpeed(tripStatistics.getAverageSpeed(), metricUnits));
"averagespeed", SendSpreadsheetsUtils.getSpeed(tripStatistics.getAverageSpeed(), metricUnits));
row.getCustomElements().setValueLocal("averagemovingspeed",
SendDocsUtils.getSpeed(tripStatistics.getAverageMovingSpeed(), metricUnits));
SendSpreadsheetsUtils.getSpeed(tripStatistics.getAverageMovingSpeed(), metricUnits));
row.getCustomElements().setValueLocal(
"maxspeed", SendDocsUtils.getSpeed(tripStatistics.getMaxSpeed(), metricUnits));
"maxspeed", SendSpreadsheetsUtils.getSpeed(tripStatistics.getMaxSpeed(), metricUnits));
row.getCustomElements().setValueLocal("speedunit", speedUnit);
row.getCustomElements().setValueLocal("elevationgain",
SendDocsUtils.getElevation(tripStatistics.getTotalElevationGain(), metricUnits));
SendSpreadsheetsUtils.getElevation(tripStatistics.getTotalElevationGain(), metricUnits));
row.getCustomElements().setValueLocal(
"minelevation", SendDocsUtils.getElevation(tripStatistics.getMinElevation(), metricUnits));
"minelevation", SendSpreadsheetsUtils.getElevation(tripStatistics.getMinElevation(), metricUnits));
row.getCustomElements().setValueLocal(
"maxelevation", SendDocsUtils.getElevation(tripStatistics.getMaxElevation(), metricUnits));
"maxelevation", SendSpreadsheetsUtils.getElevation(tripStatistics.getMaxElevation(), metricUnits));
row.getCustomElements().setValueLocal("elevationunit", elevationUnit);
String map = SendMapsUtils.getMapUrl(track);
@@ -14,7 +14,7 @@
* the License.
*/
package com.google.android.apps.mytracks.io.docs;
package com.google.android.apps.mytracks.io.spreadsheets;
import com.google.android.apps.mytracks.util.UnitConversions;
@@ -22,13 +22,13 @@ import java.text.NumberFormat;
import java.util.Locale;
/**
* Utilities for sending a track to Google Docs.
* Utilities for sending a track to Google Spreadsheet.
*
* @author Jimmy Shih
*/
public class SendDocsUtils {
public class SendSpreadsheetsUtils {
// Google Docs can only parse numbers in the English locale.
// Google Spreadsheet can only parse numbers in the English locale.
private static final NumberFormat NUMBER_FORMAT = NumberFormat.getNumberInstance(Locale.ENGLISH);
private static final NumberFormat INTEGER_FORMAT = NumberFormat.getIntegerInstance(
Locale.ENGLISH);
@@ -38,7 +38,7 @@ public class SendDocsUtils {
NUMBER_FORMAT.setMinimumFractionDigits(2);
}
private SendDocsUtils() {}
private SendSpreadsheetsUtils() {}
/**
* Gets the distance. Performs unit conversion and formatting.