Add Send to Drive in ChooseUploadServiceDialogFragment

This commit is contained in:
Jimmy Shih
2013-01-25 13:06:25 -08:00
parent 97cad0b36c
commit bf6369e1b7
9 changed files with 83 additions and 19 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

@@ -21,6 +21,16 @@ limitations under the License.
android:layout_width="match_parent"
android:padding="8dp"
android:stretchColumns="1" >
<TableRow>
<ImageView
android:contentDescription="@string/send_google_drive"
android:src="@drawable/google_drive_icon"
style="@style/ChooseUploadServiceImageView" />
<CheckBox
android:id="@+id/choose_upload_service_drive"
android:text="@string/send_google_drive"
style="@style/ChooseUploadServiceCheckBox" />
</TableRow>
<TableRow>
<ImageView
android:contentDescription="@string/send_google_maps"
+1
View File
@@ -42,6 +42,7 @@ limitations under the License.
<string name="pick_existing_map_key">pickExistingMap</string>
<string name="report_speed_key">reportSpeed</string>
<string name="send_to_docs_key">sendToDocs</string>
<string name="send_to_drive_key">sendToDrive</string>
<string name="send_to_fusion_tables_key">sendToFusionTables</string>
<string name="send_to_maps_key">sendToMaps</string>
<string name="sensor_type_key">sensorType</string>
+5
View File
@@ -1436,6 +1436,11 @@ limitations under the License.
checkbox option to send to Google Docs.">
Google Docs
</string>
<string name="send_google_drive"
translation_description="When sending a track to Google, under the 'Send to...' dialog, the
checkbox option to send to Google Drive.">
Google Drive
</string>
<string name="send_google_error"
translation_description="When sending a track to Google, a message indicating that an error has
occurred and ask the user to try again.">
@@ -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");
}
@@ -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));
@@ -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;