Search - prepare for better normalization
- code refactoring See bug: #15314612 Search - need to be able to search and have results with non accentuated chars Change-Id: Ic3eb94c0effccf6592c02b3eaa78bf26a2d09714
This commit is contained in:
@@ -914,31 +914,13 @@ public class Index {
|
|||||||
String intentAction, String intentTargetPackage, String intentTargetClass,
|
String intentAction, String intentTargetPackage, String intentTargetClass,
|
||||||
boolean enabled, String key) {
|
boolean enabled, String key) {
|
||||||
|
|
||||||
String updatedTitle;
|
String updatedTitle = normalizeHyphen(title);
|
||||||
if (title != null) {
|
String updatedSummaryOn = normalizeHyphen(summaryOn);
|
||||||
updatedTitle = title.replaceAll(NON_BREAKING_HYPHEN, HYPHEN);
|
String updatedSummaryOff = normalizeHyphen(summaryOff);
|
||||||
}
|
|
||||||
else {
|
|
||||||
updatedTitle = EMPTY;
|
|
||||||
}
|
|
||||||
|
|
||||||
String updatedSummaryOn;
|
String normalizedTitle = normalizeString(updatedTitle);
|
||||||
if (summaryOn != null) {
|
String normalizedSummaryOn = normalizeString(updatedSummaryOn);
|
||||||
updatedSummaryOn = summaryOn.replaceAll(NON_BREAKING_HYPHEN, HYPHEN);
|
String normalizedSummaryOff = normalizeString(updatedSummaryOff);
|
||||||
} else {
|
|
||||||
updatedSummaryOn = EMPTY;
|
|
||||||
}
|
|
||||||
|
|
||||||
String updatedSummaryOff;
|
|
||||||
if (summaryOff != null) {
|
|
||||||
updatedSummaryOff = summaryOff.replaceAll(NON_BREAKING_HYPHEN, HYPHEN);
|
|
||||||
} else {
|
|
||||||
updatedSummaryOff = EMPTY;
|
|
||||||
}
|
|
||||||
|
|
||||||
String normalizedTitle = updatedTitle.replaceAll(HYPHEN, EMPTY);
|
|
||||||
String normalizedSummaryOn = updatedSummaryOn.replaceAll(HYPHEN, EMPTY);
|
|
||||||
String normalizedSummaryOff = updatedSummaryOff.replaceAll(HYPHEN, EMPTY);
|
|
||||||
|
|
||||||
updateOneRow(database, locale,
|
updateOneRow(database, locale,
|
||||||
updatedTitle, normalizedTitle, updatedSummaryOn, normalizedSummaryOn,
|
updatedTitle, normalizedTitle, updatedSummaryOn, normalizedSummaryOn,
|
||||||
@@ -947,6 +929,14 @@ public class Index {
|
|||||||
rank, keywords, intentAction, intentTargetPackage, intentTargetClass, enabled, key);
|
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) {
|
||||||
|
return (input != null) ? input.replaceAll(HYPHEN, EMPTY) : EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
private void updateOneRow(SQLiteDatabase database, String locale,
|
private void updateOneRow(SQLiteDatabase database, String locale,
|
||||||
String updatedTitle, String normalizedTitle,
|
String updatedTitle, String normalizedTitle,
|
||||||
String updatedSummaryOn, String normalizedSummaryOn,
|
String updatedSummaryOn, String normalizedSummaryOn,
|
||||||
|
Reference in New Issue
Block a user