From 07206e2c106eec909fd38c16a66957a5e00372de Mon Sep 17 00:00:00 2001 From: zachh Date: Fri, 30 Mar 2018 17:12:55 -0700 Subject: Use IS_READ instead of NEW in new call log. We want to be more consistent with other usages of NEW in the app, i.e. NEW should be used primarily by notifications. Bug: 74821515 Test: unit PiperOrigin-RevId: 191139559 Change-Id: Ib6fbead8b5589aedd881db26a07f7daed4d83543 --- .../android/dialer/calllog/ClearMissedCalls.java | 36 +++++++++++----------- .../systemcalllog/SystemCallLogDataSource.java | 1 + .../dialer/calllog/ui/NewCallLogViewHolder.java | 21 +++++++------ .../dialer/calllog/ui/menu/NewCallLogMenu.java | 6 ++-- .../dialer/calllog/ui/res/values/styles.xml | 6 ++-- 5 files changed, 36 insertions(+), 34 deletions(-) diff --git a/java/com/android/dialer/calllog/ClearMissedCalls.java b/java/com/android/dialer/calllog/ClearMissedCalls.java index d216e7b88..78eb80294 100644 --- a/java/com/android/dialer/calllog/ClearMissedCalls.java +++ b/java/com/android/dialer/calllog/ClearMissedCalls.java @@ -38,8 +38,8 @@ import java.util.Collection; 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 @@ public final class ClearMissedCalls { } /** - * 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 clearAll() { - ListenableFuture markNewFuture = markNotNew(ImmutableSet.of()); + ListenableFuture markReadFuture = markRead(ImmutableSet.of()); ListenableFuture cancelNotificationsFuture = uiThreadExecutor.submit( () -> { @@ -73,11 +73,11 @@ public final class ClearMissedCalls { // 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 @@ public final class ClearMissedCalls { /** * 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 clearBySystemCallLogId(Collection ids) { - ListenableFuture markNewFuture = markNotNew(ids); + ListenableFuture markReadFuture = markRead(ids); ListenableFuture cancelNotificationsFuture = uiThreadExecutor.submit( () -> { @@ -105,11 +105,11 @@ public final class ClearMissedCalls { // 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 @@ public final class ClearMissedCalls { } /** - * 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 markNotNew(Collection ids) { + private ListenableFuture markRead(Collection 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 8362a81ac..aa4260cba 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 @@ public class SystemCallLogDataSource implements CallLogDataSource { 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 1f84ebfdf..217208d17 100644 --- a/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java +++ b/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java @@ -109,11 +109,11 @@ final class NewCallLogViewHolder extends RecyclerView.ViewHolder { 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 @@ final class NewCallLogViewHolder extends RecyclerView.ViewHolder { } } - 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 @@ final class NewCallLogViewHolder extends RecyclerView.ViewHolder { 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 @@ final class NewCallLogViewHolder extends RecyclerView.ViewHolder { } 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 dabb9bbe4..3869e78c3 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 @@ public final class NewCallLogMenu { 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 d521feed4..047f1dace 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 @@ sans-serif - @@ -35,12 +35,12 @@ sans-serif - - -- cgit v1.2.3