- use a dialog to insert markers with an option to open full insert screen

- remember the last chosen marker type
- auto increment the default marker name
- fix IME option when toggling between marker type
- add more spacing between items in the editor
- rename WaypointType to WAYPOINT and STATISTICS
- rename to ListItemUtils
- remove unused appwidget_text color
This commit is contained in:
Jimmy Shih
2012-04-27 09:48:01 -07:00
parent 2ec090354b
commit 1a23ba673c
26 changed files with 478 additions and 207 deletions
@@ -129,6 +129,15 @@ public interface MyTracksProviderUtils {
*/
long getLastWaypointId(long trackId);
/**
* Gets the next marker number.
*
* @param trackId the track id
* @param statistics true for statistics marker, false for waypoint marker
* @return the next number or -1 if unable to get the value
*/
int getNextMarkerNumber(long trackId, boolean statistics);
/**
* Finds the last recorded track from the track provider.
*
@@ -794,6 +794,37 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
return -1;
}
@Override
public int getNextMarkerNumber(long trackId, boolean statistics) {
if (trackId == -1L) {
return -1;
}
String[] projection = { "_id" };
String selection = WaypointsColumns.TRACKID + "=? AND " + WaypointsColumns.TYPE + "=?";
String[] selectionArgs = new String[] { String.valueOf(trackId),
String.valueOf(statistics ? Waypoint.TYPE_STATISTICS : Waypoint.TYPE_WAYPOINT) };
Cursor cursor = null;
try {
cursor = contentResolver.query(
WaypointsColumns.CONTENT_URI, projection, selection, selectionArgs, null);
if (cursor != null) {
int count = cursor.getCount();
/*
* For statistics markers, the first marker is for the track statistics,
* thus just return the count as the next user visible number.
*/
return statistics ? count : count + 1;
}
} catch (RuntimeException e) {
Log.w(TAG, "Caught unexpected exception.", e);
} finally {
if (cursor != null) {
cursor.close();
}
}
return -1;
}
@Override
public Track getLastTrack() {
Cursor cursor = null;
@@ -26,7 +26,7 @@ import android.os.Parcelable;
public class WaypointCreationRequest implements Parcelable {
public static enum WaypointType {
MARKER,
WAYPOINT,
STATISTICS;
}
@@ -36,8 +36,8 @@ public class WaypointCreationRequest implements Parcelable {
private String description;
private String iconUrl;
public final static WaypointCreationRequest DEFAULT_MARKER =
new WaypointCreationRequest(WaypointType.MARKER);
public final static WaypointCreationRequest DEFAULT_WAYPOINT =
new WaypointCreationRequest(WaypointType.WAYPOINT);
public final static WaypointCreationRequest DEFAULT_STATISTICS =
new WaypointCreationRequest(WaypointType.STATISTICS);