diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2018-02-15 18:08:21 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2018-02-15 18:08:21 +0000 |
commit | c54ce2658988ca36ca3dfab00daefca4dcfed3b2 (patch) | |
tree | fb432a423f670969da57a4900b5ff7dcc35d2f8c /java/com/android/dialer/searchfragment/remote | |
parent | 70f98d3997c42c7d4e3b3e3920659aca78820d14 (diff) | |
parent | 39009b4ad73d5017295b30fb18a77224195f06af (diff) |
Merge changes Ib360d3bc,Iae40d0ab,I486f7b1a,I709a1e30
* changes:
Mark calls as read in new call log.
Restored work profile contacts to Dialer search.
Clicking on a missed call in the call log no longer crashes the app.
Add bottom sheet options for blocked and/or spam numbers in the new call log.
Diffstat (limited to 'java/com/android/dialer/searchfragment/remote')
3 files changed, 24 insertions, 13 deletions
diff --git a/java/com/android/dialer/searchfragment/remote/RemoteContactViewHolder.java b/java/com/android/dialer/searchfragment/remote/RemoteContactViewHolder.java index 9d369003d..4be96fe58 100644 --- a/java/com/android/dialer/searchfragment/remote/RemoteContactViewHolder.java +++ b/java/com/android/dialer/searchfragment/remote/RemoteContactViewHolder.java @@ -26,8 +26,10 @@ import android.provider.ContactsContract.Contacts; import android.support.v7.widget.RecyclerView; import android.text.TextUtils; import android.view.View; +import android.widget.ImageView; import android.widget.QuickContactBadge; import android.widget.TextView; +import com.android.contacts.common.compat.DirectoryCompat; import com.android.dialer.callintent.CallInitiationType; import com.android.dialer.callintent.CallIntentBuilder; import com.android.dialer.contactphoto.ContactPhotoManager; @@ -46,6 +48,7 @@ public final class RemoteContactViewHolder extends RecyclerView.ViewHolder private final TextView nameView; private final TextView numberView; private final QuickContactBadge photo; + private final ImageView workBadge; private String number; @@ -55,6 +58,7 @@ public final class RemoteContactViewHolder extends RecyclerView.ViewHolder photo = view.findViewById(R.id.photo); nameView = view.findViewById(R.id.primary); numberView = view.findViewById(R.id.secondary); + workBadge = view.findViewById(R.id.work_icon); context = view.getContext(); } @@ -74,6 +78,10 @@ public final class RemoteContactViewHolder extends RecyclerView.ViewHolder nameView.setText(QueryBoldingUtil.getNameWithQueryBolded(query, name, context)); numberView.setText(QueryBoldingUtil.getNameWithQueryBolded(query, secondaryInfo, context)); + workBadge.setVisibility( + DirectoryCompat.isOnlyEnterpriseDirectoryId(cursor.getDirectoryId()) + ? View.VISIBLE + : View.GONE); if (shouldShowPhoto(cursor)) { nameView.setVisibility(View.VISIBLE); diff --git a/java/com/android/dialer/searchfragment/remote/RemoteContactsCursor.java b/java/com/android/dialer/searchfragment/remote/RemoteContactsCursor.java index 9510443b9..653c67041 100644 --- a/java/com/android/dialer/searchfragment/remote/RemoteContactsCursor.java +++ b/java/com/android/dialer/searchfragment/remote/RemoteContactsCursor.java @@ -22,6 +22,7 @@ import android.database.MatrixCursor; import android.database.MergeCursor; import android.support.annotation.Nullable; import android.support.annotation.VisibleForTesting; +import com.android.contacts.common.compat.DirectoryCompat; import com.android.dialer.common.Assert; import com.android.dialer.searchfragment.common.SearchCursor; import com.android.dialer.searchfragment.directories.DirectoriesCursorLoader; @@ -101,7 +102,12 @@ public final class RemoteContactsCursor extends MergeCursor implements SearchCur private static MatrixCursor createHeaderCursor(Context context, String name, long id) { MatrixCursor headerCursor = new MatrixCursor(PROJECTION, 1); - headerCursor.addRow(new Object[] {context.getString(R.string.directory, name), id}); + if (DirectoryCompat.isOnlyEnterpriseDirectoryId(id)) { + headerCursor.addRow( + new Object[] {context.getString(R.string.directory_search_label_work), id}); + } else { + headerCursor.addRow(new Object[] {context.getString(R.string.directory, name), id}); + } return headerCursor; } diff --git a/java/com/android/dialer/searchfragment/remote/RemoteContactsCursorLoader.java b/java/com/android/dialer/searchfragment/remote/RemoteContactsCursorLoader.java index 9feeb7e99..cf495e49c 100644 --- a/java/com/android/dialer/searchfragment/remote/RemoteContactsCursorLoader.java +++ b/java/com/android/dialer/searchfragment/remote/RemoteContactsCursorLoader.java @@ -27,6 +27,7 @@ import android.provider.ContactsContract; import android.provider.ContactsContract.CommonDataKinds.Phone; import android.support.annotation.NonNull; import android.support.annotation.VisibleForTesting; +import com.android.contacts.common.compat.DirectoryCompat; import com.android.dialer.searchfragment.common.Projections; import com.android.dialer.searchfragment.directories.DirectoriesCursorLoader.Directory; import java.util.ArrayList; @@ -71,7 +72,14 @@ public final class RemoteContactsCursorLoader extends CursorLoader { Directory directory = directories.get(i); // Filter out local directories - if (!isRemoteDirectory(directory.getId())) { + if (!DirectoryCompat.isRemoteDirectoryId(directory.getId()) + && !DirectoryCompat.isEnterpriseDirectoryId(directory.getId())) { + cursors[i] = null; + continue; + } + + // Filter out invisible directories + if (DirectoryCompat.isInvisibleDirectory(directory.getId())) { cursors[i] = null; continue; } @@ -93,17 +101,6 @@ public final class RemoteContactsCursorLoader extends CursorLoader { return RemoteContactsCursor.newInstance(getContext(), cursors, directories); } - private static boolean isRemoteDirectory(long directoryId) { - return VERSION.SDK_INT >= VERSION_CODES.N - ? ContactsContract.Directory.isRemoteDirectoryId(directoryId) - : (directoryId != ContactsContract.Directory.DEFAULT - && directoryId != ContactsContract.Directory.LOCAL_INVISIBLE - // Directory.ENTERPRISE_DEFAULT is the default work profile directory for locally stored - // contacts - && directoryId != ContactsContract.Directory.ENTERPRISE_DEFAULT - && directoryId != ContactsContract.Directory.ENTERPRISE_LOCAL_INVISIBLE); - } - private MatrixCursor createMatrixCursorFilteringNullNumbers(Cursor cursor) { if (cursor == null) { return null; |