forked from upstream-mirrors/OpenTracks
When sending to Google Fusion Table, allow either new public tables
or new private tables.
This commit is contained in:
@@ -63,7 +63,6 @@ limitations under the License.
|
|||||||
style="@style/ChooseUploadServiceImageView" />
|
style="@style/ChooseUploadServiceImageView" />
|
||||||
<CheckBox
|
<CheckBox
|
||||||
android:id="@+id/choose_upload_service_fusion_tables"
|
android:id="@+id/choose_upload_service_fusion_tables"
|
||||||
android:text="@string/send_google_fusion_tables_new_public_table"
|
|
||||||
style="@style/ChooseUploadServiceCheckBox" />
|
style="@style/ChooseUploadServiceCheckBox" />
|
||||||
</TableRow>
|
</TableRow>
|
||||||
<TableRow>
|
<TableRow>
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<!-- Keys for persisted preferences. Sorted alphabetically. DO NOT TRANSLATE. -->
|
<!-- Keys for persisted preferences. Sorted alphabetically. DO NOT TRANSLATE. -->
|
||||||
<string name="allow_access_key">allowAccess</string>
|
<string name="allow_access_key">allowAccess</string>
|
||||||
<string name="ant_bike_cadence_sensor_id_key">antBikeCadenceSensorId</string>
|
<string name="ant_bike_cadence_sensor_id_key">antBikeCadenceSensorId</string>
|
||||||
@@ -35,6 +34,7 @@ limitations under the License.
|
|||||||
<string name="confirm_share_map_key">confirmShareMap</string>
|
<string name="confirm_share_map_key">confirmShareMap</string>
|
||||||
<string name="default_activity_key">defaultActivity</string>
|
<string name="default_activity_key">defaultActivity</string>
|
||||||
<string name="default_map_public_key">defaultMapPublic</string>
|
<string name="default_map_public_key">defaultMapPublic</string>
|
||||||
|
<string name="default_table_public_key">defaultTablePublic</string>
|
||||||
<string name="drive_sync_key">driveSync</string>
|
<string name="drive_sync_key">driveSync</string>
|
||||||
<string name="google_account_key">googleAccount</string>
|
<string name="google_account_key">googleAccount</string>
|
||||||
<string name="max_recording_distance_key">maxRecordingDistance</string>
|
<string name="max_recording_distance_key">maxRecordingDistance</string>
|
||||||
@@ -48,7 +48,7 @@ limitations under the License.
|
|||||||
<string name="send_to_drive_key">sendToDrive</string>
|
<string name="send_to_drive_key">sendToDrive</string>
|
||||||
<string name="send_to_fusion_tables_key">sendToFusionTables</string>
|
<string name="send_to_fusion_tables_key">sendToFusionTables</string>
|
||||||
<string name="send_to_maps_key">sendToMaps</string>
|
<string name="send_to_maps_key">sendToMaps</string>
|
||||||
<string name="sensor_type_key">sensorType</string>
|
<string name="sensor_type_key">sensorType</string>
|
||||||
<string name="split_frequency_key">splitFrequency</string>
|
<string name="split_frequency_key">splitFrequency</string>
|
||||||
<string name="stats_show_coordinate_key">statsShowCoordinate</string>
|
<string name="stats_show_coordinate_key">statsShowCoordinate</string>
|
||||||
<string name="stats_show_elevation_key">statsShowElevation</string>
|
<string name="stats_show_elevation_key">statsShowElevation</string>
|
||||||
@@ -64,7 +64,6 @@ limitations under the License.
|
|||||||
<string name="track_widget_item3">trackWidgetItem3</string>
|
<string name="track_widget_item3">trackWidgetItem3</string>
|
||||||
<string name="track_widget_item4">trackWidgetItem4</string>
|
<string name="track_widget_item4">trackWidgetItem4</string>
|
||||||
<string name="voice_frequency_key">voiceFrequency</string>
|
<string name="voice_frequency_key">voiceFrequency</string>
|
||||||
|
|
||||||
<!-- Keys for persistend preferences. But they should not get backed up or restored. -->
|
<!-- Keys for persistend preferences. But they should not get backed up or restored. -->
|
||||||
<string name="auto_resume_track_current_retry_key">autoResumeTrackCurrentRetry</string>
|
<string name="auto_resume_track_current_retry_key">autoResumeTrackCurrentRetry</string>
|
||||||
<string name="drive_deleted_list_key">driveDeletedList</string>
|
<string name="drive_deleted_list_key">driveDeletedList</string>
|
||||||
@@ -72,7 +71,6 @@ limitations under the License.
|
|||||||
<string name="recording_track_id_key">recordingTrackId</string>
|
<string name="recording_track_id_key">recordingTrackId</string>
|
||||||
<string name="recording_track_paused_key">recordingTrackPaused</string>
|
<string name="recording_track_paused_key">recordingTrackPaused</string>
|
||||||
<string name="selected_track_id_key">selectedTrackId</string>
|
<string name="selected_track_id_key">selectedTrackId</string>
|
||||||
|
|
||||||
<!-- Keys for non-persisted preferences. Sorted alphabetically. DO NOT TRANSLATE. -->
|
<!-- Keys for non-persisted preferences. Sorted alphabetically. DO NOT TRANSLATE. -->
|
||||||
<string name="settings_backup_key">settingsBackup</string>
|
<string name="settings_backup_key">settingsBackup</string>
|
||||||
<string name="settings_backup_reset_key">settingsBackupReset</string>
|
<string name="settings_backup_reset_key">settingsBackupReset</string>
|
||||||
@@ -96,5 +94,4 @@ limitations under the License.
|
|||||||
<string name="settings_sensor_root_key">settingsSensorRoot</string>
|
<string name="settings_sensor_root_key">settingsSensorRoot</string>
|
||||||
<string name="settings_sharing_key">settingsSharing</string>
|
<string name="settings_sharing_key">settingsSharing</string>
|
||||||
<string name="settings_stats_key">settingsStats</string>
|
<string name="settings_stats_key">settingsStats</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
@@ -1461,11 +1461,15 @@ limitations under the License.
|
|||||||
translation_description="When sending a track to Google, the Google Fusion Tables name.">
|
translation_description="When sending a track to Google, the Google Fusion Tables name.">
|
||||||
Google Fusion Tables
|
Google Fusion Tables
|
||||||
</string>
|
</string>
|
||||||
<string name="send_google_fusion_tables_new_public_table"
|
<string name="send_google_fusion_tables_private"
|
||||||
translation_description="When sending a track to Google, under the 'Send to...' dialog, the
|
translation_description="When sending a track to Google Fusion Tables, indicate a new private
|
||||||
checkbox option to send to Google Fusion Tables as a new public table. Note that \n is the new
|
table will get created.">
|
||||||
line character.">
|
(new private table)
|
||||||
Google Fusion Tables\n(new public table)
|
</string>
|
||||||
|
<string name="send_google_fusion_tables_public"
|
||||||
|
translation_description="When sending a track to Google Fusion Tables, indicate a new public
|
||||||
|
table will get created.">
|
||||||
|
(new public table)
|
||||||
</string>
|
</string>
|
||||||
<string name="send_google_maps"
|
<string name="send_google_maps"
|
||||||
translation_description="When sending a track to Google, under the 'Send to...' dialog, the
|
translation_description="When sending a track to Google, under the 'Send to...' dialog, the
|
||||||
@@ -1766,6 +1770,25 @@ limitations under the License.
|
|||||||
Character limit: ~23 (1 line)">
|
Character limit: ~23 (1 line)">
|
||||||
Sync Google Drive
|
Sync Google Drive
|
||||||
</string>
|
</string>
|
||||||
|
<string name="settings_google_fusion_tables_public_summary_off"
|
||||||
|
translation_description="In the 'Google' settings, the summary for the 'New tables public'
|
||||||
|
checkbox when it is unchecked explaining that new tables created in Google Fusion Tables will
|
||||||
|
be private, instead of public.">
|
||||||
|
New tables created in Google Fusion Tables will be private, instead of public.
|
||||||
|
</string>
|
||||||
|
<string name="settings_google_fusion_tables_public_summary_on"
|
||||||
|
translation_description="In the 'Google' settings, the summary for the 'New tables public'
|
||||||
|
checkbox when it is checked explaining that new tables created in Google Fusion Tables will be
|
||||||
|
public, instead of private.">
|
||||||
|
New tables created in Google Fusion Tables will be public, instead of private.
|
||||||
|
</string>
|
||||||
|
<string name="settings_google_fusion_tables_public_title"
|
||||||
|
translation_description="In the 'Google' settings, the checkbox to make new tables created in
|
||||||
|
Google Fusion Tables public instead of private.
|
||||||
|
|
||||||
|
Character limit: ~23 (1 line)">
|
||||||
|
New tables public
|
||||||
|
</string>
|
||||||
<string name="settings_google_maps_public_summary_off"
|
<string name="settings_google_maps_public_summary_off"
|
||||||
translation_description="In the 'Google' settings, the summary for the 'New maps public'
|
translation_description="In the 'Google' settings, the summary for the 'New maps public'
|
||||||
checkbox when it is unchecked explaining that new maps created in Google Maps will be
|
checkbox when it is unchecked explaining that new maps created in Google Maps will be
|
||||||
|
|||||||
@@ -28,4 +28,10 @@ limitations under the License.
|
|||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="@string/default_map_public_key"
|
android:key="@string/default_map_public_key"
|
||||||
android:title="@string/settings_google_maps_public_title" />
|
android:title="@string/settings_google_maps_public_title" />
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:key="@string/default_table_public_key"
|
||||||
|
android:summaryOff="@string/settings_google_fusion_tables_public_summary_off"
|
||||||
|
android:summaryOn="@string/settings_google_fusion_tables_public_summary_on"
|
||||||
|
android:title="@string/settings_google_fusion_tables_public_title" />
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
+12
-2
@@ -94,7 +94,8 @@ public class ChooseUploadServiceDialogFragment extends DialogFragment {
|
|||||||
activity, R.string.send_to_maps_key, PreferencesUtils.SEND_TO_MAPS_DEFAULT));
|
activity, R.string.send_to_maps_key, PreferencesUtils.SEND_TO_MAPS_DEFAULT));
|
||||||
fusionTablesCheckBox.setChecked(PreferencesUtils.getBoolean(
|
fusionTablesCheckBox.setChecked(PreferencesUtils.getBoolean(
|
||||||
activity, R.string.send_to_fusion_tables_key,
|
activity, R.string.send_to_fusion_tables_key,
|
||||||
PreferencesUtils.SEND_TO_FUSION_TABLES_DEFAULT));
|
PreferencesUtils.SEND_TO_FUSION_TABLES_DEFAULT));
|
||||||
|
|
||||||
docsCheckBox.setChecked(PreferencesUtils.getBoolean(
|
docsCheckBox.setChecked(PreferencesUtils.getBoolean(
|
||||||
activity, R.string.send_to_docs_key, PreferencesUtils.SEND_TO_DOCS_DEFAULT));
|
activity, R.string.send_to_docs_key, PreferencesUtils.SEND_TO_DOCS_DEFAULT));
|
||||||
|
|
||||||
@@ -123,7 +124,16 @@ public class ChooseUploadServiceDialogFragment extends DialogFragment {
|
|||||||
} else {
|
} else {
|
||||||
newMapRadioButton.setChecked(true);
|
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)
|
return new AlertDialog.Builder(activity).setNegativeButton(R.string.generic_cancel, null)
|
||||||
.setPositiveButton(R.string.send_google_send_now, new DialogInterface.OnClickListener() {
|
.setPositiveButton(R.string.send_google_send_now, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+28
@@ -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.content.Waypoint.WaypointType;
|
||||||
import com.google.android.apps.mytracks.io.sendtogoogle.AbstractSendAsyncTask;
|
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.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.LocationUtils;
|
||||||
|
import com.google.android.apps.mytracks.util.PreferencesUtils;
|
||||||
import com.google.android.gms.auth.GoogleAuthException;
|
import com.google.android.gms.auth.GoogleAuthException;
|
||||||
import com.google.android.gms.auth.UserRecoverableAuthException;
|
import com.google.android.gms.auth.UserRecoverableAuthException;
|
||||||
import com.google.android.maps.mytracks.R;
|
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.GoogleAccountCredential;
|
||||||
import com.google.api.client.googleapis.extensions.android.gms.auth.UserRecoverableAuthIOException;
|
import com.google.api.client.googleapis.extensions.android.gms.auth.UserRecoverableAuthIOException;
|
||||||
import com.google.api.client.json.gson.GsonFactory;
|
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;
|
||||||
import com.google.api.services.fusiontables.Fusiontables.Query.Sql;
|
import com.google.api.services.fusiontables.Fusiontables.Query.Sql;
|
||||||
import com.google.api.services.fusiontables.model.Column;
|
import com.google.api.services.fusiontables.model.Column;
|
||||||
@@ -114,6 +118,10 @@ public class SendFusionTablesAsyncTask extends AbstractSendAsyncTask {
|
|||||||
publishProgress(PROGRESS_SET_STYLE);
|
publishProgress(PROGRESS_SET_STYLE);
|
||||||
setStyle(fusiontables, tableId);
|
setStyle(fusiontables, tableId);
|
||||||
setTemplate(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
|
// Upload all the track points plus the start and end markers
|
||||||
publishProgress(PROGRESS_UPLOAD_DATA_MIN);
|
publishProgress(PROGRESS_UPLOAD_DATA_MIN);
|
||||||
@@ -189,6 +197,26 @@ public class SendFusionTablesAsyncTask extends AbstractSendAsyncTask {
|
|||||||
fusiontables.template().insert(tableId, template).execute();
|
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. *
|
* Uploads all the points in a track. *
|
||||||
*
|
*
|
||||||
|
|||||||
+1
-1
@@ -172,7 +172,7 @@ public class AccountChooserActivity extends Activity {
|
|||||||
* Checks the Drive permission.
|
* Checks the Drive permission.
|
||||||
*/
|
*/
|
||||||
private void checkDrivePermission() {
|
private void checkDrivePermission() {
|
||||||
if (sendRequest.isSendDrive()) {
|
if (sendRequest.isSendDrive() || sendRequest.isSendFusionTables()) {
|
||||||
SendToGoogleUtils.checkPermissionByActivity(this, sendRequest.getAccount().name,
|
SendToGoogleUtils.checkPermissionByActivity(this, sendRequest.getAccount().name,
|
||||||
SendToGoogleUtils.DRIVE_SCOPE, SendToGoogleUtils.DRIVE_PERMISSION_REQUEST_CODE,
|
SendToGoogleUtils.DRIVE_SCOPE, SendToGoogleUtils.DRIVE_PERMISSION_REQUEST_CODE,
|
||||||
driveCallback);
|
driveCallback);
|
||||||
|
|||||||
+7
-1
@@ -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.fusiontables.SendFusionTablesUtils;
|
||||||
import com.google.android.apps.mytracks.io.maps.SendMapsUtils;
|
import com.google.android.apps.mytracks.io.maps.SendMapsUtils;
|
||||||
import com.google.android.apps.mytracks.util.IntentUtils;
|
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.android.maps.mytracks.R;
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
|
|
||||||
@@ -79,7 +80,12 @@ public class UploadResultActivity extends FragmentActivity {
|
|||||||
}
|
}
|
||||||
if (shareUrl == null && sendRequest.isSendFusionTables()
|
if (shareUrl == null && sendRequest.isSendFusionTables()
|
||||||
&& sendRequest.isFusionTablesSuccess()) {
|
&& 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);
|
showDialog(DIALOG_RESULT_ID);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ public class PreferencesUtils {
|
|||||||
|
|
||||||
public static final String DEFAULT_ACTIVITY_DEFAULT = "";
|
public static final String DEFAULT_ACTIVITY_DEFAULT = "";
|
||||||
public static final boolean DEFAULT_MAP_PUBLIC_DEFAULT = false;
|
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 String DRIVE_DELETED_LIST_DEFAULT = "";
|
||||||
public static final long DRIVE_LARGEST_CHANGE_ID_DEFAULT = -1L;
|
public static final long DRIVE_LARGEST_CHANGE_ID_DEFAULT = -1L;
|
||||||
public static final boolean DRIVE_SYNC_DEFAULT = false;
|
public static final boolean DRIVE_SYNC_DEFAULT = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user