Find proper snippet in multi-line and large result.
Previous CL removed the use ContactsContract.snippetize(). This method
found the proper line in a multi-line results and then snippetized the
line if it was too long.
This CL adds that functionality back without using snippetize(). This
new code is faster because it only does text intensive processing when
the text is long. The previous snippetize method did processing for all
strings. In addition, the old method iterated over the snippet multiple
times (i.e. first with contains, then subsequently tokenizes, etc). This
change re-uses the initial search results and remembers the search
information so multiple iterations are not necessary. In addition,
tokenizing has been optimized based on the match. We only need to
chop off excess content rather than tokenizing the whole string.
This CL also makes snippet more friend to landscape mode. Previously,
the number of snippet tokens shown was hard-coded to 2 on each side.
Furthermore, this caused longer tokens to exceed screen real estate. Now
the number of tokens shown are determined more accurately by character
count versus real estate. In landscape mode, this allows us to show
much more of the search result.
Finally, fixed a highlight problem when the search query contained
punctuation. For example, a search for {.ben.} would not match {ben}.
This Cl resolves that issue by cleaning the search query.
Bug: 5929143
Change-Id: I5c368e6de8b34ca912f86926f862a02f95199fa7
diff --git a/res-common/values-land/integers.xml b/res-common/values-land/integers.xml
index 44d1d5a..e0d1e05 100644
--- a/res-common/values-land/integers.xml
+++ b/res-common/values-land/integers.xml
@@ -16,4 +16,7 @@
-->
<resources>
<integer name="contact_tile_column_count_in_favorites">4</integer>
+
+ <!-- The number of characters in the snippet before we need to tokenize and ellipse. -->
+ <integer name="snippet_length_before_tokenize">60</integer>
</resources>
diff --git a/res-common/values-sw580dp-land/integers.xml b/res-common/values-sw580dp-land/integers.xml
index 03f5ed7..bd9eb0e 100644
--- a/res-common/values-sw580dp-land/integers.xml
+++ b/res-common/values-sw580dp-land/integers.xml
@@ -16,4 +16,7 @@
-->
<resources>
<integer name="contact_tile_column_count_in_favorites">3</integer>
+
+ <!-- The number of characters in the snippet before we need to tokenize and ellipse. -->
+ <integer name="snippet_length_before_tokenize">20</integer>
</resources>
diff --git a/res-common/values-sw580dp/integers.xml b/res-common/values-sw580dp/integers.xml
index 03f5ed7..5b1c92b 100644
--- a/res-common/values-sw580dp/integers.xml
+++ b/res-common/values-sw580dp/integers.xml
@@ -16,4 +16,9 @@
-->
<resources>
<integer name="contact_tile_column_count_in_favorites">3</integer>
+
+ <!-- The number of characters in the snippet before we need to tokenize and ellipse. -->
+ <!-- Yikes, there is less space on a tablet! This makes the search experience rather
+ poor. Another reason to get rid of the exist tablet layout. -->
+ <integer name="snippet_length_before_tokenize">15</integer>
</resources>
diff --git a/res-common/values-sw680dp-land/integers.xml b/res-common/values-sw680dp-land/integers.xml
index 44d1d5a..a83cdff 100644
--- a/res-common/values-sw680dp-land/integers.xml
+++ b/res-common/values-sw680dp-land/integers.xml
@@ -16,4 +16,7 @@
-->
<resources>
<integer name="contact_tile_column_count_in_favorites">4</integer>
+
+ <!-- The number of characters in the snippet before we need to tokenize and ellipse. -->
+ <integer name="snippet_length_before_tokenize">30</integer>
</resources>
diff --git a/res-common/values-sw680dp/integers.xml b/res-common/values-sw680dp/integers.xml
index 3e47757..930adb3 100644
--- a/res-common/values-sw680dp/integers.xml
+++ b/res-common/values-sw680dp/integers.xml
@@ -16,4 +16,7 @@
-->
<resources>
<integer name="contact_tile_column_count_in_favorites">2</integer>
+
+ <!-- The number of characters in the snippet before we need to tokenize and ellipse. -->
+ <integer name="snippet_length_before_tokenize">20</integer>
</resources>
diff --git a/res-common/values/integers.xml b/res-common/values/integers.xml
index 73e9aee..f3b54a4 100644
--- a/res-common/values/integers.xml
+++ b/res-common/values/integers.xml
@@ -19,4 +19,7 @@
<!-- Determines the number of columns in a ContactTileRow in the favorites tab -->
<integer name="contact_tile_column_count_in_favorites">2</integer>
+
+ <!-- The number of characters in the snippet before we need to tokenize and ellipse. -->
+ <integer name="snippet_length_before_tokenize">30</integer>
</resources>