Added icons and phone accounts to new call log.
Screenshot: https://screenshot.googleplex.com/WKmkwDggbz2
Bug: 34672501
Test: unit except for viewholder, which should probably be tested by screenshot diffs in the future
PiperOrigin-RevId: 166767607
Change-Id: I3333e4e742e401b7b870c4e8f13c484eebddf365
diff --git a/java/com/android/dialer/calllog/database/Coalescer.java b/java/com/android/dialer/calllog/database/Coalescer.java
index 55bed3e..63fa9f8 100644
--- a/java/com/android/dialer/calllog/database/Coalescer.java
+++ b/java/com/android/dialer/calllog/database/Coalescer.java
@@ -32,6 +32,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import javax.inject.Inject;
/**
@@ -129,7 +130,12 @@
*/
private static boolean rowsShouldBeCombined(
DialerPhoneNumberUtil dialerPhoneNumberUtil, ContentValues row1, ContentValues row2) {
- // TODO(zachh): Real implementation.
+ // Don't combine rows which don't use the same phone account.
+ if (!Objects.equals(
+ row1.getAsString(AnnotatedCallLog.PHONE_ACCOUNT_LABEL),
+ row2.getAsString(AnnotatedCallLog.PHONE_ACCOUNT_LABEL))) {
+ return false;
+ }
DialerPhoneNumber number1;
DialerPhoneNumber number2;
try {
diff --git a/java/com/android/dialer/calllog/datasources/systemcalllog/SystemCallLogDataSource.java b/java/com/android/dialer/calllog/datasources/systemcalllog/SystemCallLogDataSource.java
index e4af417..9d77505 100644
--- a/java/com/android/dialer/calllog/datasources/systemcalllog/SystemCallLogDataSource.java
+++ b/java/com/android/dialer/calllog/datasources/systemcalllog/SystemCallLogDataSource.java
@@ -29,6 +29,7 @@
import android.provider.CallLog;
import android.provider.CallLog.Calls;
import android.provider.ContactsContract.CommonDataKinds.Phone;
+import android.support.annotation.ColorInt;
import android.support.annotation.MainThread;
import android.support.annotation.Nullable;
import android.support.annotation.VisibleForTesting;
@@ -159,6 +160,8 @@
.useMostRecentString(AnnotatedCallLog.NUMBER_TYPE_LABEL)
.useMostRecentString(AnnotatedCallLog.GEOCODED_LOCATION)
.useMostRecentString(AnnotatedCallLog.FORMATTED_NUMBER)
+ .useSingleValueString(AnnotatedCallLog.PHONE_ACCOUNT_LABEL)
+ .useSingleValueLong(AnnotatedCallLog.PHONE_ACCOUNT_COLOR)
.combine();
CallTypes.Builder callTypes = CallTypes.newBuilder();
@@ -245,7 +248,7 @@
long id = cursor.getLong(idColumn);
long date = cursor.getLong(dateColumn);
String numberAsStr = cursor.getString(numberColumn);
- long type = cursor.getType(typeColumn);
+ long type = cursor.getInt(typeColumn);
String countryIso = cursor.getString(countryIsoColumn);
String formattedNumber = cursor.getString(cachedFormattedNumberColumn);
int cachedNumberType = cursor.getInt(cachedNumberTypeColumn);
@@ -311,9 +314,12 @@
}
contentValues.put(AnnotatedCallLog.PHONE_ACCOUNT_LABEL, label);
- int color = PhoneAccountUtils.getAccountColor(appContext, phoneAccountHandle);
+ @ColorInt int color = PhoneAccountUtils.getAccountColor(appContext, phoneAccountHandle);
if (color == PhoneAccount.NO_HIGHLIGHT_COLOR) {
- color = R.color.dialer_secondary_text_color;
+ color =
+ appContext
+ .getResources()
+ .getColor(R.color.dialer_secondary_text_color, appContext.getTheme());
}
contentValues.put(AnnotatedCallLog.PHONE_ACCOUNT_COLOR, color);
}
diff --git a/java/com/android/dialer/calllog/datasources/util/RowCombiner.java b/java/com/android/dialer/calllog/datasources/util/RowCombiner.java
index 3595a05..adb7a07 100644
--- a/java/com/android/dialer/calllog/datasources/util/RowCombiner.java
+++ b/java/com/android/dialer/calllog/datasources/util/RowCombiner.java
@@ -19,6 +19,7 @@
import com.android.dialer.common.Assert;
import java.util.Iterator;
import java.util.List;
+import java.util.Objects;
/** Convenience class for aggregating row values. */
public class RowCombiner {
@@ -48,11 +49,19 @@
String singleValue = iterator.next().getAsString(columnName);
while (iterator.hasNext()) {
String current = iterator.next().getAsString(columnName);
- if (current == null) {
- Assert.checkState(singleValue == null);
- } else {
- Assert.checkState(current.equals(singleValue));
- }
+ Assert.checkState(Objects.equals(singleValue, current), "Values different for " + columnName);
+ }
+ combinedRow.put(columnName, singleValue);
+ return this;
+ }
+
+ /** Asserts that all column values for the given column name are the same, and uses it. */
+ public RowCombiner useSingleValueLong(String columnName) {
+ Iterator<ContentValues> iterator = individualRowsSortedByTimestampDesc.iterator();
+ Long singleValue = iterator.next().getAsLong(columnName);
+ while (iterator.hasNext()) {
+ Long current = iterator.next().getAsLong(columnName);
+ Assert.checkState(Objects.equals(singleValue, current), "Values different for " + columnName);
}
combinedRow.put(columnName, singleValue);
return this;
diff --git a/java/com/android/dialer/calllog/ui/CoalescedAnnotatedCallLogCursorLoader.java b/java/com/android/dialer/calllog/ui/CoalescedAnnotatedCallLogCursorLoader.java
index 51a5532..0dacece 100644
--- a/java/com/android/dialer/calllog/ui/CoalescedAnnotatedCallLogCursorLoader.java
+++ b/java/com/android/dialer/calllog/ui/CoalescedAnnotatedCallLogCursorLoader.java
@@ -18,9 +18,12 @@
import android.content.Context;
import android.database.Cursor;
+import android.support.annotation.ColorInt;
+import android.support.annotation.NonNull;
import android.support.v4.content.CursorLoader;
import com.android.dialer.CallTypes;
import com.android.dialer.calllog.database.contract.AnnotatedCallLogContract.CoalescedAnnotatedCallLog;
+import com.android.dialer.common.Assert;
import com.google.protobuf.InvalidProtocolBufferException;
/** CursorLoader for the coalesced annotated call log. */
@@ -89,6 +92,7 @@
return cursor.getString(PHONE_ACCOUNT_LABEL);
}
+ @ColorInt
int phoneAccountColor() {
return cursor.getInt(PHONE_ACCOUNT_COLOR);
}
@@ -113,8 +117,13 @@
return cursor.getString(FORMATTED_NUMBER);
}
- CallTypes callTypes() throws InvalidProtocolBufferException {
- return CallTypes.parseFrom(cursor.getBlob(CALL_TYPES));
+ @NonNull
+ CallTypes callTypes() {
+ try {
+ return CallTypes.parseFrom(cursor.getBlob(CALL_TYPES));
+ } catch (InvalidProtocolBufferException e) {
+ throw Assert.createAssertionFailException("Couldn't parse call types", e);
+ }
}
}
diff --git a/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java b/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java
index b6b658f..58c98f6 100644
--- a/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java
+++ b/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java
@@ -23,9 +23,12 @@
import android.view.View;
import android.widget.QuickContactBadge;
import android.widget.TextView;
+import com.android.dialer.calllog.ui.CoalescedAnnotatedCallLogCursorLoader.Row;
import com.android.dialer.calllogutils.CallLogDates;
+import com.android.dialer.calllogutils.CallTypeIconsView;
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 java.util.Locale;
@@ -36,6 +39,9 @@
private final TextView primaryTextView;
private final TextView secondaryTextView;
private final QuickContactBadge quickContactBadge;
+ private final CallTypeIconsView primaryCallTypeIconsView; // Used for Wifi, HD icons
+ private final CallTypeIconsView secondaryCallTypeIconsView; // Used for call types
+ private final TextView phoneAccountView;
private final Clock clock;
NewCallLogViewHolder(View view, Clock clock) {
@@ -44,6 +50,9 @@
primaryTextView = view.findViewById(R.id.primary_text);
secondaryTextView = view.findViewById(R.id.secondary_text);
quickContactBadge = view.findViewById(R.id.quick_contact_photo);
+ primaryCallTypeIconsView = view.findViewById(R.id.primary_call_type_icons);
+ secondaryCallTypeIconsView = view.findViewById(R.id.secondary_call_type_icons);
+ phoneAccountView = view.findViewById(R.id.phone_account);
this.clock = clock;
}
@@ -52,8 +61,6 @@
CoalescedAnnotatedCallLogCursorLoader.Row row =
new CoalescedAnnotatedCallLogCursorLoader.Row(cursor);
- // TODO(zachh): Add HD icon and Wifi icon after primary text.
- // TODO(zachh): Call type icons for last 3 calls.
// TODO(zachh): Use name for primary text if available.
// TODO(zachh): Handle CallLog.Calls.PRESENTATION_*, including Verizon restricted numbers.
// TODO(zachh): Handle RTL properly.
@@ -68,6 +75,9 @@
}
setPhoto();
+ setPrimaryCallTypes(row);
+ setSecondaryCallTypes(row);
+ setPhoneAccounts(row);
}
private String buildPrimaryText(CoalescedAnnotatedCallLogCursorLoader.Row row) {
@@ -130,4 +140,28 @@
.loadDialerThumbnailOrPhoto(
quickContactBadge, null, 0, null, null, LetterTileDrawable.TYPE_DEFAULT);
}
+
+ private void setPrimaryCallTypes(Row row) {
+ // Only HD and Wifi icons are shown following the primary text.
+ primaryCallTypeIconsView.setShowHd(
+ MotorolaUtils.shouldShowHdIconInCallLog(context, row.features()));
+ primaryCallTypeIconsView.setShowWifi(
+ MotorolaUtils.shouldShowWifiIconInCallLog(context, row.features()));
+ }
+
+ private void setSecondaryCallTypes(Row row) {
+ // Only call type icons are shown before the secondary text.
+ for (int callType : row.callTypes().getTypeList()) {
+ secondaryCallTypeIconsView.add(callType);
+ }
+ // TODO(zachh): Per new mocks, may need to add method to CallTypeIconsView to disable coloring.
+ }
+
+ private void setPhoneAccounts(Row row) {
+ if (row.phoneAccountLabel() != null) {
+ phoneAccountView.setText(row.phoneAccountLabel());
+ phoneAccountView.setTextColor(row.phoneAccountColor());
+ phoneAccountView.setVisibility(View.VISIBLE);
+ }
+ }
}
diff --git a/java/com/android/dialer/calllog/ui/res/layout/new_call_log_entry.xml b/java/com/android/dialer/calllog/ui/res/layout/new_call_log_entry.xml
index 568b351..77ba681 100644
--- a/java/com/android/dialer/calllog/ui/res/layout/new_call_log_entry.xml
+++ b/java/com/android/dialer/calllog/ui/res/layout/new_call_log_entry.xml
@@ -42,19 +42,52 @@
android:layout_toStartOf="@+id/menu_button"
android:orientation="vertical">
- <TextView
- android:id="@+id/primary_text"
- style="@style/PrimaryText"
+ <!-- TODO(zachh): Optimize this layout -->
+ <LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginStart="@dimen/call_log_entry_photo_text_margin"/>
+ android:orientation="horizontal">
- <TextView
- android:id="@+id/secondary_text"
- style="@style/SecondaryText"
+ <TextView
+ android:id="@+id/primary_text"
+ style="@style/PrimaryText"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="@dimen/call_log_entry_photo_text_margin"/>
+
+ <!-- HD and Wifi icons are shown adjacent to primary text. Call types are shown adjacent to
+ secondary text (below). -->
+ <com.android.dialer.calllogutils.CallTypeIconsView
+ android:id="@+id/primary_call_type_icons"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="12dp"
+ android:layout_gravity="center_vertical"/>
+
+ </LinearLayout>
+
+ <!-- TODO(zachh): Optimize this layout -->
+ <LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginStart="@dimen/call_log_entry_photo_text_margin"/>
+ android:orientation="horizontal">
+
+ <!-- Only call types are shown adjacent to secondary text. HD and Wifi icons are shown
+ adjacent to primary text (above). -->
+ <com.android.dialer.calllogutils.CallTypeIconsView
+ android:id="@+id/secondary_call_type_icons"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="12dp"
+ android:layout_gravity="center_vertical"/>
+
+ <TextView
+ android:id="@+id/secondary_text"
+ style="@style/SecondaryText"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="@dimen/call_log_entry_photo_text_margin"/>
+ </LinearLayout>
<TextView
android:id="@+id/phone_account"
diff --git a/java/com/android/dialer/contactsfragment/ContactsFragment.java b/java/com/android/dialer/contactsfragment/ContactsFragment.java
index 86ac834..0e76086 100644
--- a/java/com/android/dialer/contactsfragment/ContactsFragment.java
+++ b/java/com/android/dialer/contactsfragment/ContactsFragment.java
@@ -16,6 +16,9 @@
package com.android.dialer.contactsfragment;
+import static com.android.dialer.contactsfragment.ContactsFragment.Header.ADD_CONTACT;
+import static com.android.dialer.contactsfragment.ContactsFragment.Header.NONE;
+
import android.app.Fragment;
import android.app.LoaderManager.LoaderCallbacks;
import android.content.Loader;
@@ -67,9 +70,7 @@
/** An enum for the different types of headers that be inserted at position 0 in the list. */
@Retention(RetentionPolicy.SOURCE)
- @IntDef({
- ContactsFragment.Header.NONE,
- ContactsFragment.Header.ADD_CONTACT})
+ @IntDef({NONE, ADD_CONTACT})
public @interface Header {
int NONE = 0;
/** Header that allows the user to add a new contact. */
diff --git a/java/com/android/dialer/strictmode/DialerStrictMode.java b/java/com/android/dialer/strictmode/DialerStrictMode.java
index c7d0b3f..f895f7c 100644
--- a/java/com/android/dialer/strictmode/DialerStrictMode.java
+++ b/java/com/android/dialer/strictmode/DialerStrictMode.java
@@ -145,5 +145,3 @@
runnable.run();
}
}
-
-