diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2017-11-12 00:55:34 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2017-11-12 00:55:34 +0000 |
commit | 2b52d2a3cdcb0ac00d87d2c2cbd1d6b750ea036d (patch) | |
tree | c87ae220455edeac1c6fb5b12e033e37a07c9ed4 /java/com/android/dialer/searchfragment | |
parent | 5e20ba7b1c6a9644da034b345000b37856d78125 (diff) | |
parent | b7dba5aaa8c477d97121fc6e3411332e66cbabe8 (diff) |
Merge changes I0ed4fa1b,Ie03ce41e,If41868df,Iba2e9092
* changes:
Expose tab index to protected
Added temporary logging to debug problem with null phone numbers from remote contacts.
Hook up pre-call actions
Implement CallingAccountSelector and AssistedDialAction
Diffstat (limited to 'java/com/android/dialer/searchfragment')
6 files changed, 62 insertions, 14 deletions
diff --git a/java/com/android/dialer/searchfragment/list/NewSearchFragment.java b/java/com/android/dialer/searchfragment/list/NewSearchFragment.java index c0a6700eb..e797a0390 100644 --- a/java/com/android/dialer/searchfragment/list/NewSearchFragment.java +++ b/java/com/android/dialer/searchfragment/list/NewSearchFragment.java @@ -58,6 +58,7 @@ 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.precall.PreCall; import com.android.dialer.searchfragment.common.RowClickListener; import com.android.dialer.searchfragment.common.SearchCursor; import com.android.dialer.searchfragment.cp2.SearchContactsCursorLoader; @@ -483,12 +484,11 @@ public final class NewSearchFragment extends Fragment .setCharactersInSearchString(query == null ? 0 : query.length()) .setAllowAssistedDialing(allowAssistedDial) .build(); - Intent intent = + PreCall.start( + getContext(), new CallIntentBuilder(phoneNumber, callSpecificAppData) .setIsVideoCall(isVideoCall) - .setAllowAssistedDial(allowAssistedDial) - .build(); - DialerUtils.startActivityWithErrorToast(getActivity(), intent); + .setAllowAssistedDial(allowAssistedDial)); FragmentUtils.getParentUnsafe(this, SearchFragmentListener.class).onCallPlaced(); } diff --git a/java/com/android/dialer/searchfragment/list/SearchActionViewHolder.java b/java/com/android/dialer/searchfragment/list/SearchActionViewHolder.java index 62e5c72b0..b557a8259 100644 --- a/java/com/android/dialer/searchfragment/list/SearchActionViewHolder.java +++ b/java/com/android/dialer/searchfragment/list/SearchActionViewHolder.java @@ -31,6 +31,7 @@ import com.android.dialer.callintent.CallSpecificAppData; import com.android.dialer.common.Assert; import com.android.dialer.logging.DialerImpression; import com.android.dialer.logging.Logger; +import com.android.dialer.precall.PreCall; import com.android.dialer.util.DialerUtils; import com.android.dialer.util.IntentUtil; import java.lang.annotation.Retention; @@ -128,8 +129,8 @@ final class SearchActionViewHolder extends RecyclerView.ViewHolder implements On .setPositionOfSelectedSearchResult(position) .setCharactersInSearchString(query.length()) .build(); - intent = new CallIntentBuilder(query, callSpecificAppData).setIsVideoCall(true).build(); - DialerUtils.startActivityWithErrorToast(context, intent); + PreCall.start( + context, new CallIntentBuilder(query, callSpecificAppData).setIsVideoCall(true)); break; case Action.SEND_SMS: diff --git a/java/com/android/dialer/searchfragment/list/SearchAdapter.java b/java/com/android/dialer/searchfragment/list/SearchAdapter.java index dc78953b5..cc090ac47 100644 --- a/java/com/android/dialer/searchfragment/list/SearchAdapter.java +++ b/java/com/android/dialer/searchfragment/list/SearchAdapter.java @@ -17,6 +17,7 @@ package com.android.dialer.searchfragment.list; import android.content.Context; +import android.database.Cursor; import android.support.annotation.VisibleForTesting; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView.ViewHolder; @@ -26,12 +27,15 @@ import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import com.android.dialer.common.Assert; +import com.android.dialer.common.LogUtil; +import com.android.dialer.searchfragment.common.Projections; 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.searchfragment.remote.RemoteDirectoriesCursorLoader; import java.util.List; /** RecyclerView adapter for {@link NewSearchFragment}. */ @@ -99,6 +103,23 @@ public final class SearchAdapter extends RecyclerView.Adapter<ViewHolder> { } else if (holder instanceof NearbyPlaceViewHolder) { ((NearbyPlaceViewHolder) holder).bind(searchCursorManager.getCursor(position), query); } else if (holder instanceof RemoteContactViewHolder) { + Cursor cursor = searchCursorManager.getCursor(position); + // Temporary logging to identify cause of a bug: + if (cursor.getString(Projections.PHONE_NUMBER) == null) { + LogUtil.e( + "SearchAdapter.onBindViewHolder", "cursor class: %s", cursor.getClass().getName()); + LogUtil.e("SearchAdapter.onBindViewHolder", "position: %d", position); + LogUtil.e( + "SearchAdapter.onBindViewHolder", + "query length: %s", + query == null ? "null" : query.length()); + logDirectories(); + LogUtil.e( + "SearchAdapter.onBindViewHolder", + "directory id: %d", + ((SearchCursor) cursor).getDirectoryId()); + throw new IllegalStateException("Null phone number reading remote contact"); + } ((RemoteContactViewHolder) holder).bind(searchCursorManager.getCursor(position), query); } else if (holder instanceof HeaderViewHolder) { String header = @@ -114,6 +135,21 @@ public final class SearchAdapter extends RecyclerView.Adapter<ViewHolder> { } } + private void logDirectories() { + try (Cursor directories = new RemoteDirectoriesCursorLoader(context).loadInBackground()) { + if (directories.moveToFirst()) { + do { + LogUtil.e( + "SearchAdapter.logDirectories", + "directory: %s", + RemoteDirectoriesCursorLoader.readDirectory(directories)); + } while (directories.moveToNext()); + } else { + LogUtil.e("SearchAdapter.logDirectories", "no directories found"); + } + } + } + public void setContactsCursor(SearchCursor cursor) { if (searchCursorManager.setContactsCursor(cursor)) { // Since this is a new contacts cursor, we need to reapply the filter. diff --git a/java/com/android/dialer/searchfragment/nearbyplaces/NearbyPlaceViewHolder.java b/java/com/android/dialer/searchfragment/nearbyplaces/NearbyPlaceViewHolder.java index 2e1fd5e9d..f15b236dd 100644 --- a/java/com/android/dialer/searchfragment/nearbyplaces/NearbyPlaceViewHolder.java +++ b/java/com/android/dialer/searchfragment/nearbyplaces/NearbyPlaceViewHolder.java @@ -29,11 +29,11 @@ import com.android.dialer.callintent.CallInitiationType; import com.android.dialer.callintent.CallIntentBuilder; import com.android.dialer.contactphoto.ContactPhotoManager; import com.android.dialer.lettertile.LetterTileDrawable; +import com.android.dialer.precall.PreCall; import com.android.dialer.searchfragment.common.Projections; import com.android.dialer.searchfragment.common.QueryBoldingUtil; import com.android.dialer.searchfragment.common.R; import com.android.dialer.searchfragment.common.SearchCursor; -import com.android.dialer.telecom.TelecomUtil; /** ViewHolder for a nearby place row. */ public final class NearbyPlaceViewHolder extends RecyclerView.ViewHolder @@ -93,7 +93,6 @@ public final class NearbyPlaceViewHolder extends RecyclerView.ViewHolder @Override public void onClick(View v) { - TelecomUtil.placeCall( - context, new CallIntentBuilder(number, CallInitiationType.Type.REGULAR_SEARCH).build()); + PreCall.start(context, new CallIntentBuilder(number, CallInitiationType.Type.REGULAR_SEARCH)); } } diff --git a/java/com/android/dialer/searchfragment/remote/RemoteContactViewHolder.java b/java/com/android/dialer/searchfragment/remote/RemoteContactViewHolder.java index 339855fbb..9d369003d 100644 --- a/java/com/android/dialer/searchfragment/remote/RemoteContactViewHolder.java +++ b/java/com/android/dialer/searchfragment/remote/RemoteContactViewHolder.java @@ -32,11 +32,11 @@ import com.android.dialer.callintent.CallInitiationType; import com.android.dialer.callintent.CallIntentBuilder; import com.android.dialer.contactphoto.ContactPhotoManager; import com.android.dialer.lettertile.LetterTileDrawable; +import com.android.dialer.precall.PreCall; import com.android.dialer.searchfragment.common.Projections; import com.android.dialer.searchfragment.common.QueryBoldingUtil; import com.android.dialer.searchfragment.common.R; import com.android.dialer.searchfragment.common.SearchCursor; -import com.android.dialer.telecom.TelecomUtil; /** ViewHolder for a nearby place row. */ public final class RemoteContactViewHolder extends RecyclerView.ViewHolder @@ -132,7 +132,6 @@ public final class RemoteContactViewHolder extends RecyclerView.ViewHolder @Override public void onClick(View v) { - TelecomUtil.placeCall( - context, new CallIntentBuilder(number, CallInitiationType.Type.REGULAR_SEARCH).build()); + PreCall.start(context, new CallIntentBuilder(number, CallInitiationType.Type.REGULAR_SEARCH)); } } diff --git a/java/com/android/dialer/searchfragment/remote/RemoteDirectoriesCursorLoader.java b/java/com/android/dialer/searchfragment/remote/RemoteDirectoriesCursorLoader.java index de71025cd..3d16c4351 100644 --- a/java/com/android/dialer/searchfragment/remote/RemoteDirectoriesCursorLoader.java +++ b/java/com/android/dialer/searchfragment/remote/RemoteDirectoriesCursorLoader.java @@ -36,12 +36,14 @@ public final class RemoteDirectoriesCursorLoader extends CursorLoader { private static final int DISPLAY_NAME = 1; private static final int PHOTO_SUPPORT = 2; + private static final int AUTHORITY = 3; @VisibleForTesting static final String[] PROJECTION = { ContactsContract.Directory._ID, ContactsContract.Directory.DISPLAY_NAME, ContactsContract.Directory.PHOTO_SUPPORT, + ContactsContract.Directory.DIRECTORY_AUTHORITY, }; public RemoteDirectoriesCursorLoader(Context context) { @@ -51,7 +53,10 @@ public final class RemoteDirectoriesCursorLoader extends CursorLoader { /** @return current cursor row represented as a {@link Directory}. */ public static Directory readDirectory(Cursor cursor) { return Directory.create( - cursor.getInt(ID), cursor.getString(DISPLAY_NAME), cursor.getInt(PHOTO_SUPPORT) != 0); + cursor.getInt(ID), + cursor.getString(DISPLAY_NAME), + cursor.getInt(PHOTO_SUPPORT) != 0, + cursor.getString(AUTHORITY)); } private static Uri getContentUri() { @@ -63,8 +68,14 @@ public final class RemoteDirectoriesCursorLoader extends CursorLoader { /** POJO representing the results returned from {@link RemoteDirectoriesCursorLoader}. */ @AutoValue public abstract static class Directory { + public static Directory create( + int id, @Nullable String displayName, boolean supportsPhotos, @Nullable String authority) { + return new AutoValue_RemoteDirectoriesCursorLoader_Directory( + id, displayName, supportsPhotos, authority); + } + public static Directory create(int id, @Nullable String displayName, boolean supportsPhotos) { - return new AutoValue_RemoteDirectoriesCursorLoader_Directory(id, displayName, supportsPhotos); + return create(id, displayName, supportsPhotos, null); } public abstract int getId(); @@ -73,5 +84,7 @@ public final class RemoteDirectoriesCursorLoader extends CursorLoader { abstract @Nullable String getDisplayName(); abstract boolean supportsPhotos(); + + abstract @Nullable String authority(); } } |