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

Commit 977dbb6d authored by Ta-wei Yen's avatar Ta-wei Yen
Browse files

Add getTtsSpannedPhoneNumber() to ContactDisplayUtils

Change-Id: I5bc09a6e459fee8d522481c1c42cca4c892bbfde
parent b01be06b
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static android.provider.ContactsContract.CommonDataKinds.Phone;
import com.google.common.base.Preconditions;

import android.content.Context;
import android.content.res.Resources;
import android.telephony.PhoneNumberUtils;
import android.text.Spannable;
import android.text.SpannableString;
@@ -224,6 +225,21 @@ public class ContactDisplayUtils {
        return spannable;
    }

    /**
     * Retrieves a string from a string template that takes 1 phone number as argument,
     * span the number with a telephone {@link TtsSpan}, and return the spanned string.
     *
     * @param resources to retrieve the string from
     * @param stringId ID of the string
     * @param number to pass in the template
     * @return CharSequence with the phone number wrapped in a TtsSpan
     */
    public static CharSequence getTtsSpannedPhoneNumber(Resources resources,
            int stringId, String number){
        String msg = resources.getString(stringId, number);
        return ContactDisplayUtils.getTelephoneTtsSpannable(msg, number);
    }

    /**
     * Returns either namePrimary or nameAlternative based on the value of displayOrderPreference
     *