forked from upstream-mirrors/OpenTracks
Keeping db version 18. Bug fixes.
This commit is contained in:
@@ -40,7 +40,7 @@ import android.util.Log;
|
|||||||
public class MyTracksProvider extends ContentProvider {
|
public class MyTracksProvider extends ContentProvider {
|
||||||
|
|
||||||
private static final String DATABASE_NAME = "mytracks.db";
|
private static final String DATABASE_NAME = "mytracks.db";
|
||||||
private static final int DATABASE_VERSION = 19;
|
private static final int DATABASE_VERSION = 18;
|
||||||
private static final int TRACKPOINTS = 1;
|
private static final int TRACKPOINTS = 1;
|
||||||
private static final int TRACKPOINTS_ID = 2;
|
private static final int TRACKPOINTS_ID = 2;
|
||||||
private static final int TRACKS = 3;
|
private static final int TRACKS = 3;
|
||||||
@@ -151,11 +151,9 @@ public class MyTracksProvider extends ContentProvider {
|
|||||||
// Sensor data.
|
// Sensor data.
|
||||||
if (oldVersion <= 17) {
|
if (oldVersion <= 17) {
|
||||||
Log.w(TAG, "Upgrading database from version " + oldVersion + " to "
|
Log.w(TAG, "Upgrading database from version " + oldVersion + " to "
|
||||||
+ newVersion + ", adding sensor column.");
|
+ newVersion + ", adding sensor and tableid columns.");
|
||||||
db.execSQL("ALTER TABLE " + TRACKPOINTS_TABLE
|
db.execSQL("ALTER TABLE " + TRACKPOINTS_TABLE
|
||||||
+ " ADD " + TrackPointsColumns.SENSOR + " BLOB");
|
+ " ADD " + TrackPointsColumns.SENSOR + " BLOB");
|
||||||
};
|
|
||||||
if (oldVersion >= 17) {
|
|
||||||
db.execSQL("ALTER TABLE " + TRACKS_TABLE
|
db.execSQL("ALTER TABLE " + TRACKS_TABLE
|
||||||
+ " ADD " + TracksColumns.TABLEID + " STRING");
|
+ " ADD " + TracksColumns.TABLEID + " STRING");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import com.google.api.client.googleapis.GoogleTransport;
|
|||||||
import com.google.api.client.http.GenericUrl;
|
import com.google.api.client.http.GenericUrl;
|
||||||
import com.google.api.client.http.HttpRequest;
|
import com.google.api.client.http.HttpRequest;
|
||||||
import com.google.api.client.http.HttpResponse;
|
import com.google.api.client.http.HttpResponse;
|
||||||
|
import com.google.api.client.http.HttpResponseException;
|
||||||
import com.google.api.client.http.HttpTransport;
|
import com.google.api.client.http.HttpTransport;
|
||||||
import com.google.api.client.http.InputStreamContent;
|
import com.google.api.client.http.InputStreamContent;
|
||||||
import com.google.api.client.util.Strings;
|
import com.google.api.client.util.Strings;
|
||||||
@@ -152,6 +153,10 @@ public class SendToFusionTables implements Runnable {
|
|||||||
progressIndicator.setProgressMessage(R.string.progress_message_creating_fusiontable);
|
progressIndicator.setProgressMessage(R.string.progress_message_creating_fusiontable);
|
||||||
success = createNewTable(track);
|
success = createNewTable(track);
|
||||||
|
|
||||||
|
if (success) {
|
||||||
|
success = makeTableUnlisted(tableId);
|
||||||
|
}
|
||||||
|
|
||||||
// Upload all of the segments of the track plus start/end markers
|
// Upload all of the segments of the track plus start/end markers
|
||||||
if (success) {
|
if (success) {
|
||||||
success = uploadAllTrackPoints(track, originalDescription);
|
success = uploadAllTrackPoints(track, originalDescription);
|
||||||
@@ -192,6 +197,12 @@ public class SendToFusionTables implements Runnable {
|
|||||||
return runUpdate(query);
|
return runUpdate(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean makeTableUnlisted(String tableId) {
|
||||||
|
Log.d(MyTracksConstants.TAG, "Setting visibility to unlisted.");
|
||||||
|
String query = "UPDATE TABLE " + tableId + " SET VISIBILITY = unlisted";
|
||||||
|
return runUpdate(query);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Formats given values SQL style. Escapes single quotes with a backslash.
|
* Formats given values SQL style. Escapes single quotes with a backslash.
|
||||||
*
|
*
|
||||||
@@ -604,7 +615,8 @@ public class SendToFusionTables implements Runnable {
|
|||||||
wrapper.runQuery(new QueryFunction<HttpTransport>() {
|
wrapper.runQuery(new QueryFunction<HttpTransport>() {
|
||||||
@Override
|
@Override
|
||||||
public void query(HttpTransport client)
|
public void query(HttpTransport client)
|
||||||
throws IOException, GDataWrapper.ParseException, GDataWrapper.HttpException {
|
throws IOException, GDataWrapper.ParseException, GDataWrapper.HttpException,
|
||||||
|
GDataWrapper.AuthenticationException {
|
||||||
HttpRequest request = transport.buildPostRequest();
|
HttpRequest request = transport.buildPostRequest();
|
||||||
request.headers.contentType = "application/x-www-form-urlencoded";
|
request.headers.contentType = "application/x-www-form-urlencoded";
|
||||||
GenericUrl url = new GenericUrl(FUSIONTABLES_BASE_FEED_URL);
|
GenericUrl url = new GenericUrl(FUSIONTABLES_BASE_FEED_URL);
|
||||||
@@ -614,24 +626,31 @@ public class SendToFusionTables implements Runnable {
|
|||||||
isc.inputStream = new ByteArrayInputStream(Strings.toBytesUtf8(sql));
|
isc.inputStream = new ByteArrayInputStream(Strings.toBytesUtf8(sql));
|
||||||
request.content = isc;
|
request.content = isc;
|
||||||
Log.d(MyTracksConstants.TAG, "Running update query " + url.toString() + ": " + sql);
|
Log.d(MyTracksConstants.TAG, "Running update query " + url.toString() + ": " + sql);
|
||||||
HttpResponse response = request.execute();
|
try {
|
||||||
boolean success = response.isSuccessStatusCode;
|
HttpResponse response = request.execute();
|
||||||
if (success) {
|
boolean success = response.isSuccessStatusCode;
|
||||||
byte[] result = new byte[1024];
|
if (success) {
|
||||||
response.getContent().read(result);
|
byte[] result = new byte[1024];
|
||||||
String s = Strings.fromBytesUtf8(result);
|
response.getContent().read(result);
|
||||||
String[] lines = s.split(Strings.LINE_SEPARATOR);
|
String s = Strings.fromBytesUtf8(result);
|
||||||
if (lines[0].equals("tableid")) {
|
String[] lines = s.split(Strings.LINE_SEPARATOR);
|
||||||
tableId = lines[1];
|
if (lines[0].equals("tableid")) {
|
||||||
Log.d(MyTracksConstants.TAG, "tableId = " + tableId);
|
tableId = lines[1];
|
||||||
|
Log.d(MyTracksConstants.TAG, "tableId = " + tableId);
|
||||||
|
} else {
|
||||||
|
Log.w(MyTracksConstants.TAG, "Unrecognized response: " + lines[0]);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.w(MyTracksConstants.TAG, "Unrecognized response: " + lines[0]);
|
Log.d(MyTracksConstants.TAG, "Query failed: " + response.statusMessage + " (" +
|
||||||
|
response.statusCode + ")");
|
||||||
|
throw new GDataWrapper.HttpException(response.statusCode, response.statusMessage);
|
||||||
|
}
|
||||||
|
} catch (HttpResponseException e) {
|
||||||
|
if (e.response.statusCode == 401) {
|
||||||
|
throw new GDataWrapper.AuthenticationException(e);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
Log.d(MyTracksConstants.TAG, "Query failed: " + response.statusMessage + " (" +
|
|
||||||
response.statusCode + ")");
|
|
||||||
throw new GDataWrapper.HttpException(response.statusCode, response.statusMessage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return wrapper.getErrorType() == GDataWrapper.ERROR_NO_ERROR;
|
return wrapper.getErrorType() == GDataWrapper.ERROR_NO_ERROR;
|
||||||
|
|||||||
@@ -86,7 +86,8 @@ public class DocsHelper {
|
|||||||
|
|
||||||
boolean result = docListWrapper.runQuery(new QueryFunction<GDataServiceClient>() {
|
boolean result = docListWrapper.runQuery(new QueryFunction<GDataServiceClient>() {
|
||||||
@Override
|
@Override
|
||||||
public void query(GDataServiceClient client) throws IOException {
|
public void query(GDataServiceClient client) throws IOException,
|
||||||
|
GDataWrapper.AuthenticationException {
|
||||||
// Construct and send request
|
// Construct and send request
|
||||||
URL url = new URL(DOCS_FEED_URL);
|
URL url = new URL(DOCS_FEED_URL);
|
||||||
URLConnection conn = url.openConnection();
|
URLConnection conn = url.openConnection();
|
||||||
@@ -171,7 +172,8 @@ public class DocsHelper {
|
|||||||
boolean result = docListWrapper.runQuery(new QueryFunction<GDataServiceClient>() {
|
boolean result = docListWrapper.runQuery(new QueryFunction<GDataServiceClient>() {
|
||||||
@Override
|
@Override
|
||||||
public void query(GDataServiceClient client)
|
public void query(GDataServiceClient client)
|
||||||
throws IOException, GDataWrapper.ParseException, GDataWrapper.HttpException {
|
throws IOException, GDataWrapper.ParseException, GDataWrapper.HttpException,
|
||||||
|
GDataWrapper.AuthenticationException {
|
||||||
GDataParser listParser;
|
GDataParser listParser;
|
||||||
try {
|
try {
|
||||||
listParser = client.getParserForFeed(Entry.class,
|
listParser = client.getParserForFeed(Entry.class,
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ public class GDataWrapper<C> {
|
|||||||
errorMessage = null;
|
errorMessage = null;
|
||||||
|
|
||||||
} catch (AuthenticationException e) {
|
} catch (AuthenticationException e) {
|
||||||
Log.e(MyTracksConstants.TAG, "Exception", e);
|
Log.e(MyTracksConstants.TAG, "AuthenticationException", e);
|
||||||
errorType = ERROR_AUTH;
|
errorType = ERROR_AUTH;
|
||||||
errorMessage = e.getMessage();
|
errorMessage = e.getMessage();
|
||||||
} catch (HttpException e) {
|
} catch (HttpException e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user