forked from upstream-mirrors/OpenTracks
Addressing review comments for the search functionality.
This commit is contained in:
@@ -15,44 +15,39 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:paddingTop="2dip"
|
|
||||||
android:paddingBottom="2dip"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical"
|
||||||
|
android:paddingBottom="2dip"
|
||||||
|
android:paddingTop="2dip">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:orientation="horizontal"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content">
|
android:orientation="horizontal">
|
||||||
<ImageView android:id="@+id/track_list_item_icon"
|
<ImageView android:id="@+id/track_list_item_icon"
|
||||||
android:layout_width="wrap_content"
|
android:contentDescription="@string/track_list_icon_description"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
android:paddingLeft="4dip"
|
android:paddingLeft="4dip"
|
||||||
android:paddingRight="2dip"
|
android:paddingRight="2dip"
|
||||||
android:paddingTop="5dip"
|
android:paddingTop="5dip"
|
||||||
android:src="@drawable/track"
|
android:src="@drawable/track" />
|
||||||
android:contentDescription="@string/track_list_icon_description"/>
|
<TextView android:id="@+id/track_list_item_name"
|
||||||
<LinearLayout
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:layout_marginLeft="6dip"
|
||||||
|
android:layout_marginTop="6dip"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceLarge"/>
|
||||||
|
<TextView android:id="@+id/track_list_item_category"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="6dip"
|
||||||
|
android:layout_marginTop="6dip"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content">
|
android:singleLine = "true"
|
||||||
<TextView android:id="@+id/track_list_item_name"
|
android:textAppearance="?android:attr/textAppearanceSmall"/>
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="6dip"
|
|
||||||
android:layout_marginTop="6dip"
|
|
||||||
android:singleLine="true"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"/>
|
|
||||||
<TextView android:id="@+id/track_list_item_category"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="6dip"
|
|
||||||
android:layout_marginTop="6dip"
|
|
||||||
android:singleLine = "true"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall"/>
|
|
||||||
</LinearLayout>
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView android:id="@+id/track_list_item_time"
|
<TextView android:id="@+id/track_list_item_time"
|
||||||
|
|||||||
@@ -20,15 +20,15 @@ limitations under the License.
|
|||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent">
|
android:layout_height="fill_parent">
|
||||||
<ListView android:id="@android:id/list"
|
<ListView android:id="@android:id/list"
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="fill_parent" />
|
|
||||||
<TextView android:id="@android:id/empty"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
|
android:layout_width="fill_parent" />
|
||||||
|
<TextView android:id="@android:id/empty"
|
||||||
|
android:gravity="center"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
android:text="@string/search_no_results"
|
android:text="@string/search_no_results"
|
||||||
android:textColor="@android:color/white"
|
android:textColor="@android:color/white"
|
||||||
android:textSize="20dip"
|
android:textSize="20dip"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:gravity="center"
|
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
@@ -816,9 +816,7 @@ limitations under the License.
|
|||||||
Edit
|
Edit
|
||||||
</string>
|
</string>
|
||||||
<string name="marker_list_icon_description"
|
<string name="marker_list_icon_description"
|
||||||
translation_description="In the Markers page, the accessibility description for the marker icon.
|
translation_description="In the Markers page, the accessibility description for the marker icon.">
|
||||||
|
|
||||||
Screenshot: marker_list.png">
|
|
||||||
Marker
|
Marker
|
||||||
</string>
|
</string>
|
||||||
<string name="marker_list_insert_statistics"
|
<string name="marker_list_insert_statistics"
|
||||||
@@ -842,12 +840,6 @@ limitations under the License.
|
|||||||
Screenshot: marker_list.png">
|
Screenshot: marker_list.png">
|
||||||
Pick a marker. Press & hold for more options.
|
Pick a marker. Press & hold for more options.
|
||||||
</string>
|
</string>
|
||||||
<string name="marker_list_name"
|
|
||||||
translation_description="In the Markers page, the label for the marker's name.
|
|
||||||
|
|
||||||
Screenshot: marker_list.png">
|
|
||||||
Name
|
|
||||||
</string>
|
|
||||||
<string name="marker_list_show_on_map"
|
<string name="marker_list_show_on_map"
|
||||||
translation_description="In the context menu for a marker, the menu option to show the marker
|
translation_description="In the context menu for a marker, the menu option to show the marker
|
||||||
on the map.
|
on the map.
|
||||||
@@ -2344,16 +2336,14 @@ limitations under the License.
|
|||||||
Show on map
|
Show on map
|
||||||
</string>
|
</string>
|
||||||
<string name="track_list_icon_description"
|
<string name="track_list_icon_description"
|
||||||
translation_description="In the 'Tracks' page, the accessibility description for the track icon.
|
translation_description="In the 'Tracks' page, the accessibility description for the track icon.">
|
||||||
|
|
||||||
Screenshot: track_list.png">
|
|
||||||
Track
|
Track
|
||||||
</string>
|
</string>
|
||||||
<string name="track_list_track_name"
|
<string name="track_list_track_name"
|
||||||
translation_description="In the 'Search Result' page, the text field indicating the track that a
|
translation_description="In the 'Search Result' page, the text field indicating the track that a
|
||||||
waypoint belongs to.
|
waypoint belongs to.
|
||||||
|
|
||||||
%1$d: track name. E.g., 'Grand Canyon trail'">
|
%1$s: track name. E.g., 'Grand Canyon trail'">
|
||||||
In track \'%1$s\'.
|
In track \'%1$s\'.
|
||||||
</string>
|
</string>
|
||||||
<string name="track_name_format"
|
<string name="track_name_format"
|
||||||
|
|||||||
@@ -60,6 +60,15 @@ import java.util.SortedSet;
|
|||||||
*/
|
*/
|
||||||
public class SearchActivity extends ListActivity {
|
public class SearchActivity extends ListActivity {
|
||||||
|
|
||||||
|
private static final String ICON_FIELD = "icon";
|
||||||
|
private static final String NAME_FIELD = "name";
|
||||||
|
private static final String DESCRIPTION_FIELD = "description";
|
||||||
|
private static final String CATEGORY_FIELD = "category";
|
||||||
|
private static final String TIME_FIELD = "time";
|
||||||
|
private static final String STATS_FIELD = "stats";
|
||||||
|
private static final String TRACK_ID_FIELD = "trackId";
|
||||||
|
private static final String WAYPOINT_ID_FIELD = "waypointId";
|
||||||
|
|
||||||
private static final String EXTRA_CURRENT_TRACK_ID = "trackId";
|
private static final String EXTRA_CURRENT_TRACK_ID = "trackId";
|
||||||
|
|
||||||
private static final boolean LOG_SCORES = true;
|
private static final boolean LOG_SCORES = true;
|
||||||
@@ -179,28 +188,29 @@ public class SearchActivity extends ListActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Yellow pushpin for statistics marker.
|
// TODO: Yellow pushpin for statistics marker.
|
||||||
resultMap.put("icon", R.drawable.blue_pushpin);
|
resultMap.put(ICON_FIELD, R.drawable.blue_pushpin);
|
||||||
resultMap.put("name", waypoint.getName());
|
resultMap.put(NAME_FIELD, waypoint.getName());
|
||||||
resultMap.put("description", waypoint.getDescription());
|
resultMap.put(DESCRIPTION_FIELD, waypoint.getDescription());
|
||||||
resultMap.put("category", waypoint.getCategory());
|
resultMap.put(CATEGORY_FIELD, waypoint.getCategory());
|
||||||
resultMap.put("stats", StringUtils.formatDateTime(this, waypoint.getLocation().getTime()));
|
// In the same place as we show time for tracks, show the track name for waypoints.
|
||||||
resultMap.put("trackId", waypoint.getTrackId());
|
resultMap.put(TIME_FIELD, getString(R.string.track_list_track_name, trackName));
|
||||||
resultMap.put("waypointId", waypoint.getId());
|
resultMap.put(STATS_FIELD, StringUtils.formatDateTime(this, waypoint.getLocation().getTime()));
|
||||||
resultMap.put("time", getString(R.string.track_list_track_name, trackName));
|
resultMap.put(TRACK_ID_FIELD, waypoint.getTrackId());
|
||||||
|
resultMap.put(WAYPOINT_ID_FIELD, waypoint.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void prepareTrackForDisplay(Track track, Map<String, Object> resultMap) {
|
private void prepareTrackForDisplay(Track track, Map<String, Object> resultMap) {
|
||||||
TripStatistics stats = track.getStatistics();
|
TripStatistics stats = track.getStatistics();
|
||||||
|
|
||||||
resultMap.put("icon", R.drawable.track);
|
resultMap.put(ICON_FIELD, R.drawable.track);
|
||||||
resultMap.put("name", track.getName());
|
resultMap.put(NAME_FIELD, track.getName());
|
||||||
resultMap.put("description", track.getDescription());
|
resultMap.put(DESCRIPTION_FIELD, track.getDescription());
|
||||||
resultMap.put("category", track.getCategory());
|
resultMap.put(CATEGORY_FIELD, track.getCategory());
|
||||||
resultMap.put("time", StringUtils.formatDateTime(this, stats.getStartTime()));
|
resultMap.put(TIME_FIELD, StringUtils.formatDateTime(this, stats.getStartTime()));
|
||||||
resultMap.put("trackId", track.getId());
|
resultMap.put(STATS_FIELD,
|
||||||
resultMap.put("stats",
|
|
||||||
StringUtils.formatTimeDistance(this, stats.getTotalDistance(), stats.getTotalTime(),
|
StringUtils.formatTimeDistance(this, stats.getTotalDistance(), stats.getTotalTime(),
|
||||||
metricUnits));
|
metricUnits));
|
||||||
|
resultMap.put(TRACK_ID_FIELD, track.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -214,12 +224,12 @@ public class SearchActivity extends ListActivity {
|
|||||||
// TODO: Custom view for search results.
|
// TODO: Custom view for search results.
|
||||||
R.layout.mytracks_list_item,
|
R.layout.mytracks_list_item,
|
||||||
new String[] {
|
new String[] {
|
||||||
"icon",
|
ICON_FIELD,
|
||||||
"name",
|
NAME_FIELD,
|
||||||
"description",
|
DESCRIPTION_FIELD,
|
||||||
"category",
|
CATEGORY_FIELD,
|
||||||
"time",
|
TIME_FIELD,
|
||||||
"stats",
|
STATS_FIELD,
|
||||||
},
|
},
|
||||||
new int[] {
|
new int[] {
|
||||||
R.id.track_list_item_icon,
|
R.id.track_list_item_icon,
|
||||||
@@ -243,12 +253,12 @@ public class SearchActivity extends ListActivity {
|
|||||||
|
|
||||||
private Intent createViewDataIntent(Map<String, Object> clickedData) {
|
private Intent createViewDataIntent(Map<String, Object> clickedData) {
|
||||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||||
if (clickedData.containsKey("waypointId")) {
|
if (clickedData.containsKey(WAYPOINT_ID_FIELD)) {
|
||||||
long waypointId = (Long) clickedData.get("waypointId");
|
long waypointId = (Long) clickedData.get(WAYPOINT_ID_FIELD);
|
||||||
Uri uri = ContentUris.withAppendedId(WaypointsColumns.CONTENT_URI, waypointId);
|
Uri uri = ContentUris.withAppendedId(WaypointsColumns.CONTENT_URI, waypointId);
|
||||||
intent.setDataAndType(uri, WaypointsColumns.CONTENT_ITEMTYPE);
|
intent.setDataAndType(uri, WaypointsColumns.CONTENT_ITEMTYPE);
|
||||||
} else {
|
} else {
|
||||||
long trackId = (Long) clickedData.get("trackId");
|
long trackId = (Long) clickedData.get(TRACK_ID_FIELD);
|
||||||
Uri uri = ContentUris.withAppendedId(TracksColumns.CONTENT_URI, trackId);
|
Uri uri = ContentUris.withAppendedId(TracksColumns.CONTENT_URI, trackId);
|
||||||
intent.setDataAndType(uri, TracksColumns.CONTENT_ITEMTYPE);
|
intent.setDataAndType(uri, TracksColumns.CONTENT_ITEMTYPE);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,14 +89,14 @@ public class StringUtils implements DescriptionGenerator {
|
|||||||
public static String formatTimeDistance(Context context, double totalDistance, long totalTime, boolean metric) {
|
public static String formatTimeDistance(Context context, double totalDistance, long totalTime, boolean metric) {
|
||||||
String distanceUnit;
|
String distanceUnit;
|
||||||
if (metric) {
|
if (metric) {
|
||||||
if (totalDistance > 1000.0) {
|
if (totalDistance > 2000.0) {
|
||||||
totalDistance /= 1000.0;
|
totalDistance /= 1000.0;
|
||||||
distanceUnit = context.getString(R.string.unit_kilometer);
|
distanceUnit = context.getString(R.string.unit_kilometer);
|
||||||
} else {
|
} else {
|
||||||
distanceUnit = context.getString(R.string.unit_meter);
|
distanceUnit = context.getString(R.string.unit_meter);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (totalDistance > UnitConversions.MI_TO_M) {
|
if (totalDistance > 2 * UnitConversions.MI_TO_M) {
|
||||||
totalDistance /= UnitConversions.MI_TO_M;
|
totalDistance /= UnitConversions.MI_TO_M;
|
||||||
distanceUnit = context.getString(R.string.unit_mile);
|
distanceUnit = context.getString(R.string.unit_mile);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user