Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e93d24de authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Use IS_READ instead of NEW in new call log."

parents d2c13e28 07206e2c
Loading
Loading
Loading
Loading
+18 −18
Original line number Diff line number Diff line
@@ -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<Void> clearAll() {
    ListenableFuture<Void> markNewFuture = markNotNew(ImmutableSet.of());
    ListenableFuture<Void> markReadFuture = markRead(ImmutableSet.of());
    ListenableFuture<Void> 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<Void> clearBySystemCallLogId(Collection<Long> ids) {
    ListenableFuture<Void> markNewFuture = markNotNew(ids);
    ListenableFuture<Void> markReadFuture = markRead(ids);
    ListenableFuture<Void> 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<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)));
+1 −0
Original line number Diff line number Diff line
@@ -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.
+11 −10
Original line number Diff line number Diff line
@@ -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 {
+3 −3
Original line number Diff line number Diff line
@@ -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()
+3 −3
Original line number Diff line number Diff line
@@ -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>