forked from upstream-mirrors/OpenTracks
Merge heads
This commit is contained in:
@@ -23,6 +23,7 @@ limitations under the License.
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:scaleType="centerCrop" />
|
android:scaleType="centerCrop" />
|
||||||
|
<!-- Table 1 -->
|
||||||
<TableLayout
|
<TableLayout
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -33,9 +34,9 @@ limitations under the License.
|
|||||||
android:shrinkColumns="1"
|
android:shrinkColumns="1"
|
||||||
android:stretchColumns="1"
|
android:stretchColumns="1"
|
||||||
style="@style/ListItem" >
|
style="@style/ListItem" >
|
||||||
<!-- First row -->
|
<!-- Table 1: Row 1 -->
|
||||||
<TableRow>
|
<TableRow>
|
||||||
<!-- First column -->
|
<!-- Table 1: Row 1: Column 1: (icon) -->
|
||||||
<ImageView
|
<ImageView
|
||||||
android:contentDescription="@string/icon_track"
|
android:contentDescription="@string/icon_track"
|
||||||
android:id="@+id/list_item_icon"
|
android:id="@+id/list_item_icon"
|
||||||
@@ -44,44 +45,57 @@ limitations under the License.
|
|||||||
android:layout_marginLeft="8dp"
|
android:layout_marginLeft="8dp"
|
||||||
android:layout_marginRight="8dp"
|
android:layout_marginRight="8dp"
|
||||||
android:layout_width="wrap_content" />
|
android:layout_width="wrap_content" />
|
||||||
<!-- Second column -->
|
<!-- Table 1: Row 1: Column 2: (Table 2) -->
|
||||||
<TableLayout
|
<TableLayout
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:shrinkColumns="0"
|
android:shrinkColumns="0"
|
||||||
android:stretchColumns="0" >
|
android:stretchColumns="0" >
|
||||||
<TableRow>
|
<TableRow>
|
||||||
|
<!-- Table 2: Row 1: Column 1: (name) -->
|
||||||
<TextView
|
<TextView
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:id="@+id/list_item_name"
|
android:id="@+id/list_item_name"
|
||||||
android:layout_gravity="bottom"
|
android:layout_gravity="bottom"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="match_parent"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
style="@style/TextMedium" />
|
style="@style/TextMedium" />
|
||||||
|
<!-- Table 2: Row 1: Column 2: (date) -->
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/list_item_date"
|
android:id="@+id/list_item_date"
|
||||||
style="@style/ListItemDate" />
|
style="@style/ListItemDate" />
|
||||||
</TableRow>
|
</TableRow>
|
||||||
<TableRow>
|
<TableRow>
|
||||||
<!-- Need to match the style set in ListItemUtils.setListItem -->
|
<!-- Need to match the style set in ListItemUtils.setListItem -->
|
||||||
<TextView
|
<!-- Table 2: Row 2: Column 1: (shared owner, total time, total distance, and marker count) -->
|
||||||
android:ellipsize="end"
|
<LinearLayout
|
||||||
android:id="@+id/list_item_time_distance"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="bottom"
|
android:layout_width="match_parent" >
|
||||||
android:layout_width="fill_parent"
|
<TextView
|
||||||
android:singleLine="true"
|
android:ellipsize="end"
|
||||||
style="@style/TextSmall" />
|
android:id="@+id/list_item_owner_time_distance"
|
||||||
|
android:layout_gravity="bottom"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:singleLine="true"
|
||||||
|
style="@style/TextSmall" />
|
||||||
|
<TextView
|
||||||
|
android:drawablePadding="4dp"
|
||||||
|
android:id="@+id/list_item_marker_count"
|
||||||
|
android:layout_gravity="bottom"
|
||||||
|
style="@style/TextSmall" />
|
||||||
|
</LinearLayout>
|
||||||
|
<!-- Table 2: Row 2: Column 2: (time) -->
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/list_item_time"
|
android:id="@+id/list_item_time"
|
||||||
style="@style/ListItemDate" />
|
style="@style/ListItemDate" />
|
||||||
</TableRow>
|
</TableRow>
|
||||||
</TableLayout>
|
</TableLayout>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
<!-- Second row -->
|
|
||||||
<TableRow>
|
<TableRow>
|
||||||
|
<!-- Table 1: Row 2: (category and description) -->
|
||||||
<TextView
|
<TextView
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:id="@+id/list_item_description"
|
android:id="@+id/list_item_category_description"
|
||||||
android:layout_column="1"
|
android:layout_column="1"
|
||||||
android:maxLines="2"
|
android:maxLines="2"
|
||||||
android:singleLine="false"
|
android:singleLine="false"
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ limitations under the License.
|
|||||||
android:id="@+id/track_edit_activity_type"
|
android:id="@+id/track_edit_activity_type"
|
||||||
android:imeOptions="actionNext"
|
android:imeOptions="actionNext"
|
||||||
android:layout_gravity="bottom"
|
android:layout_gravity="bottom"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
style="@style/EditCategory" />
|
style="@style/EditCategory" />
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ limitations under the License.
|
|||||||
-->
|
-->
|
||||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="match_parent"
|
||||||
android:paddingBottom="4dp"
|
android:paddingBottom="4dp"
|
||||||
android:paddingLeft="24dp"
|
android:paddingLeft="24dp"
|
||||||
android:paddingTop="32dp"
|
android:paddingTop="32dp"
|
||||||
|
|||||||
@@ -173,10 +173,10 @@ public class MarkerListActivity extends AbstractMyTracksActivity implements Dele
|
|||||||
public void bindView(View view, Context context, Cursor cursor) {
|
public void bindView(View view, Context context, Cursor cursor) {
|
||||||
int typeIndex = cursor.getColumnIndex(WaypointsColumns.TYPE);
|
int typeIndex = cursor.getColumnIndex(WaypointsColumns.TYPE);
|
||||||
int nameIndex = cursor.getColumnIndex(WaypointsColumns.NAME);
|
int nameIndex = cursor.getColumnIndex(WaypointsColumns.NAME);
|
||||||
int photoUrlIndex = cursor.getColumnIndex(WaypointsColumns.PHOTOURL);
|
|
||||||
int timeIndex = cursor.getColumnIndexOrThrow(WaypointsColumns.TIME);
|
int timeIndex = cursor.getColumnIndexOrThrow(WaypointsColumns.TIME);
|
||||||
int categoryIndex = cursor.getColumnIndex(WaypointsColumns.CATEGORY);
|
int categoryIndex = cursor.getColumnIndex(WaypointsColumns.CATEGORY);
|
||||||
int descriptionIndex = cursor.getColumnIndex(WaypointsColumns.DESCRIPTION);
|
int descriptionIndex = cursor.getColumnIndex(WaypointsColumns.DESCRIPTION);
|
||||||
|
int photoUrlIndex = cursor.getColumnIndex(WaypointsColumns.PHOTOURL);
|
||||||
|
|
||||||
boolean statistics = WaypointType.values()[cursor.getInt(typeIndex)]
|
boolean statistics = WaypointType.values()[cursor.getInt(typeIndex)]
|
||||||
== WaypointType.STATISTICS;
|
== WaypointType.STATISTICS;
|
||||||
@@ -184,14 +184,14 @@ public class MarkerListActivity extends AbstractMyTracksActivity implements Dele
|
|||||||
: R.drawable.ic_marker_blue_pushpin;
|
: R.drawable.ic_marker_blue_pushpin;
|
||||||
String name = cursor.getString(nameIndex);
|
String name = cursor.getString(nameIndex);
|
||||||
String sharedOwner = track.getSharedOwner();
|
String sharedOwner = track.getSharedOwner();
|
||||||
String photoUrl = cursor.getString(photoUrlIndex);
|
|
||||||
long time = cursor.getLong(timeIndex);
|
long time = cursor.getLong(timeIndex);
|
||||||
String category = statistics ? null : cursor.getString(categoryIndex);
|
String category = statistics ? null : cursor.getString(categoryIndex);
|
||||||
String description = statistics ? null : cursor.getString(descriptionIndex);
|
String description = statistics ? null : cursor.getString(descriptionIndex);
|
||||||
|
String photoUrl = cursor.getString(photoUrlIndex);
|
||||||
|
|
||||||
ListItemUtils.setListItem(MarkerListActivity.this, view, false, true, iconId,
|
ListItemUtils.setListItem(MarkerListActivity.this, view, false, true, iconId,
|
||||||
R.string.icon_marker, name, sharedOwner, null, null, photoUrl, time, category,
|
R.string.icon_marker, name, sharedOwner, null, null, 0, time, category, description,
|
||||||
description);
|
photoUrl);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
listView.setAdapter(resourceCursorAdapter);
|
listView.setAdapter(resourceCursorAdapter);
|
||||||
|
|||||||
@@ -86,10 +86,11 @@ public class SearchListActivity extends AbstractSendToGoogleActivity implements
|
|||||||
private static final String SHARED_OWNER_FIELD = "sharedOwner";
|
private static final String SHARED_OWNER_FIELD = "sharedOwner";
|
||||||
private static final String TOTAL_TIME_FIELD = "totalTime";
|
private static final String TOTAL_TIME_FIELD = "totalTime";
|
||||||
private static final String TOTAL_DISTANCE_FIELD = "totalDistance";
|
private static final String TOTAL_DISTANCE_FIELD = "totalDistance";
|
||||||
private static final String PHOTO_URL_FIELD = "photoUrl";
|
private static final String MARKER_COUNT_FIELD = "markerCount";
|
||||||
private static final String START_TIME_FIELD = "startTime";
|
private static final String START_TIME_FIELD = "startTime";
|
||||||
private static final String CATEGORY_FIELD = "category";
|
private static final String CATEGORY_FIELD = "category";
|
||||||
private static final String DESCRIPTION_FIELD = "description";
|
private static final String DESCRIPTION_FIELD = "description";
|
||||||
|
private static final String PHOTO_URL_FIELD = "photoUrl";
|
||||||
|
|
||||||
private static final String TRACK_ID_FIELD = "trackId";
|
private static final String TRACK_ID_FIELD = "trackId";
|
||||||
private static final String MARKER_ID_FIELD = "markerId";
|
private static final String MARKER_ID_FIELD = "markerId";
|
||||||
@@ -233,14 +234,15 @@ public class SearchListActivity extends AbstractSendToGoogleActivity implements
|
|||||||
String sharedOwner = (String) resultMap.get(SHARED_OWNER_FIELD);
|
String sharedOwner = (String) resultMap.get(SHARED_OWNER_FIELD);
|
||||||
String totalTime = (String) resultMap.get(TOTAL_TIME_FIELD);
|
String totalTime = (String) resultMap.get(TOTAL_TIME_FIELD);
|
||||||
String totalDistance = (String) resultMap.get(TOTAL_DISTANCE_FIELD);
|
String totalDistance = (String) resultMap.get(TOTAL_DISTANCE_FIELD);
|
||||||
String photoUrl = (String) resultMap.get(PHOTO_URL_FIELD);
|
int markerCount = (Integer) resultMap.get(MARKER_COUNT_FIELD);
|
||||||
Long startTime = (Long) resultMap.get(START_TIME_FIELD);
|
Long startTime = (Long) resultMap.get(START_TIME_FIELD);
|
||||||
String category = (String) resultMap.get(CATEGORY_FIELD);
|
String category = (String) resultMap.get(CATEGORY_FIELD);
|
||||||
String description = (String) resultMap.get(DESCRIPTION_FIELD);
|
String description = (String) resultMap.get(DESCRIPTION_FIELD);
|
||||||
|
String photoUrl = (String) resultMap.get(PHOTO_URL_FIELD);
|
||||||
|
|
||||||
ListItemUtils.setListItem(SearchListActivity.this, view, isRecording, isPaused, iconId,
|
ListItemUtils.setListItem(SearchListActivity.this, view, isRecording, isPaused, iconId,
|
||||||
iconContentDescriptionId, name, sharedOwner, totalTime, totalDistance, photoUrl,
|
iconContentDescriptionId, name, sharedOwner, totalTime, totalDistance, markerCount,
|
||||||
startTime, category, description);
|
startTime, category, description, photoUrl);
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -496,10 +498,11 @@ public class SearchListActivity extends AbstractSendToGoogleActivity implements
|
|||||||
resultMap.put(TOTAL_TIME_FIELD, trackName == null ? null
|
resultMap.put(TOTAL_TIME_FIELD, trackName == null ? null
|
||||||
: getString(R.string.search_list_marker_track_location, trackName));
|
: getString(R.string.search_list_marker_track_location, trackName));
|
||||||
resultMap.put(TOTAL_DISTANCE_FIELD, null);
|
resultMap.put(TOTAL_DISTANCE_FIELD, null);
|
||||||
resultMap.put(PHOTO_URL_FIELD, waypoint.getPhotoUrl());
|
resultMap.put(MARKER_COUNT_FIELD, 0);
|
||||||
resultMap.put(START_TIME_FIELD, waypoint.getLocation().getTime());
|
resultMap.put(START_TIME_FIELD, waypoint.getLocation().getTime());
|
||||||
resultMap.put(CATEGORY_FIELD, statistics ? null : waypoint.getCategory());
|
resultMap.put(CATEGORY_FIELD, statistics ? null : waypoint.getCategory());
|
||||||
resultMap.put(DESCRIPTION_FIELD, statistics ? null : waypoint.getDescription());
|
resultMap.put(DESCRIPTION_FIELD, statistics ? null : waypoint.getDescription());
|
||||||
|
resultMap.put(PHOTO_URL_FIELD, waypoint.getPhotoUrl());
|
||||||
resultMap.put(TRACK_ID_FIELD, waypoint.getTrackId());
|
resultMap.put(TRACK_ID_FIELD, waypoint.getTrackId());
|
||||||
resultMap.put(MARKER_ID_FIELD, waypoint.getId());
|
resultMap.put(MARKER_ID_FIELD, waypoint.getId());
|
||||||
}
|
}
|
||||||
@@ -524,10 +527,11 @@ public class SearchListActivity extends AbstractSendToGoogleActivity implements
|
|||||||
resultMap.put(TOTAL_TIME_FIELD, StringUtils.formatElapsedTime(tripStatitics.getTotalTime()));
|
resultMap.put(TOTAL_TIME_FIELD, StringUtils.formatElapsedTime(tripStatitics.getTotalTime()));
|
||||||
resultMap.put(TOTAL_DISTANCE_FIELD,
|
resultMap.put(TOTAL_DISTANCE_FIELD,
|
||||||
StringUtils.formatDistance(this, tripStatitics.getTotalDistance(), metricUnits));
|
StringUtils.formatDistance(this, tripStatitics.getTotalDistance(), metricUnits));
|
||||||
resultMap.put(PHOTO_URL_FIELD, null);
|
resultMap.put(MARKER_COUNT_FIELD, myTracksProviderUtils.getWaypointCount(track.getId()));
|
||||||
resultMap.put(START_TIME_FIELD, tripStatitics.getStartTime());
|
resultMap.put(START_TIME_FIELD, tripStatitics.getStartTime());
|
||||||
resultMap.put(CATEGORY_FIELD, category);
|
resultMap.put(CATEGORY_FIELD, category);
|
||||||
resultMap.put(DESCRIPTION_FIELD, track.getDescription());
|
resultMap.put(DESCRIPTION_FIELD, track.getDescription());
|
||||||
|
resultMap.put(PHOTO_URL_FIELD, null);
|
||||||
resultMap.put(TRACK_ID_FIELD, track.getId());
|
resultMap.put(TRACK_ID_FIELD, track.getId());
|
||||||
resultMap.put(MARKER_ID_FIELD, null);
|
resultMap.put(MARKER_ID_FIELD, null);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -361,11 +361,12 @@ public class TrackListActivity extends AbstractSendToGoogleActivity
|
|||||||
int sharedOwnerIndex = cursor.getColumnIndex(TracksColumns.SHAREDOWNER);
|
int sharedOwnerIndex = cursor.getColumnIndex(TracksColumns.SHAREDOWNER);
|
||||||
int totalTimeIndex = cursor.getColumnIndexOrThrow(TracksColumns.TOTALTIME);
|
int totalTimeIndex = cursor.getColumnIndexOrThrow(TracksColumns.TOTALTIME);
|
||||||
int totalDistanceIndex = cursor.getColumnIndexOrThrow(TracksColumns.TOTALDISTANCE);
|
int totalDistanceIndex = cursor.getColumnIndexOrThrow(TracksColumns.TOTALDISTANCE);
|
||||||
int startTimeIndex = cursor.getColumnIndexOrThrow(TracksColumns.STARTTIME);
|
int startTimeIndex = cursor.getColumnIndexOrThrow(TracksColumns.STARTTIME);
|
||||||
int categoryIndex = cursor.getColumnIndex(TracksColumns.CATEGORY);
|
int categoryIndex = cursor.getColumnIndex(TracksColumns.CATEGORY);
|
||||||
int descriptionIndex = cursor.getColumnIndex(TracksColumns.DESCRIPTION);
|
int descriptionIndex = cursor.getColumnIndex(TracksColumns.DESCRIPTION);
|
||||||
|
|
||||||
boolean isRecording = cursor.getLong(idIndex) == recordingTrackId;
|
long trackId = cursor.getLong(idIndex);
|
||||||
|
boolean isRecording = trackId == recordingTrackId;
|
||||||
String icon = cursor.getString(iconIndex);
|
String icon = cursor.getString(iconIndex);
|
||||||
int iconId = TrackIconUtils.getIconDrawable(icon);
|
int iconId = TrackIconUtils.getIconDrawable(icon);
|
||||||
String name = cursor.getString(nameIndex);
|
String name = cursor.getString(nameIndex);
|
||||||
@@ -373,13 +374,14 @@ public class TrackListActivity extends AbstractSendToGoogleActivity
|
|||||||
String totalTime = StringUtils.formatElapsedTime(cursor.getLong(totalTimeIndex));
|
String totalTime = StringUtils.formatElapsedTime(cursor.getLong(totalTimeIndex));
|
||||||
String totalDistance = StringUtils.formatDistance(
|
String totalDistance = StringUtils.formatDistance(
|
||||||
TrackListActivity.this, cursor.getDouble(totalDistanceIndex), metricUnits);
|
TrackListActivity.this, cursor.getDouble(totalDistanceIndex), metricUnits);
|
||||||
long startTime = cursor.getLong(startTimeIndex);
|
int markerCount = myTracksProviderUtils.getWaypointCount(trackId);
|
||||||
String category = icon != null && !icon.equals("") ? null : cursor.getString(categoryIndex);
|
long startTime = cursor.getLong(startTimeIndex);
|
||||||
|
String category = icon != null && !icon.equals("") ? null : cursor.getString(categoryIndex);
|
||||||
String description = cursor.getString(descriptionIndex);
|
String description = cursor.getString(descriptionIndex);
|
||||||
|
|
||||||
ListItemUtils.setListItem(TrackListActivity.this, view, isRecording, recordingTrackPaused,
|
ListItemUtils.setListItem(TrackListActivity.this, view, isRecording, recordingTrackPaused,
|
||||||
iconId, R.string.icon_track, name, sharedOwner, totalTime, totalDistance, null,
|
iconId, R.string.icon_track, name, sharedOwner, totalTime, totalDistance, markerCount,
|
||||||
startTime, category, description);
|
startTime, category, description, null);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
listView.setAdapter(sectionResourceCursorAdapter);
|
listView.setAdapter(sectionResourceCursorAdapter);
|
||||||
|
|||||||
@@ -179,6 +179,9 @@ public class KmzTrackImporter implements TrackImporter {
|
|||||||
if (importTrackId == -1L) {
|
if (importTrackId == -1L) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (fileName.equals("")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
File dir = new File(
|
File dir = new File(
|
||||||
FileUtils.getPath(FileUtils.PICTURES_DIR, Long.toString(importTrackId)));
|
FileUtils.getPath(FileUtils.PICTURES_DIR, Long.toString(importTrackId)));
|
||||||
FileUtils.ensureDirectoryExists(dir);
|
FileUtils.ensureDirectoryExists(dir);
|
||||||
|
|||||||
@@ -102,14 +102,22 @@ public class BitmapLoader extends AsyncTask<Void, Void, Bitmap> {
|
|||||||
} else {
|
} else {
|
||||||
Matrix matrix = new Matrix();
|
Matrix matrix = new Matrix();
|
||||||
matrix.postRotate(rotation);
|
matrix.postRotate(rotation);
|
||||||
int offset = 0;
|
int xOffset = 0;
|
||||||
|
int yOffset = 0;
|
||||||
|
int width = scaledBitmap.getWidth();
|
||||||
int height = scaledBitmap.getHeight();
|
int height = scaledBitmap.getHeight();
|
||||||
if (!fitWithin && height > targetHeight) {
|
if (rotation == 0 || rotation == 180) {
|
||||||
offset = (height - targetHeight) / 2;
|
if (!fitWithin && height > targetHeight) {
|
||||||
height = targetHeight;
|
xOffset = (height - targetHeight) / 2;
|
||||||
|
height = targetHeight;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!fitWithin && width > targetHeight) {
|
||||||
|
yOffset = (width - targetHeight) / 2;
|
||||||
|
width = targetHeight;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
bitmap = Bitmap.createBitmap(
|
bitmap = Bitmap.createBitmap(scaledBitmap, yOffset, xOffset, width, height, matrix, true);
|
||||||
scaledBitmap, 0, offset, scaledBitmap.getWidth(), height, matrix, true);
|
|
||||||
scaledBitmap.recycle();
|
scaledBitmap.recycle();
|
||||||
}
|
}
|
||||||
return bitmap;
|
return bitmap;
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import com.google.android.maps.mytracks.R;
|
|||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.text.format.DateUtils;
|
import android.text.format.DateUtils;
|
||||||
import android.view.Display;
|
import android.view.Display;
|
||||||
@@ -54,16 +55,17 @@ public class ListItemUtils {
|
|||||||
* @param sharedOwner if shared with me track, the owner, else null
|
* @param sharedOwner if shared with me track, the owner, else null
|
||||||
* @param totalTime the total time value
|
* @param totalTime the total time value
|
||||||
* @param totalDistance the total distance value
|
* @param totalDistance the total distance value
|
||||||
* @param photoUrl the photo url
|
* @param markerCount the marker count
|
||||||
* @param startTime the start time value
|
* @param startTime the start time value
|
||||||
* @param category the category value
|
* @param category the category value
|
||||||
* @param description the description value
|
* @param description the description value
|
||||||
|
* @param photoUrl the photo url
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public static void setListItem(Activity activity, View view, boolean isRecording,
|
public static void setListItem(Activity activity, View view, boolean isRecording,
|
||||||
boolean isPaused, int iconId, int iconContentDescriptionId, String name, String sharedOwner,
|
boolean isPaused, int iconId, int iconContentDescriptionId, String name, String sharedOwner,
|
||||||
String totalTime, String totalDistance, String photoUrl, long startTime, String category,
|
String totalTime, String totalDistance, int markerCount, long startTime, String category,
|
||||||
String description) {
|
String description, String photoUrl) {
|
||||||
|
|
||||||
if (isRecording) {
|
if (isRecording) {
|
||||||
iconId = isPaused ? R.drawable.ic_track_paused : R.drawable.ic_track_recording;
|
iconId = isPaused ? R.drawable.ic_track_paused : R.drawable.ic_track_recording;
|
||||||
@@ -80,16 +82,60 @@ public class ListItemUtils {
|
|||||||
nameTextView.setText(name);
|
nameTextView.setText(name);
|
||||||
|
|
||||||
// Set sharedOwner/totalTime/totalDistance
|
// Set sharedOwner/totalTime/totalDistance
|
||||||
TextView timeDistanceTextView = (TextView) view.findViewById(R.id.list_item_time_distance);
|
TextView ownerTimeDistanceTextView = (TextView) view.findViewById(
|
||||||
|
R.id.list_item_owner_time_distance);
|
||||||
|
String ownerTimeDistance;
|
||||||
if (isRecording) {
|
if (isRecording) {
|
||||||
timeDistanceTextView.setTextColor(activity.getResources()
|
ownerTimeDistanceTextView.setTextColor(activity.getResources()
|
||||||
.getColor(isPaused ? android.R.color.white : R.color.recording_text));
|
.getColor(isPaused ? android.R.color.white : R.color.recording_text));
|
||||||
|
ownerTimeDistance = activity.getString(
|
||||||
|
isPaused ? R.string.generic_paused : R.string.generic_recording);
|
||||||
} else {
|
} else {
|
||||||
// Need to match the style set in list_item.xml
|
// Need to match the style set in list_item.xml
|
||||||
timeDistanceTextView.setTextAppearance(activity, R.style.TextSmall);
|
ownerTimeDistanceTextView.setTextAppearance(activity, R.style.TextSmall);
|
||||||
|
ownerTimeDistance = getOwnerTimeDistance(sharedOwner, totalTime, totalDistance);
|
||||||
|
if (markerCount > 0) {
|
||||||
|
ownerTimeDistance += " \u2027 ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
setTextView(timeDistanceTextView,
|
setTextView(ownerTimeDistanceTextView, ownerTimeDistance);
|
||||||
getTimeDistance(activity, isRecording, isPaused, sharedOwner, totalTime, totalDistance));
|
|
||||||
|
// Set markerCount
|
||||||
|
TextView markerCountTextView = (TextView) view.findViewById(R.id.list_item_marker_count);
|
||||||
|
if (markerCount > 0) {
|
||||||
|
markerCountTextView.setVisibility(View.VISIBLE);
|
||||||
|
Drawable markerDrawable = activity.getResources()
|
||||||
|
.getDrawable(R.drawable.ic_menu_insert_marker);
|
||||||
|
int size = markerCountTextView.getLineHeight();
|
||||||
|
markerDrawable.setBounds(0, 0, size, size);
|
||||||
|
markerCountTextView.setCompoundDrawables(markerDrawable, null, null, null);
|
||||||
|
markerCountTextView.setText(markerCount + "");
|
||||||
|
} else {
|
||||||
|
markerCountTextView.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set date/time
|
||||||
|
String[] dateTime = getDateTime(isRecording, activity, startTime);
|
||||||
|
TextView dateTextView = (TextView) view.findViewById(R.id.list_item_date);
|
||||||
|
setTextView(dateTextView, dateTime[0]);
|
||||||
|
|
||||||
|
TextView timeTextView = (TextView) view.findViewById(R.id.list_item_time);
|
||||||
|
setTextView(timeTextView, dateTime[1]);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If column0 is GONE, change to INVISIBLE so column1 is placed at the
|
||||||
|
* correct position.
|
||||||
|
*/
|
||||||
|
if (timeTextView.getVisibility() == View.VISIBLE
|
||||||
|
&& ownerTimeDistanceTextView.getVisibility() == View.GONE) {
|
||||||
|
ownerTimeDistanceTextView.setVisibility(View.INVISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set category and description
|
||||||
|
TextView categoryDescription = (TextView) view.findViewById(
|
||||||
|
R.id.list_item_category_description);
|
||||||
|
setTextView(categoryDescription,
|
||||||
|
isRecording ? null : StringUtils.getCategoryDescription(category, description));
|
||||||
|
|
||||||
ImageView photo = (ImageView) view.findViewById(R.id.list_item_background);
|
ImageView photo = (ImageView) view.findViewById(R.id.list_item_background);
|
||||||
if (photoUrl == null || photoUrl.equals("")) {
|
if (photoUrl == null || photoUrl.equals("")) {
|
||||||
@@ -100,45 +146,17 @@ public class ListItemUtils {
|
|||||||
PhotoUtils.setImageVew(
|
PhotoUtils.setImageVew(
|
||||||
photo, Uri.parse(photoUrl), defaultDisplay.getWidth(), getPhotoHeight(activity), false);
|
photo, Uri.parse(photoUrl), defaultDisplay.getWidth(), getPhotoHeight(activity), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set date/time
|
|
||||||
String[] startTimeDisplay = getStartTime(isRecording, activity, startTime);
|
|
||||||
TextView dateTextView = (TextView) view.findViewById(R.id.list_item_date);
|
|
||||||
setTextView(dateTextView, startTimeDisplay[0]);
|
|
||||||
|
|
||||||
TextView timeTextView = (TextView) view.findViewById(R.id.list_item_time);
|
|
||||||
setTextView(timeTextView, startTimeDisplay[1]);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If column0 is GONE, change to INVISIBLE so column1 is placed at the
|
|
||||||
* correct position.
|
|
||||||
*/
|
|
||||||
if (timeTextView.getVisibility() == View.VISIBLE
|
|
||||||
&& timeDistanceTextView.getVisibility() == View.GONE) {
|
|
||||||
timeDistanceTextView.setVisibility(View.INVISIBLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set category/description
|
|
||||||
TextView descriptionTextView = (TextView) view.findViewById(R.id.list_item_description);
|
|
||||||
setTextView(descriptionTextView,
|
|
||||||
isRecording ? null : StringUtils.getCategoryDescription(category, description));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the time/distance text.
|
* Gets a string for share owner, total time, and total distance.
|
||||||
*
|
*
|
||||||
* @param context the context
|
* @param sharedOwner the share owner. Can be null
|
||||||
* @param isRecording true if recording
|
* @param totalTime the total time. Can be null
|
||||||
* @param isPaused true if paused
|
* @param totalDistance the total distance. Can be null
|
||||||
* @param sharedOwner the shared owner
|
|
||||||
* @param totalTime the total time
|
|
||||||
* @param totalDistance the total distance
|
|
||||||
*/
|
*/
|
||||||
private static String getTimeDistance(Context context, boolean isRecording, boolean isPaused,
|
private static String getOwnerTimeDistance(
|
||||||
String sharedOwner, String totalTime, String totalDistance) {
|
String sharedOwner, String totalTime, String totalDistance) {
|
||||||
if (isRecording) {
|
|
||||||
return context.getString(isPaused ? R.string.generic_paused : R.string.generic_recording);
|
|
||||||
}
|
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuffer buffer = new StringBuffer();
|
||||||
if (sharedOwner != null && sharedOwner.length() != 0) {
|
if (sharedOwner != null && sharedOwner.length() != 0) {
|
||||||
buffer.append(sharedOwner);
|
buffer.append(sharedOwner);
|
||||||
@@ -159,29 +177,28 @@ public class ListItemUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the start time text.
|
* Gets the date and time as an array of two strings.
|
||||||
*
|
*
|
||||||
* @param isRecording true if recording
|
* @param isRecording true if recording
|
||||||
* @param context the context
|
* @param context the context
|
||||||
* @param startTime the start time
|
* @param time the start time
|
||||||
* @return array of two strings.
|
|
||||||
*/
|
*/
|
||||||
private static String[] getStartTime(boolean isRecording, Context context, long startTime) {
|
private static String[] getDateTime(boolean isRecording, Context context, long time) {
|
||||||
if (isRecording || startTime == 0L) {
|
if (isRecording || time == 0L) {
|
||||||
return new String[] { null, null };
|
return new String[] { null, null };
|
||||||
}
|
}
|
||||||
if (DateUtils.isToday(startTime)) {
|
if (DateUtils.isToday(time)) {
|
||||||
return new String[] { DateUtils.getRelativeTimeSpanString(
|
return new String[] { DateUtils.getRelativeTimeSpanString(
|
||||||
startTime, System.currentTimeMillis(), DateUtils.MINUTE_IN_MILLIS,
|
time, System.currentTimeMillis(), DateUtils.MINUTE_IN_MILLIS,
|
||||||
DateUtils.FORMAT_ABBREV_RELATIVE).toString(), null };
|
DateUtils.FORMAT_ABBREV_RELATIVE).toString(), null };
|
||||||
}
|
}
|
||||||
int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_ALL;
|
int dateFlags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_ALL;
|
||||||
if (!isThisYear(startTime)) {
|
if (!isThisYear(time)) {
|
||||||
flags |= DateUtils.FORMAT_NUMERIC_DATE;
|
dateFlags |= DateUtils.FORMAT_NUMERIC_DATE;
|
||||||
}
|
}
|
||||||
return new String[] { DateUtils.formatDateTime(context, startTime, flags),
|
int timeFlags = DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_ABBREV_TIME;
|
||||||
DateUtils.formatDateTime(
|
return new String[] { DateUtils.formatDateTime(context, time, dateFlags),
|
||||||
context, startTime, DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_ABBREV_TIME) };
|
DateUtils.formatDateTime(context, time, timeFlags) };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -190,6 +190,13 @@ public interface MyTracksProviderUtils {
|
|||||||
*/
|
*/
|
||||||
public Cursor getWaypointCursor(long trackId, long minWaypointId, int maxWaypoints);
|
public Cursor getWaypointCursor(long trackId, long minWaypointId, int maxWaypoints);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the number of waypoints for a track.
|
||||||
|
*
|
||||||
|
* @param trackId the track id
|
||||||
|
*/
|
||||||
|
public int getWaypointCount(long trackId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inserts a waypoint.
|
* Inserts a waypoint.
|
||||||
*
|
*
|
||||||
|
|||||||
+18
@@ -657,6 +657,24 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
|||||||
return getWaypointCursor(null, selection, selectionArgs, WaypointsColumns._ID, maxWaypoints);
|
return getWaypointCursor(null, selection, selectionArgs, WaypointsColumns._ID, maxWaypoints);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getWaypointCount(long trackId) {
|
||||||
|
if (trackId < 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] projection = new String[] { "count(*) AS count" };
|
||||||
|
String selection = WaypointsColumns.TRACKID + "=?";
|
||||||
|
String[] selectionArgs = new String[] { Long.toString(trackId) };
|
||||||
|
Cursor cursor = contentResolver.query(
|
||||||
|
WaypointsColumns.CONTENT_URI, projection, selection, selectionArgs, WaypointsColumns._ID);
|
||||||
|
|
||||||
|
cursor.moveToFirst();
|
||||||
|
int count = cursor.getInt(0);
|
||||||
|
// not count the first waypoint
|
||||||
|
return count > 0 ? count - 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Uri insertWaypoint(Waypoint waypoint) {
|
public Uri insertWaypoint(Waypoint waypoint) {
|
||||||
waypoint.setId(-1L);
|
waypoint.setId(-1L);
|
||||||
|
|||||||
+6
-6
@@ -225,8 +225,8 @@ public class TripStatisticsUpdaterTest extends TestCase {
|
|||||||
Location location = getLocation(i + locationOffset, (i + locationOffset) * .001, MOVING_SPEED,
|
Location location = getLocation(i + locationOffset, (i + locationOffset) * .001, MOVING_SPEED,
|
||||||
startTime + (timeOffset + i) * TEN_SECONDS);
|
startTime + (timeOffset + i) * TEN_SECONDS);
|
||||||
tripStatisticsUpdater.addLocation(location,
|
tripStatisticsUpdater.addLocation(location,
|
||||||
PreferencesUtils.RECORDING_DISTANCE_INTERVAL_DEFAULT, ActivityType.FOOT,
|
PreferencesUtils.RECORDING_DISTANCE_INTERVAL_DEFAULT, true, ActivityType.FOOT,
|
||||||
PreferencesUtils.STATS_WEIGHT_DEFAULT, true);
|
PreferencesUtils.STATS_WEIGHT_DEFAULT);
|
||||||
tripStatistics = tripStatisticsUpdater.getTripStatistics();
|
tripStatistics = tripStatisticsUpdater.getTripStatistics();
|
||||||
|
|
||||||
assertEquals((timeOffset + i) * TEN_SECONDS, tripStatistics.getTotalTime());
|
assertEquals((timeOffset + i) * TEN_SECONDS, tripStatistics.getTotalTime());
|
||||||
@@ -272,8 +272,8 @@ public class TripStatisticsUpdaterTest extends TestCase {
|
|||||||
Location location = getLocation(
|
Location location = getLocation(
|
||||||
locationOffset, locationOffset * .001, 0, startTime + (i + timeOffset) * TEN_SECONDS);
|
locationOffset, locationOffset * .001, 0, startTime + (i + timeOffset) * TEN_SECONDS);
|
||||||
tripStatisticsUpdater.addLocation(location,
|
tripStatisticsUpdater.addLocation(location,
|
||||||
PreferencesUtils.RECORDING_DISTANCE_INTERVAL_DEFAULT, ActivityType.FOOT,
|
PreferencesUtils.RECORDING_DISTANCE_INTERVAL_DEFAULT, false, ActivityType.FOOT,
|
||||||
PreferencesUtils.STATS_WEIGHT_DEFAULT, false);
|
PreferencesUtils.STATS_WEIGHT_DEFAULT);
|
||||||
|
|
||||||
tripStatistics = tripStatisticsUpdater.getTripStatistics();
|
tripStatistics = tripStatisticsUpdater.getTripStatistics();
|
||||||
assertEquals((i + timeOffset) * TEN_SECONDS, tripStatistics.getTotalTime());
|
assertEquals((i + timeOffset) * TEN_SECONDS, tripStatistics.getTotalTime());
|
||||||
@@ -310,8 +310,8 @@ public class TripStatisticsUpdaterTest extends TestCase {
|
|||||||
Location location = getLocation(i + locationOffset, (i + locationOffset) * .001, 99999,
|
Location location = getLocation(i + locationOffset, (i + locationOffset) * .001, 99999,
|
||||||
startTime + (timeOffset + i) * TEN_SECONDS);
|
startTime + (timeOffset + i) * TEN_SECONDS);
|
||||||
tripStatisticsUpdater.addLocation(location,
|
tripStatisticsUpdater.addLocation(location,
|
||||||
PreferencesUtils.RECORDING_DISTANCE_INTERVAL_DEFAULT, ActivityType.FOOT,
|
PreferencesUtils.RECORDING_DISTANCE_INTERVAL_DEFAULT, true, ActivityType.FOOT,
|
||||||
PreferencesUtils.STATS_WEIGHT_DEFAULT, true);
|
PreferencesUtils.STATS_WEIGHT_DEFAULT);
|
||||||
tripStatistics = tripStatisticsUpdater.getTripStatistics();
|
tripStatistics = tripStatisticsUpdater.getTripStatistics();
|
||||||
|
|
||||||
assertTrue(tripStatistics.getMovingTime() <= tripStatistics.getTotalTime());
|
assertTrue(tripStatistics.getMovingTime() <= tripStatistics.getTotalTime());
|
||||||
|
|||||||
Reference in New Issue
Block a user