diff options
author | calderwoodra <calderwoodra@google.com> | 2017-08-31 02:01:35 -0700 |
---|---|---|
committer | Eric Erfanian <erfanian@google.com> | 2017-09-06 16:42:02 -0700 |
commit | dede7e703541f81af4533ce4a53f18f327090568 (patch) | |
tree | e85d530eef4e2ffe4b450ff937c188832ed22d72 /java/com/android/dialer/searchfragment/list | |
parent | 6627396c33440abd1bd32daa617aa4848be167e1 (diff) |
NewSearchFragment contact photos now properly open quick contact cards.
There was an issue where businesses' and remote contacts' contact photos
wouldn't open contact cards correctly. The issue was rooted in the incorrect
contact uri being assigned to the quick contact badge.
from the bugbash:
16. Tap on business icon from search results says “ no application found” instead of opening the business info
17. Same as #16 but with contact from Directory Google.com - “The contact doesn’t exist” when tapping contact icon
Bug: 64902476
Test: existing
PiperOrigin-RevId: 167111016
Change-Id: I4b6f7ca812d2fc4dc220951e8c05db2c8b8d6114
Diffstat (limited to 'java/com/android/dialer/searchfragment/list')
-rw-r--r-- | java/com/android/dialer/searchfragment/list/NewSearchFragment.java | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/java/com/android/dialer/searchfragment/list/NewSearchFragment.java b/java/com/android/dialer/searchfragment/list/NewSearchFragment.java index 7fee9699a..910e454f8 100644 --- a/java/com/android/dialer/searchfragment/list/NewSearchFragment.java +++ b/java/com/android/dialer/searchfragment/list/NewSearchFragment.java @@ -120,7 +120,6 @@ public final class NewSearchFragment extends Fragment private void initLoaders() { getLoaderManager().initLoader(CONTACTS_LOADER_ID, null, this); - loadNearbyPlacesCursor(); loadRemoteDirectoriesCursor(); } @@ -129,7 +128,14 @@ public final class NewSearchFragment extends Fragment if (id == CONTACTS_LOADER_ID) { return new SearchContactsCursorLoader(getContext(), query); } else if (id == NEARBY_PLACES_LOADER_ID) { - return new NearbyPlacesCursorLoader(getContext(), query); + // Directories represent contact data sources on the device, but since nearby places aren't + // stored on the device, they don't have a directory ID. We pass the list of all existing IDs + // so that we can find one that doesn't collide. + List<Integer> directoryIds = new ArrayList<>(); + for (Directory directory : directories) { + directoryIds.add(directory.getId()); + } + return new NearbyPlacesCursorLoader(getContext(), query, directoryIds); } else if (id == REMOTE_DIRECTORIES_LOADER_ID) { return new RemoteDirectoriesCursorLoader(getContext()); } else if (id == REMOTE_CONTACTS_LOADER_ID) { @@ -162,6 +168,7 @@ public final class NewSearchFragment extends Fragment while (cursor.moveToNext()) { directories.add(RemoteDirectoriesCursorLoader.readDirectory(cursor)); } + loadNearbyPlacesCursor(); loadRemoteContactsCursors(); } else { @@ -212,18 +219,6 @@ public final class NewSearchFragment extends Fragment ThreadUtil.getUiThreadHandler().removeCallbacks(capabilitiesUpdatedRunnable); } - private void loadNearbyPlacesCursor() { - // Cancel existing load if one exists. - ThreadUtil.getUiThreadHandler().removeCallbacks(loadNearbyPlacesRunnable); - - // If nearby places is not enabled, do not try to load them. - if (!PhoneDirectoryExtenderAccessor.get(getContext()).isEnabled(getContext())) { - return; - } - ThreadUtil.getUiThreadHandler() - .postDelayed(loadNearbyPlacesRunnable, NETWORK_SEARCH_DELAY_MILLIS); - } - @Override public void onRequestPermissionsResult( int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { @@ -250,12 +245,14 @@ public final class NewSearchFragment extends Fragment } } + // Loads remote directories. private void loadRemoteDirectoriesCursor() { if (!remoteDirectoriesDisabledForTesting) { getLoaderManager().initLoader(REMOTE_DIRECTORIES_LOADER_ID, null, this); } } + // Should not be called before remote directories have finished loading. private void loadRemoteContactsCursors() { if (remoteDirectoriesDisabledForTesting) { return; @@ -267,6 +264,19 @@ public final class NewSearchFragment extends Fragment .postDelayed(loadRemoteContactsRunnable, NETWORK_SEARCH_DELAY_MILLIS); } + // Should not be called before remote directories (not contacts) have finished loading. + private void loadNearbyPlacesCursor() { + // Cancel existing load if one exists. + ThreadUtil.getUiThreadHandler().removeCallbacks(loadNearbyPlacesRunnable); + + // If nearby places is not enabled, do not try to load them. + if (!PhoneDirectoryExtenderAccessor.get(getContext()).isEnabled(getContext())) { + return; + } + ThreadUtil.getUiThreadHandler() + .postDelayed(loadNearbyPlacesRunnable, NETWORK_SEARCH_DELAY_MILLIS); + } + @Override public void onResume() { super.onResume(); |