forked from upstream-mirrors/OpenTracks
Move Track Points table constants to TrackPointsColumns.java.
This commit is contained in:
@@ -52,7 +52,6 @@ public class MyTracksProvider extends ContentProvider {
|
|||||||
private static final int TRACKS_ID = 4;
|
private static final int TRACKS_ID = 4;
|
||||||
private static final int WAYPOINTS = 5;
|
private static final int WAYPOINTS = 5;
|
||||||
private static final int WAYPOINTS_ID = 6;
|
private static final int WAYPOINTS_ID = 6;
|
||||||
private static final String TRACKPOINTS_TABLE = "trackpoints";
|
|
||||||
private static final String WAYPOINTS_TABLE = "waypoints";
|
private static final String WAYPOINTS_TABLE = "waypoints";
|
||||||
private static final String TAG = MyTracksProvider.class.getSimpleName();
|
private static final String TAG = MyTracksProvider.class.getSimpleName();
|
||||||
|
|
||||||
@@ -67,17 +66,7 @@ public class MyTracksProvider extends ContentProvider {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(SQLiteDatabase db) {
|
public void onCreate(SQLiteDatabase db) {
|
||||||
db.execSQL("CREATE TABLE " + TRACKPOINTS_TABLE + " ("
|
db.execSQL(TrackPointsColumns.CREATE_TABLE);
|
||||||
+ TrackPointsColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
|
|
||||||
+ TrackPointsColumns.TRACKID + " INTEGER, "
|
|
||||||
+ TrackPointsColumns.LONGITUDE + " INTEGER, "
|
|
||||||
+ TrackPointsColumns.LATITUDE + " INTEGER, "
|
|
||||||
+ TrackPointsColumns.TIME + " INTEGER, "
|
|
||||||
+ TrackPointsColumns.ALTITUDE + " FLOAT, "
|
|
||||||
+ TrackPointsColumns.ACCURACY + " FLOAT, "
|
|
||||||
+ TrackPointsColumns.SPEED + " FLOAT, "
|
|
||||||
+ TrackPointsColumns.BEARING + " FLOAT, "
|
|
||||||
+ TrackPointsColumns.SENSOR + " BLOB);");
|
|
||||||
db.execSQL(TracksColumns.CREATE_TABLE);
|
db.execSQL(TracksColumns.CREATE_TABLE);
|
||||||
db.execSQL("CREATE TABLE " + WAYPOINTS_TABLE + " ("
|
db.execSQL("CREATE TABLE " + WAYPOINTS_TABLE + " ("
|
||||||
+ WaypointsColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
|
+ WaypointsColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
|
||||||
@@ -118,7 +107,7 @@ public class MyTracksProvider extends ContentProvider {
|
|||||||
if (oldVersion < 17) {
|
if (oldVersion < 17) {
|
||||||
// Delete the old data
|
// Delete the old data
|
||||||
Log.w(TAG, "Delete all old data");
|
Log.w(TAG, "Delete all old data");
|
||||||
db.execSQL("DROP TABLE IF EXISTS " + TRACKPOINTS_TABLE);
|
db.execSQL("DROP TABLE IF EXISTS " + TrackPointsColumns.TABLE_NAME);
|
||||||
db.execSQL("DROP TABLE IF EXISTS " + TracksColumns.TABLE_NAME);
|
db.execSQL("DROP TABLE IF EXISTS " + TracksColumns.TABLE_NAME);
|
||||||
db.execSQL("DROP TABLE IF EXISTS " + WAYPOINTS_TABLE);
|
db.execSQL("DROP TABLE IF EXISTS " + WAYPOINTS_TABLE);
|
||||||
onCreate(db);
|
onCreate(db);
|
||||||
@@ -128,8 +117,8 @@ public class MyTracksProvider extends ContentProvider {
|
|||||||
// Track points sensor column
|
// Track points sensor column
|
||||||
if (oldVersion <= 17) {
|
if (oldVersion <= 17) {
|
||||||
Log.w(TAG, "Upgrade DB: Adding sensor column.");
|
Log.w(TAG, "Upgrade DB: Adding sensor column.");
|
||||||
db.execSQL(
|
db.execSQL("ALTER TABLE " + TrackPointsColumns.TABLE_NAME + " ADD "
|
||||||
"ALTER TABLE " + TRACKPOINTS_TABLE + " ADD " + TrackPointsColumns.SENSOR + " BLOB");
|
+ TrackPointsColumns.SENSOR + " BLOB");
|
||||||
}
|
}
|
||||||
// Tracks table id column
|
// Tracks table id column
|
||||||
if (oldVersion <= 18) {
|
if (oldVersion <= 18) {
|
||||||
@@ -196,7 +185,7 @@ public class MyTracksProvider extends ContentProvider {
|
|||||||
boolean shouldVacuum = false;
|
boolean shouldVacuum = false;
|
||||||
switch (urlMatcher.match(url)) {
|
switch (urlMatcher.match(url)) {
|
||||||
case TRACKPOINTS:
|
case TRACKPOINTS:
|
||||||
table = TRACKPOINTS_TABLE;
|
table = TrackPointsColumns.TABLE_NAME;
|
||||||
break;
|
break;
|
||||||
case TRACKS:
|
case TRACKS:
|
||||||
table = TracksColumns.TABLE_NAME;
|
table = TracksColumns.TABLE_NAME;
|
||||||
@@ -311,7 +300,7 @@ public class MyTracksProvider extends ContentProvider {
|
|||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"Latitude, longitude, and time values are required.");
|
"Latitude, longitude, and time values are required.");
|
||||||
}
|
}
|
||||||
long rowId = db.insert(TRACKPOINTS_TABLE, TrackPointsColumns._ID, values);
|
long rowId = db.insert(TrackPointsColumns.TABLE_NAME, TrackPointsColumns._ID, values);
|
||||||
if (rowId >= 0) {
|
if (rowId >= 0) {
|
||||||
Uri uri = ContentUris.appendId(
|
Uri uri = ContentUris.appendId(
|
||||||
TrackPointsColumns.CONTENT_URI.buildUpon(), rowId).build();
|
TrackPointsColumns.CONTENT_URI.buildUpon(), rowId).build();
|
||||||
@@ -360,14 +349,14 @@ public class MyTracksProvider extends ContentProvider {
|
|||||||
int match = urlMatcher.match(url);
|
int match = urlMatcher.match(url);
|
||||||
String sortOrder = null;
|
String sortOrder = null;
|
||||||
if (match == TRACKPOINTS) {
|
if (match == TRACKPOINTS) {
|
||||||
qb.setTables(TRACKPOINTS_TABLE);
|
qb.setTables(TrackPointsColumns.TABLE_NAME);
|
||||||
if (sort != null) {
|
if (sort != null) {
|
||||||
sortOrder = sort;
|
sortOrder = sort;
|
||||||
} else {
|
} else {
|
||||||
sortOrder = TrackPointsColumns.DEFAULT_SORT_ORDER;
|
sortOrder = TrackPointsColumns.DEFAULT_SORT_ORDER;
|
||||||
}
|
}
|
||||||
} else if (match == TRACKPOINTS_ID) {
|
} else if (match == TRACKPOINTS_ID) {
|
||||||
qb.setTables(TRACKPOINTS_TABLE);
|
qb.setTables(TrackPointsColumns.TABLE_NAME);
|
||||||
qb.appendWhere("_id=" + url.getPathSegments().get(1));
|
qb.appendWhere("_id=" + url.getPathSegments().get(1));
|
||||||
} else if (match == TRACKS) {
|
} else if (match == TRACKS) {
|
||||||
qb.setTables(TracksColumns.TABLE_NAME);
|
qb.setTables(TracksColumns.TABLE_NAME);
|
||||||
@@ -410,10 +399,10 @@ public class MyTracksProvider extends ContentProvider {
|
|||||||
int count;
|
int count;
|
||||||
int match = urlMatcher.match(url);
|
int match = urlMatcher.match(url);
|
||||||
if (match == TRACKPOINTS) {
|
if (match == TRACKPOINTS) {
|
||||||
count = db.update(TRACKPOINTS_TABLE, values, where, selectionArgs);
|
count = db.update(TrackPointsColumns.TABLE_NAME, values, where, selectionArgs);
|
||||||
} else if (match == TRACKPOINTS_ID) {
|
} else if (match == TRACKPOINTS_ID) {
|
||||||
String segment = url.getPathSegments().get(1);
|
String segment = url.getPathSegments().get(1);
|
||||||
count = db.update(TRACKPOINTS_TABLE, values, "_id=" + segment
|
count = db.update(TrackPointsColumns.TABLE_NAME, values, "_id=" + segment
|
||||||
+ (!TextUtils.isEmpty(where)
|
+ (!TextUtils.isEmpty(where)
|
||||||
? " AND (" + where + ')'
|
? " AND (" + where + ')'
|
||||||
: ""),
|
: ""),
|
||||||
|
|||||||
@@ -15,26 +15,15 @@
|
|||||||
*/
|
*/
|
||||||
package com.google.android.apps.mytracks.io.backup;
|
package com.google.android.apps.mytracks.io.backup;
|
||||||
|
|
||||||
import static com.google.android.apps.mytracks.content.ContentTypeIds.BLOB_TYPE_ID;
|
|
||||||
import static com.google.android.apps.mytracks.content.ContentTypeIds.FLOAT_TYPE_ID;
|
import static com.google.android.apps.mytracks.content.ContentTypeIds.FLOAT_TYPE_ID;
|
||||||
import static com.google.android.apps.mytracks.content.ContentTypeIds.INT_TYPE_ID;
|
import static com.google.android.apps.mytracks.content.ContentTypeIds.INT_TYPE_ID;
|
||||||
import static com.google.android.apps.mytracks.content.ContentTypeIds.LONG_TYPE_ID;
|
import static com.google.android.apps.mytracks.content.ContentTypeIds.LONG_TYPE_ID;
|
||||||
import static com.google.android.apps.mytracks.content.ContentTypeIds.STRING_TYPE_ID;
|
import static com.google.android.apps.mytracks.content.ContentTypeIds.STRING_TYPE_ID;
|
||||||
|
|
||||||
import com.google.android.apps.mytracks.content.TrackPointsColumns;
|
|
||||||
import com.google.android.apps.mytracks.content.WaypointsColumns;
|
import com.google.android.apps.mytracks.content.WaypointsColumns;
|
||||||
|
|
||||||
public class BackupColumns {
|
public class BackupColumns {
|
||||||
/** Columns that go into the backup. */
|
/** Columns that go into the backup. */
|
||||||
public static final String[] POINTS_BACKUP_COLUMNS =
|
|
||||||
{ TrackPointsColumns._ID, TrackPointsColumns.TRACKID, TrackPointsColumns.LATITUDE,
|
|
||||||
TrackPointsColumns.LONGITUDE, TrackPointsColumns.ALTITUDE, TrackPointsColumns.BEARING,
|
|
||||||
TrackPointsColumns.TIME, TrackPointsColumns.ACCURACY, TrackPointsColumns.SPEED,
|
|
||||||
TrackPointsColumns.SENSOR };
|
|
||||||
public static final byte[] POINTS_BACKUP_COLUMN_TYPES =
|
|
||||||
{ LONG_TYPE_ID, LONG_TYPE_ID, INT_TYPE_ID, INT_TYPE_ID, FLOAT_TYPE_ID,
|
|
||||||
FLOAT_TYPE_ID, LONG_TYPE_ID, FLOAT_TYPE_ID, FLOAT_TYPE_ID, BLOB_TYPE_ID };
|
|
||||||
|
|
||||||
public static final String[] WAYPOINTS_BACKUP_COLUMNS = {
|
public static final String[] WAYPOINTS_BACKUP_COLUMNS = {
|
||||||
WaypointsColumns._ID, WaypointsColumns.TRACKID, WaypointsColumns.NAME,
|
WaypointsColumns._ID, WaypointsColumns.TRACKID, WaypointsColumns.NAME,
|
||||||
WaypointsColumns.DESCRIPTION, WaypointsColumns.CATEGORY, WaypointsColumns.ICON,
|
WaypointsColumns.DESCRIPTION, WaypointsColumns.CATEGORY, WaypointsColumns.ICON,
|
||||||
|
|||||||
@@ -160,8 +160,8 @@ class ExternalFileBackup {
|
|||||||
BackupColumns.WAYPOINTS_BACKUP_COLUMN_TYPES,
|
BackupColumns.WAYPOINTS_BACKUP_COLUMN_TYPES,
|
||||||
false);
|
false);
|
||||||
DatabaseDumper pointDumper = new DatabaseDumper(
|
DatabaseDumper pointDumper = new DatabaseDumper(
|
||||||
BackupColumns.POINTS_BACKUP_COLUMNS,
|
TrackPointsColumns.COLUMNS,
|
||||||
BackupColumns.POINTS_BACKUP_COLUMN_TYPES,
|
TrackPointsColumns.COLUMN_TYPES,
|
||||||
false);
|
false);
|
||||||
|
|
||||||
// Open the target for writing
|
// Open the target for writing
|
||||||
|
|||||||
@@ -15,6 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
package com.google.android.apps.mytracks.content;
|
package com.google.android.apps.mytracks.content;
|
||||||
|
|
||||||
|
import com.google.android.apps.mytracks.content.Sensor.SensorDataSet;
|
||||||
|
|
||||||
import android.location.Location;
|
import android.location.Location;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -24,7 +26,7 @@ import android.location.Location;
|
|||||||
*/
|
*/
|
||||||
public class MyTracksLocation extends Location {
|
public class MyTracksLocation extends Location {
|
||||||
|
|
||||||
private Sensor.SensorDataSet sensorDataSet = null;
|
private SensorDataSet sensorDataSet = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The id of this location from the provider.
|
* The id of this location from the provider.
|
||||||
@@ -40,12 +42,12 @@ public class MyTracksLocation extends Location {
|
|||||||
super(provider);
|
super(provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Sensor.SensorDataSet getSensorDataSet() {
|
public SensorDataSet getSensorDataSet() {
|
||||||
return sensorDataSet;
|
return sensorDataSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSensorData(Sensor.SensorDataSet sensorData) {
|
public void setSensorDataSet(SensorDataSet sensorDataSet) {
|
||||||
this.sensorDataSet = sensorData;
|
this.sensorDataSet = sensorDataSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
|
|||||||
+32
-37
@@ -17,6 +17,7 @@ package com.google.android.apps.mytracks.content;
|
|||||||
|
|
||||||
import static com.google.android.apps.mytracks.lib.MyTracksLibConstants.TAG;
|
import static com.google.android.apps.mytracks.lib.MyTracksLibConstants.TAG;
|
||||||
|
|
||||||
|
import com.google.android.apps.mytracks.content.Sensor.SensorDataSet;
|
||||||
import com.google.android.apps.mytracks.stats.TripStatistics;
|
import com.google.android.apps.mytracks.stats.TripStatistics;
|
||||||
import com.google.protobuf.InvalidProtocolBufferException;
|
import com.google.protobuf.InvalidProtocolBufferException;
|
||||||
|
|
||||||
@@ -54,32 +55,29 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
|||||||
* @param trackId the id of the track it belongs to
|
* @param trackId the id of the track it belongs to
|
||||||
* @return a filled in ContentValues object
|
* @return a filled in ContentValues object
|
||||||
*/
|
*/
|
||||||
private static ContentValues createContentValues(
|
private static ContentValues createContentValues(Location location, long trackId) {
|
||||||
Location location, long trackId) {
|
|
||||||
ContentValues values = new ContentValues();
|
ContentValues values = new ContentValues();
|
||||||
values.put(TrackPointsColumns.TRACKID, trackId);
|
values.put(TrackPointsColumns.TRACKID, trackId);
|
||||||
values.put(TrackPointsColumns.LATITUDE,
|
values.put(TrackPointsColumns.LONGITUDE, (int) (location.getLongitude() * 1E6));
|
||||||
(int) (location.getLatitude() * 1E6));
|
values.put(TrackPointsColumns.LATITUDE, (int) (location.getLatitude() * 1E6));
|
||||||
values.put(TrackPointsColumns.LONGITUDE,
|
|
||||||
(int) (location.getLongitude() * 1E6));
|
|
||||||
// This is an ugly hack for Samsung phones that don't properly populate the
|
// This is an ugly hack for Samsung phones that don't properly populate the
|
||||||
// time field.
|
// time field.
|
||||||
values.put(TrackPointsColumns.TIME,
|
values.put(TrackPointsColumns.TIME,
|
||||||
(location.getTime() == 0)
|
(location.getTime() == 0) ? System.currentTimeMillis() : location.getTime());
|
||||||
? System.currentTimeMillis()
|
|
||||||
: location.getTime());
|
|
||||||
if (location.hasAltitude()) {
|
if (location.hasAltitude()) {
|
||||||
values.put(TrackPointsColumns.ALTITUDE, location.getAltitude());
|
values.put(TrackPointsColumns.ALTITUDE, location.getAltitude());
|
||||||
}
|
}
|
||||||
if (location.hasBearing()) {
|
|
||||||
values.put(TrackPointsColumns.BEARING, location.getBearing());
|
|
||||||
}
|
|
||||||
if (location.hasAccuracy()) {
|
if (location.hasAccuracy()) {
|
||||||
values.put(TrackPointsColumns.ACCURACY, location.getAccuracy());
|
values.put(TrackPointsColumns.ACCURACY, location.getAccuracy());
|
||||||
}
|
}
|
||||||
if (location.hasSpeed()) {
|
if (location.hasSpeed()) {
|
||||||
values.put(TrackPointsColumns.SPEED, location.getSpeed());
|
values.put(TrackPointsColumns.SPEED, location.getSpeed());
|
||||||
}
|
}
|
||||||
|
if (location.hasBearing()) {
|
||||||
|
values.put(TrackPointsColumns.BEARING, location.getBearing());
|
||||||
|
}
|
||||||
|
|
||||||
if (location instanceof MyTracksLocation) {
|
if (location instanceof MyTracksLocation) {
|
||||||
MyTracksLocation mtLocation = (MyTracksLocation) location;
|
MyTracksLocation mtLocation = (MyTracksLocation) location;
|
||||||
if (mtLocation.getSensorDataSet() != null) {
|
if (mtLocation.getSensorDataSet() != null) {
|
||||||
@@ -197,61 +195,58 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
|||||||
*/
|
*/
|
||||||
private static class CachedTrackColumnIndices {
|
private static class CachedTrackColumnIndices {
|
||||||
public final int idxId;
|
public final int idxId;
|
||||||
public final int idxLatitude;
|
|
||||||
public final int idxLongitude;
|
public final int idxLongitude;
|
||||||
public final int idxAltitude;
|
public final int idxLatitude;
|
||||||
public final int idxTime;
|
public final int idxTime;
|
||||||
public final int idxBearing;
|
public final int idxAltitude;
|
||||||
public final int idxAccuracy;
|
public final int idxAccuracy;
|
||||||
public final int idxSpeed;
|
public final int idxSpeed;
|
||||||
|
public final int idxBearing;
|
||||||
public final int idxSensor;
|
public final int idxSensor;
|
||||||
|
|
||||||
public CachedTrackColumnIndices(Cursor cursor) {
|
public CachedTrackColumnIndices(Cursor cursor) {
|
||||||
idxId = cursor.getColumnIndex(TrackPointsColumns._ID);
|
idxId = cursor.getColumnIndex(TrackPointsColumns._ID);
|
||||||
idxLatitude = cursor.getColumnIndexOrThrow(TrackPointsColumns.LATITUDE);
|
|
||||||
idxLongitude = cursor.getColumnIndexOrThrow(TrackPointsColumns.LONGITUDE);
|
idxLongitude = cursor.getColumnIndexOrThrow(TrackPointsColumns.LONGITUDE);
|
||||||
idxAltitude = cursor.getColumnIndexOrThrow(TrackPointsColumns.ALTITUDE);
|
idxLatitude = cursor.getColumnIndexOrThrow(TrackPointsColumns.LATITUDE);
|
||||||
idxTime = cursor.getColumnIndexOrThrow(TrackPointsColumns.TIME);
|
idxTime = cursor.getColumnIndexOrThrow(TrackPointsColumns.TIME);
|
||||||
idxBearing = cursor.getColumnIndexOrThrow(TrackPointsColumns.BEARING);
|
idxAltitude = cursor.getColumnIndexOrThrow(TrackPointsColumns.ALTITUDE);
|
||||||
idxAccuracy = cursor.getColumnIndexOrThrow(TrackPointsColumns.ACCURACY);
|
idxAccuracy = cursor.getColumnIndexOrThrow(TrackPointsColumns.ACCURACY);
|
||||||
idxSpeed = cursor.getColumnIndexOrThrow(TrackPointsColumns.SPEED);
|
idxSpeed = cursor.getColumnIndexOrThrow(TrackPointsColumns.SPEED);
|
||||||
|
idxBearing = cursor.getColumnIndexOrThrow(TrackPointsColumns.BEARING);
|
||||||
idxSensor = cursor.getColumnIndexOrThrow(TrackPointsColumns.SENSOR);
|
idxSensor = cursor.getColumnIndexOrThrow(TrackPointsColumns.SENSOR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fillLocation(Cursor cursor, CachedTrackColumnIndices columnIndices,
|
private void fillLocation(
|
||||||
Location location) {
|
Cursor cursor, CachedTrackColumnIndices columnIndices, Location location) {
|
||||||
location.reset();
|
location.reset();
|
||||||
|
|
||||||
if (!cursor.isNull(columnIndices.idxLatitude)) {
|
|
||||||
location.setLatitude(1. * cursor.getInt(columnIndices.idxLatitude) / 1E6);
|
|
||||||
}
|
|
||||||
if (!cursor.isNull(columnIndices.idxLongitude)) {
|
if (!cursor.isNull(columnIndices.idxLongitude)) {
|
||||||
location.setLongitude(1. * cursor.getInt(columnIndices.idxLongitude) / 1E6);
|
location.setLongitude(1. * cursor.getInt(columnIndices.idxLongitude) / 1E6);
|
||||||
}
|
}
|
||||||
if (!cursor.isNull(columnIndices.idxAltitude)) {
|
if (!cursor.isNull(columnIndices.idxLatitude)) {
|
||||||
location.setAltitude(cursor.getFloat(columnIndices.idxAltitude));
|
location.setLatitude(1. * cursor.getInt(columnIndices.idxLatitude) / 1E6);
|
||||||
}
|
}
|
||||||
if (!cursor.isNull(columnIndices.idxTime)) {
|
if (!cursor.isNull(columnIndices.idxTime)) {
|
||||||
location.setTime(cursor.getLong(columnIndices.idxTime));
|
location.setTime(cursor.getLong(columnIndices.idxTime));
|
||||||
}
|
}
|
||||||
if (!cursor.isNull(columnIndices.idxBearing)) {
|
if (!cursor.isNull(columnIndices.idxAltitude)) {
|
||||||
location.setBearing(cursor.getFloat(columnIndices.idxBearing));
|
location.setAltitude(cursor.getFloat(columnIndices.idxAltitude));
|
||||||
}
|
|
||||||
if (!cursor.isNull(columnIndices.idxSpeed)) {
|
|
||||||
location.setSpeed(cursor.getFloat(columnIndices.idxSpeed));
|
|
||||||
}
|
}
|
||||||
if (!cursor.isNull(columnIndices.idxAccuracy)) {
|
if (!cursor.isNull(columnIndices.idxAccuracy)) {
|
||||||
location.setAccuracy(cursor.getFloat(columnIndices.idxAccuracy));
|
location.setAccuracy(cursor.getFloat(columnIndices.idxAccuracy));
|
||||||
}
|
}
|
||||||
if (location instanceof MyTracksLocation &&
|
if (!cursor.isNull(columnIndices.idxSpeed)) {
|
||||||
!cursor.isNull(columnIndices.idxSensor)) {
|
location.setSpeed(cursor.getFloat(columnIndices.idxSpeed));
|
||||||
MyTracksLocation mtLocation = (MyTracksLocation) location;
|
}
|
||||||
// TODO get the right buffer.
|
if (!cursor.isNull(columnIndices.idxBearing)) {
|
||||||
Sensor.SensorDataSet sensorData;
|
location.setBearing(cursor.getFloat(columnIndices.idxBearing));
|
||||||
|
}
|
||||||
|
if (location instanceof MyTracksLocation && !cursor.isNull(columnIndices.idxSensor)) {
|
||||||
|
MyTracksLocation myTracksLocation = (MyTracksLocation) location;
|
||||||
try {
|
try {
|
||||||
sensorData = Sensor.SensorDataSet.parseFrom(cursor.getBlob(columnIndices.idxSensor));
|
myTracksLocation.setSensorDataSet(
|
||||||
mtLocation.setSensorData(sensorData);
|
SensorDataSet.parseFrom(cursor.getBlob(columnIndices.idxSensor)));
|
||||||
} catch (InvalidProtocolBufferException e) {
|
} catch (InvalidProtocolBufferException e) {
|
||||||
Log.w(TAG, "Failed to parse sensor data.", e);
|
Log.w(TAG, "Failed to parse sensor data.", e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,34 +13,77 @@
|
|||||||
* License for the specific language governing permissions and limitations under
|
* License for the specific language governing permissions and limitations under
|
||||||
* the License.
|
* the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.google.android.apps.mytracks.content;
|
package com.google.android.apps.mytracks.content;
|
||||||
|
|
||||||
|
import static com.google.android.apps.mytracks.content.ContentTypeIds.BLOB_TYPE_ID;
|
||||||
|
import static com.google.android.apps.mytracks.content.ContentTypeIds.FLOAT_TYPE_ID;
|
||||||
|
import static com.google.android.apps.mytracks.content.ContentTypeIds.INT_TYPE_ID;
|
||||||
|
import static com.google.android.apps.mytracks.content.ContentTypeIds.LONG_TYPE_ID;
|
||||||
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.provider.BaseColumns;
|
import android.provider.BaseColumns;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines the URI for the track points provider and the available column names
|
* Constants for the track points table.
|
||||||
* and content types.
|
|
||||||
*
|
*
|
||||||
* @author Leif Hendrik Wilden
|
* @author Leif Hendrik Wilden
|
||||||
*/
|
*/
|
||||||
public interface TrackPointsColumns extends BaseColumns {
|
public interface TrackPointsColumns extends BaseColumns {
|
||||||
public static final Uri CONTENT_URI =
|
|
||||||
Uri.parse("content://com.google.android.maps.mytracks/trackpoints");
|
public static final String TABLE_NAME = "trackpoints";
|
||||||
public static final String CONTENT_TYPE =
|
public static final Uri CONTENT_URI = Uri.parse(
|
||||||
"vnd.android.cursor.dir/vnd.google.trackpoint";
|
"content://com.google.android.maps.mytracks/trackpoints");
|
||||||
public static final String CONTENT_ITEMTYPE =
|
public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.google.trackpoint";
|
||||||
"vnd.android.cursor.item/vnd.google.trackpoint";
|
public static final String CONTENT_ITEMTYPE = "vnd.android.cursor.item/vnd.google.trackpoint";
|
||||||
public static final String DEFAULT_SORT_ORDER = "_id";
|
public static final String DEFAULT_SORT_ORDER = "_id";
|
||||||
|
|
||||||
/* All columns */
|
// Columns
|
||||||
public static final String TRACKID = "trackid";
|
public static final String TRACKID = "trackid"; // track id
|
||||||
public static final String LATITUDE = "latitude";
|
public static final String LONGITUDE = "longitude"; // longitude
|
||||||
public static final String LONGITUDE = "longitude";
|
public static final String LATITUDE = "latitude"; // latitude
|
||||||
public static final String ALTITUDE = "elevation";
|
public static final String TIME = "time"; // time
|
||||||
public static final String BEARING = "bearing";
|
public static final String ALTITUDE = "elevation"; // altitude
|
||||||
public static final String TIME = "time";
|
public static final String ACCURACY = "accuracy"; // accuracy
|
||||||
public static final String ACCURACY = "accuracy";
|
public static final String SPEED = "speed"; // speed
|
||||||
public static final String SPEED = "speed";
|
public static final String BEARING = "bearing"; // bearing
|
||||||
public static final String SENSOR = "sensor";
|
public static final String SENSOR = "sensor"; // sensor
|
||||||
|
|
||||||
|
public static final String CREATE_TABLE = "CREATE TABLE " + TABLE_NAME + " ("
|
||||||
|
+ _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
|
||||||
|
+ TRACKID + " INTEGER, "
|
||||||
|
+ LONGITUDE + " INTEGER, "
|
||||||
|
+ LATITUDE + " INTEGER, "
|
||||||
|
+ TIME + " INTEGER, "
|
||||||
|
+ ALTITUDE + " FLOAT, "
|
||||||
|
+ ACCURACY + " FLOAT, "
|
||||||
|
+ SPEED + " FLOAT, "
|
||||||
|
+ BEARING + " FLOAT, "
|
||||||
|
+ SENSOR + " BLOB);";
|
||||||
|
|
||||||
|
public static final String[] COLUMNS = {
|
||||||
|
_ID,
|
||||||
|
TRACKID,
|
||||||
|
LONGITUDE,
|
||||||
|
LATITUDE,
|
||||||
|
TIME,
|
||||||
|
ALTITUDE,
|
||||||
|
ACCURACY,
|
||||||
|
SPEED,
|
||||||
|
BEARING,
|
||||||
|
SENSOR
|
||||||
|
};
|
||||||
|
|
||||||
|
public static final byte[] COLUMN_TYPES = {
|
||||||
|
LONG_TYPE_ID, // id
|
||||||
|
LONG_TYPE_ID, // track id
|
||||||
|
INT_TYPE_ID, // longitude
|
||||||
|
INT_TYPE_ID, // latitude
|
||||||
|
LONG_TYPE_ID, // time
|
||||||
|
FLOAT_TYPE_ID, // altitude
|
||||||
|
FLOAT_TYPE_ID, // accuracy
|
||||||
|
FLOAT_TYPE_ID, // speed
|
||||||
|
FLOAT_TYPE_ID, // bearing
|
||||||
|
BLOB_TYPE_ID // sensor
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user