summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/search
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/settings/search')
-rw-r--r--src/com/android/settings/search/Index.java48
-rw-r--r--src/com/android/settings/search/SearchIndexableResources.java7
2 files changed, 30 insertions, 25 deletions
diff --git a/src/com/android/settings/search/Index.java b/src/com/android/settings/search/Index.java
index 8ed607421..1b1825c4f 100644
--- a/src/com/android/settings/search/Index.java
+++ b/src/com/android/settings/search/Index.java
@@ -45,6 +45,7 @@ import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
import java.lang.reflect.Field;
+import java.text.Normalizer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
@@ -54,6 +55,7 @@ import java.util.Locale;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.regex.Pattern;
import static android.provider.SearchIndexablesContract.COLUMN_INDEX_NON_INDEXABLE_KEYS_KEY_VALUE;
import static android.provider.SearchIndexablesContract.COLUMN_INDEX_RAW_RANK;
@@ -150,8 +152,11 @@ public class Index {
private static final List<String> EMPTY_LIST = Collections.<String>emptyList();
-
private static Index sInstance;
+
+ private static final Pattern REMOVE_DIACRITICALS_PATTERN
+ = Pattern.compile("\\p{InCombiningDiacriticalMarks}+");
+
private final AtomicBoolean mIsAvailable = new AtomicBoolean(false);
private final UpdateData mDataToProcess = new UpdateData();
private Context mContext;
@@ -920,31 +925,13 @@ public class Index {
String intentAction, String intentTargetPackage, String intentTargetClass,
boolean enabled, String key) {
- String updatedTitle;
- if (title != null) {
- updatedTitle = title.replaceAll(NON_BREAKING_HYPHEN, HYPHEN);
- }
- else {
- updatedTitle = EMPTY;
- }
-
- String updatedSummaryOn;
- if (summaryOn != null) {
- updatedSummaryOn = summaryOn.replaceAll(NON_BREAKING_HYPHEN, HYPHEN);
- } else {
- updatedSummaryOn = EMPTY;
- }
-
- String updatedSummaryOff;
- if (summaryOff != null) {
- updatedSummaryOff = summaryOff.replaceAll(NON_BREAKING_HYPHEN, HYPHEN);
- } else {
- updatedSummaryOff = EMPTY;
- }
+ final String updatedTitle = normalizeHyphen(title);
+ final String updatedSummaryOn = normalizeHyphen(summaryOn);
+ final String updatedSummaryOff = normalizeHyphen(summaryOff);
- String normalizedTitle = updatedTitle.replaceAll(HYPHEN, EMPTY);
- String normalizedSummaryOn = updatedSummaryOn.replaceAll(HYPHEN, EMPTY);
- String normalizedSummaryOff = updatedSummaryOff.replaceAll(HYPHEN, EMPTY);
+ final String normalizedTitle = normalizeString(updatedTitle);
+ final String normalizedSummaryOn = normalizeString(updatedSummaryOn);
+ final String normalizedSummaryOff = normalizeString(updatedSummaryOff);
updateOneRow(database, locale,
updatedTitle, normalizedTitle, updatedSummaryOn, normalizedSummaryOn,
@@ -953,6 +940,17 @@ public class Index {
rank, keywords, intentAction, intentTargetPackage, intentTargetClass, enabled, key);
}
+ private static String normalizeHyphen(String input) {
+ return (input != null) ? input.replaceAll(NON_BREAKING_HYPHEN, HYPHEN) : EMPTY;
+ }
+
+ private static String normalizeString(String input) {
+ final String nohyphen = (input != null) ? input.replaceAll(HYPHEN, EMPTY) : EMPTY;
+ final String normalized = Normalizer.normalize(nohyphen, Normalizer.Form.NFD);
+
+ return REMOVE_DIACRITICALS_PATTERN.matcher(normalized).replaceAll("").toLowerCase();
+ }
+
private void updateOneRow(SQLiteDatabase database, String locale,
String updatedTitle, String normalizedTitle,
String updatedSummaryOn, String normalizedSummaryOn,
diff --git a/src/com/android/settings/search/SearchIndexableResources.java b/src/com/android/settings/search/SearchIndexableResources.java
index 3d942188a..cea57b956 100644
--- a/src/com/android/settings/search/SearchIndexableResources.java
+++ b/src/com/android/settings/search/SearchIndexableResources.java
@@ -18,6 +18,7 @@ package com.android.settings.search;
import android.provider.SearchIndexableResource;
+import com.android.settings.ChooseLockGeneric;
import com.android.settings.DataUsageSummary;
import com.android.settings.DateTimeSettings;
import com.android.settings.DevelopmentSettings;
@@ -174,6 +175,12 @@ public final class SearchIndexableResources {
SecuritySettings.class.getName(),
R.drawable.ic_settings_security));
+ sResMap.put(ChooseLockGeneric.ChooseLockGenericFragment.class.getName(),
+ new SearchIndexableResource(RANK_SECURITY,
+ R.xml.security_settings_picker,
+ ChooseLockGeneric.ChooseLockGenericFragment.class.getName(),
+ R.drawable.ic_settings_security));
+
sResMap.put(InputMethodAndLanguageSettings.class.getName(),
new SearchIndexableResource(
Ranking.getRankForClassName(InputMethodAndLanguageSettings.class.getName()),