diff options
author | Eric Erfanian <erfanian@google.com> | 2017-08-31 06:57:16 -0700 |
---|---|---|
committer | Eric Erfanian <erfanian@google.com> | 2017-08-31 16:13:53 +0000 |
commit | 2ca4318cc1ee57dda907ba2069bd61d162b1baef (patch) | |
tree | e282668a9587cf6c1ec7b604dea860400c75c6c7 /java/com/android/contacts/common/list/PhoneNumberPickerFragment.java | |
parent | 68038172793ee0e2ab3e2e56ddfbeb82879d1f58 (diff) |
Update Dialer source to latest internal Google revision.
Previously, Android's Dialer app was developed in an internal Google
source control system and only exported to public during AOSP drops.
The Dialer team is now switching to a public development model similar
to the telephony team.
This CL represents all internal Google changes that were committed to
Dialer between the public O release and today's tip of tree on internal
master. This CL squashes those changes into a single commit.
In subsequent changes, changes will be exported on a per-commit basis.
Test: make, flash install, run
Merged-In: I45270eaa8ce732d71a1bd84b08c7fa0e99af3160
Change-Id: I529aaeb88535b9533c0ae4ef4e6c1222d4e0f1c8
PiperOrigin-RevId: 167068436
Diffstat (limited to 'java/com/android/contacts/common/list/PhoneNumberPickerFragment.java')
-rw-r--r-- | java/com/android/contacts/common/list/PhoneNumberPickerFragment.java | 73 |
1 files changed, 48 insertions, 25 deletions
diff --git a/java/com/android/contacts/common/list/PhoneNumberPickerFragment.java b/java/com/android/contacts/common/list/PhoneNumberPickerFragment.java index 8f25f82a5..d704e5492 100644 --- a/java/com/android/contacts/common/list/PhoneNumberPickerFragment.java +++ b/java/com/android/contacts/common/list/PhoneNumberPickerFragment.java @@ -29,16 +29,20 @@ import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import com.android.contacts.common.R; +import com.android.contacts.common.list.PhoneNumberListAdapter.Listener; import com.android.contacts.common.util.AccountFilterUtil; -import com.android.dialer.callcomposer.CallComposerContact; import com.android.dialer.callintent.CallInitiationType; import com.android.dialer.callintent.CallInitiationType.Type; import com.android.dialer.callintent.CallSpecificAppData; import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; +import com.android.dialer.dialercontact.DialerContact; import com.android.dialer.enrichedcall.EnrichedCallComponent; import com.android.dialer.enrichedcall.EnrichedCallManager; +import com.android.dialer.lightbringer.LightbringerComponent; +import com.android.dialer.logging.DialerImpression; import com.android.dialer.logging.Logger; +import com.android.dialer.performancereport.PerformanceReport; import com.android.dialer.protos.ProtoParsers; import java.util.Set; import org.json.JSONException; @@ -61,9 +65,6 @@ public class PhoneNumberPickerFragment extends ContactEntryListFragment<ContactE private boolean mUseCallableUri; - private ContactListItemView.PhotoPosition mPhotoPosition = - ContactListItemView.getDefaultPhotoPosition(false /* normal/non opposite */); - private final Set<OnLoadFinishedListener> mLoadFinishedListeners = new ArraySet<>(); private CursorReranker mCursorReranker; @@ -71,7 +72,7 @@ public class PhoneNumberPickerFragment extends ContactEntryListFragment<ContactE public PhoneNumberPickerFragment() { setQuickContactEnabled(false); setPhotoLoaderEnabled(true); - setSectionHeaderDisplayEnabled(true); + setSectionHeaderDisplayEnabled(false); setDirectorySearchMode(DirectoryListLoader.SEARCH_MODE_NONE); // Show nothing instead of letting caller Activity show something. @@ -85,17 +86,33 @@ public class PhoneNumberPickerFragment extends ContactEntryListFragment<ContactE */ @Override public void onVideoCallIconClicked(int position) { + Logger.get(getContext()).logImpression(DialerImpression.Type.IMS_VIDEO_REQUESTED_FROM_SEARCH); callNumber(position, true /* isVideoCall */); } @Override + public void onLightbringerIconClicked(int position) { + PerformanceReport.stopRecording(); + String phoneNumber = getPhoneNumber(position); + Intent intent = + LightbringerComponent.get(getContext()) + .getLightbringer() + .getIntent(getContext(), phoneNumber); + // DialtactsActivity.ACTIVITY_REQUEST_CODE_LIGHTBRINGER + // Cannot reference because of cyclic dependencies + Logger.get(getContext()) + .logImpression(DialerImpression.Type.LIGHTBRINGER_VIDEO_REQUESTED_FROM_SEARCH); + int dialactsActivityRequestCode = 3; + getActivity().startActivityForResult(intent, dialactsActivityRequestCode); + } + + @Override public void onCallAndShareIconClicked(int position) { // Required because of cyclic dependencies of everything depending on contacts/common. String componentName = "com.android.dialer.callcomposer.CallComposerActivity"; Intent intent = new Intent(); intent.setComponent(new ComponentName(getContext(), componentName)); - CallComposerContact contact = - ((PhoneNumberListAdapter) getAdapter()).getCallComposerContact(position); + DialerContact contact = ((PhoneNumberListAdapter) getAdapter()).getDialerContact(position); ProtoParsers.put(intent, "CALL_COMPOSER_CONTACT", contact); startActivity(intent); } @@ -218,6 +235,7 @@ public class PhoneNumberPickerFragment extends ContactEntryListFragment<ContactE cacheContactInfo(position); CallSpecificAppData callSpecificAppData = CallSpecificAppData.newBuilder() + .setAllowAssistedDialing(true) .setCallInitiationType(getCallInitiationType(true /* isRemoteDirectory */)) .setPositionOfSelectedSearchResult(position) .setCharactersInSearchString(getQueryString() == null ? 0 : getQueryString().length()) @@ -261,13 +279,13 @@ public class PhoneNumberPickerFragment extends ContactEntryListFragment<ContactE @MainThread public void onLoadFinished(Loader<Cursor> loader, Cursor data) { Assert.isMainThread(); - // TODO: define and verify behavior for "Nearby places", corp directories, + // TODO(strongarm): define and verify behavior for "Nearby places", corp directories, // and dividers listed in UI between these categories if (mCursorReranker != null && data != null && !data.isClosed() && data.getCount() > 0 - && loader.getId() != -1) { // skip invalid directory ID of -1 + && loader.getId() == 0) { // only re-rank if a suggestions loader with id of 0. data = mCursorReranker.rerankCursor(data); } super.onLoadFinished(loader, data); @@ -320,7 +338,27 @@ public class PhoneNumberPickerFragment extends ContactEntryListFragment<ContactE @Override public void onCapabilitiesUpdated() { if (getAdapter() != null) { - getAdapter().notifyDataSetChanged(); + EnrichedCallManager manager = + EnrichedCallComponent.get(getContext()).getEnrichedCallManager(); + Listener listener = ((PhoneNumberListAdapter) getAdapter()).getListener(); + + for (int i = 0; i < getListView().getChildCount(); i++) { + if (!(getListView().getChildAt(i) instanceof ContactListItemView)) { + continue; + } + + // Since call and share is the lowest priority call to action, if any others are set, + // do not reset the call to action. Also do not set the call and share call to action if + // the number doesn't support call composer. + ContactListItemView view = (ContactListItemView) getListView().getChildAt(i); + if (view.getCallToAction() != ContactListItemView.NONE + || view.getPhoneNumber() == null + || manager.getCapabilities(view.getPhoneNumber()) == null + || !manager.getCapabilities(view.getPhoneNumber()).isCallComposerCapable()) { + continue; + } + view.setCallToAction(ContactListItemView.CALL_AND_SHARE, listener, view.getPosition()); + } } } @@ -360,12 +398,6 @@ public class PhoneNumberPickerFragment extends ContactEntryListFragment<ContactE if (!isSearchMode() && mFilter != null) { adapter.setFilter(mFilter); } - - setPhotoPosition(adapter); - } - - protected void setPhotoPosition(ContactEntryListAdapter adapter) { - ((PhoneNumberListAdapter) adapter).setPhotoPosition(mPhotoPosition); } @Override @@ -389,15 +421,6 @@ public class PhoneNumberPickerFragment extends ContactEntryListFragment<ContactE updateFilterHeaderView(); } - public void setPhotoPosition(ContactListItemView.PhotoPosition photoPosition) { - mPhotoPosition = photoPosition; - - final PhoneNumberListAdapter adapter = (PhoneNumberListAdapter) getAdapter(); - if (adapter != null) { - adapter.setPhotoPosition(photoPosition); - } - } - /** * @param isRemoteDirectory {@code true} if the call was initiated using a contact/phone number * not in the local contacts database |