diff --git a/MyTracks/res/drawable-hdpi/google_drive_icon.png b/MyTracks/res/drawable-hdpi/google_drive_icon.png new file mode 100644 index 000000000..0f5f2449f Binary files /dev/null and b/MyTracks/res/drawable-hdpi/google_drive_icon.png differ diff --git a/MyTracks/res/drawable-ldpi/google_drive_icon.png b/MyTracks/res/drawable-ldpi/google_drive_icon.png new file mode 100644 index 000000000..4e82793e0 Binary files /dev/null and b/MyTracks/res/drawable-ldpi/google_drive_icon.png differ diff --git a/MyTracks/res/drawable-mdpi/google_drive_icon.png b/MyTracks/res/drawable-mdpi/google_drive_icon.png new file mode 100644 index 000000000..1ce335594 Binary files /dev/null and b/MyTracks/res/drawable-mdpi/google_drive_icon.png differ diff --git a/MyTracks/res/layout/choose_upload_service.xml b/MyTracks/res/layout/choose_upload_service.xml index 6e36c969e..8dd4d494f 100644 --- a/MyTracks/res/layout/choose_upload_service.xml +++ b/MyTracks/res/layout/choose_upload_service.xml @@ -21,6 +21,16 @@ limitations under the License. android:layout_width="match_parent" android:padding="8dp" android:stretchColumns="1" > + + + + pickExistingMap reportSpeed sendToDocs + sendToDrive sendToFusionTables sendToMaps sensorType diff --git a/MyTracks/res/values/strings.xml b/MyTracks/res/values/strings.xml index af09fd6a3..57eb66f6e 100644 --- a/MyTracks/res/values/strings.xml +++ b/MyTracks/res/values/strings.xml @@ -1436,6 +1436,11 @@ limitations under the License. checkbox option to send to Google Docs."> Google Docs + + Google Drive + diff --git a/MyTracks/src/com/google/android/apps/mytracks/fragments/ChooseUploadServiceDialogFragment.java b/MyTracks/src/com/google/android/apps/mytracks/fragments/ChooseUploadServiceDialogFragment.java index 17c973e1d..daf933a94 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/fragments/ChooseUploadServiceDialogFragment.java +++ b/MyTracks/src/com/google/android/apps/mytracks/fragments/ChooseUploadServiceDialogFragment.java @@ -13,6 +13,7 @@ * License for the specific language governing permissions and limitations under * the License. */ + package com.google.android.apps.mytracks.fragments; import com.google.android.apps.mytracks.io.sendtogoogle.AccountChooserActivity; @@ -52,8 +53,7 @@ public class ChooseUploadServiceDialogFragment extends DialogFragment { Bundle bundle = new Bundle(); bundle.putParcelable(KEY_SEND_REQUEST, sendRequest); - ChooseUploadServiceDialogFragment chooseUploadServiceDialogFragment = - new ChooseUploadServiceDialogFragment(); + ChooseUploadServiceDialogFragment chooseUploadServiceDialogFragment = new ChooseUploadServiceDialogFragment(); chooseUploadServiceDialogFragment.setArguments(bundle); return chooseUploadServiceDialogFragment; } @@ -61,6 +61,7 @@ public class ChooseUploadServiceDialogFragment extends DialogFragment { private FragmentActivity activity; private SendRequest sendRequest; + private CheckBox driveCheckBox; private CheckBox mapsCheckBox; private CheckBox fusionTablesCheckBox; private CheckBox docsCheckBox; @@ -75,10 +76,13 @@ public class ChooseUploadServiceDialogFragment extends DialogFragment { View view = activity.getLayoutInflater().inflate(R.layout.choose_upload_service, null); + driveCheckBox = (CheckBox) view.findViewById(R.id.choose_upload_service_drive); mapsCheckBox = (CheckBox) view.findViewById(R.id.choose_upload_service_maps); fusionTablesCheckBox = (CheckBox) view.findViewById(R.id.choose_upload_service_fusion_tables); docsCheckBox = (CheckBox) view.findViewById(R.id.choose_upload_service_docs); + driveCheckBox.setChecked(PreferencesUtils.getBoolean( + activity, R.string.send_to_drive_key, PreferencesUtils.SEND_TO_DRIVE_DEFAULT)); mapsCheckBox.setChecked(PreferencesUtils.getBoolean( activity, R.string.send_to_maps_key, PreferencesUtils.SEND_TO_MAPS_DEFAULT)); fusionTablesCheckBox.setChecked(PreferencesUtils.getBoolean( @@ -97,8 +101,8 @@ public class ChooseUploadServiceDialogFragment extends DialogFragment { RadioButton newMapRadioButton = (RadioButton) view.findViewById( R.id.choose_upload_service_new_map); - boolean defaultMapPublic = PreferencesUtils.getBoolean(activity, - R.string.default_map_public_key, PreferencesUtils.DEFAULT_MAP_PUBLIC_DEFAULT); + boolean defaultMapPublic = PreferencesUtils.getBoolean( + activity, R.string.default_map_public_key, PreferencesUtils.DEFAULT_MAP_PUBLIC_DEFAULT); newMapRadioButton.setText(defaultMapPublic ? R.string.send_google_new_public_map : R.string.send_google_new_unlisted_map); @@ -106,8 +110,8 @@ public class ChooseUploadServiceDialogFragment extends DialogFragment { R.id.choose_upload_service_existing_map); updateMapsOption(); - if (PreferencesUtils.getBoolean(activity, R.string.pick_existing_map_key, - PreferencesUtils.PICK_EXISTING_MAP_DEFAULT)) { + if (PreferencesUtils.getBoolean( + activity, R.string.pick_existing_map_key, PreferencesUtils.PICK_EXISTING_MAP_DEFAULT)) { existingMapRadioButton.setChecked(true); } else { newMapRadioButton.setChecked(true); @@ -117,27 +121,25 @@ public class ChooseUploadServiceDialogFragment extends DialogFragment { .setPositiveButton(R.string.send_google_send_now, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { + PreferencesUtils.setBoolean( + activity, R.string.send_to_drive_key, driveCheckBox.isChecked()); PreferencesUtils.setBoolean( activity, R.string.pick_existing_map_key, existingMapRadioButton.isChecked()); PreferencesUtils.setBoolean( activity, R.string.send_to_maps_key, mapsCheckBox.isChecked()); - PreferencesUtils.setBoolean(activity, R.string.send_to_fusion_tables_key, - fusionTablesCheckBox.isChecked()); + PreferencesUtils.setBoolean( + activity, R.string.send_to_fusion_tables_key, fusionTablesCheckBox.isChecked()); PreferencesUtils.setBoolean( activity, R.string.send_to_docs_key, docsCheckBox.isChecked()); - if (mapsCheckBox.isChecked() || fusionTablesCheckBox.isChecked() - || docsCheckBox.isChecked()) { + if (driveCheckBox.isChecked() || mapsCheckBox.isChecked() + || fusionTablesCheckBox.isChecked() || docsCheckBox.isChecked()) { startNextActivity(); } else { - Toast.makeText( - activity, R.string.send_google_no_service_selected, Toast.LENGTH_LONG) + Toast.makeText(activity, R.string.send_google_no_service_selected, Toast.LENGTH_LONG) .show(); } } - }) - .setTitle(R.string.send_google_title) - .setView(view) - .create(); + }).setTitle(R.string.send_google_title).setView(view).create(); } /** @@ -151,6 +153,7 @@ public class ChooseUploadServiceDialogFragment extends DialogFragment { * Starts the next activity, {@link AccountChooserActivity}. */ private void startNextActivity() { + sendRequest.setSendDrive(driveCheckBox.isChecked()); sendRequest.setSendMaps(mapsCheckBox.isChecked()); sendRequest.setSendFusionTables(fusionTablesCheckBox.isChecked()); sendRequest.setSendDocs(docsCheckBox.isChecked()); @@ -165,6 +168,9 @@ public class ChooseUploadServiceDialogFragment extends DialogFragment { * Sends stats to Google Analytics. */ private void sendStats() { + if (sendRequest.isSendDrive()) { + AnalyticsUtils.sendPageViews(activity, "/send/drive"); + } if (sendRequest.isSendMaps()) { AnalyticsUtils.sendPageViews(activity, "/send/maps"); } diff --git a/MyTracks/src/com/google/android/apps/mytracks/io/sendtogoogle/SendRequest.java b/MyTracks/src/com/google/android/apps/mytracks/io/sendtogoogle/SendRequest.java index 4dd2d0ed0..840ea1c0d 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/io/sendtogoogle/SendRequest.java +++ b/MyTracks/src/com/google/android/apps/mytracks/io/sendtogoogle/SendRequest.java @@ -33,12 +33,14 @@ public class SendRequest implements Parcelable { private long trackId = -1L; private String sharingAppPackageName = null; private String sharingAppClassName = null; + private boolean sendDrive = false; private boolean sendMaps = false; private boolean sendFusionTables = false; private boolean sendDocs = 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 fusionTablesSuccess = false; @@ -91,6 +93,23 @@ public class SendRequest implements Parcelable { this.sharingAppClassName = sharingAppClassName; } + /** + * True if the user has selected the send to Google Drive option. + */ + public boolean isSendDrive() { + return sendDrive; + } + + /** + * Sets the send to Google Drive option. + * + * @param sendDrive true if the user has selected the send to Google Drive + * option + */ + public void setSendDrive(boolean sendDrive) { + this.sendDrive = sendDrive; + } + /** * True if the user has selected the send to Google Maps option. */ @@ -191,6 +210,22 @@ public class SendRequest implements Parcelable { this.mapId = mapId; } + /** + * True if sending to Google Drive is success. + */ + public boolean isDriveSuccess() { + return driveSuccess; + } + + /** + * Sets the Google Drive result. + * + * @param driveSuccess true if sending to Google Drive is success + */ + public void setDriveSuccess(boolean driveSuccess) { + this.driveSuccess = driveSuccess; + } + /** * True if sending to Google Maps is success. */ @@ -244,12 +279,14 @@ public class SendRequest implements Parcelable { trackId = in.readLong(); sharingAppPackageName = in.readString(); sharingAppClassName = in.readString(); + sendDrive = in.readByte() == 1; sendMaps = in.readByte() == 1; sendFusionTables = in.readByte() == 1; sendDocs = 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; @@ -265,12 +302,14 @@ public class SendRequest implements Parcelable { out.writeLong(trackId); out.writeString(sharingAppPackageName); out.writeString(sharingAppClassName); + 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) (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)); diff --git a/MyTracks/src/com/google/android/apps/mytracks/util/PreferencesUtils.java b/MyTracks/src/com/google/android/apps/mytracks/util/PreferencesUtils.java index 83af28af2..c20dc8e4e 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/util/PreferencesUtils.java +++ b/MyTracks/src/com/google/android/apps/mytracks/util/PreferencesUtils.java @@ -78,9 +78,12 @@ public class PreferencesUtils { public static final boolean RECORDING_TRACK_PAUSED_DEFAULT = true; public static final boolean REPORT_SPEED_DEFAULT = true; public static final long SELECTED_TRACK_ID_DEFAULT = -1L; - public static final boolean SEND_TO_DOCS_DEFAULT = true; - public static final boolean SEND_TO_FUSION_TABLES_DEFAULT = true; - public static final boolean SEND_TO_MAPS_DEFAULT = true; + + public static final boolean SEND_TO_DRIVE_DEFAULT = false; + public static final boolean SEND_TO_DOCS_DEFAULT = false; + public static final boolean SEND_TO_FUSION_TABLES_DEFAULT = false; + public static final boolean SEND_TO_MAPS_DEFAULT = false; + public static final String SENSOR_TYPE_DEFAULT = "NONE"; public static final boolean SHOW_CONFIRM_PLAY_DIALOG_DEFAULT = true; public static final boolean SHOW_CONFIRM_SHARING_DIALOG_DEFAULT = true;