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