diff --git a/MyTracks/res/values/strings.xml b/MyTracks/res/values/strings.xml
index 4c3b5cf99..b8b93cc9d 100644
--- a/MyTracks/res/values/strings.xml
+++ b/MyTracks/res/values/strings.xml
@@ -1102,6 +1102,24 @@ limitations under the License.
Finished writing to the SD card.
+
+
+ Search My Tracks tracks and waypoints
+
+
+ My Tracks tracks and waypoints
+
+
+ Speak the name of a track or waypoint.
+
+
What are waypoint markers?
-
-
-
- Search My Tracks tracks and waypoints
-
-
- My Tracks tracks and waypoints
-
-
- Speak the name of a track or waypoint.
-
diff --git a/MyTracks/res/xml/search.xml b/MyTracks/res/xml/search.xml
index 09eaabd19..22c82610d 100644
--- a/MyTracks/res/xml/search.xml
+++ b/MyTracks/res/xml/search.xml
@@ -1,10 +1,10 @@
-
+ android:voicePromptText="@string/search_voice_prompt"
+ android:voiceSearchMode="showVoiceSearchButton|launchRecognizer">
+
\ No newline at end of file
diff --git a/MyTracks/src/com/google/android/apps/mytracks/SearchActivity.java b/MyTracks/src/com/google/android/apps/mytracks/SearchActivity.java
index f0da88c49..3d2f2d117 100644
--- a/MyTracks/src/com/google/android/apps/mytracks/SearchActivity.java
+++ b/MyTracks/src/com/google/android/apps/mytracks/SearchActivity.java
@@ -54,6 +54,16 @@ import java.util.TreeSet;
*/
public class SearchActivity extends ListActivity {
+ private static final double TRACK_CATEGORY_PROMOTION = 2.0;
+
+ private static final double TRACK_DESCRIPTION_PROMOTION = 8.0;
+
+ private static final double TRACK_NAME_PROMOTION = 16.0;
+
+ private static final double CURRENT_TRACK_WAYPOINT_PROMOTION = 2.0;
+
+ private static final double CURRENT_TRACK_DEMOTION = 0.5;
+
private static final String EXTRA_CURRENT_TRACK_ID = "trackId";
/** Maximum number of waypoints which will be retrieved and scored. */
@@ -257,7 +267,7 @@ public class SearchActivity extends ListActivity {
// Score the currently-selected track lower (user is already there, wouldn't be searching for it).
if (track.getId() == query.currentTrackId) {
- score *= 0.5;
+ score *= CURRENT_TRACK_DEMOTION;
}
return score;
@@ -283,7 +293,7 @@ public class SearchActivity extends ListActivity {
// Score waypoints in the currently-selected track higher (searching inside the current track).
if (waypoint.getTrackId() == query.currentTrackId) {
- score *= 2.0;
+ score *= CURRENT_TRACK_WAYPOINT_PROMOTION;
}
return score;
@@ -294,13 +304,13 @@ public class SearchActivity extends ListActivity {
// Title boost: track name > description > category.
double boost = 1.0;
if (name.toLowerCase().contains(query.textQuery)) {
- boost *= 16.0;
+ boost *= TRACK_NAME_PROMOTION;
}
if (description.toLowerCase().contains(query.textQuery)) {
- boost *= 8.0;
+ boost *= TRACK_DESCRIPTION_PROMOTION;
}
if (category.toLowerCase().contains(query.textQuery)) {
- boost *= 2.0;
+ boost *= TRACK_CATEGORY_PROMOTION;
}
return boost;
}
@@ -309,7 +319,7 @@ public class SearchActivity extends ListActivity {
// Score recent tracks higher.
long timeAgoHours = (query.currentTimestamp - timestamp) / (60L * 60L);
if (timeAgoHours > 0L) {
- return 1.0 / Math.log(1.0 + timeAgoHours);
+ return squash(timeAgoHours);
} else {
// Should rarely happen (track recorded in the last hour).
return Double.POSITIVE_INFINITY;
@@ -332,7 +342,7 @@ public class SearchActivity extends ListActivity {
double distanceKm = distanceResults[0] / 1000.0;
if (distanceKm > 0.0) {
// Use the inverse of the amortized distance.
- return 1.0 / Math.log(1.0 + distanceKm);
+ return squash(distanceKm);
} else {
// Should rarely happen (distance is exactly 0).
return Double.POSITIVE_INFINITY;
@@ -422,4 +432,8 @@ public class SearchActivity extends ListActivity {
startActivity(intent);
}
}
+
+ private static double squash(double timeAgoHours) {
+ return 1.0 / Math.log1p(timeAgoHours);
+ }
}
diff --git a/MyTracksLib/src/com/google/android/apps/mytracks/content/MyTracksProviderUtils.java b/MyTracksLib/src/com/google/android/apps/mytracks/content/MyTracksProviderUtils.java
index c04b9d081..b52f41d9c 100644
--- a/MyTracksLib/src/com/google/android/apps/mytracks/content/MyTracksProviderUtils.java
+++ b/MyTracksLib/src/com/google/android/apps/mytracks/content/MyTracksProviderUtils.java
@@ -154,7 +154,7 @@ public interface MyTracksProviderUtils {
/**
* Creates a cursor over the locations in the track points provider which
* iterates over a given range of unique ids.
- * Caller gets to own the returned cursor. Don't forget to close it.
+ * Caller owns the returned cursor and is responsible for closing it.
*
* @param trackId the id of the track for which to get the points
* @param minTrackPointId the minimum id for the track points
@@ -168,7 +168,7 @@ public interface MyTracksProviderUtils {
/**
* Creates a cursor over the waypoints of a track.
- * Caller gets to own the returned cursor. Don't forget to close it.
+ * Caller owns the returned cursor and is responsible for closing it.
*
* @param trackId the id of the track for which to get the points
* @param minWaypointId the minimum id for the track points
@@ -180,7 +180,7 @@ public interface MyTracksProviderUtils {
/**
* Creates a cursor over waypoints with the given selection.
- * Caller gets to own the returned cursor. Don't forget to close it.
+ * Caller owns the returned cursor and is responsible for closing it.
*
* @param selection a given selection
* @param selectionArgs arguments for the given selection
@@ -211,7 +211,7 @@ public interface MyTracksProviderUtils {
/**
* Creates a cursor over the tracks provider with a given selection.
- * Caller gets to own the returned cursor. Don't forget to close it.
+ * Caller owns the returned cursor and is responsible for closing it.
*
* @param selection a given selection
* @param selecttionArgs parameters for the given selection