diff --git a/MyTracks/res/layout/choose_upload_service.xml b/MyTracks/res/layout/choose_upload_service.xml
index 1af9231f3..11294c89b 100644
--- a/MyTracks/res/layout/choose_upload_service.xml
+++ b/MyTracks/res/layout/choose_upload_service.xml
@@ -63,7 +63,6 @@ limitations under the License.
style="@style/ChooseUploadServiceImageView" />
diff --git a/MyTracks/res/values/keys.xml b/MyTracks/res/values/keys.xml
index 2b0024241..97415457d 100644
--- a/MyTracks/res/values/keys.xml
+++ b/MyTracks/res/values/keys.xml
@@ -15,7 +15,6 @@ See the License for the specific language governing permissions and
limitations under the License.
-->
-
allowAccess
antBikeCadenceSensorId
@@ -35,6 +34,7 @@ limitations under the License.
confirmShareMap
defaultActivity
defaultMapPublic
+ defaultTablePublic
driveSync
googleAccount
maxRecordingDistance
@@ -48,7 +48,7 @@ limitations under the License.
sendToDrive
sendToFusionTables
sendToMaps
- sensorType
+ sensorType
splitFrequency
statsShowCoordinate
statsShowElevation
@@ -64,7 +64,6 @@ limitations under the License.
trackWidgetItem3
trackWidgetItem4
voiceFrequency
-
autoResumeTrackCurrentRetry
driveDeletedList
@@ -72,7 +71,6 @@ limitations under the License.
recordingTrackId
recordingTrackPaused
selectedTrackId
-
settingsBackup
settingsBackupReset
@@ -96,5 +94,4 @@ limitations under the License.
settingsSensorRoot
settingsSharing
settingsStats
-
\ No newline at end of file
diff --git a/MyTracks/res/values/strings.xml b/MyTracks/res/values/strings.xml
index 8b2beae24..92f0f9986 100644
--- a/MyTracks/res/values/strings.xml
+++ b/MyTracks/res/values/strings.xml
@@ -1461,11 +1461,15 @@ limitations under the License.
translation_description="When sending a track to Google, the Google Fusion Tables name.">
Google Fusion Tables
-
- Google Fusion Tables\n(new public table)
+
+ (new private table)
+
+
+ (new public table)
Sync Google Drive
+
+ New tables created in Google Fusion Tables will be private, instead of public.
+
+
+ New tables created in Google Fusion Tables will be public, instead of private.
+
+
+ New tables public
+
+
\ No newline at end of file
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 8043c94bd..03bd9ab33 100644
--- a/MyTracks/src/com/google/android/apps/mytracks/fragments/ChooseUploadServiceDialogFragment.java
+++ b/MyTracks/src/com/google/android/apps/mytracks/fragments/ChooseUploadServiceDialogFragment.java
@@ -94,7 +94,8 @@ public class ChooseUploadServiceDialogFragment extends DialogFragment {
activity, R.string.send_to_maps_key, PreferencesUtils.SEND_TO_MAPS_DEFAULT));
fusionTablesCheckBox.setChecked(PreferencesUtils.getBoolean(
activity, R.string.send_to_fusion_tables_key,
- PreferencesUtils.SEND_TO_FUSION_TABLES_DEFAULT));
+ PreferencesUtils.SEND_TO_FUSION_TABLES_DEFAULT));
+
docsCheckBox.setChecked(PreferencesUtils.getBoolean(
activity, R.string.send_to_docs_key, PreferencesUtils.SEND_TO_DOCS_DEFAULT));
@@ -123,7 +124,16 @@ public class ChooseUploadServiceDialogFragment extends DialogFragment {
} else {
newMapRadioButton.setChecked(true);
}
-
+
+ // Update fusion table
+ boolean defaultTablePublic = PreferencesUtils.getBoolean(activity,
+ R.string.default_table_public_key,
+ PreferencesUtils.DEFAULT_TABLE_PUBLIC_DEFAULT);
+ String text = getString(R.string.send_google_fusion_tables) + "\n"
+ + getString(defaultTablePublic ? R.string.send_google_fusion_tables_public
+ : R.string.send_google_fusion_tables_private);
+ fusionTablesCheckBox.setText(text);
+
return new AlertDialog.Builder(activity).setNegativeButton(R.string.generic_cancel, null)
.setPositiveButton(R.string.send_google_send_now, new DialogInterface.OnClickListener() {
@Override
diff --git a/MyTracks/src/com/google/android/apps/mytracks/io/fusiontables/SendFusionTablesAsyncTask.java b/MyTracks/src/com/google/android/apps/mytracks/io/fusiontables/SendFusionTablesAsyncTask.java
index 17ed23cd8..047500975 100644
--- a/MyTracks/src/com/google/android/apps/mytracks/io/fusiontables/SendFusionTablesAsyncTask.java
+++ b/MyTracks/src/com/google/android/apps/mytracks/io/fusiontables/SendFusionTablesAsyncTask.java
@@ -11,7 +11,9 @@ import com.google.android.apps.mytracks.content.Waypoint;
import com.google.android.apps.mytracks.content.Waypoint.WaypointType;
import com.google.android.apps.mytracks.io.sendtogoogle.AbstractSendAsyncTask;
import com.google.android.apps.mytracks.io.sendtogoogle.SendToGoogleUtils;
+import com.google.android.apps.mytracks.io.sync.SyncUtils;
import com.google.android.apps.mytracks.util.LocationUtils;
+import com.google.android.apps.mytracks.util.PreferencesUtils;
import com.google.android.gms.auth.GoogleAuthException;
import com.google.android.gms.auth.UserRecoverableAuthException;
import com.google.android.maps.mytracks.R;
@@ -19,6 +21,8 @@ import com.google.api.client.extensions.android.http.AndroidHttp;
import com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential;
import com.google.api.client.googleapis.extensions.android.gms.auth.UserRecoverableAuthIOException;
import com.google.api.client.json.gson.GsonFactory;
+import com.google.api.services.drive.Drive;
+import com.google.api.services.drive.model.Permission;
import com.google.api.services.fusiontables.Fusiontables;
import com.google.api.services.fusiontables.Fusiontables.Query.Sql;
import com.google.api.services.fusiontables.model.Column;
@@ -114,6 +118,10 @@ public class SendFusionTablesAsyncTask extends AbstractSendAsyncTask {
publishProgress(PROGRESS_SET_STYLE);
setStyle(fusiontables, tableId);
setTemplate(fusiontables, tableId);
+ if (!setPermission(tableId)) {
+ Log.d(TAG, "Cannot set permission for table " + tableId);
+ return false;
+ }
// Upload all the track points plus the start and end markers
publishProgress(PROGRESS_UPLOAD_DATA_MIN);
@@ -189,6 +197,26 @@ public class SendFusionTablesAsyncTask extends AbstractSendAsyncTask {
fusiontables.template().insert(tableId, template).execute();
}
+ private boolean setPermission(String tableId) throws IOException, GoogleAuthException {
+ boolean defaultTablePublic = PreferencesUtils.getBoolean(context,
+ R.string.default_table_public_key,
+ PreferencesUtils.DEFAULT_TABLE_PUBLIC_DEFAULT);
+ if (!defaultTablePublic) {
+ return true;
+ }
+ GoogleAccountCredential driveCredential = SendToGoogleUtils.getGoogleAccountCredential(
+ context, account.name, SendToGoogleUtils.DRIVE_SCOPE);
+ if (driveCredential == null) {
+ return false;
+ }
+ Drive drive = SyncUtils.getDriveService(driveCredential);
+ Permission permission = new Permission();
+ permission.setType("anyone");
+ permission.setRole("reader");
+ drive.permissions().insert(tableId, permission).execute();
+ return true;
+ }
+
/**
* Uploads all the points in a track. *
*
diff --git a/MyTracks/src/com/google/android/apps/mytracks/io/sendtogoogle/AccountChooserActivity.java b/MyTracks/src/com/google/android/apps/mytracks/io/sendtogoogle/AccountChooserActivity.java
index 1ab0d36f2..6c314aff1 100644
--- a/MyTracks/src/com/google/android/apps/mytracks/io/sendtogoogle/AccountChooserActivity.java
+++ b/MyTracks/src/com/google/android/apps/mytracks/io/sendtogoogle/AccountChooserActivity.java
@@ -172,7 +172,7 @@ public class AccountChooserActivity extends Activity {
* Checks the Drive permission.
*/
private void checkDrivePermission() {
- if (sendRequest.isSendDrive()) {
+ if (sendRequest.isSendDrive() || sendRequest.isSendFusionTables()) {
SendToGoogleUtils.checkPermissionByActivity(this, sendRequest.getAccount().name,
SendToGoogleUtils.DRIVE_SCOPE, SendToGoogleUtils.DRIVE_PERMISSION_REQUEST_CODE,
driveCallback);
diff --git a/MyTracks/src/com/google/android/apps/mytracks/io/sendtogoogle/UploadResultActivity.java b/MyTracks/src/com/google/android/apps/mytracks/io/sendtogoogle/UploadResultActivity.java
index e3e590296..4bd3498a5 100644
--- a/MyTracks/src/com/google/android/apps/mytracks/io/sendtogoogle/UploadResultActivity.java
+++ b/MyTracks/src/com/google/android/apps/mytracks/io/sendtogoogle/UploadResultActivity.java
@@ -22,6 +22,7 @@ import com.google.android.apps.mytracks.fragments.ChooseActivityDialogFragment;
import com.google.android.apps.mytracks.io.fusiontables.SendFusionTablesUtils;
import com.google.android.apps.mytracks.io.maps.SendMapsUtils;
import com.google.android.apps.mytracks.util.IntentUtils;
+import com.google.android.apps.mytracks.util.PreferencesUtils;
import com.google.android.maps.mytracks.R;
import com.google.common.annotations.VisibleForTesting;
@@ -79,7 +80,12 @@ public class UploadResultActivity extends FragmentActivity {
}
if (shareUrl == null && sendRequest.isSendFusionTables()
&& sendRequest.isFusionTablesSuccess()) {
- shareUrl = SendFusionTablesUtils.getMapUrl(track);
+ boolean defaultTablePublic = PreferencesUtils.getBoolean(this,
+ R.string.default_table_public_key,
+ PreferencesUtils.DEFAULT_TABLE_PUBLIC_DEFAULT);
+ if (defaultTablePublic) {
+ shareUrl = SendFusionTablesUtils.getMapUrl(track);
+ }
}
showDialog(DIALOG_RESULT_ID);
}
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 87a739866..5a5a093dd 100644
--- a/MyTracks/src/com/google/android/apps/mytracks/util/PreferencesUtils.java
+++ b/MyTracks/src/com/google/android/apps/mytracks/util/PreferencesUtils.java
@@ -56,6 +56,7 @@ public class PreferencesUtils {
public static final String DEFAULT_ACTIVITY_DEFAULT = "";
public static final boolean DEFAULT_MAP_PUBLIC_DEFAULT = false;
+ public static final boolean DEFAULT_TABLE_PUBLIC_DEFAULT = false;
public static final String DRIVE_DELETED_LIST_DEFAULT = "";
public static final long DRIVE_LARGEST_CHANGE_ID_DEFAULT = -1L;
public static final boolean DRIVE_SYNC_DEFAULT = false;