Merge "Use IS_READ instead of NEW in new call log."
diff --git a/java/com/android/dialer/calllog/ClearMissedCalls.java b/java/com/android/dialer/calllog/ClearMissedCalls.java
index d216e7b..78eb802 100644
--- a/java/com/android/dialer/calllog/ClearMissedCalls.java
+++ b/java/com/android/dialer/calllog/ClearMissedCalls.java
@@ -38,8 +38,8 @@
 import javax.inject.Inject;
 
 /**
- * Clears missed calls. This includes cancelling notifications and updating the "NEW" status in the
- * system call log.
+ * Clears missed calls. This includes cancelling notifications and updating the "IS_READ" status in
+ * the system call log.
  */
 public final class ClearMissedCalls {
 
@@ -58,11 +58,11 @@
   }
 
   /**
-   * Cancels all missed call notifications and marks all "new" missed calls in the system call log
-   * as "not new".
+   * Cancels all missed call notifications and marks all "unread" missed calls in the system call
+   * log as "read".
    */
   public ListenableFuture<Void> clearAll() {
-    ListenableFuture<Void> markNewFuture = markNotNew(ImmutableSet.of());
+    ListenableFuture<Void> markReadFuture = markRead(ImmutableSet.of());
     ListenableFuture<Void> cancelNotificationsFuture =
         uiThreadExecutor.submit(
             () -> {
@@ -73,11 +73,11 @@
     // Note on this usage of whenAllComplete:
     //   -The returned future completes when all sub-futures complete (whether they fail or not)
     //   -The returned future fails if any sub-future fails
-    return Futures.whenAllComplete(markNewFuture, cancelNotificationsFuture)
+    return Futures.whenAllComplete(markReadFuture, cancelNotificationsFuture)
         .call(
             () -> {
               // Calling get() is necessary to propagate failures.
-              markNewFuture.get();
+              markReadFuture.get();
               cancelNotificationsFuture.get();
               return null;
             },
@@ -86,12 +86,12 @@
 
   /**
    * For the provided set of IDs from the system call log, cancels their missed call notifications
-   * and marks them "not new".
+   * and marks them "read".
    *
    * @param ids IDs from the system call log (see {@link Calls#_ID}}.
    */
   public ListenableFuture<Void> clearBySystemCallLogId(Collection<Long> ids) {
-    ListenableFuture<Void> markNewFuture = markNotNew(ids);
+    ListenableFuture<Void> markReadFuture = markRead(ids);
     ListenableFuture<Void> cancelNotificationsFuture =
         uiThreadExecutor.submit(
             () -> {
@@ -105,11 +105,11 @@
     // Note on this usage of whenAllComplete:
     //   -The returned future completes when all sub-futures complete (whether they fail or not)
     //   -The returned future fails if any sub-future fails
-    return Futures.whenAllComplete(markNewFuture, cancelNotificationsFuture)
+    return Futures.whenAllComplete(markReadFuture, cancelNotificationsFuture)
         .call(
             () -> {
               // Calling get() is necessary to propagate failures.
-              markNewFuture.get();
+              markReadFuture.get();
               cancelNotificationsFuture.get();
               return null;
             },
@@ -117,28 +117,28 @@
   }
 
   /**
-   * Marks all provided system call log IDs as not new, or if the provided collection is empty,
-   * marks all calls as not new.
+   * Marks all provided system call log IDs as read, or if the provided collection is empty, marks
+   * all calls as read.
    */
   @SuppressLint("MissingPermission")
-  private ListenableFuture<Void> markNotNew(Collection<Long> ids) {
+  private ListenableFuture<Void> markRead(Collection<Long> ids) {
     return backgroundExecutor.submit(
         () -> {
           if (!UserManagerCompat.isUserUnlocked(appContext)) {
-            LogUtil.e("ClearMissedCalls.markNotNew", "locked");
+            LogUtil.e("ClearMissedCalls.markRead", "locked");
             return null;
           }
           if (!PermissionsUtil.hasCallLogWritePermissions(appContext)) {
-            LogUtil.e("ClearMissedCalls.markNotNew", "no permission");
+            LogUtil.e("ClearMissedCalls.markRead", "no permission");
             return null;
           }
 
           ContentValues values = new ContentValues();
-          values.put(Calls.NEW, 0);
+          values.put(Calls.IS_READ, 1);
 
           Selection.Builder selectionBuilder =
               Selection.builder()
-                  .and(Selection.column(Calls.NEW).is("=", 1))
+                  .and(Selection.column(Calls.IS_READ).is("=", 0))
                   .and(Selection.column(Calls.TYPE).is("=", Calls.MISSED_TYPE));
           if (!ids.isEmpty()) {
             selectionBuilder.and(Selection.column(Calls._ID).in(toStrings(ids)));
diff --git a/java/com/android/dialer/calllog/datasources/systemcalllog/SystemCallLogDataSource.java b/java/com/android/dialer/calllog/datasources/systemcalllog/SystemCallLogDataSource.java
index 8362a81..aa4260c 100644
--- a/java/com/android/dialer/calllog/datasources/systemcalllog/SystemCallLogDataSource.java
+++ b/java/com/android/dialer/calllog/datasources/systemcalllog/SystemCallLogDataSource.java
@@ -225,6 +225,7 @@
     return new RowCombiner(individualRowsSortedByTimestampDesc)
         .useMostRecentLong(AnnotatedCallLog.TIMESTAMP)
         .useMostRecentLong(AnnotatedCallLog.NEW)
+        .useMostRecentLong(AnnotatedCallLog.IS_READ)
         // Two different DialerPhoneNumbers could be combined if they are different but considered
         // to be an "exact match" by libphonenumber; in this case we arbitrarily select the most
         // recent one.
diff --git a/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java b/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java
index 1f84ebf..217208d 100644
--- a/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java
+++ b/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java
@@ -109,11 +109,11 @@
     primaryTextView.setText(CallLogEntryText.buildPrimaryText(context, row));
     secondaryTextView.setText(CallLogEntryText.buildSecondaryTextForEntries(context, clock, row));
 
-    if (isNewMissedCall(row)) {
-      primaryTextView.setTextAppearance(R.style.primary_textview_new_call);
-      callCountTextView.setTextAppearance(R.style.primary_textview_new_call);
-      secondaryTextView.setTextAppearance(R.style.secondary_textview_new_call);
-      phoneAccountView.setTextAppearance(R.style.phoneaccount_textview_new_call);
+    if (isUnreadMissedCall(row)) {
+      primaryTextView.setTextAppearance(R.style.primary_textview_unread_call);
+      callCountTextView.setTextAppearance(R.style.primary_textview_unread_call);
+      secondaryTextView.setTextAppearance(R.style.secondary_textview_unread_call);
+      phoneAccountView.setTextAppearance(R.style.phoneaccount_textview_unread_call);
     } else {
       primaryTextView.setTextAppearance(R.style.primary_textview);
       callCountTextView.setTextAppearance(R.style.primary_textview);
@@ -140,10 +140,11 @@
     }
   }
 
-  private boolean isNewMissedCall(CoalescedRow row) {
+  private boolean isUnreadMissedCall(CoalescedRow row) {
     // Show missed call styling if the most recent call in the group was missed and it is still
-    // marked as NEW. It is not clear what IS_READ should be used for and it is currently not used.
-    return row.getCallType() == Calls.MISSED_TYPE && row.getIsNew();
+    // marked as not read. The "NEW" column is presumably used for notifications and voicemails
+    // only.
+    return row.getCallType() == Calls.MISSED_TYPE && !row.getIsRead();
   }
 
   private void setPhoto(CoalescedRow row) {
@@ -159,7 +160,7 @@
     ColorStateList colorStateList =
         ColorStateList.valueOf(
             context.getColor(
-                isNewMissedCall(row)
+                isUnreadMissedCall(row)
                     ? R.color.feature_icon_unread_color
                     : R.color.feature_icon_read_color));
 
@@ -217,7 +218,7 @@
     }
     callTypeIcon.setImageResource(resId);
 
-    if (isNewMissedCall(row)) {
+    if (isUnreadMissedCall(row)) {
       callTypeIcon.setImageTintList(
           ColorStateList.valueOf(context.getColor(R.color.call_type_icon_unread_color)));
     } else {
diff --git a/java/com/android/dialer/calllog/ui/menu/NewCallLogMenu.java b/java/com/android/dialer/calllog/ui/menu/NewCallLogMenu.java
index dabb9bb..3869e78 100644
--- a/java/com/android/dialer/calllog/ui/menu/NewCallLogMenu.java
+++ b/java/com/android/dialer/calllog/ui/menu/NewCallLogMenu.java
@@ -35,9 +35,9 @@
       HistoryItemActionBottomSheet.show(
           context, BottomSheetHeader.fromRow(context, row), Modules.fromRow(context, row));
 
-      // If the user opens the bottom sheet for a new call, clear the notifications and make the row
-      // not bold immediately. To do this, mark all of the calls in group as not new.
-      if (row.getIsNew() && row.getCallType() == Calls.MISSED_TYPE) {
+      // If the user opens the bottom sheet for an unread call, clear the notifications and make the
+      // row not bold immediately. To do this, mark all of the calls in group as read.
+      if (!row.getIsRead() && row.getCallType() == Calls.MISSED_TYPE) {
         Futures.addCallback(
             CallLogComponent.get(context)
                 .getClearMissedCalls()
diff --git a/java/com/android/dialer/calllog/ui/res/values/styles.xml b/java/com/android/dialer/calllog/ui/res/values/styles.xml
index d521fee..047f1da 100644
--- a/java/com/android/dialer/calllog/ui/res/values/styles.xml
+++ b/java/com/android/dialer/calllog/ui/res/values/styles.xml
@@ -21,7 +21,7 @@
     <item name="android:fontFamily">sans-serif</item>
   </style>
 
-  <style name="primary_textview_new_call">
+  <style name="primary_textview_unread_call">
     <item name="android:textColor">@color/primary_text_color</item>
     <item name="android:fontFamily">sans-serif-medium</item>
   </style>
@@ -35,12 +35,12 @@
     <item name="android:fontFamily">sans-serif</item>
   </style>
 
-  <style name="secondary_textview_new_call">
+  <style name="secondary_textview_unread_call">
     <item name="android:textColor">@color/missed_call</item>
     <item name="android:fontFamily">sans-serif-medium</item>
   </style>
 
-  <style name="phoneaccount_textview_new_call">
+  <style name="phoneaccount_textview_unread_call">
     <item name="android:fontFamily">sans-serif-medium</item>
   </style>