Search results - just show the first item of ListPreference entries

- need to increment the database model version to force re-indexing
- change entries separator from SPACE to PIPE
- just show the first entries value in the Search results

Change-Id: I747218ff3528c3231c0209f8870c12f65e036070
This commit is contained in:
Fabrice Di Meglio
2014-04-15 14:03:19 -07:00
parent 7a6bfd132c
commit 8f5c65fd01
3 changed files with 14 additions and 6 deletions

View File

@@ -342,12 +342,18 @@ public class SearchResultsSummary extends Fragment {
!summaryOn.contains(PERCENT_RECLACE) && !summaryOn.contains(DOLLAR_REPLACE)) { !summaryOn.contains(PERCENT_RECLACE) && !summaryOn.contains(DOLLAR_REPLACE)) {
sb.append(summaryOn); sb.append(summaryOn);
sb.append(ELLIPSIS); sb.append(ELLIPSIS);
} } else if (!TextUtils.isEmpty(entries)) {
if (!TextUtils.isEmpty(entries)) { final int index = entries.indexOf(Index.ENTRIES_SEPARATOR);
sb.append(" \n "); if (index > 0) {
sb.append(entries); final String firstEntriesValue = entries.substring(0, index);
sb.append(firstEntriesValue);
} else {
sb.append(entries);
}
sb.append(ELLIPSIS);
} }
textSummary.setText(sb.toString()); textSummary.setText(sb.toString());
if (result.iconResId != R.drawable.empty_icon) { if (result.iconResId != R.drawable.empty_icon) {
final Context packageContext = result.context; final Context packageContext = result.context;
final Drawable drawable; final Drawable drawable;

View File

@@ -100,6 +100,8 @@ public class Index {
public static final int COLUMN_INDEX_ENABLED = 12; public static final int COLUMN_INDEX_ENABLED = 12;
public static final int COLUMN_INDEX_KEY = 13; public static final int COLUMN_INDEX_KEY = 13;
public static final String ENTRIES_SEPARATOR = "|";
// If you change the order of columns here, you SHOULD change the COLUMN_INDEX_XXX values // If you change the order of columns here, you SHOULD change the COLUMN_INDEX_XXX values
private static final String[] SELECT_COLUMNS = new String[] { private static final String[] SELECT_COLUMNS = new String[] {
IndexColumns.DATA_RANK, // 0 IndexColumns.DATA_RANK, // 0
@@ -994,7 +996,7 @@ public class Index {
final StringBuilder result = new StringBuilder(); final StringBuilder result = new StringBuilder();
for (int n = 0; n < count; n++) { for (int n = 0; n < count; n++) {
result.append(data[n]); result.append(data[n]);
result.append(" "); result.append(ENTRIES_SEPARATOR);
} }
return result.toString(); return result.toString();
} }

View File

@@ -28,7 +28,7 @@ public class IndexDatabaseHelper extends SQLiteOpenHelper {
private static final String TAG = "IndexDatabaseHelper"; private static final String TAG = "IndexDatabaseHelper";
private static final String DATABASE_NAME = "search_index.db"; private static final String DATABASE_NAME = "search_index.db";
private static final int DATABASE_VERSION = 108; private static final int DATABASE_VERSION = 109;
public interface Tables { public interface Tables {
public static final String TABLE_PREFS_INDEX = "prefs_index"; public static final String TABLE_PREFS_INDEX = "prefs_index";