README.md
1# Dialer Search Ui
2
3searchfragment/ contains all code relevant to loading, rendering and filtering
4search results in both dialpad search and regular search.
5
6## Loading
7
8### On Device Contacts
9
10On device contacts loading happens in SearchContactsCursorLoader. It is used in
11conjunction with NewSearchFragment and Loader Callbacks to return a cursor from
12cp2 containing all of the relevant info needed to rendering.
13
14### Business Search
15
16// TODO(calderwoodra)
17
18### Google Directory Search
19
20// TODO(calderwoodra)
21
22## Rendering
23
24NewSearchFragment, SearchAdapter, SearchContactViewHolder and
25SearchCursorManager are used to render contact information. The fragment's
26recyclerview, adapter and viewholder work as expected like a normal recyclerview
27paradigm.
28
29The are three things to note about rendering:
30
31* There are three data sources rendered: On device contacts, business search
32 results and google directory results.
33* SearchContactsCursorLoader returns its cursor from cp2 and we filter/wrap it
34 with SearchContactCursor to render useful results (see below).
35* SearchCursorManager is used to coalesce all three data sources to help with
36 determining row count, row type and returning the correct data source for
37 each position.
38
39## Filtering
40
41On device contacts are filtered using SearchContactCursor. We wrap the cursor
42returned from SearchContactsCursorLoader in NewSearchFragment#onLoadFinished in
43order to abstract away the filtering logic from the recyclerview adapter and
44viewholders.
45
46SearchContactCursor applies filtering in SearchContactCursor#filter to remove
47duplicate phone numbers returned from cp2 and phone numbers that do not match
48the given search query.
49
50Filtering methods used are:
51
52* T9/dialpad search methods
53 * Initial match (957 matches [W]illiam [J]ohn [S]mith)
54 * Number + name match (1800946 matches [1800-Win]-A-Prize)
55* Numeric/dialpad search methods
56 * Simple number match (510333 matches [510-333]-7596)
57 * Country-code agnostic matching for E164 normalized numbers (9177 matches
58 +65[9177]6930)
59 * Country-code agnostic matching (510333 matches 1-[510-333]-7596)
60 * Area-code agnostic matching (333 matches 510-[333]-7596)
61* Name/keyboard search methods:
62 * Simple name match (564 matches [Joh]n)
63