diff options
Diffstat (limited to 'java/com/android/dialer/searchfragment')
3 files changed, 24 insertions, 11 deletions
diff --git a/java/com/android/dialer/searchfragment/cp2/SearchContactsCursorLoader.java b/java/com/android/dialer/searchfragment/cp2/SearchContactsCursorLoader.java index d75a66122..84fd64ae5 100644 --- a/java/com/android/dialer/searchfragment/cp2/SearchContactsCursorLoader.java +++ b/java/com/android/dialer/searchfragment/cp2/SearchContactsCursorLoader.java @@ -20,12 +20,16 @@ import android.content.Context; import android.content.CursorLoader; import android.database.Cursor; import android.provider.ContactsContract.CommonDataKinds.Phone; +import android.support.annotation.Nullable; import com.android.dialer.searchfragment.common.Projections; /** Cursor Loader for CP2 contacts. */ public final class SearchContactsCursorLoader extends CursorLoader { - public SearchContactsCursorLoader(Context context) { + private final String query; + + /** @param query Contacts cursor will be filtered based on this query. */ + public SearchContactsCursorLoader(Context context, @Nullable String query) { super( context, Phone.CONTENT_URI, @@ -33,6 +37,7 @@ public final class SearchContactsCursorLoader extends CursorLoader { null, null, Phone.SORT_KEY_PRIMARY + " ASC"); + this.query = query; } @Override @@ -40,7 +45,7 @@ public final class SearchContactsCursorLoader extends CursorLoader { // All contacts Cursor cursor = super.loadInBackground(); // Filtering logic - ContactFilterCursor contactFilterCursor = new ContactFilterCursor(cursor, null); + ContactFilterCursor contactFilterCursor = new ContactFilterCursor(cursor, query); // Header logic return SearchContactsCursor.newInstnace(getContext(), contactFilterCursor); } diff --git a/java/com/android/dialer/searchfragment/list/NewSearchFragment.java b/java/com/android/dialer/searchfragment/list/NewSearchFragment.java index 7d355c91c..7fee9699a 100644 --- a/java/com/android/dialer/searchfragment/list/NewSearchFragment.java +++ b/java/com/android/dialer/searchfragment/list/NewSearchFragment.java @@ -34,6 +34,7 @@ import android.view.ViewGroup; import android.view.animation.Interpolator; import com.android.contacts.common.extensions.PhoneDirectoryExtenderAccessor; import com.android.dialer.animation.AnimUtils; +import com.android.dialer.callintent.CallInitiationType; import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; import com.android.dialer.common.concurrent.ThreadUtil; @@ -77,6 +78,7 @@ public final class NewSearchFragment extends Fragment private RecyclerView recyclerView; private SearchAdapter adapter; private String query; + private CallInitiationType.Type callInitiationType = CallInitiationType.Type.UNKNOWN_INITIATION; private boolean remoteDirectoriesDisabledForTesting; private final List<Directory> directories = new ArrayList<>(); @@ -94,6 +96,7 @@ public final class NewSearchFragment extends Fragment LayoutInflater inflater, @Nullable ViewGroup parent, @Nullable Bundle bundle) { View view = inflater.inflate(R.layout.fragment_search, parent, false); adapter = new SearchAdapter(getActivity(), new SearchCursorManager()); + adapter.setCallInitiationType(callInitiationType); emptyContentView = view.findViewById(R.id.empty_view); recyclerView = view.findViewById(R.id.recycler_view); recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); @@ -123,9 +126,8 @@ public final class NewSearchFragment extends Fragment @Override public Loader<Cursor> onCreateLoader(int id, Bundle bundle) { - // TODO(calderwoodra) add enterprise loader if (id == CONTACTS_LOADER_ID) { - return new SearchContactsCursorLoader(getContext()); + return new SearchContactsCursorLoader(getContext(), query); } else if (id == NEARBY_PLACES_LOADER_ID) { return new NearbyPlacesCursorLoader(getContext(), query); } else if (id == REMOTE_DIRECTORIES_LOADER_ID) { @@ -182,6 +184,13 @@ public final class NewSearchFragment extends Fragment } } + public void setCallInitiationType(CallInitiationType.Type callInitiationType) { + this.callInitiationType = callInitiationType; + if (adapter != null) { + adapter.setCallInitiationType(callInitiationType); + } + } + public void animatePosition(int start, int end, int duration) { // Called before the view is ready, prepare a runnable to run in onCreateView if (getView() == null) { diff --git a/java/com/android/dialer/searchfragment/list/SearchAdapter.java b/java/com/android/dialer/searchfragment/list/SearchAdapter.java index 4cb44a2db..f08d60e09 100644 --- a/java/com/android/dialer/searchfragment/list/SearchAdapter.java +++ b/java/com/android/dialer/searchfragment/list/SearchAdapter.java @@ -25,7 +25,6 @@ import android.view.LayoutInflater; import android.view.ViewGroup; import com.android.dialer.callcomposer.CallComposerActivity; import com.android.dialer.callintent.CallInitiationType; -import com.android.dialer.callintent.CallInitiationType.Type; import com.android.dialer.callintent.CallIntentBuilder; import com.android.dialer.callintent.CallSpecificAppData; import com.android.dialer.common.Assert; @@ -51,6 +50,7 @@ public final class SearchAdapter extends RecyclerView.Adapter<ViewHolder> private final Activity activity; private String query; + private CallInitiationType.Type callInitiationType = CallInitiationType.Type.UNKNOWN_INITIATION; @VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE) public SearchAdapter(Activity activity, SearchCursorManager searchCursorManager) { @@ -124,6 +124,10 @@ public final class SearchAdapter extends RecyclerView.Adapter<ViewHolder> } } + void setCallInitiationType(CallInitiationType.Type callInitiationType) { + this.callInitiationType = callInitiationType; + } + public void setNearbyPlacesCursor(SearchCursor nearbyPlacesCursor) { if (searchCursorManager.setNearbyPlacesCursor(nearbyPlacesCursor)) { notifyDataSetChanged(); @@ -149,7 +153,7 @@ public final class SearchAdapter extends RecyclerView.Adapter<ViewHolder> private void placeCall(String phoneNumber, int position, boolean isVideoCall) { CallSpecificAppData callSpecificAppData = CallSpecificAppData.newBuilder() - .setCallInitiationType(getCallInitiationType()) + .setCallInitiationType(callInitiationType) .setPositionOfSelectedSearchResult(position) .setCharactersInSearchString(query == null ? 0 : query.length()) .build(); @@ -172,9 +176,4 @@ public final class SearchAdapter extends RecyclerView.Adapter<ViewHolder> Intent intent = CallComposerActivity.newIntent(activity, contact); DialerUtils.startActivityWithErrorToast(activity, intent); } - - private CallInitiationType.Type getCallInitiationType() { - // TODO(calderwoodra): add correct initiation type - return Type.REGULAR_SEARCH; - } } |