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
10 files changed