forked from upstream-mirrors/OpenTracks
Extracted content uri definition.
This commit is contained in:
@@ -183,7 +183,7 @@ public class TrackDataHubTest {
|
|||||||
// .thenReturn(waypoint2)
|
// .thenReturn(waypoint2)
|
||||||
// .thenReturn(waypoint1)
|
// .thenReturn(waypoint1)
|
||||||
// .thenReturn(waypoint2);
|
// .thenReturn(waypoint2);
|
||||||
// dataSource.registerContentObserver(eq(WaypointsColumns.CONTENT_URI), contentObserverCapture.capture());
|
// dataSource.registerContentObserver(eq(WaypointsColumns.CONTENT_BASE_URI), contentObserverCapture.capture());
|
||||||
// trackDataListener1.clearWaypoints();
|
// trackDataListener1.clearWaypoints();
|
||||||
// trackDataListener2.clearWaypoints();
|
// trackDataListener2.clearWaypoints();
|
||||||
// trackDataListener1.onNewWaypoint(waypoint1);
|
// trackDataListener1.onNewWaypoint(waypoint1);
|
||||||
@@ -417,7 +417,7 @@ public class TrackDataHubTest {
|
|||||||
// @Test
|
// @Test
|
||||||
// public void testTrackPointsTableUpdate_largeTrackSampling() {
|
// public void testTrackPointsTableUpdate_largeTrackSampling() {
|
||||||
// ArgumentCaptor<ContentObserver> contentObserverCapture = ArgumentCaptor.forClass(ContentObserver.class);
|
// ArgumentCaptor<ContentObserver> contentObserverCapture = ArgumentCaptor.forClass(ContentObserver.class);
|
||||||
// dataSource.registerContentObserver(eq(TrackPointsColumns.CONTENT_URI), contentObserverCapture.capture());
|
// dataSource.registerContentObserver(eq(TrackPointsColumns.CONTENT_BASE_URI), contentObserverCapture.capture());
|
||||||
//
|
//
|
||||||
// when(contentProviderUtils.getLastTrackPointId(TRACK_ID)).thenReturn(200L);
|
// when(contentProviderUtils.getLastTrackPointId(TRACK_ID)).thenReturn(200L);
|
||||||
// AndroidMock.expectLastCall().anyTimes();
|
// AndroidMock.expectLastCall().anyTimes();
|
||||||
@@ -565,7 +565,7 @@ public class TrackDataHubTest {
|
|||||||
// @Test
|
// @Test
|
||||||
// public void testRegisterTracksTableListener() {
|
// public void testRegisterTracksTableListener() {
|
||||||
// ArgumentCaptor<ContentObserver> observerCapture = ArgumentCaptor.forClass(ContentObserver.class);
|
// ArgumentCaptor<ContentObserver> observerCapture = ArgumentCaptor.forClass(ContentObserver.class);
|
||||||
// dataSource.registerContentObserver(eq(TracksColumns.CONTENT_URI), observerCapture.capture());
|
// dataSource.registerContentObserver(eq(TracksColumns.CONTENT_BASE_URI), observerCapture.capture());
|
||||||
// Track track = TrackStubUtils.createTrack(1);
|
// Track track = TrackStubUtils.createTrack(1);
|
||||||
//
|
//
|
||||||
// when(contentProviderUtils.getTrack(capture(new Capture<Long>())).thenReturn(track);
|
// when(contentProviderUtils.getTrack(capture(new Capture<Long>())).thenReturn(track);
|
||||||
@@ -585,7 +585,7 @@ public class TrackDataHubTest {
|
|||||||
// @Test
|
// @Test
|
||||||
// public void testRegisterWaypointsTableListener() {
|
// public void testRegisterWaypointsTableListener() {
|
||||||
// ArgumentCaptor<ContentObserver> observerCapture = ArgumentCaptor.forClass(ContentObserver.class);
|
// ArgumentCaptor<ContentObserver> observerCapture = ArgumentCaptor.forClass(ContentObserver.class);
|
||||||
// dataSource.registerContentObserver(eq(WaypointsColumns.CONTENT_URI), observerCapture.capture());
|
// dataSource.registerContentObserver(eq(WaypointsColumns.CONTENT_BASE_URI), observerCapture.capture());
|
||||||
// when(contentProviderUtils.getWaypointCursor(
|
// when(contentProviderUtils.getWaypointCursor(
|
||||||
// capture(new Capture<Long>()), capture(new Capture<Long>()),
|
// capture(new Capture<Long>()), capture(new Capture<Long>()),
|
||||||
// capture(new Capture<Integer>()))).thenReturn(null);
|
// capture(new Capture<Integer>()))).thenReturn(null);
|
||||||
|
|||||||
@@ -36,10 +36,15 @@ import de.dennisguse.opentracks.content.Waypoint.WaypointType;
|
|||||||
public interface ContentProviderUtils {
|
public interface ContentProviderUtils {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The authority (the first part of the URI) for the app's content
|
* The authority (the first part of the URI) for the app's content provider.
|
||||||
* provider.
|
|
||||||
*/
|
*/
|
||||||
String AUTHORITY = BuildConfig.APPLICATION_ID + ".content";
|
String AUTHORITY_PACKAGE = BuildConfig.APPLICATION_ID + ".content";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The base URI for the app's content provider.
|
||||||
|
*/
|
||||||
|
String CONTENT_BASE_URI = "content://" + AUTHORITY_PACKAGE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default {@link LocationFactory} which creates a location each time.
|
* The default {@link LocationFactory} which creates a location each time.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -52,12 +52,12 @@ public abstract class CustomContentProvider extends ContentProvider {
|
|||||||
|
|
||||||
public CustomContentProvider() {
|
public CustomContentProvider() {
|
||||||
uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
|
uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
|
||||||
uriMatcher.addURI(ContentProviderUtils.AUTHORITY, TrackPointsColumns.TABLE_NAME, UrlType.TRACKPOINTS.ordinal());
|
uriMatcher.addURI(ContentProviderUtils.AUTHORITY_PACKAGE, TrackPointsColumns.TABLE_NAME, UrlType.TRACKPOINTS.ordinal());
|
||||||
uriMatcher.addURI(ContentProviderUtils.AUTHORITY, TrackPointsColumns.TABLE_NAME + "/#", UrlType.TRACKPOINTS_ID.ordinal());
|
uriMatcher.addURI(ContentProviderUtils.AUTHORITY_PACKAGE, TrackPointsColumns.TABLE_NAME + "/#", UrlType.TRACKPOINTS_ID.ordinal());
|
||||||
uriMatcher.addURI(ContentProviderUtils.AUTHORITY, TracksColumns.TABLE_NAME, UrlType.TRACKS.ordinal());
|
uriMatcher.addURI(ContentProviderUtils.AUTHORITY_PACKAGE, TracksColumns.TABLE_NAME, UrlType.TRACKS.ordinal());
|
||||||
uriMatcher.addURI(ContentProviderUtils.AUTHORITY, TracksColumns.TABLE_NAME + "/#", UrlType.TRACKS_ID.ordinal());
|
uriMatcher.addURI(ContentProviderUtils.AUTHORITY_PACKAGE, TracksColumns.TABLE_NAME + "/#", UrlType.TRACKS_ID.ordinal());
|
||||||
uriMatcher.addURI(ContentProviderUtils.AUTHORITY, WaypointsColumns.TABLE_NAME, UrlType.WAYPOINTS.ordinal());
|
uriMatcher.addURI(ContentProviderUtils.AUTHORITY_PACKAGE, WaypointsColumns.TABLE_NAME, UrlType.WAYPOINTS.ordinal());
|
||||||
uriMatcher.addURI(ContentProviderUtils.AUTHORITY, WaypointsColumns.TABLE_NAME + "/#", UrlType.WAYPOINTS_ID.ordinal());
|
uriMatcher.addURI(ContentProviderUtils.AUTHORITY_PACKAGE, WaypointsColumns.TABLE_NAME + "/#", UrlType.WAYPOINTS_ID.ordinal());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -20,10 +20,6 @@ import android.location.Location;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import de.dennisguse.opentracks.stats.TripStatistics;
|
|
||||||
import de.dennisguse.opentracks.util.LocationUtils;
|
|
||||||
import de.dennisguse.opentracks.util.UnitConversions;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
@@ -31,6 +27,10 @@ import java.util.Locale;
|
|||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
|
||||||
|
import de.dennisguse.opentracks.stats.TripStatistics;
|
||||||
|
import de.dennisguse.opentracks.util.LocationUtils;
|
||||||
|
import de.dennisguse.opentracks.util.UnitConversions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Engine for searching for tracks and waypoints by text.
|
* Engine for searching for tracks and waypoints by text.
|
||||||
*
|
*
|
||||||
@@ -381,6 +381,7 @@ public class SearchEngine {
|
|||||||
public final Location currentLocation;
|
public final Location currentLocation;
|
||||||
public final long currentTrackId;
|
public final long currentTrackId;
|
||||||
public final long currentTimestamp;
|
public final long currentTimestamp;
|
||||||
|
|
||||||
public SearchQuery(String textQuery, Location currentLocation, long currentTrackId,
|
public SearchQuery(String textQuery, Location currentLocation, long currentTrackId,
|
||||||
long currentTimestamp) {
|
long currentTimestamp) {
|
||||||
this.textQuery = textQuery.toLowerCase(Locale.getDefault());
|
this.textQuery = textQuery.toLowerCase(Locale.getDefault());
|
||||||
@@ -397,11 +398,13 @@ public class SearchEngine {
|
|||||||
public final Track track;
|
public final Track track;
|
||||||
public final Waypoint waypoint;
|
public final Waypoint waypoint;
|
||||||
public final double score;
|
public final double score;
|
||||||
|
|
||||||
ScoredResult(Track track, double score) {
|
ScoredResult(Track track, double score) {
|
||||||
this.track = track;
|
this.track = track;
|
||||||
this.waypoint = null;
|
this.waypoint = null;
|
||||||
this.score = score;
|
this.score = score;
|
||||||
}
|
}
|
||||||
|
|
||||||
ScoredResult(Waypoint waypoint, double score) {
|
ScoredResult(Waypoint waypoint, double score) {
|
||||||
this.track = null;
|
this.track = null;
|
||||||
this.waypoint = waypoint;
|
this.waypoint = waypoint;
|
||||||
|
|||||||
@@ -59,12 +59,12 @@ public class ShareContentProvider extends CustomContentProvider implements ICont
|
|||||||
}
|
}
|
||||||
builder.deleteCharAt(builder.lastIndexOf(","));
|
builder.deleteCharAt(builder.lastIndexOf(","));
|
||||||
|
|
||||||
return Uri.parse("content://" + ContentProviderUtils.AUTHORITY + "/" + TracksColumns.TABLE_NAME + "/kml/" + builder + ".kml");
|
return Uri.parse(ContentProviderUtils.CONTENT_BASE_URI + "/" + TracksColumns.TABLE_NAME + "/kml/" + builder + ".kml");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreate() {
|
public boolean onCreate() {
|
||||||
uriMatcher.addURI(ContentProviderUtils.AUTHORITY, TracksColumns.TABLE_NAME + "/kml/*", URI_KML);
|
uriMatcher.addURI(ContentProviderUtils.AUTHORITY_PACKAGE, TracksColumns.TABLE_NAME + "/kml/*", URI_KML);
|
||||||
return super.onCreate();
|
return super.onCreate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import android.provider.BaseColumns;
|
|||||||
public interface TrackPointsColumns extends BaseColumns {
|
public interface TrackPointsColumns extends BaseColumns {
|
||||||
|
|
||||||
String TABLE_NAME = "trackpoints";
|
String TABLE_NAME = "trackpoints";
|
||||||
Uri CONTENT_URI = Uri.parse("content://" + ContentProviderUtils.AUTHORITY + "/trackpoints");
|
Uri CONTENT_URI = Uri.parse(ContentProviderUtils.CONTENT_BASE_URI + "/trackpoints");
|
||||||
String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.de.dennisguse.trackpoint";
|
String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.de.dennisguse.trackpoint";
|
||||||
String CONTENT_ITEMTYPE = "vnd.android.cursor.item/vnd.de.dennisguse.trackpoint";
|
String CONTENT_ITEMTYPE = "vnd.android.cursor.item/vnd.de.dennisguse.trackpoint";
|
||||||
String DEFAULT_SORT_ORDER = "_id";
|
String DEFAULT_SORT_ORDER = "_id";
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public interface TracksColumns extends BaseColumns {
|
|||||||
/**
|
/**
|
||||||
* Tracks provider uri.
|
* Tracks provider uri.
|
||||||
*/
|
*/
|
||||||
Uri CONTENT_URI = Uri.parse("content://" + ContentProviderUtils.AUTHORITY + "/tracks");
|
Uri CONTENT_URI = Uri.parse(ContentProviderUtils.CONTENT_BASE_URI + "/tracks");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Track content type.
|
* Track content type.
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import android.provider.BaseColumns;
|
|||||||
public interface WaypointsColumns extends BaseColumns {
|
public interface WaypointsColumns extends BaseColumns {
|
||||||
|
|
||||||
String TABLE_NAME = "waypoints";
|
String TABLE_NAME = "waypoints";
|
||||||
Uri CONTENT_URI = Uri.parse("content://" + ContentProviderUtils.AUTHORITY + "/waypoints");
|
Uri CONTENT_URI = Uri.parse(ContentProviderUtils.CONTENT_BASE_URI + "/waypoints");
|
||||||
String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.de.dennisguse.waypoint";
|
String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.de.dennisguse.waypoint";
|
||||||
String CONTENT_ITEMTYPE = "vnd.android.cursor.item/vnd.de.dennisguse.waypoint";
|
String CONTENT_ITEMTYPE = "vnd.android.cursor.item/vnd.de.dennisguse.waypoint";
|
||||||
String DEFAULT_SORT_ORDER = "_id";
|
String DEFAULT_SORT_ORDER = "_id";
|
||||||
|
|||||||
Reference in New Issue
Block a user