summaryrefslogtreecommitdiffstats
path: root/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'java/com')
-rw-r--r--java/com/android/dialer/calllog/datasources/phonelookup/PhoneLookupDataSource.java13
-rw-r--r--java/com/android/dialer/calllog/ui/NewCallLogAdapter.java20
-rw-r--r--java/com/android/dialer/calllog/ui/NewCallLogFragment.java11
-rw-r--r--java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java12
-rw-r--r--java/com/android/dialer/calllog/ui/menu/PrimaryAction.java9
-rw-r--r--java/com/android/dialer/calllogutils/CallLogContactTypes.java38
-rw-r--r--java/com/android/dialer/contactactions/ContactActionBottomSheet.java4
-rw-r--r--java/com/android/dialer/contactactions/res/layout/contact_layout.xml17
8 files changed, 97 insertions, 27 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();
diff --git a/java/com/android/dialer/calllogutils/CallLogContactTypes.java b/java/com/android/dialer/calllogutils/CallLogContactTypes.java
new file mode 100644
index 000000000..01ae653b4
--- /dev/null
+++ b/java/com/android/dialer/calllogutils/CallLogContactTypes.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.dialer.calllogutils;
+
+import com.android.dialer.calllog.model.CoalescedRow;
+import com.android.dialer.lettertile.LetterTileDrawable;
+
+/** Determines the {@link LetterTileDrawable.ContactType} for a {@link CoalescedRow}. */
+public class CallLogContactTypes {
+
+ /** Determines the {@link LetterTileDrawable.ContactType} for a {@link CoalescedRow}. */
+ @LetterTileDrawable.ContactType
+ public static int getContactType(CoalescedRow row) {
+ // TODO(zachh): Set these fields correctly.
+ boolean isVoicemail = false;
+ boolean isSpam = false;
+ boolean isBusiness = false;
+ int numberPresentation = 0;
+ boolean isConference = false;
+
+ return LetterTileDrawable.getContactTypeFromPrimitives(
+ isVoicemail, isSpam, isBusiness, numberPresentation, isConference);
+ }
+}
diff --git a/java/com/android/dialer/contactactions/ContactActionBottomSheet.java b/java/com/android/dialer/contactactions/ContactActionBottomSheet.java
index f2f1d189b..7e216aaa1 100644
--- a/java/com/android/dialer/contactactions/ContactActionBottomSheet.java
+++ b/java/com/android/dialer/contactactions/ContactActionBottomSheet.java
@@ -89,9 +89,9 @@ public class ContactActionBottomSheet extends BottomSheetDialog implements OnCli
ContactPhotoManager.getInstance(getContext())
.loadDialerThumbnailOrPhoto(
contactView.findViewById(R.id.quick_contact_photo),
- photoInfo.lookupUri() != null ? Uri.parse(photoInfo.lookupUri()) : null,
+ !TextUtils.isEmpty(photoInfo.lookupUri()) ? Uri.parse(photoInfo.lookupUri()) : null,
photoInfo.photoId(),
- photoInfo.photoUri() != null ? Uri.parse(photoInfo.photoUri()) : null,
+ !TextUtils.isEmpty(photoInfo.photoUri()) ? Uri.parse(photoInfo.photoUri()) : null,
photoInfo.displayName(),
photoInfo.contactType());
diff --git a/java/com/android/dialer/contactactions/res/layout/contact_layout.xml b/java/com/android/dialer/contactactions/res/layout/contact_layout.xml
index 8ea05d4d6..4deef3e07 100644
--- a/java/com/android/dialer/contactactions/res/layout/contact_layout.xml
+++ b/java/com/android/dialer/contactactions/res/layout/contact_layout.xml
@@ -15,12 +15,13 @@
~ limitations under the License
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="8dp"
android:layout_marginBottom="12dp"
- android:layout_marginEnd="8dp">
+ android:layout_marginEnd="8dp"
+ android:gravity="center_vertical"
+ android:orientation="horizontal">
<QuickContactBadge
android:id="@+id/quick_contact_photo"
@@ -32,22 +33,22 @@
android:focusable="true"/>
<LinearLayout
- android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:gravity="center_vertical">
+ android:gravity="center_vertical"
+ android:orientation="vertical">
<TextView
android:id="@+id/primary_text"
+ style="@style/PrimaryText"
android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- style="@style/PrimaryText"/>
+ android:layout_height="wrap_content"/>
<TextView
android:id="@+id/secondary_text"
+ style="@style/SecondaryText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginTop="2dp"
- style="@style/SecondaryText"/>
+ android:layout_marginTop="2dp"/>
</LinearLayout>
</LinearLayout> \ No newline at end of file