diff options
Diffstat (limited to 'java/com/android/dialer/calllog')
5 files changed, 48 insertions, 17 deletions
diff --git a/java/com/android/dialer/calllog/datasources/phonelookup/PhoneLookupDataSource.java b/java/com/android/dialer/calllog/datasources/phonelookup/PhoneLookupDataSource.java index 508191cde..dca992789 100644 --- a/java/com/android/dialer/calllog/datasources/phonelookup/PhoneLookupDataSource.java +++ b/java/com/android/dialer/calllog/datasources/phonelookup/PhoneLookupDataSource.java @@ -141,6 +141,13 @@ public final class PhoneLookupDataSource */ @Override public ListenableFuture<Void> fill(Context appContext, CallLogMutations mutations) { + LogUtil.v( + "PhoneLookupDataSource.fill", + "processing mutations (inserts: %d, updates: %d, deletes: %d)", + mutations.getInserts().size(), + mutations.getUpdates().size(), + mutations.getDeletes().size()); + // Clear state saved since the last call to fill. This is necessary in case fill is called but // onSuccessfulFill is not called during a previous flow. phoneLookupHistoryRowsToUpdate.clear(); @@ -224,6 +231,12 @@ public final class PhoneLookupDataSource rowsToUpdateFuture, rowsToUpdate -> { updateMutations(rowsToUpdate, mutations); + LogUtil.v( + "PhoneLookupDataSource.fill", + "updated mutations (inserts: %d, updates: %d, deletes: %d)", + mutations.getInserts().size(), + mutations.getUpdates().size(), + mutations.getDeletes().size()); return null; }, lightweightExecutorService); diff --git a/java/com/android/dialer/calllog/ui/NewCallLogAdapter.java b/java/com/android/dialer/calllog/ui/NewCallLogAdapter.java index 6dd742be5..a4a67d712 100644 --- a/java/com/android/dialer/calllog/ui/NewCallLogAdapter.java +++ b/java/com/android/dialer/calllog/ui/NewCallLogAdapter.java @@ -44,23 +44,35 @@ final class NewCallLogAdapter extends RecyclerView.Adapter<ViewHolder> { int CALL_LOG_ENTRY = 3; } - private final Cursor cursor; private final Clock clock; private final RealtimeRowProcessor realtimeRowProcessor; + private Cursor cursor; + /** Null when the "Today" header should not be displayed. */ - @Nullable private final Integer todayHeaderPosition; + @Nullable private Integer todayHeaderPosition; /** Null when the "Older" header should not be displayed. */ - @Nullable private final Integer olderHeaderPosition; + @Nullable private Integer olderHeaderPosition; NewCallLogAdapter(Context context, Cursor cursor, Clock clock) { this.cursor = cursor; this.clock = clock; this.realtimeRowProcessor = CallLogUiComponent.get(context).realtimeRowProcessor(); + setHeaderPositions(); + } + + void updateCursor(Cursor updatedCursor) { + this.cursor = updatedCursor; + + setHeaderPositions(); + notifyDataSetChanged(); + } + + private void setHeaderPositions() { // Calculate header adapter positions by reading cursor. long currentTimeMillis = clock.currentTimeMillis(); - if (cursor.moveToNext()) { + if (cursor.moveToFirst()) { long firstTimestamp = CoalescedAnnotatedCallLogCursorLoader.getTimestamp(cursor); if (CallLogDates.isSameDay(currentTimeMillis, firstTimestamp)) { this.todayHeaderPosition = 0; diff --git a/java/com/android/dialer/calllog/ui/NewCallLogFragment.java b/java/com/android/dialer/calllog/ui/NewCallLogFragment.java index d0656a433..6db7c5d6c 100644 --- a/java/com/android/dialer/calllog/ui/NewCallLogFragment.java +++ b/java/com/android/dialer/calllog/ui/NewCallLogFragment.java @@ -174,10 +174,15 @@ public final class NewCallLogFragment extends Fragment LogUtil.w("NewCallLogFragment.onLoadFinished", "null cursor"); return; } + // TODO(zachh): Handle empty cursor by showing empty view. - recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); - recyclerView.setAdapter( - new NewCallLogAdapter(getContext(), newCursor, System::currentTimeMillis)); + if (recyclerView.getAdapter() == null) { + recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); + recyclerView.setAdapter( + new NewCallLogAdapter(getContext(), newCursor, System::currentTimeMillis)); + } else { + ((NewCallLogAdapter) recyclerView.getAdapter()).updateCursor(newCursor); + } } @Override diff --git a/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java b/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java index 5cceac989..7482efdea 100644 --- a/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java +++ b/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java @@ -21,12 +21,14 @@ import android.database.Cursor; import android.net.Uri; import android.provider.CallLog.Calls; 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.dialer.calllog.model.CoalescedRow; import com.android.dialer.calllog.ui.menu.NewCallLogMenu; +import com.android.dialer.calllogutils.CallLogContactTypes; import com.android.dialer.calllogutils.CallLogEntryText; import com.android.dialer.calllogutils.CallLogIntents; import com.android.dialer.calllogutils.CallTypeIconsView; @@ -34,7 +36,6 @@ import com.android.dialer.common.LogUtil; import com.android.dialer.common.concurrent.DialerExecutorComponent; import com.android.dialer.compat.telephony.TelephonyManagerCompat; import com.android.dialer.contactphoto.ContactPhotoManager; -import com.android.dialer.lettertile.LetterTileDrawable; import com.android.dialer.oem.MotorolaUtils; import com.android.dialer.time.Clock; import com.google.common.base.Optional; @@ -130,15 +131,14 @@ final class NewCallLogViewHolder extends RecyclerView.ViewHolder { } private void setPhoto(CoalescedRow row) { - // TODO(zachh): Set the contact type. ContactPhotoManager.getInstance(context) .loadDialerThumbnailOrPhoto( quickContactBadge, - row.lookupUri() == null ? null : Uri.parse(row.lookupUri()), + TextUtils.isEmpty(row.lookupUri()) ? null : Uri.parse(row.lookupUri()), row.photoId(), - row.photoUri() == null ? null : Uri.parse(row.photoUri()), - row.name(), - LetterTileDrawable.TYPE_DEFAULT); + TextUtils.isEmpty(row.photoUri()) ? null : Uri.parse(row.photoUri()), + CallLogEntryText.buildPrimaryText(context, row).toString(), + CallLogContactTypes.getContactType(row)); } private void setPrimaryCallTypes(CoalescedRow row) { diff --git a/java/com/android/dialer/calllog/ui/menu/PrimaryAction.java b/java/com/android/dialer/calllog/ui/menu/PrimaryAction.java index 404c41787..faedc8f62 100644 --- a/java/com/android/dialer/calllog/ui/menu/PrimaryAction.java +++ b/java/com/android/dialer/calllog/ui/menu/PrimaryAction.java @@ -19,16 +19,17 @@ package com.android.dialer.calllog.ui.menu; import android.content.Context; import android.provider.CallLog.Calls; import com.android.dialer.calllog.model.CoalescedRow; +import com.android.dialer.calllogutils.CallLogContactTypes; import com.android.dialer.calllogutils.CallLogEntryText; import com.android.dialer.calllogutils.CallLogIntents; import com.android.dialer.contactactions.ContactPrimaryActionInfo; import com.android.dialer.contactactions.ContactPrimaryActionInfo.PhotoInfo; -import com.android.dialer.lettertile.LetterTileDrawable; /** Configures the primary action row (top row) for the bottom sheet. */ final class PrimaryAction { static ContactPrimaryActionInfo fromRow(Context context, CoalescedRow row) { + CharSequence primaryText = CallLogEntryText.buildPrimaryText(context, row); return ContactPrimaryActionInfo.builder() .setNumber(row.number()) .setPhotoInfo( @@ -37,10 +38,10 @@ final class PrimaryAction { .setPhotoUri(row.photoUri()) .setLookupUri(row.lookupUri()) .setIsVideo((row.features() & Calls.FEATURES_VIDEO) == Calls.FEATURES_VIDEO) - .setContactType(LetterTileDrawable.TYPE_DEFAULT) // TODO(zachh): Use proper type. - .setDisplayName(row.name()) + .setContactType(CallLogContactTypes.getContactType(row)) + .setDisplayName(primaryText.toString()) .build()) - .setPrimaryText(CallLogEntryText.buildPrimaryText(context, row)) + .setPrimaryText(primaryText) .setSecondaryText(CallLogEntryText.buildSecondaryTextForBottomSheet(context, row)) .setIntent(CallLogIntents.getCallBackIntent(context, row)) .build(); |