forked from upstream-mirrors/OpenTracks
For "Shared with me" tracks, do not allow sending to Google Drive,
do not allow sharing with Google Drive. For Drive tracks, exclude shared tracks.
This commit is contained in:
@@ -21,7 +21,7 @@ limitations under the License.
|
||||
android:layout_width="match_parent"
|
||||
android:padding="8dp"
|
||||
android:stretchColumns="1" >
|
||||
<TableRow>
|
||||
<TableRow android:id="@+id/choose_upload_service_drive_options">
|
||||
<ImageView
|
||||
android:contentDescription="@string/send_google_drive"
|
||||
android:src="@drawable/google_drive_icon"
|
||||
|
||||
@@ -297,11 +297,13 @@ public class TrackDetailActivity extends AbstractMyTracksActivity implements Del
|
||||
|
||||
Track track = myTracksProviderUtils.getTrack(trackId);
|
||||
menu.findItem(R.id.track_detail_edit).setVisible(!track.isSharedWithMe());
|
||||
shareDriveMenuItem = menu.findItem(R.id.track_detail_share_drive);
|
||||
shareDriveMenuItem.setEnabled(!track.isSharedWithMe());
|
||||
shareDriveMenuItem.setVisible(!track.isSharedWithMe());
|
||||
|
||||
insertMarkerMenuItem = menu.findItem(R.id.track_detail_insert_marker);
|
||||
playMenuItem = menu.findItem(R.id.track_detail_play);
|
||||
shareMenuItem = menu.findItem(R.id.track_detail_share);
|
||||
shareDriveMenuItem = menu.findItem(R.id.track_detail_share_drive);
|
||||
sendGoogleMenuItem = menu.findItem(R.id.track_detail_send_google);
|
||||
saveMenuItem = menu.findItem(R.id.track_detail_save);
|
||||
voiceFrequencyMenuItem = menu.findItem(R.id.track_detail_voice_frequency);
|
||||
@@ -398,8 +400,9 @@ public class TrackDetailActivity extends AbstractMyTracksActivity implements Del
|
||||
return true;
|
||||
case R.id.track_detail_send_google:
|
||||
AnalyticsUtils.sendPageViews(this, "/action/send_google");
|
||||
ChooseUploadServiceDialogFragment.newInstance(new SendRequest(trackId)).show(
|
||||
getSupportFragmentManager(),
|
||||
Track track = myTracksProviderUtils.getTrack(trackId);
|
||||
ChooseUploadServiceDialogFragment.newInstance(
|
||||
new SendRequest(trackId), track.isSharedWithMe()).show(getSupportFragmentManager(),
|
||||
ChooseUploadServiceDialogFragment.CHOOSE_UPLOAD_SERVICE_DIALOG_TAG);
|
||||
return true;
|
||||
case R.id.track_detail_save_gpx:
|
||||
@@ -524,7 +527,7 @@ public class TrackDetailActivity extends AbstractMyTracksActivity implements Del
|
||||
if (shareMenuItem != null) {
|
||||
shareMenuItem.setVisible(!isRecording);
|
||||
}
|
||||
if (shareDriveMenuItem != null) {
|
||||
if (shareDriveMenuItem != null && shareDriveMenuItem.isEnabled()) {
|
||||
shareDriveMenuItem.setVisible(!isRecording);
|
||||
}
|
||||
if (sendGoogleMenuItem != null) {
|
||||
|
||||
+19
-5
@@ -48,10 +48,12 @@ public class ChooseUploadServiceDialogFragment extends DialogFragment {
|
||||
public static final String CHOOSE_UPLOAD_SERVICE_DIALOG_TAG = "chooseUploadService";
|
||||
|
||||
private static final String KEY_SEND_REQUEST = "sendRequest";
|
||||
private static final String KEY_HIDE_DRIVE = "hideDrive";
|
||||
|
||||
public static ChooseUploadServiceDialogFragment newInstance(SendRequest sendRequest) {
|
||||
public static ChooseUploadServiceDialogFragment newInstance(SendRequest sendRequest, boolean hideDrive) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putParcelable(KEY_SEND_REQUEST, sendRequest);
|
||||
bundle.putBoolean(KEY_HIDE_DRIVE, hideDrive);
|
||||
|
||||
ChooseUploadServiceDialogFragment chooseUploadServiceDialogFragment = new ChooseUploadServiceDialogFragment();
|
||||
chooseUploadServiceDialogFragment.setArguments(bundle);
|
||||
@@ -60,7 +62,8 @@ public class ChooseUploadServiceDialogFragment extends DialogFragment {
|
||||
|
||||
private FragmentActivity activity;
|
||||
private SendRequest sendRequest;
|
||||
|
||||
private boolean hideDrive;
|
||||
|
||||
private CheckBox driveCheckBox;
|
||||
private CheckBox mapsCheckBox;
|
||||
private CheckBox fusionTablesCheckBox;
|
||||
@@ -73,9 +76,13 @@ public class ChooseUploadServiceDialogFragment extends DialogFragment {
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
activity = getActivity();
|
||||
sendRequest = getArguments().getParcelable(KEY_SEND_REQUEST);
|
||||
|
||||
hideDrive = getArguments().getBoolean(KEY_HIDE_DRIVE);
|
||||
|
||||
View view = activity.getLayoutInflater().inflate(R.layout.choose_upload_service, null);
|
||||
|
||||
view.findViewById(R.id.choose_upload_service_drive_options)
|
||||
.setVisibility(hideDrive ? View.GONE : View.VISIBLE);
|
||||
|
||||
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);
|
||||
@@ -131,7 +138,7 @@ public class ChooseUploadServiceDialogFragment extends DialogFragment {
|
||||
activity, R.string.send_to_fusion_tables_key, fusionTablesCheckBox.isChecked());
|
||||
PreferencesUtils.setBoolean(
|
||||
activity, R.string.send_to_docs_key, docsCheckBox.isChecked());
|
||||
if (driveCheckBox.isChecked() || mapsCheckBox.isChecked()
|
||||
if (sendDrive() || mapsCheckBox.isChecked()
|
||||
|| fusionTablesCheckBox.isChecked() || docsCheckBox.isChecked()) {
|
||||
startNextActivity();
|
||||
} else {
|
||||
@@ -153,7 +160,7 @@ public class ChooseUploadServiceDialogFragment extends DialogFragment {
|
||||
* Starts the next activity, {@link AccountChooserActivity}.
|
||||
*/
|
||||
private void startNextActivity() {
|
||||
sendRequest.setSendDrive(driveCheckBox.isChecked());
|
||||
sendRequest.setSendDrive(sendDrive());
|
||||
sendRequest.setSendMaps(mapsCheckBox.isChecked());
|
||||
sendRequest.setSendFusionTables(fusionTablesCheckBox.isChecked());
|
||||
sendRequest.setSendDocs(docsCheckBox.isChecked());
|
||||
@@ -181,4 +188,11 @@ public class ChooseUploadServiceDialogFragment extends DialogFragment {
|
||||
AnalyticsUtils.sendPageViews(activity, "/send/docs");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* True to send to Google Drive.
|
||||
*/
|
||||
private boolean sendDrive() {
|
||||
return !hideDrive && driveCheckBox.isChecked();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import android.os.Parcelable;
|
||||
/**
|
||||
* Send request states for sending a track to Google Maps, Google Fusion Tables,
|
||||
* and Google Docs.
|
||||
*
|
||||
*
|
||||
* @author Jimmy Shih
|
||||
*/
|
||||
public class SendRequest implements Parcelable {
|
||||
@@ -48,7 +48,7 @@ public class SendRequest implements Parcelable {
|
||||
|
||||
/**
|
||||
* Creates a new send request.
|
||||
*
|
||||
*
|
||||
* @param trackId the track id
|
||||
*/
|
||||
public SendRequest(long trackId) {
|
||||
@@ -100,7 +100,7 @@ public class SendRequest implements Parcelable {
|
||||
public String getAcl() {
|
||||
return acl;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the email address of the user to share the track with.
|
||||
*
|
||||
@@ -109,7 +109,7 @@ public class SendRequest implements Parcelable {
|
||||
public void setAcl(String acl) {
|
||||
this.acl = acl;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* True if the user has selected the send to Google Drive option.
|
||||
*/
|
||||
@@ -136,7 +136,7 @@ public class SendRequest implements Parcelable {
|
||||
|
||||
/**
|
||||
* Sets the send to Google Maps option.
|
||||
*
|
||||
*
|
||||
* @param sendMaps true if the user has selected the send to Google Maps
|
||||
* option
|
||||
*/
|
||||
@@ -153,7 +153,7 @@ public class SendRequest implements Parcelable {
|
||||
|
||||
/**
|
||||
* Sets the send to Google Fusion Tables option.
|
||||
*
|
||||
*
|
||||
* @param sendFusionTables true if the user has selected the send to Google
|
||||
* Fusion Tables option
|
||||
*/
|
||||
@@ -170,7 +170,7 @@ public class SendRequest implements Parcelable {
|
||||
|
||||
/**
|
||||
* Sets the send to Google Docs option.
|
||||
*
|
||||
*
|
||||
* @param sendDocs true if the user has selected the send to Google Docs
|
||||
* option
|
||||
*/
|
||||
@@ -187,7 +187,7 @@ public class SendRequest implements Parcelable {
|
||||
|
||||
/**
|
||||
* Sets the new map option.
|
||||
*
|
||||
*
|
||||
* @param newMap true if the user has selected to create a new Google Maps.
|
||||
*/
|
||||
public void setNewMap(boolean newMap) {
|
||||
@@ -203,7 +203,7 @@ public class SendRequest implements Parcelable {
|
||||
|
||||
/**
|
||||
* Sets the account.
|
||||
*
|
||||
*
|
||||
* @param account the account
|
||||
*/
|
||||
public void setAccount(Account account) {
|
||||
@@ -220,7 +220,7 @@ public class SendRequest implements Parcelable {
|
||||
|
||||
/**
|
||||
* Sets the map id.
|
||||
*
|
||||
*
|
||||
* @param mapId the map id
|
||||
*/
|
||||
public void setMapId(String mapId) {
|
||||
@@ -236,13 +236,13 @@ public class SendRequest implements Parcelable {
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
@@ -252,7 +252,7 @@ public class SendRequest implements Parcelable {
|
||||
|
||||
/**
|
||||
* Sets the Google Maps result.
|
||||
*
|
||||
*
|
||||
* @param mapsSuccess true if sending to Google Maps is success
|
||||
*/
|
||||
public void setMapsSuccess(boolean mapsSuccess) {
|
||||
@@ -268,7 +268,7 @@ public class SendRequest implements Parcelable {
|
||||
|
||||
/**
|
||||
* Sets the Google Fusion Tables result.
|
||||
*
|
||||
*
|
||||
* @param fusionTablesSuccess true if sending to Google Fusion Tables is
|
||||
* success
|
||||
*/
|
||||
@@ -285,7 +285,7 @@ public class SendRequest implements Parcelable {
|
||||
|
||||
/**
|
||||
* Sets the Google Docs result.
|
||||
*
|
||||
*
|
||||
* @param docsSuccess true if sending to Google Docs is success
|
||||
*/
|
||||
public void setDocsSuccess(boolean docsSuccess) {
|
||||
@@ -334,14 +334,14 @@ public class SendRequest implements Parcelable {
|
||||
out.writeByte((byte) (docsSuccess ? 1 : 0));
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<SendRequest> CREATOR = new Parcelable.Creator<
|
||||
SendRequest>() {
|
||||
public SendRequest createFromParcel(Parcel in) {
|
||||
return new SendRequest(in);
|
||||
}
|
||||
public static final Parcelable.Creator<SendRequest>
|
||||
CREATOR = new Parcelable.Creator<SendRequest>() {
|
||||
public SendRequest createFromParcel(Parcel in) {
|
||||
return new SendRequest(in);
|
||||
}
|
||||
|
||||
public SendRequest[] newArray(int size) {
|
||||
return new SendRequest[size];
|
||||
}
|
||||
};
|
||||
public SendRequest[] newArray(int size) {
|
||||
return new SendRequest[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ public class SyncUtils {
|
||||
|
||||
// Get My Tracks folder KML files
|
||||
public static final String MY_TRACKS_FOLDER_FILES_QUERY = "'%s' in parents and mimeType = '"
|
||||
+ KML_MIME_TYPE + "' and trashed = false";
|
||||
+ KML_MIME_TYPE + "' and trashed = false and not sharedWithMe";
|
||||
|
||||
// Get shared with me KML files
|
||||
public static final String SHARED_WITH_ME_FILES_QUERY = "sharedWithMe and mimeType = '"
|
||||
@@ -98,7 +98,7 @@ public class SyncUtils {
|
||||
@VisibleForTesting
|
||||
public static final String MY_TRACKS_FOLDER_QUERY =
|
||||
"'root' in parents and title = '%s' and mimeType = '" + FOLDER_MIME_TYPE
|
||||
+ "' and trashed = false";
|
||||
+ "' and trashed = false and not sharedWithMe";
|
||||
|
||||
private static final String TAG = SyncUtils.class.getSimpleName();
|
||||
private static final String SYNC_AUTHORITY = "com.google.android.maps.mytracks";
|
||||
@@ -310,6 +310,9 @@ public class SyncUtils {
|
||||
if (!SyncUtils.KML_MIME_TYPE.equals(driveFile.getMimeType())) {
|
||||
return false;
|
||||
}
|
||||
if (driveFile.getSharedWithMeDate() != null) {
|
||||
return false;
|
||||
}
|
||||
for (ParentReference parentReference : driveFile.getParents()) {
|
||||
String id = parentReference.getId();
|
||||
if (id != null && id.equals(folderId)) {
|
||||
|
||||
Reference in New Issue
Block a user