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

Commit cbdaac3e authored by maxwelb's avatar maxwelb Committed by android-build-merger
Browse files

Merge "Display "Emergency number" in the call log for emergency numbers" am: 1ed932d7

am: 433968a8

Change-Id: I5b9e01a8795dd195bb3387af3908189673fc2294
parents e0194856 433968a8
Loading
Loading
Loading
Loading
+22 −32
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.support.v4.content.ContextCompat;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
import android.telephony.PhoneNumberUtils;
import android.text.SpannableString;
import android.text.TextUtils;
import android.text.format.DateUtils;
@@ -199,20 +200,7 @@ public class PhoneCallDetailsHelper
      views.callAccountLabel.setVisibility(View.GONE);
    }

    final CharSequence nameText;
    final CharSequence displayNumber = details.displayNumber;
    if (TextUtils.isEmpty(details.getPreferredName())) {
      nameText = displayNumber;
      // We have a real phone number as "nameView" so make it always LTR
      views.nameView.setTextDirection(View.TEXT_DIRECTION_LTR);
    } else {
      nameText = details.getPreferredName();
      // "nameView" is updated from phone number to contact name after number matching.
      // Since TextDirection remains at View.TEXT_DIRECTION_LTR, initialize it.
      views.nameView.setTextDirection(View.TEXT_DIRECTION_INHERIT);
    }

    views.nameView.setText(nameText);
    setNameView(views, details);

    if (isVoicemail) {
      int relevantLinkTypes = Linkify.EMAIL_ADDRESSES | Linkify.PHONE_NUMBERS | Linkify.WEB_URLS;
@@ -282,6 +270,26 @@ public class PhoneCallDetailsHelper
            details.isRead ? R.color.call_log_detail_color : R.color.call_log_unread_text_color));
  }

  private void setNameView(PhoneCallDetailsViews views, PhoneCallDetails details) {
    if (!TextUtils.isEmpty(details.getPreferredName())) {
      views.nameView.setText(details.getPreferredName());
      // "nameView" is updated from phone number to contact name after number matching.
      // Since TextDirection remains at View.TEXT_DIRECTION_LTR, initialize it.
      views.nameView.setTextDirection(View.TEXT_DIRECTION_INHERIT);
      return;
    }

    if (PhoneNumberUtils.isEmergencyNumber(details.number.toString())) {
      views.nameView.setText(R.string.emergency_number);
      views.nameView.setTextDirection(View.TEXT_DIRECTION_INHERIT);
      return;
    }

    views.nameView.setText(details.displayNumber);
    // We have a real phone number as "nameView" so make it always LTR
    views.nameView.setTextDirection(View.TEXT_DIRECTION_LTR);
  }

  private boolean shouldShowTranscriptionRating(
      int transcriptionState, PhoneAccountHandle account) {
    if (transcriptionState != VoicemailCompat.TRANSCRIPTION_AVAILABLE) {
@@ -548,24 +556,6 @@ public class PhoneCallDetailsHelper
    return currentYear != calendar.get(Calendar.YEAR);
  }

  /** Sets the text of the header view for the details page of a phone call. */
  public void setCallDetailsHeader(TextView nameView, PhoneCallDetails details) {
    final CharSequence nameText;
    if (!TextUtils.isEmpty(details.namePrimary)) {
      nameText = details.namePrimary;
    } else if (!TextUtils.isEmpty(details.displayNumber)) {
      nameText = details.displayNumber;
    } else {
      nameText = resources.getString(R.string.unknown);
    }

    nameView.setText(nameText);
  }

  public void setCurrentTimeForTest(long currentTimeMillis) {
    currentTimeMillisForTest = currentTimeMillis;
  }

  /**
   * Returns the current time in milliseconds since the epoch.
   *
+3 −0
Original line number Diff line number Diff line
@@ -26,6 +26,9 @@
  <!-- String used to display calls from pay phone in the call log -->
  <string name="payphone">Payphone</string>

  <!-- String used to display calls from emergency numbers in the call log and incallui -->
  <string name="emergency_number">Emergency number</string>

  <!-- Title for the activity that dials the phone.  This is the name
       used in the Launcher icon. -->
  <string name="launcherActivityLabel">Phone</string>
+1 −1
Original line number Diff line number Diff line
@@ -485,7 +485,7 @@ public class CallerInfo {
   * @return this instance.
   */
  /* package */ CallerInfo markAsEmergency(Context context) {
    name = context.getString(R.string.emergency_call_dialog_number_for_display);
    name = context.getString(R.string.emergency_number);
    phoneNumber = null;

    isEmergency = true;
+0 −3
Original line number Diff line number Diff line
@@ -172,9 +172,6 @@
  <!-- Label for "Manage conference call" panel [CHAR LIMIT=40] -->
  <string name="manageConferenceLabel" tools:ignore="UnusedResources">Manage conference call</string>

  <!-- This can be used in any application wanting to disable the text "Emergency number" -->
  <string name="emergency_call_dialog_number_for_display">Emergency number</string>

  <!-- Used to inform the user that a call was received via a number other than the primary
      phone number associated with their device. [CHAR LIMIT=16] -->
  <string name="child_number">via <xliff:g example="650-555-1212" id="child_number">%s</xliff:g></string>