Add indexing for Notifications preferences
- also add indexing of CheckBoxPreferences - also some code cleaning Change-Id: I2943caaec3d64fb2a6be85168454fc76fe572afe
This commit is contained in:
@@ -386,16 +386,13 @@ public class SettingsActivity extends Activity
|
|||||||
// Cache the search query (can be overriden by the OnQueryTextListener)
|
// Cache the search query (can be overriden by the OnQueryTextListener)
|
||||||
final String query = mSearchQuery;
|
final String query = mSearchQuery;
|
||||||
|
|
||||||
// Associate searchable configuration with the SearchView
|
mSearchMenuItem = menu.findItem(R.id.search);
|
||||||
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
|
mSearchView = (SearchView) mSearchMenuItem.getActionView();
|
||||||
mSearchView = (SearchView) menu.findItem(R.id.search).getActionView();
|
|
||||||
|
|
||||||
|
mSearchMenuItem.setOnActionExpandListener(this);
|
||||||
mSearchView.setOnQueryTextListener(this);
|
mSearchView.setOnQueryTextListener(this);
|
||||||
mSearchView.setOnCloseListener(this);
|
mSearchView.setOnCloseListener(this);
|
||||||
|
|
||||||
mSearchMenuItem = menu.findItem(R.id.search);
|
|
||||||
mSearchMenuItem.setOnActionExpandListener(this);
|
|
||||||
|
|
||||||
if (mSearchMenuItemExpanded) {
|
if (mSearchMenuItemExpanded) {
|
||||||
mSearchMenuItem.expandActionView();
|
mSearchMenuItem.expandActionView();
|
||||||
}
|
}
|
||||||
|
@@ -195,14 +195,17 @@ public class SearchResultsSummary extends Fragment {
|
|||||||
|
|
||||||
private static class SearchResult {
|
private static class SearchResult {
|
||||||
public String title;
|
public String title;
|
||||||
public String summary;
|
public String summaryOn;
|
||||||
|
public String summaryOff;
|
||||||
public int iconResId;
|
public int iconResId;
|
||||||
public Context context;
|
public Context context;
|
||||||
|
|
||||||
public SearchResult(Context context, String title, String summary, int iconResId) {
|
public SearchResult(Context context, String title, String summaryOn, String summaryOff,
|
||||||
|
int iconResId) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.summary = summary;
|
this.summaryOn = summaryOn;
|
||||||
|
this.summaryOff = summaryOff;
|
||||||
this.iconResId = iconResId;
|
this.iconResId = iconResId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -247,7 +250,8 @@ public class SearchResultsSummary extends Fragment {
|
|||||||
public Object getItem(int position) {
|
public Object getItem(int position) {
|
||||||
if (mDataValid && mCursor.moveToPosition(position)) {
|
if (mDataValid && mCursor.moveToPosition(position)) {
|
||||||
final String title = mCursor.getString(Index.COLUMN_INDEX_TITLE);
|
final String title = mCursor.getString(Index.COLUMN_INDEX_TITLE);
|
||||||
final String summary = mCursor.getString(Index.COLUMN_INDEX_SUMMARY);
|
final String summaryOn = mCursor.getString(Index.COLUMN_INDEX_SUMMARY_ON);
|
||||||
|
final String summaryOff = mCursor.getString(Index.COLUMN_INDEX_SUMMARY_OFF);
|
||||||
final String iconResStr = mCursor.getString(Index.COLUMN_INDEX_ICON);
|
final String iconResStr = mCursor.getString(Index.COLUMN_INDEX_ICON);
|
||||||
final String className = mCursor.getString(
|
final String className = mCursor.getString(
|
||||||
Index.COLUMN_INDEX_CLASS_NAME);
|
Index.COLUMN_INDEX_CLASS_NAME);
|
||||||
@@ -271,7 +275,7 @@ public class SearchResultsSummary extends Fragment {
|
|||||||
}
|
}
|
||||||
final int iconResId = TextUtils.isEmpty(iconResStr) ?
|
final int iconResId = TextUtils.isEmpty(iconResStr) ?
|
||||||
R.drawable.empty_icon : Integer.parseInt(iconResStr);
|
R.drawable.empty_icon : Integer.parseInt(iconResStr);
|
||||||
return new SearchResult(packageContext, title, summary, iconResId);
|
return new SearchResult(packageContext, title, summaryOn, summaryOff, iconResId);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -308,7 +312,12 @@ public class SearchResultsSummary extends Fragment {
|
|||||||
SearchResult result = (SearchResult) getItem(position);
|
SearchResult result = (SearchResult) getItem(position);
|
||||||
|
|
||||||
textTitle.setText(result.title);
|
textTitle.setText(result.title);
|
||||||
textSummary.setText(result.summary);
|
final StringBuilder sb = new StringBuilder(result.summaryOn);
|
||||||
|
if (!TextUtils.isEmpty(result.summaryOff)) {
|
||||||
|
sb.append(" | ");
|
||||||
|
sb.append(result.summaryOff);
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
@@ -58,34 +58,39 @@ public class Index {
|
|||||||
|
|
||||||
// Those indices should match the indices of SELECT_COLUMNS !
|
// Those indices should match the indices of SELECT_COLUMNS !
|
||||||
public static final int COLUMN_INDEX_TITLE = 1;
|
public static final int COLUMN_INDEX_TITLE = 1;
|
||||||
public static final int COLUMN_INDEX_SUMMARY = 2;
|
public static final int COLUMN_INDEX_SUMMARY_ON = 2;
|
||||||
public static final int COLUMN_INDEX_CLASS_NAME = 4;
|
public static final int COLUMN_INDEX_SUMMARY_OFF = 3;
|
||||||
public static final int COLUMN_INDEX_SCREEN_TITLE = 5;
|
public static final int COLUMN_INDEX_KEYWORDS = 4;
|
||||||
public static final int COLUMN_INDEX_ICON = 6;
|
public static final int COLUMN_INDEX_CLASS_NAME = 5;
|
||||||
public static final int COLUMN_INDEX_INTENT_ACTION = 7;
|
public static final int COLUMN_INDEX_SCREEN_TITLE = 6;
|
||||||
public static final int COLUMN_INDEX_INTENT_ACTION_TARGET_PACKAGE = 8;
|
public static final int COLUMN_INDEX_ICON = 7;
|
||||||
public static final int COLUMN_INDEX_INTENT_ACTION_TARGET_CLASS = 9;
|
public static final int COLUMN_INDEX_INTENT_ACTION = 8;
|
||||||
public static final int COLUMN_INDEX_ENABLED = 10;
|
public static final int COLUMN_INDEX_INTENT_ACTION_TARGET_PACKAGE = 9;
|
||||||
|
public static final int COLUMN_INDEX_INTENT_ACTION_TARGET_CLASS = 10;
|
||||||
|
public static final int COLUMN_INDEX_ENABLED = 11;
|
||||||
|
|
||||||
// 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,
|
IndexColumns.DATA_RANK, // 0
|
||||||
IndexColumns.DATA_TITLE,
|
IndexColumns.DATA_TITLE, // 1
|
||||||
IndexColumns.DATA_SUMMARY,
|
IndexColumns.DATA_SUMMARY_ON, // 2
|
||||||
IndexColumns.DATA_KEYWORDS,
|
IndexColumns.DATA_SUMMARY_OFF, // 3
|
||||||
IndexColumns.CLASS_NAME,
|
IndexColumns.DATA_KEYWORDS, // 4
|
||||||
IndexColumns.SCREEN_TITLE,
|
IndexColumns.CLASS_NAME, // 5
|
||||||
IndexColumns.ICON,
|
IndexColumns.SCREEN_TITLE, // 6
|
||||||
IndexColumns.INTENT_ACTION,
|
IndexColumns.ICON, // 7
|
||||||
IndexColumns.INTENT_TARGET_PACKAGE,
|
IndexColumns.INTENT_ACTION, // 8
|
||||||
IndexColumns.INTENT_TARGET_CLASS
|
IndexColumns.INTENT_TARGET_PACKAGE, // 9
|
||||||
|
IndexColumns.INTENT_TARGET_CLASS // 10
|
||||||
};
|
};
|
||||||
|
|
||||||
private static final String[] MATCH_COLUMNS = {
|
private static final String[] MATCH_COLUMNS = {
|
||||||
IndexColumns.DATA_TITLE,
|
IndexColumns.DATA_TITLE,
|
||||||
IndexColumns.DATA_TITLE_NORMALIZED,
|
IndexColumns.DATA_TITLE_NORMALIZED,
|
||||||
IndexColumns.DATA_SUMMARY,
|
IndexColumns.DATA_SUMMARY_ON,
|
||||||
IndexColumns.DATA_SUMMARY_NORMALIZED,
|
IndexColumns.DATA_SUMMARY_ON_NORMALIZED,
|
||||||
|
IndexColumns.DATA_SUMMARY_OFF,
|
||||||
|
IndexColumns.DATA_SUMMARY_OFF_NORMALIZED,
|
||||||
IndexColumns.DATA_KEYWORDS
|
IndexColumns.DATA_KEYWORDS
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -93,6 +98,12 @@ public class Index {
|
|||||||
private static final String NON_BREAKING_HYPHEN = "\u2011";
|
private static final String NON_BREAKING_HYPHEN = "\u2011";
|
||||||
private static final String HYPHEN = "-";
|
private static final String HYPHEN = "-";
|
||||||
|
|
||||||
|
private static final String FIELD_NAME_SEARCH_INDEX_DATA_PROVIDER =
|
||||||
|
"SEARCH_INDEX_DATA_PROVIDER";
|
||||||
|
|
||||||
|
private static final String NODE_NAME_PREFERENCE_SCREEN = "PreferenceScreen";
|
||||||
|
private static final String NODE_NAME_CHECK_BOX_PREFERENCE = "CheckBoxPreference";
|
||||||
|
|
||||||
private static Index sInstance;
|
private static Index sInstance;
|
||||||
private final AtomicBoolean mIsAvailable = new AtomicBoolean(false);
|
private final AtomicBoolean mIsAvailable = new AtomicBoolean(false);
|
||||||
private final UpdateData mDataToProcess = new UpdateData();
|
private final UpdateData mDataToProcess = new UpdateData();
|
||||||
@@ -335,22 +346,24 @@ public class Index {
|
|||||||
while (cursor.moveToNext()) {
|
while (cursor.moveToNext()) {
|
||||||
final int rank = cursor.getInt(0);
|
final int rank = cursor.getInt(0);
|
||||||
final String title = cursor.getString(1);
|
final String title = cursor.getString(1);
|
||||||
final String summary = cursor.getString(2);
|
final String summaryOn = cursor.getString(2);
|
||||||
final String keywords = cursor.getString(3);
|
final String summaryOff = cursor.getString(3);
|
||||||
|
final String keywords = cursor.getString(4);
|
||||||
|
|
||||||
final String screenTitle = cursor.getString(4);
|
final String screenTitle = cursor.getString(5);
|
||||||
|
|
||||||
final String className = cursor.getString(5);
|
final String className = cursor.getString(6);
|
||||||
final int iconResId = cursor.getInt(6);
|
final int iconResId = cursor.getInt(7);
|
||||||
|
|
||||||
final String action = cursor.getString(7);
|
final String action = cursor.getString(8);
|
||||||
final String targetPackage = cursor.getString(8);
|
final String targetPackage = cursor.getString(9);
|
||||||
final String targetClass = cursor.getString(9);
|
final String targetClass = cursor.getString(10);
|
||||||
|
|
||||||
SearchIndexableRaw data = new SearchIndexableRaw(packageContext);
|
SearchIndexableRaw data = new SearchIndexableRaw(packageContext);
|
||||||
data.rank = rank;
|
data.rank = rank;
|
||||||
data.title = title;
|
data.title = title;
|
||||||
data.summary = summary;
|
data.summaryOn = summaryOn;
|
||||||
|
data.summaryOff = summaryOff;
|
||||||
data.keywords = keywords;
|
data.keywords = keywords;
|
||||||
data.screenTitle = screenTitle;
|
data.screenTitle = screenTitle;
|
||||||
data.className = className;
|
data.className = className;
|
||||||
@@ -458,7 +471,7 @@ public class Index {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String nodeName = parser.getName();
|
String nodeName = parser.getName();
|
||||||
if (!"PreferenceScreen".equals(nodeName)) {
|
if (!NODE_NAME_PREFERENCE_SCREEN.equals(nodeName)) {
|
||||||
throw new RuntimeException(
|
throw new RuntimeException(
|
||||||
"XML document must start with <PreferenceScreen> tag; found"
|
"XML document must start with <PreferenceScreen> tag; found"
|
||||||
+ nodeName + " at " + parser.getPositionDescription());
|
+ nodeName + " at " + parser.getPositionDescription());
|
||||||
@@ -474,7 +487,7 @@ public class Index {
|
|||||||
|
|
||||||
// Insert rows for the main PreferenceScreen node. Rewrite the data for removing
|
// Insert rows for the main PreferenceScreen node. Rewrite the data for removing
|
||||||
// hyphens.
|
// hyphens.
|
||||||
updateOneRowWithFilteredData(database, localeStr, title, summary, fragmentName,
|
updateOneRowWithFilteredData(database, localeStr, title, summary, null, fragmentName,
|
||||||
screenTitle, iconResId, rank, keywords,
|
screenTitle, iconResId, rank, keywords,
|
||||||
intentAction, intentTargetPackage, intentTargetClass, true);
|
intentAction, intentTargetPackage, intentTargetClass, true);
|
||||||
|
|
||||||
@@ -484,14 +497,26 @@ public class Index {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nodeName = parser.getName();
|
||||||
|
|
||||||
title = getDataTitle(context, attrs);
|
title = getDataTitle(context, attrs);
|
||||||
summary = getDataSummary(context, attrs);
|
|
||||||
keywords = getDataKeywords(context, attrs);
|
keywords = getDataKeywords(context, attrs);
|
||||||
|
|
||||||
|
if (!nodeName.equals(NODE_NAME_CHECK_BOX_PREFERENCE)) {
|
||||||
|
summary = getDataSummary(context, attrs);
|
||||||
|
|
||||||
// Insert rows for the child nodes of PreferenceScreen
|
// Insert rows for the child nodes of PreferenceScreen
|
||||||
updateOneRowWithFilteredData(database, localeStr, title, summary, fragmentName,
|
updateOneRowWithFilteredData(database, localeStr, title, summary, null,
|
||||||
screenTitle, iconResId, rank, keywords,
|
fragmentName, screenTitle, iconResId, rank, keywords,
|
||||||
intentAction, intentTargetPackage, intentTargetClass, true);
|
intentAction, intentTargetPackage, intentTargetClass, true);
|
||||||
|
} else {
|
||||||
|
final String summaryOn = getDataSummaryOn(context, attrs);
|
||||||
|
final String summaryOff = getDataSummaryOff(context, attrs);
|
||||||
|
|
||||||
|
updateOneRowWithFilteredData(database, localeStr, title, summaryOn, summaryOff,
|
||||||
|
fragmentName, screenTitle, iconResId, rank, keywords,
|
||||||
|
intentAction, intentTargetPackage, intentTargetClass, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (XmlPullParserException e) {
|
} catch (XmlPullParserException e) {
|
||||||
@@ -512,7 +537,8 @@ public class Index {
|
|||||||
|
|
||||||
updateOneRowWithFilteredData(database, localeStr,
|
updateOneRowWithFilteredData(database, localeStr,
|
||||||
raw.title,
|
raw.title,
|
||||||
raw.summary,
|
raw.summaryOn,
|
||||||
|
raw.summaryOff,
|
||||||
raw.className,
|
raw.className,
|
||||||
raw.screenTitle,
|
raw.screenTitle,
|
||||||
raw.iconResId,
|
raw.iconResId,
|
||||||
@@ -529,7 +555,7 @@ public class Index {
|
|||||||
try {
|
try {
|
||||||
final Class<?> clazz = Class.forName(sir.className);
|
final Class<?> clazz = Class.forName(sir.className);
|
||||||
if (Indexable.class.isAssignableFrom(clazz)) {
|
if (Indexable.class.isAssignableFrom(clazz)) {
|
||||||
final Field f = clazz.getField("SEARCH_INDEX_DATA_PROVIDER");
|
final Field f = clazz.getField(FIELD_NAME_SEARCH_INDEX_DATA_PROVIDER);
|
||||||
final Indexable.SearchIndexProvider provider =
|
final Indexable.SearchIndexProvider provider =
|
||||||
(Indexable.SearchIndexProvider) f.get(null);
|
(Indexable.SearchIndexProvider) f.get(null);
|
||||||
|
|
||||||
@@ -547,7 +573,8 @@ public class Index {
|
|||||||
|
|
||||||
updateOneRowWithFilteredData(database, localeStr,
|
updateOneRowWithFilteredData(database, localeStr,
|
||||||
raw.title,
|
raw.title,
|
||||||
raw.summary,
|
raw.summaryOn,
|
||||||
|
raw.summaryOff,
|
||||||
sir.className,
|
sir.className,
|
||||||
raw.screenTitle,
|
raw.screenTitle,
|
||||||
sir.iconResId,
|
sir.iconResId,
|
||||||
@@ -582,14 +609,15 @@ public class Index {
|
|||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
Log.e(LOG_TAG, "Cannot find class: " + sir.className, e);
|
Log.e(LOG_TAG, "Cannot find class: " + sir.className, e);
|
||||||
} catch (NoSuchFieldException e) {
|
} catch (NoSuchFieldException e) {
|
||||||
Log.e(LOG_TAG, "Cannot find field 'SEARCH_INDEX_DATA_PROVIDER'", e);
|
Log.e(LOG_TAG, "Cannot find field '" + FIELD_NAME_SEARCH_INDEX_DATA_PROVIDER + "'", e);
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
Log.e(LOG_TAG, "Illegal access to field 'SEARCH_INDEX_DATA_PROVIDER'", e);
|
Log.e(LOG_TAG,
|
||||||
|
"Illegal access to field '" + FIELD_NAME_SEARCH_INDEX_DATA_PROVIDER + "'", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateOneRowWithFilteredData(SQLiteDatabase database, String locale,
|
private void updateOneRowWithFilteredData(SQLiteDatabase database, String locale,
|
||||||
String title, String summary, String className, String screenTitle,
|
String title, String summaryOn, String summaryOff, String className, String screenTitle,
|
||||||
int iconResId, int rank, String keywords,
|
int iconResId, int rank, String keywords,
|
||||||
String intentAction, String intentTargetPackage, String intentTargetClass,
|
String intentAction, String intentTargetPackage, String intentTargetClass,
|
||||||
boolean enabled) {
|
boolean enabled) {
|
||||||
@@ -602,27 +630,35 @@ public class Index {
|
|||||||
updatedTitle = EMPTY;
|
updatedTitle = EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
String updatedSummary;
|
String updatedSummaryOn;
|
||||||
if (summary != null) {
|
if (summaryOn != null) {
|
||||||
updatedSummary = summary.replaceAll(NON_BREAKING_HYPHEN, HYPHEN);
|
updatedSummaryOn = summaryOn.replaceAll(NON_BREAKING_HYPHEN, HYPHEN);
|
||||||
} else {
|
} else {
|
||||||
updatedSummary = EMPTY;
|
updatedSummaryOn = EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
String updatedSummaryOff;
|
||||||
|
if (summaryOff != null) {
|
||||||
|
updatedSummaryOff = summaryOff.replaceAll(NON_BREAKING_HYPHEN, HYPHEN);
|
||||||
|
} else {
|
||||||
|
updatedSummaryOff = EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
String normalizedTitle = updatedTitle.replaceAll(HYPHEN, EMPTY);
|
String normalizedTitle = updatedTitle.replaceAll(HYPHEN, EMPTY);
|
||||||
String normalizedSummary = updatedSummary.replaceAll(HYPHEN, EMPTY);
|
String normalizedSummaryOn = updatedSummaryOn.replaceAll(HYPHEN, EMPTY);
|
||||||
|
String normalizedSummaryOff = updatedSummaryOff.replaceAll(HYPHEN, EMPTY);
|
||||||
|
|
||||||
updateOneRow(database, locale,
|
updateOneRow(database, locale,
|
||||||
updatedTitle, normalizedTitle, updatedSummary, normalizedSummary,
|
updatedTitle, normalizedTitle, updatedSummaryOn, normalizedSummaryOn,
|
||||||
className, screenTitle, iconResId, rank, keywords,
|
updatedSummaryOff, normalizedSummaryOff, className, screenTitle, iconResId,
|
||||||
intentAction, intentTargetPackage, intentTargetClass, enabled);
|
rank, keywords, intentAction, intentTargetPackage, intentTargetClass, enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateOneRow(SQLiteDatabase database, String locale,
|
private void updateOneRow(SQLiteDatabase database, String locale,
|
||||||
String updatedTitle, String normalizedTitle,
|
String updatedTitle, String normalizedTitle,
|
||||||
String updatedSummary, String normalizedSummary,
|
String updatedSummaryOn, String normalizedSummaryOn,
|
||||||
String className, String screenTitle,
|
String updatedSummaryOff, String normalizedSummaryOff, String className,
|
||||||
int iconResId, int rank, String keywords,
|
String screenTitle, int iconResId, int rank, String keywords,
|
||||||
String intentAction, String intentTargetPackage, String intentTargetClass,
|
String intentAction, String intentTargetPackage, String intentTargetClass,
|
||||||
boolean enabled) {
|
boolean enabled) {
|
||||||
|
|
||||||
@@ -636,8 +672,10 @@ public class Index {
|
|||||||
values.put(IndexColumns.DATA_RANK, rank);
|
values.put(IndexColumns.DATA_RANK, rank);
|
||||||
values.put(IndexColumns.DATA_TITLE, updatedTitle);
|
values.put(IndexColumns.DATA_TITLE, updatedTitle);
|
||||||
values.put(IndexColumns.DATA_TITLE_NORMALIZED, normalizedTitle);
|
values.put(IndexColumns.DATA_TITLE_NORMALIZED, normalizedTitle);
|
||||||
values.put(IndexColumns.DATA_SUMMARY, updatedSummary);
|
values.put(IndexColumns.DATA_SUMMARY_ON, updatedSummaryOn);
|
||||||
values.put(IndexColumns.DATA_SUMMARY_NORMALIZED, normalizedSummary);
|
values.put(IndexColumns.DATA_SUMMARY_ON_NORMALIZED, normalizedSummaryOn);
|
||||||
|
values.put(IndexColumns.DATA_SUMMARY_OFF, updatedSummaryOff);
|
||||||
|
values.put(IndexColumns.DATA_SUMMARY_OFF_NORMALIZED, normalizedSummaryOff);
|
||||||
values.put(IndexColumns.DATA_KEYWORDS, keywords);
|
values.put(IndexColumns.DATA_KEYWORDS, keywords);
|
||||||
values.put(IndexColumns.CLASS_NAME, className);
|
values.put(IndexColumns.CLASS_NAME, className);
|
||||||
values.put(IndexColumns.SCREEN_TITLE, screenTitle);
|
values.put(IndexColumns.SCREEN_TITLE, screenTitle);
|
||||||
@@ -662,6 +700,18 @@ public class Index {
|
|||||||
com.android.internal.R.styleable.Preference_summary);
|
com.android.internal.R.styleable.Preference_summary);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getDataSummaryOn(Context context, AttributeSet attrs) {
|
||||||
|
return getData(context, attrs,
|
||||||
|
com.android.internal.R.styleable.CheckBoxPreference,
|
||||||
|
com.android.internal.R.styleable.CheckBoxPreference_summaryOn);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getDataSummaryOff(Context context, AttributeSet attrs) {
|
||||||
|
return getData(context, attrs,
|
||||||
|
com.android.internal.R.styleable.CheckBoxPreference,
|
||||||
|
com.android.internal.R.styleable.CheckBoxPreference_summaryOff);
|
||||||
|
}
|
||||||
|
|
||||||
private String getDataKeywords(Context context, AttributeSet attrs) {
|
private String getDataKeywords(Context context, AttributeSet attrs) {
|
||||||
return getData(context, attrs, R.styleable.Preference, R.styleable.Preference_keywords);
|
return getData(context, attrs, R.styleable.Preference, R.styleable.Preference_keywords);
|
||||||
}
|
}
|
||||||
|
@@ -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 = 103;
|
private static final int DATABASE_VERSION = 104;
|
||||||
|
|
||||||
public interface Tables {
|
public interface Tables {
|
||||||
public static final String TABLE_PREFS_INDEX = "prefs_index";
|
public static final String TABLE_PREFS_INDEX = "prefs_index";
|
||||||
@@ -41,8 +41,10 @@ public class IndexDatabaseHelper extends SQLiteOpenHelper {
|
|||||||
public static final String DATA_RANK = "data_rank";
|
public static final String DATA_RANK = "data_rank";
|
||||||
public static final String DATA_TITLE = "data_title";
|
public static final String DATA_TITLE = "data_title";
|
||||||
public static final String DATA_TITLE_NORMALIZED = "data_title_normalized";
|
public static final String DATA_TITLE_NORMALIZED = "data_title_normalized";
|
||||||
public static final String DATA_SUMMARY = "data_summary";
|
public static final String DATA_SUMMARY_ON = "data_summary_on";
|
||||||
public static final String DATA_SUMMARY_NORMALIZED = "data_summary_normalized";
|
public static final String DATA_SUMMARY_ON_NORMALIZED = "data_summary_on_normalized";
|
||||||
|
public static final String DATA_SUMMARY_OFF = "data_summary_off";
|
||||||
|
public static final String DATA_SUMMARY_OFF_NORMALIZED = "data_summary_off_normalized";
|
||||||
public static final String DATA_KEYWORDS = "data_keywords";
|
public static final String DATA_KEYWORDS = "data_keywords";
|
||||||
public static final String CLASS_NAME = "class_name";
|
public static final String CLASS_NAME = "class_name";
|
||||||
public static final String SCREEN_TITLE = "screen_title";
|
public static final String SCREEN_TITLE = "screen_title";
|
||||||
@@ -68,9 +70,13 @@ public class IndexDatabaseHelper extends SQLiteOpenHelper {
|
|||||||
", " +
|
", " +
|
||||||
IndexColumns.DATA_TITLE_NORMALIZED +
|
IndexColumns.DATA_TITLE_NORMALIZED +
|
||||||
", " +
|
", " +
|
||||||
IndexColumns.DATA_SUMMARY +
|
IndexColumns.DATA_SUMMARY_ON +
|
||||||
", " +
|
", " +
|
||||||
IndexColumns.DATA_SUMMARY_NORMALIZED +
|
IndexColumns.DATA_SUMMARY_ON_NORMALIZED +
|
||||||
|
", " +
|
||||||
|
IndexColumns.DATA_SUMMARY_OFF +
|
||||||
|
", " +
|
||||||
|
IndexColumns.DATA_SUMMARY_OFF_NORMALIZED +
|
||||||
", " +
|
", " +
|
||||||
IndexColumns.DATA_KEYWORDS +
|
IndexColumns.DATA_KEYWORDS +
|
||||||
", " +
|
", " +
|
||||||
@@ -129,9 +135,9 @@ public class IndexDatabaseHelper extends SQLiteOpenHelper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||||
if (oldVersion == 100 || oldVersion == 101 || oldVersion == 102) {
|
if (oldVersion == 100 || oldVersion == 101 || oldVersion == 102 || oldVersion == 103) {
|
||||||
Log.w(TAG, "Detected schema version 100, 101 or 102. " +
|
Log.w(TAG, "Detected schema version 100, 101, 102 or 103. " +
|
||||||
"Index needs to be rebuilt for schema version 103");
|
"Index needs to be rebuilt for schema version 104");
|
||||||
// We need to drop the tables and recreate them
|
// We need to drop the tables and recreate them
|
||||||
dropTables(db);
|
dropTables(db);
|
||||||
bootstrapDB(db);
|
bootstrapDB(db);
|
||||||
|
@@ -29,7 +29,8 @@ import android.provider.SearchIndexableData;
|
|||||||
public class SearchIndexableRaw extends SearchIndexableData {
|
public class SearchIndexableRaw extends SearchIndexableData {
|
||||||
|
|
||||||
public String title;
|
public String title;
|
||||||
public String summary;
|
public String summaryOn;
|
||||||
|
public String summaryOff;
|
||||||
public String keywords;
|
public String keywords;
|
||||||
|
|
||||||
public String screenTitle;
|
public String screenTitle;
|
||||||
|
@@ -22,6 +22,8 @@ import com.android.settings.DevelopmentSettings;
|
|||||||
import com.android.settings.DeviceInfoSettings;
|
import com.android.settings.DeviceInfoSettings;
|
||||||
import com.android.settings.DisplaySettings;
|
import com.android.settings.DisplaySettings;
|
||||||
import com.android.settings.HomeSettings;
|
import com.android.settings.HomeSettings;
|
||||||
|
import com.android.settings.NotificationAccessSettings;
|
||||||
|
import com.android.settings.NotificationSettings;
|
||||||
import com.android.settings.PrivacySettings;
|
import com.android.settings.PrivacySettings;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.SecuritySettings;
|
import com.android.settings.SecuritySettings;
|
||||||
@@ -47,110 +49,137 @@ public final class SearchIndexableResources {
|
|||||||
|
|
||||||
private static int NO_DATA_RES_ID = 0;
|
private static int NO_DATA_RES_ID = 0;
|
||||||
|
|
||||||
|
private static final int RANK_WIFI = 1;
|
||||||
|
private static final int RANK_BT = 2;
|
||||||
|
private static final int RANK_DATA_USAGE = 3;
|
||||||
|
private static final int RANK_WIRELESS = 4;
|
||||||
|
private static final int RANK_HOME = 5;
|
||||||
|
private static final int RANK_SOUND = 6;
|
||||||
|
private static final int RANK_DISPLAY = 7;
|
||||||
|
private static final int RANK_WALLPAPER = 7;
|
||||||
|
private static final int RANK_NOTIFICATIONS = 8;
|
||||||
|
private static final int RANK_MEMORY = 9;
|
||||||
|
private static final int RANK_POWER_USAGE = 10;
|
||||||
|
private static final int RANK_USERS = 11;
|
||||||
|
private static final int RANK_LOCATION = 12;
|
||||||
|
private static final int RANK_SECURITY = 13;
|
||||||
|
private static final int RANK_IME = 14;
|
||||||
|
private static final int RANK_PRIVACY = 15;
|
||||||
|
private static final int RANK_DATE_TIME = 16;
|
||||||
|
private static final int RANK_ACCESSIBILITY = 17;
|
||||||
|
private static final int RANK_PRINTING = 18;
|
||||||
|
private static final int RANK_DEVELOPEMENT = 19;
|
||||||
|
private static final int RANK_DEVICE_INFO = 20;
|
||||||
|
|
||||||
private static HashMap<String, SearchIndexableResource> sResMap =
|
private static HashMap<String, SearchIndexableResource> sResMap =
|
||||||
new HashMap<String, SearchIndexableResource>();
|
new HashMap<String, SearchIndexableResource>();
|
||||||
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
sResMap.put(WifiSettings.class.getName(),
|
sResMap.put(WifiSettings.class.getName(),
|
||||||
new SearchIndexableResource(1,
|
new SearchIndexableResource(RANK_WIFI,
|
||||||
NO_DATA_RES_ID,
|
NO_DATA_RES_ID,
|
||||||
WifiSettings.class.getName(),
|
WifiSettings.class.getName(),
|
||||||
R.drawable.ic_settings_wireless));
|
R.drawable.ic_settings_wireless));
|
||||||
|
|
||||||
sResMap.put(BluetoothSettings.class.getName(),
|
sResMap.put(BluetoothSettings.class.getName(),
|
||||||
new SearchIndexableResource(2,
|
new SearchIndexableResource(RANK_BT,
|
||||||
NO_DATA_RES_ID,
|
NO_DATA_RES_ID,
|
||||||
BluetoothSettings.class.getName(),
|
BluetoothSettings.class.getName(),
|
||||||
R.drawable.ic_settings_bluetooth2));
|
R.drawable.ic_settings_bluetooth2));
|
||||||
|
|
||||||
sResMap.put(DataUsageMeteredSettings.class.getName(),
|
sResMap.put(DataUsageMeteredSettings.class.getName(),
|
||||||
new SearchIndexableResource(3, R.xml.data_usage_metered_prefs,
|
new SearchIndexableResource(RANK_DATA_USAGE, R.xml.data_usage_metered_prefs,
|
||||||
DataUsageMeteredSettings.class.getName(),
|
DataUsageMeteredSettings.class.getName(),
|
||||||
R.drawable.ic_settings_data_usage));
|
R.drawable.ic_settings_data_usage));
|
||||||
|
|
||||||
sResMap.put(WirelessSettings.class.getName(),
|
sResMap.put(WirelessSettings.class.getName(),
|
||||||
new SearchIndexableResource(4, R.xml.wireless_settings,
|
new SearchIndexableResource(RANK_WIRELESS, R.xml.wireless_settings,
|
||||||
WirelessSettings.class.getName(),
|
WirelessSettings.class.getName(),
|
||||||
R.drawable.empty_icon));
|
R.drawable.empty_icon));
|
||||||
|
|
||||||
sResMap.put(HomeSettings.class.getName(),
|
sResMap.put(HomeSettings.class.getName(),
|
||||||
new SearchIndexableResource(5, R.xml.home_selection,
|
new SearchIndexableResource(RANK_HOME, R.xml.home_selection,
|
||||||
HomeSettings.class.getName(),
|
HomeSettings.class.getName(),
|
||||||
R.drawable.ic_settings_home));
|
R.drawable.ic_settings_home));
|
||||||
|
|
||||||
sResMap.put(SoundSettings.class.getName(),
|
sResMap.put(SoundSettings.class.getName(),
|
||||||
new SearchIndexableResource(6, R.xml.sound_settings,
|
new SearchIndexableResource(RANK_SOUND, R.xml.sound_settings,
|
||||||
SoundSettings.class.getName(),
|
SoundSettings.class.getName(),
|
||||||
R.drawable.ic_settings_sound));
|
R.drawable.ic_settings_sound));
|
||||||
|
|
||||||
sResMap.put(DisplaySettings.class.getName(),
|
sResMap.put(DisplaySettings.class.getName(),
|
||||||
new SearchIndexableResource(7, R.xml.display_settings,
|
new SearchIndexableResource(RANK_DISPLAY, R.xml.display_settings,
|
||||||
DisplaySettings.class.getName(),
|
DisplaySettings.class.getName(),
|
||||||
R.drawable.ic_settings_display));
|
R.drawable.ic_settings_display));
|
||||||
|
|
||||||
sResMap.put(WallpaperTypeSettings.class.getName(),
|
sResMap.put(WallpaperTypeSettings.class.getName(),
|
||||||
new SearchIndexableResource(7, NO_DATA_RES_ID,
|
new SearchIndexableResource(RANK_WALLPAPER, NO_DATA_RES_ID,
|
||||||
WallpaperTypeSettings.class.getName(),
|
WallpaperTypeSettings.class.getName(),
|
||||||
R.drawable.ic_settings_display));
|
R.drawable.ic_settings_display));
|
||||||
|
|
||||||
|
sResMap.put(NotificationSettings.class.getName(),
|
||||||
|
new SearchIndexableResource(RANK_NOTIFICATIONS, R.xml.notification_settings,
|
||||||
|
NotificationSettings.class.getName(),
|
||||||
|
R.drawable.ic_settings_notifications));
|
||||||
|
|
||||||
sResMap.put(Memory.class.getName(),
|
sResMap.put(Memory.class.getName(),
|
||||||
new SearchIndexableResource(8, R.xml.device_info_memory,
|
new SearchIndexableResource(RANK_MEMORY, R.xml.device_info_memory,
|
||||||
Memory.class.getName(),
|
Memory.class.getName(),
|
||||||
R.drawable.ic_settings_storage));
|
R.drawable.ic_settings_storage));
|
||||||
|
|
||||||
sResMap.put(PowerUsageSummary.class.getName(),
|
sResMap.put(PowerUsageSummary.class.getName(),
|
||||||
new SearchIndexableResource(9, R.xml.power_usage_summary,
|
new SearchIndexableResource(RANK_POWER_USAGE, R.xml.power_usage_summary,
|
||||||
PowerUsageSummary.class.getName(),
|
PowerUsageSummary.class.getName(),
|
||||||
R.drawable.ic_settings_battery));
|
R.drawable.ic_settings_battery));
|
||||||
|
|
||||||
sResMap.put(UserSettings.class.getName(),
|
sResMap.put(UserSettings.class.getName(),
|
||||||
new SearchIndexableResource(10, R.xml.user_settings,
|
new SearchIndexableResource(RANK_USERS, R.xml.user_settings,
|
||||||
UserSettings.class.getName(),
|
UserSettings.class.getName(),
|
||||||
R.drawable.ic_settings_multiuser));
|
R.drawable.ic_settings_multiuser));
|
||||||
|
|
||||||
sResMap.put(LocationSettings.class.getName(),
|
sResMap.put(LocationSettings.class.getName(),
|
||||||
new SearchIndexableResource(11, R.xml.location_settings,
|
new SearchIndexableResource(RANK_LOCATION, R.xml.location_settings,
|
||||||
LocationSettings.class.getName(),
|
LocationSettings.class.getName(),
|
||||||
R.drawable.ic_settings_location));
|
R.drawable.ic_settings_location));
|
||||||
|
|
||||||
sResMap.put(SecuritySettings.class.getName(),
|
sResMap.put(SecuritySettings.class.getName(),
|
||||||
new SearchIndexableResource(12, R.xml.security_settings,
|
new SearchIndexableResource(RANK_SECURITY, R.xml.security_settings,
|
||||||
SecuritySettings.class.getName(),
|
SecuritySettings.class.getName(),
|
||||||
R.drawable.ic_settings_security));
|
R.drawable.ic_settings_security));
|
||||||
|
|
||||||
sResMap.put(InputMethodAndLanguageSettings.class.getName(),
|
sResMap.put(InputMethodAndLanguageSettings.class.getName(),
|
||||||
new SearchIndexableResource(13, R.xml.language_settings,
|
new SearchIndexableResource(RANK_IME, R.xml.language_settings,
|
||||||
InputMethodAndLanguageSettings.class.getName(),
|
InputMethodAndLanguageSettings.class.getName(),
|
||||||
R.drawable.ic_settings_language));
|
R.drawable.ic_settings_language));
|
||||||
|
|
||||||
sResMap.put(PrivacySettings.class.getName(),
|
sResMap.put(PrivacySettings.class.getName(),
|
||||||
new SearchIndexableResource(14, R.xml.privacy_settings,
|
new SearchIndexableResource(RANK_PRIVACY, R.xml.privacy_settings,
|
||||||
PrivacySettings.class.getName(),
|
PrivacySettings.class.getName(),
|
||||||
R.drawable.ic_settings_backup));
|
R.drawable.ic_settings_backup));
|
||||||
|
|
||||||
sResMap.put(DateTimeSettings.class.getName(),
|
sResMap.put(DateTimeSettings.class.getName(),
|
||||||
new SearchIndexableResource(15, R.xml.date_time_prefs,
|
new SearchIndexableResource(RANK_DATE_TIME, R.xml.date_time_prefs,
|
||||||
DateTimeSettings.class.getName(),
|
DateTimeSettings.class.getName(),
|
||||||
R.drawable.ic_settings_date_time));
|
R.drawable.ic_settings_date_time));
|
||||||
|
|
||||||
sResMap.put(AccessibilitySettings.class.getName(),
|
sResMap.put(AccessibilitySettings.class.getName(),
|
||||||
new SearchIndexableResource(16, R.xml.accessibility_settings,
|
new SearchIndexableResource(RANK_ACCESSIBILITY, R.xml.accessibility_settings,
|
||||||
AccessibilitySettings.class.getName(),
|
AccessibilitySettings.class.getName(),
|
||||||
R.drawable.ic_settings_accessibility));
|
R.drawable.ic_settings_accessibility));
|
||||||
|
|
||||||
sResMap.put(PrintSettingsFragment.class.getName(),
|
sResMap.put(PrintSettingsFragment.class.getName(),
|
||||||
new SearchIndexableResource(17, R.xml.print_settings,
|
new SearchIndexableResource(RANK_PRINTING, R.xml.print_settings,
|
||||||
PrintSettingsFragment.class.getName(),
|
PrintSettingsFragment.class.getName(),
|
||||||
com.android.internal.R.drawable.ic_print));
|
com.android.internal.R.drawable.ic_print));
|
||||||
|
|
||||||
sResMap.put(DevelopmentSettings.class.getName(),
|
sResMap.put(DevelopmentSettings.class.getName(),
|
||||||
new SearchIndexableResource(18, R.xml.development_prefs,
|
new SearchIndexableResource(RANK_DEVELOPEMENT, R.xml.development_prefs,
|
||||||
DevelopmentSettings.class.getName(),
|
DevelopmentSettings.class.getName(),
|
||||||
R.drawable.ic_settings_development));
|
R.drawable.ic_settings_development));
|
||||||
|
|
||||||
sResMap.put(DeviceInfoSettings.class.getName(),
|
sResMap.put(DeviceInfoSettings.class.getName(),
|
||||||
new SearchIndexableResource(19, R.xml.device_info_settings,
|
new SearchIndexableResource(RANK_DEVICE_INFO, R.xml.device_info_settings,
|
||||||
DeviceInfoSettings.class.getName(),
|
DeviceInfoSettings.class.getName(),
|
||||||
R.drawable.ic_settings_about));
|
R.drawable.ic_settings_about));
|
||||||
}
|
}
|
||||||
|
@@ -20,27 +20,6 @@ import android.database.Cursor;
|
|||||||
import android.database.MatrixCursor;
|
import android.database.MatrixCursor;
|
||||||
import android.provider.SearchIndexableResource;
|
import android.provider.SearchIndexableResource;
|
||||||
import android.provider.SearchIndexablesProvider;
|
import android.provider.SearchIndexablesProvider;
|
||||||
import com.android.settings.DateTimeSettings;
|
|
||||||
import com.android.settings.DevelopmentSettings;
|
|
||||||
import com.android.settings.DeviceInfoSettings;
|
|
||||||
import com.android.settings.DisplaySettings;
|
|
||||||
import com.android.settings.HomeSettings;
|
|
||||||
import com.android.settings.PrivacySettings;
|
|
||||||
import com.android.settings.R;
|
|
||||||
import com.android.settings.SecuritySettings;
|
|
||||||
import com.android.settings.SoundSettings;
|
|
||||||
import com.android.settings.WallpaperTypeSettings;
|
|
||||||
import com.android.settings.WirelessSettings;
|
|
||||||
import com.android.settings.accessibility.AccessibilitySettings;
|
|
||||||
import com.android.settings.bluetooth.BluetoothSettings;
|
|
||||||
import com.android.settings.deviceinfo.Memory;
|
|
||||||
import com.android.settings.fuelgauge.PowerUsageSummary;
|
|
||||||
import com.android.settings.inputmethod.InputMethodAndLanguageSettings;
|
|
||||||
import com.android.settings.location.LocationSettings;
|
|
||||||
import com.android.settings.net.DataUsageMeteredSettings;
|
|
||||||
import com.android.settings.print.PrintSettingsFragment;
|
|
||||||
import com.android.settings.users.UserSettings;
|
|
||||||
import com.android.settings.wifi.WifiSettings;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user