Adressing comments from f11312d2fdc6

This commit is contained in:
Rodrigo Damazio
2012-01-03 05:33:00 -02:00
parent c3912042e9
commit 5a3bcfa51a
4 changed files with 47 additions and 33 deletions
+18 -18
View File
@@ -1102,6 +1102,24 @@ limitations under the License.
Finished writing to the SD card.
</string>
<!-- Search interface -->
<string name="search_hint"
translation_description="The hint shown on the search box until the user types a search query.
See suggestion at http://developer.android.com/guide/topics/search/search-dialog.html about
keeping this consistent with other Android apps.">
Search My Tracks tracks and waypoints
</string>
<string name="search_global_description"
translation_description="Description of what is searched in My Tracks, to be displayed in the
global system search settings.">
My Tracks tracks and waypoints
</string>
<string name="search_voice_prompt"
translation_description="Prompt shown when the user activates voice search, asking him to
speak what will be searched for.">
Speak the name of a track or waypoint.
</string>
<!-- Send Google -->
<string name="send_google_by_my_tracks"
translation_description="When sending a track to Google, a note indicating it is created by
@@ -3322,22 +3340,4 @@ limitations under the License.
Screenshot: welcome.png">
What are waypoint markers?
</string>
<!-- Search interface -->
<string name="search_hint"
translation_description="The hint shown on the search box until the user types a search query.
See suggestion at http://developer.android.com/guide/topics/search/search-dialog.html about
keeping this consistent with other Android apps.">
Search My Tracks tracks and waypoints
</string>
<string name="search_global_description"
translation_description="Description of what is searched in My Tracks, to be displayed in the
global system search settings.">
My Tracks tracks and waypoints
</string>
<string name="search_voice_prompt"
translation_description="Prompt shown when the user activates voice search, asking him to
speak what will be searched for.">
Speak the name of a track or waypoint.
</string>
</resources>
+4 -4
View File
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:label="@string/my_tracks_app_name"
android:hint="@string/search_hint"
android:includeInGlobalSearch="true"
android:label="@string/my_tracks_app_name"
android:searchSettingsDescription="@string/search_global_description"
android:voiceSearchMode="showVoiceSearchButton|launchRecognizer"
android:voicePromptText="@string/search_voice_prompt">
<!-- TODO: Add search suggestions -->
android:voicePromptText="@string/search_voice_prompt"
android:voiceSearchMode="showVoiceSearchButton|launchRecognizer">
<!-- TODO: Add search suggestions -->
</searchable>
@@ -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);
}
}
@@ -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