diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2017-10-26 18:11:22 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2017-10-26 18:11:22 +0000 |
commit | 9b99b22391a92fe20a74076bf5e47d36eb9b4ab4 (patch) | |
tree | 510aa70e1d1421be75f8f5cea57a6fce51427cbc /java/com/android/dialer/searchfragment/list | |
parent | e5041c35b4c0ef31e5d242a8dd61d7441d490f44 (diff) | |
parent | 65c21801bf47cf24e2755445545bedabc0f393bf (diff) |
Merge changes I1fa267c0,Ia6812794,Ib5715d0f,I71d4c03b
* changes:
Cp2 Phonelookup isDirty implementation.
App latency test migration. Migrate the existing app latency test to a new solution from Project Fi team. The main change on this new solution is that the data collection part is done by Primes now.
Search fragment now closes after placing a call.
Display CDMA voice privacy icon on notification bar.
Diffstat (limited to 'java/com/android/dialer/searchfragment/list')
-rw-r--r-- | java/com/android/dialer/searchfragment/list/NewSearchFragment.java | 75 | ||||
-rw-r--r-- | java/com/android/dialer/searchfragment/list/SearchAdapter.java | 90 |
2 files changed, 83 insertions, 82 deletions
diff --git a/java/com/android/dialer/searchfragment/list/NewSearchFragment.java b/java/com/android/dialer/searchfragment/list/NewSearchFragment.java index ef1b4fc19..c200b946c 100644 --- a/java/com/android/dialer/searchfragment/list/NewSearchFragment.java +++ b/java/com/android/dialer/searchfragment/list/NewSearchFragment.java @@ -20,6 +20,7 @@ import static android.Manifest.permission.ACCESS_FINE_LOCATION; import android.app.Fragment; import android.app.LoaderManager.LoaderCallbacks; +import android.content.Intent; import android.content.Loader; import android.content.pm.PackageManager; import android.database.Cursor; @@ -31,6 +32,7 @@ import android.support.annotation.VisibleForTesting; import android.support.v13.app.FragmentCompat; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; +import android.telephony.TelephonyManager; import android.text.TextUtils; import android.view.LayoutInflater; import android.view.MotionEvent; @@ -42,13 +44,23 @@ import android.widget.FrameLayout; import android.widget.FrameLayout.LayoutParams; import com.android.contacts.common.extensions.PhoneDirectoryExtenderAccessor; import com.android.dialer.animation.AnimUtils; +import com.android.dialer.assisteddialing.ConcreteCreator; +import com.android.dialer.callcomposer.CallComposerActivity; import com.android.dialer.callintent.CallInitiationType; +import com.android.dialer.callintent.CallIntentBuilder; +import com.android.dialer.callintent.CallSpecificAppData; import com.android.dialer.common.Assert; import com.android.dialer.common.FragmentUtils; import com.android.dialer.common.LogUtil; import com.android.dialer.common.concurrent.ThreadUtil; +import com.android.dialer.constants.ActivityRequestCodes; +import com.android.dialer.dialercontact.DialerContact; +import com.android.dialer.duo.DuoComponent; import com.android.dialer.enrichedcall.EnrichedCallComponent; import com.android.dialer.enrichedcall.EnrichedCallManager.CapabilitiesListener; +import com.android.dialer.logging.DialerImpression; +import com.android.dialer.logging.Logger; +import com.android.dialer.searchfragment.common.RowClickListener; import com.android.dialer.searchfragment.common.SearchCursor; import com.android.dialer.searchfragment.cp2.SearchContactsCursorLoader; import com.android.dialer.searchfragment.list.SearchActionViewHolder.Action; @@ -72,7 +84,8 @@ public final class NewSearchFragment extends Fragment implements LoaderCallbacks<Cursor>, OnEmptyViewActionButtonClickedListener, CapabilitiesListener, - OnTouchListener { + OnTouchListener, + RowClickListener { // Since some of our queries can generate network requests, we should delay them until the user // stops typing to prevent generating too much network traffic. @@ -124,9 +137,8 @@ public final class NewSearchFragment extends Fragment public View onCreateView( LayoutInflater inflater, @Nullable ViewGroup parent, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_search, parent, false); - adapter = new SearchAdapter(getActivity(), new SearchCursorManager()); + adapter = new SearchAdapter(getContext(), new SearchCursorManager(), this); adapter.setQuery(query); - adapter.setCallInitiationType(callInitiationType); adapter.setSearchActions(getActions()); adapter.setZeroSuggestVisible(getArguments().getBoolean(KEY_SHOW_ZERO_SUGGEST)); emptyContentView = view.findViewById(R.id.empty_view); @@ -241,7 +253,6 @@ public final class NewSearchFragment extends Fragment this.callInitiationType = callInitiationType; if (adapter != null) { adapter.setQuery(query); - adapter.setCallInitiationType(callInitiationType); adapter.setSearchActions(getActions()); adapter.setZeroSuggestVisible(isRegularSearch()); loadNearbyPlacesCursor(); @@ -449,12 +460,59 @@ public final class NewSearchFragment extends Fragment if (event.getAction() == MotionEvent.ACTION_UP) { v.performClick(); } - return FragmentUtils.getParentUnsafe(this, SearchFragmentListTouchListener.class) + return FragmentUtils.getParentUnsafe(this, SearchFragmentListener.class) .onSearchListTouch(event); } - /** Callback to {@link NewSearchFragment}'s parent to notify when the list is touched. */ - public interface SearchFragmentListTouchListener { + @Override + public void placeVoiceCall(String phoneNumber, int ranking) { + placeCall(phoneNumber, ranking, false, true); + } + + @Override + public void placeVideoCall(String phoneNumber, int ranking) { + placeCall(phoneNumber, ranking, true, false); + } + + private void placeCall( + String phoneNumber, int position, boolean isVideoCall, boolean allowAssistedDial) { + CallSpecificAppData callSpecificAppData = + CallSpecificAppData.newBuilder() + .setCallInitiationType(callInitiationType) + .setPositionOfSelectedSearchResult(position) + .setCharactersInSearchString(query == null ? 0 : query.length()) + .setAllowAssistedDialing(allowAssistedDial) + .build(); + Intent intent = + new CallIntentBuilder(phoneNumber, callSpecificAppData) + .setIsVideoCall(isVideoCall) + .setAllowAssistedDial( + allowAssistedDial, + ConcreteCreator.createNewAssistedDialingMediator( + getContext().getSystemService(TelephonyManager.class), + getContext().getApplicationContext())) + .build(); + DialerUtils.startActivityWithErrorToast(getActivity(), intent); + FragmentUtils.getParentUnsafe(this, SearchFragmentListener.class).onCallPlaced(); + } + + @Override + public void placeDuoCall(String phoneNumber) { + Logger.get(getContext()) + .logImpression(DialerImpression.Type.LIGHTBRINGER_VIDEO_REQUESTED_FROM_SEARCH); + Intent intent = DuoComponent.get(getContext()).getDuo().getIntent(getContext(), phoneNumber); + getActivity().startActivityForResult(intent, ActivityRequestCodes.DIALTACTS_DUO); + FragmentUtils.getParentUnsafe(this, SearchFragmentListener.class).onCallPlaced(); + } + + @Override + public void openCallAndShare(DialerContact contact) { + Intent intent = CallComposerActivity.newIntent(getContext(), contact); + DialerUtils.startActivityWithErrorToast(getContext(), intent); + } + + /** Callback to {@link NewSearchFragment}'s parent to be notified of important events. */ + public interface SearchFragmentListener { /** * Called when the list view in {@link NewSearchFragment} is touched. @@ -462,5 +520,8 @@ public final class NewSearchFragment extends Fragment * @see OnTouchListener#onTouch(View, MotionEvent) */ boolean onSearchListTouch(MotionEvent event); + + /** Called when a call is placed from the search fragment. */ + void onCallPlaced(); } } diff --git a/java/com/android/dialer/searchfragment/list/SearchAdapter.java b/java/com/android/dialer/searchfragment/list/SearchAdapter.java index 949c2a2c5..dc78953b5 100644 --- a/java/com/android/dialer/searchfragment/list/SearchAdapter.java +++ b/java/com/android/dialer/searchfragment/list/SearchAdapter.java @@ -16,55 +16,43 @@ package com.android.dialer.searchfragment.list; -import android.app.Activity; -import android.content.Intent; +import android.content.Context; import android.support.annotation.VisibleForTesting; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView.ViewHolder; -import android.telephony.TelephonyManager; import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; -import com.android.dialer.assisteddialing.ConcreteCreator; -import com.android.dialer.callcomposer.CallComposerActivity; -import com.android.dialer.callintent.CallInitiationType; -import com.android.dialer.callintent.CallIntentBuilder; -import com.android.dialer.callintent.CallSpecificAppData; import com.android.dialer.common.Assert; -import com.android.dialer.constants.ActivityRequestCodes; -import com.android.dialer.dialercontact.DialerContact; -import com.android.dialer.duo.DuoComponent; -import com.android.dialer.logging.DialerImpression; -import com.android.dialer.logging.Logger; import com.android.dialer.searchfragment.common.RowClickListener; import com.android.dialer.searchfragment.common.SearchCursor; import com.android.dialer.searchfragment.cp2.SearchContactViewHolder; import com.android.dialer.searchfragment.list.SearchCursorManager.RowType; import com.android.dialer.searchfragment.nearbyplaces.NearbyPlaceViewHolder; import com.android.dialer.searchfragment.remote.RemoteContactViewHolder; -import com.android.dialer.util.DialerUtils; import java.util.List; /** RecyclerView adapter for {@link NewSearchFragment}. */ @VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE) -public final class SearchAdapter extends RecyclerView.Adapter<ViewHolder> - implements RowClickListener { +public final class SearchAdapter extends RecyclerView.Adapter<ViewHolder> { private final SearchCursorManager searchCursorManager; - private final Activity activity; + private final Context context; private boolean showZeroSuggest; private String query; - private CallInitiationType.Type callInitiationType = CallInitiationType.Type.UNKNOWN_INITIATION; private OnClickListener allowClickListener; private OnClickListener dismissClickListener; + private RowClickListener rowClickListener; @VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE) - public SearchAdapter(Activity activity, SearchCursorManager searchCursorManager) { - this.activity = activity; + public SearchAdapter( + Context context, SearchCursorManager searchCursorManager, RowClickListener rowClickListener) { + this.context = context; this.searchCursorManager = searchCursorManager; + this.rowClickListener = rowClickListener; } @Override @@ -72,24 +60,25 @@ public final class SearchAdapter extends RecyclerView.Adapter<ViewHolder> switch (rowType) { case RowType.CONTACT_ROW: return new SearchContactViewHolder( - LayoutInflater.from(activity).inflate(R.layout.search_contact_row, root, false), this); + LayoutInflater.from(context).inflate(R.layout.search_contact_row, root, false), + rowClickListener); case RowType.NEARBY_PLACES_ROW: return new NearbyPlaceViewHolder( - LayoutInflater.from(activity).inflate(R.layout.search_contact_row, root, false)); + LayoutInflater.from(context).inflate(R.layout.search_contact_row, root, false)); case RowType.CONTACT_HEADER: case RowType.DIRECTORY_HEADER: case RowType.NEARBY_PLACES_HEADER: return new HeaderViewHolder( - LayoutInflater.from(activity).inflate(R.layout.header_layout, root, false)); + LayoutInflater.from(context).inflate(R.layout.header_layout, root, false)); case RowType.DIRECTORY_ROW: return new RemoteContactViewHolder( - LayoutInflater.from(activity).inflate(R.layout.search_contact_row, root, false)); + LayoutInflater.from(context).inflate(R.layout.search_contact_row, root, false)); case RowType.SEARCH_ACTION: return new SearchActionViewHolder( - LayoutInflater.from(activity).inflate(R.layout.search_action_layout, root, false)); + LayoutInflater.from(context).inflate(R.layout.search_action_layout, root, false)); case RowType.LOCATION_REQUEST: return new LocationPermissionViewHolder( - LayoutInflater.from(activity).inflate(R.layout.location_permission_row, root, false), + LayoutInflater.from(context).inflate(R.layout.location_permission_row, root, false), allowClickListener, dismissClickListener); case RowType.INVALID: @@ -168,10 +157,6 @@ 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(); @@ -209,51 +194,6 @@ public final class SearchAdapter extends RecyclerView.Adapter<ViewHolder> } } - @Override - public void placeVoiceCall(String phoneNumber, int ranking) { - placeCall(phoneNumber, ranking, false, true); - } - - @Override - public void placeVideoCall(String phoneNumber, int ranking) { - placeCall(phoneNumber, ranking, true, false); - } - - private void placeCall( - String phoneNumber, int position, boolean isVideoCall, boolean allowAssistedDial) { - CallSpecificAppData callSpecificAppData = - CallSpecificAppData.newBuilder() - .setCallInitiationType(callInitiationType) - .setPositionOfSelectedSearchResult(position) - .setCharactersInSearchString(query == null ? 0 : query.length()) - .setAllowAssistedDialing(allowAssistedDial) - .build(); - Intent intent = - new CallIntentBuilder(phoneNumber, callSpecificAppData) - .setIsVideoCall(isVideoCall) - .setAllowAssistedDial( - allowAssistedDial, - ConcreteCreator.createNewAssistedDialingMediator( - activity.getSystemService(TelephonyManager.class), - activity.getApplicationContext())) - .build(); - DialerUtils.startActivityWithErrorToast(activity, intent); - } - - @Override - public void placeDuoCall(String phoneNumber) { - Logger.get(activity) - .logImpression(DialerImpression.Type.LIGHTBRINGER_VIDEO_REQUESTED_FROM_SEARCH); - Intent intent = DuoComponent.get(activity).getDuo().getIntent(activity, phoneNumber); - activity.startActivityForResult(intent, ActivityRequestCodes.DIALTACTS_DUO); - } - - @Override - public void openCallAndShare(DialerContact contact) { - Intent intent = CallComposerActivity.newIntent(activity, contact); - DialerUtils.startActivityWithErrorToast(activity, intent); - } - /** Viewholder for R.layout.location_permission_row that requests the location permission. */ private static class LocationPermissionViewHolder extends RecyclerView.ViewHolder { |