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

Commit d67712a9 authored by roldenburg's avatar roldenburg Committed by Eric Erfanian
Browse files

Display correct string for Lightbringer calls in call details

Without this change, all video calls are referred to as just "video call". This
CL uses the Lightbringer interface to allow customizing that text.

Before: https://drive.google.com/open?id=0B7uuA4cyYX0xeVZCTGtMUUtoRVU
After: https://drive.google.com/open?id=0B7uuA4cyYX0xMnFhbTBXMDI2VW8
Bug: 63138393
Test: CallTypeHelperTest
PiperOrigin-RevId: 161692812
Change-Id: I36dc1a1fae96dddee91c5efb8892c4a6c7ef67ca
parent 905b5862
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -967,7 +967,7 @@ public class CallLogAdapter extends GroupingListAdapter
  }

  @MainThread
  private static CallDetailsEntries createCallDetailsEntries(Cursor cursor, int count) {
  private CallDetailsEntries createCallDetailsEntries(Cursor cursor, int count) {
    Assert.isMainThread();
    int position = cursor.getPosition();
    CallDetailsEntries.Builder entries = CallDetailsEntries.newBuilder();
@@ -980,6 +980,16 @@ public class CallLogAdapter extends GroupingListAdapter
              .setDate(cursor.getLong(CallLogQuery.DATE))
              .setDuration(cursor.getLong(CallLogQuery.DURATION))
              .setFeatures(cursor.getInt(CallLogQuery.FEATURES));

      String phoneAccountComponentName = cursor.getString(CallLogQuery.ACCOUNT_COMPONENT_NAME);
      if (getLightbringer().getPhoneAccountComponentName() != null
          && getLightbringer()
              .getPhoneAccountComponentName()
              .flattenToString()
              .equals(phoneAccountComponentName)) {
        entry.setIsLightbringerCall(true);
      }

      entries.addEntries(entry.build());
      cursor.moveToNext();
    }
+4 −1
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import com.android.dialer.calldetails.CallDetailsEntries.CallDetailsEntry;
import com.android.dialer.calllogutils.CallTypeHelper;
import com.android.dialer.common.Assert;
import com.android.dialer.dialercontact.DialerContact;
import com.android.dialer.lightbringer.LightbringerComponent;
import java.util.List;

/** Adapter for RecyclerView in {@link CallDetailsActivity}. */
@@ -48,7 +49,9 @@ final class CallDetailsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
    this.contact = Assert.isNotNull(contact);
    this.callDetailsEntries = callDetailsEntries;
    this.listener = listener;
    callTypeHelper = new CallTypeHelper(context.getResources());
    callTypeHelper =
        new CallTypeHelper(
            context.getResources(), LightbringerComponent.get(context).getLightbringer());
  }

  @Override
+3 −1
Original line number Diff line number Diff line
@@ -91,6 +91,7 @@ public class CallDetailsEntryViewHolder extends ViewHolder {
    boolean isPulledCall =
        (entry.getFeatures() & Calls.FEATURES_PULLED_EXTERNALLY)
            == Calls.FEATURES_PULLED_EXTERNALLY;
    boolean isLightbringerCall = entry.getIsLightbringerCall();

    callTime.setTextColor(getColorForCallType(context, callType));
    callTypeIcon.clear();
@@ -100,7 +101,8 @@ public class CallDetailsEntryViewHolder extends ViewHolder {
    callTypeIcon.setShowWifi(
        MotorolaUtils.shouldShowWifiIconInCallLog(context, entry.getFeatures()));

    callTypeText.setText(callTypeHelper.getCallTypeText(callType, isVideoCall, isPulledCall));
    callTypeText.setText(
        callTypeHelper.getCallTypeText(callType, isVideoCall, isPulledCall, isLightbringerCall));
    callTime.setText(CallEntryFormatter.formatDate(context, entry.getDate()));
    if (CallTypeHelper.isMissedCallType(callType)) {
      callDuration.setVisibility(View.GONE);
+1 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ message CallDetailsEntries {
    optional int64 duration = 5;
    optional int64 data_usage = 6;
    repeated enrichedcall.historyquery.proto.HistoryResult history_results = 7;
    optional bool is_lightbringer_call = 8;
  }

  repeated CallDetailsEntry entries = 1;
+26 −2
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.dialer.calllogutils;

import android.content.res.Resources;
import com.android.dialer.compat.AppCompatConstants;
import com.android.dialer.lightbringer.Lightbringer;

/** Helper class to perform operations related to call types. */
public class CallTypeHelper {
@@ -50,8 +51,12 @@ public class CallTypeHelper {
  private final CharSequence mBlockedName;
  /** Name used to identify calls which were answered on another device. */
  private final CharSequence mAnsweredElsewhereName;
  /** Name used to identify incoming lightbringer calls. */
  private final CharSequence mIncomingLightbringerCall;
  /** Name used to identify outgoing lightbringer calls. */
  private final CharSequence mOutgoingLightbringerCall;

  public CallTypeHelper(Resources resources) {
  public CallTypeHelper(Resources resources, Lightbringer lightbringer) {
    // Cache these values so that we do not need to look them up each time.
    mIncomingName = resources.getString(R.string.type_incoming);
    mIncomingPulledName = resources.getString(R.string.type_incoming_pulled);
@@ -67,6 +72,18 @@ public class CallTypeHelper {
    mRejectedName = resources.getString(R.string.type_rejected);
    mBlockedName = resources.getString(R.string.type_blocked);
    mAnsweredElsewhereName = resources.getString(R.string.type_answered_elsewhere);

    if (lightbringer.getIncomingCallTypeText() != -1) {
      mIncomingLightbringerCall = resources.getString(lightbringer.getIncomingCallTypeText());
    } else {
      mIncomingLightbringerCall = mIncomingVideoName;
    }

    if (lightbringer.getOutgoingCallTypeText() != -1) {
      mOutgoingLightbringerCall = resources.getString(lightbringer.getOutgoingCallTypeText());
    } else {
      mOutgoingLightbringerCall = mOutgoingVideoName;
    }
  }

  public static boolean isMissedCallType(int callType) {
@@ -77,13 +94,17 @@ public class CallTypeHelper {
  }

  /** Returns the text used to represent the given call type. */
  public CharSequence getCallTypeText(int callType, boolean isVideoCall, boolean isPulledCall) {
  public CharSequence getCallTypeText(
      int callType, boolean isVideoCall, boolean isPulledCall, boolean isLightbringerCall) {
    switch (callType) {
      case AppCompatConstants.CALLS_INCOMING_TYPE:
        if (isVideoCall) {
          if (isPulledCall) {
            return mIncomingVideoPulledName;
          } else {
            if (isLightbringerCall) {
              return mIncomingLightbringerCall;
            }
            return mIncomingVideoName;
          }
        } else {
@@ -99,6 +120,9 @@ public class CallTypeHelper {
          if (isPulledCall) {
            return mOutgoingVideoPulledName;
          } else {
            if (isLightbringerCall) {
              return mOutgoingLightbringerCall;
            }
            return mOutgoingVideoName;
          }
        } else {
Loading