From 6d98cf688855372ffbef12a41ef1f69f990409f1 Mon Sep 17 00:00:00 2001 From: Ta-wei Yen Date: Thu, 5 Nov 2015 17:33:58 -0800 Subject: Add phone number TTS to strings that show phone numbers. Bug:25452669 Change-Id: I9c1685ee05f2ffc2fc6ac94714c2ae4d1137ffbe --- src/com/android/dialer/SpecialCharSequenceMgr.java | 7 +++--- .../dialer/calllog/DefaultVoicemailNotifier.java | 8 +++++-- .../filterednumber/BlockNumberDialogFragment.java | 25 +++++++++++----------- .../dialer/list/BlockedListSearchFragment.java | 12 ++++++++--- .../dialer/list/DialerPhoneNumberListAdapter.java | 7 +++--- 5 files changed, 36 insertions(+), 23 deletions(-) diff --git a/src/com/android/dialer/SpecialCharSequenceMgr.java b/src/com/android/dialer/SpecialCharSequenceMgr.java index 994829a50..5d1bc917f 100644 --- a/src/com/android/dialer/SpecialCharSequenceMgr.java +++ b/src/com/android/dialer/SpecialCharSequenceMgr.java @@ -42,6 +42,7 @@ import android.widget.Toast; import com.android.common.io.MoreCloseables; import com.android.contacts.common.database.NoNullCursorAsyncQueryHandler; +import com.android.contacts.common.util.ContactDisplayUtils; import com.android.contacts.common.widget.SelectPhoneAccountDialogFragment; import com.android.contacts.common.widget.SelectPhoneAccountDialogFragment.SelectPhoneAccountListener; import com.android.dialer.calllog.PhoneAccountUtils; @@ -474,9 +475,9 @@ public class SpecialCharSequenceMgr { // display the name as a toast Context context = sc.progressDialog.getContext(); - name = context.getString(R.string.menu_callNumber, name); - Toast.makeText(context, name, Toast.LENGTH_SHORT) - .show(); + CharSequence msg = ContactDisplayUtils.getTtsSpannedPhoneNumberString( + context.getResources(), R.string.menu_callNumber, name); + Toast.makeText(context, msg, Toast.LENGTH_SHORT).show(); } } finally { MoreCloseables.closeQuietly(c); diff --git a/src/com/android/dialer/calllog/DefaultVoicemailNotifier.java b/src/com/android/dialer/calllog/DefaultVoicemailNotifier.java index ff9137249..eccad58b3 100644 --- a/src/com/android/dialer/calllog/DefaultVoicemailNotifier.java +++ b/src/com/android/dialer/calllog/DefaultVoicemailNotifier.java @@ -36,6 +36,7 @@ import android.text.TextUtils; import android.util.Log; import com.android.common.io.MoreCloseables; +import com.android.contacts.common.util.ContactDisplayUtils; import com.android.contacts.common.util.PermissionsUtil; import com.android.dialer.DialtactsActivity; import com.android.dialer.R; @@ -213,8 +214,11 @@ public class DefaultVoicemailNotifier { // The text to show in the ticker, describing the new event. if (callToNotify != null) { - notificationBuilder.setTicker(resources.getString( - R.string.notification_new_voicemail_ticker, names.get(callToNotify.number))); + CharSequence msg = ContactDisplayUtils.getTtsSpannedPhoneNumberString( + resources, + R.string.notification_new_voicemail_ticker, + names.get(callToNotify.number)); + notificationBuilder.setTicker(msg); } mNotificationManager.notify(NOTIFICATION_TAG, NOTIFICATION_ID, notificationBuilder.build()); diff --git a/src/com/android/dialer/filterednumber/BlockNumberDialogFragment.java b/src/com/android/dialer/filterednumber/BlockNumberDialogFragment.java index 4cbd4ddb8..abc502f6a 100644 --- a/src/com/android/dialer/filterednumber/BlockNumberDialogFragment.java +++ b/src/com/android/dialer/filterednumber/BlockNumberDialogFragment.java @@ -134,13 +134,15 @@ public class BlockNumberDialogFragment extends DialogFragment String okText; String message; if (isBlocked) { - title = getTtsSpannedPhoneNumberString(R.string.unblock_number_confirmation_title, - mDisplayNumber); + title = ContactDisplayUtils.getTtsSpannedPhoneNumberString(getResources(), + R.string.unblock_number_confirmation_title, + mDisplayNumber); okText = getString(R.string.unblock_number_ok); message = null; } else { - title = getTtsSpannedPhoneNumberString(R.string.block_number_confirmation_title, - mDisplayNumber); + title = ContactDisplayUtils.getTtsSpannedPhoneNumberString(getResources(), + R.string.block_number_confirmation_title, + mDisplayNumber); okText = getString(R.string.block_number_ok); if (mVoicemailEnabledChecker.isVisualVoicemailEnabled()) { message = getString(R.string.block_number_confirmation_message_vvm); @@ -177,7 +179,9 @@ public class BlockNumberDialogFragment extends DialogFragment super.onActivityCreated(savedInstanceState); if (!FilteredNumbersUtil.canBlockNumber(getActivity(), mNumber, mCountryIso)) { dismiss(); - Toast.makeText(getContext(), getString(R.string.invalidNumber, mDisplayNumber), + Toast.makeText(getContext(), + ContactDisplayUtils.getTtsSpannedPhoneNumberString( + getResources(), R.string.invalidNumber, mDisplayNumber), Toast.LENGTH_SHORT).show(); } } @@ -195,17 +199,14 @@ public class BlockNumberDialogFragment extends DialogFragment mCallback = callback; } - private CharSequence getTtsSpannedPhoneNumberString(int id,String number){ - String msg = getString(id, mDisplayNumber); - return ContactDisplayUtils.getTelephoneTtsSpannable(msg,mDisplayNumber); - } - private CharSequence getBlockedMessage() { - return getTtsSpannedPhoneNumberString(R.string.snackbar_number_blocked, mDisplayNumber); + return ContactDisplayUtils.getTtsSpannedPhoneNumberString(getResources(), + R.string.snackbar_number_blocked, mDisplayNumber); } private CharSequence getUnblockedMessage() { - return getTtsSpannedPhoneNumberString(R.string.snackbar_number_unblocked, mDisplayNumber); + return ContactDisplayUtils.getTtsSpannedPhoneNumberString(getResources(), + R.string.snackbar_number_unblocked, mDisplayNumber); } private int getActionTextColor() { diff --git a/src/com/android/dialer/list/BlockedListSearchFragment.java b/src/com/android/dialer/list/BlockedListSearchFragment.java index 7f8f12c73..a54a72173 100644 --- a/src/com/android/dialer/list/BlockedListSearchFragment.java +++ b/src/com/android/dialer/list/BlockedListSearchFragment.java @@ -32,6 +32,7 @@ import android.widget.Toast; import com.android.contacts.common.GeoUtil; import com.android.contacts.common.list.ContactEntryListAdapter; import com.android.contacts.common.list.ContactListItemView; +import com.android.contacts.common.util.ContactDisplayUtils; import com.android.dialer.R; import com.android.dialer.database.FilteredNumberAsyncQueryHandler; import com.android.dialer.database.FilteredNumberAsyncQueryHandler.OnCheckBlockedListener; @@ -185,7 +186,9 @@ public class BlockedListSearchFragment extends RegularSearchFragment getFragmentManager(), BlockedListSearchFragment.this); } else { - Toast.makeText(getContext(), getString(R.string.alreadyBlocked, number), + Toast.makeText(getContext(), + ContactDisplayUtils.getTtsSpannedPhoneNumberString(getResources(), + R.string.alreadyBlocked, number), Toast.LENGTH_SHORT).show(); } } @@ -193,7 +196,9 @@ public class BlockedListSearchFragment extends RegularSearchFragment final boolean success = mFilteredNumberAsyncQueryHandler.isBlockedNumber( onCheckListener, number, countryIso); if (!success) { - Toast.makeText(getContext(), getString(R.string.invalidNumber, number), + Toast.makeText(getContext(), + ContactDisplayUtils.getTtsSpannedPhoneNumberString( + getResources(), R.string.invalidNumber, number), Toast.LENGTH_SHORT).show(); } } @@ -218,7 +223,8 @@ public class BlockedListSearchFragment extends RegularSearchFragment final String number, final Integer blockId) { if (blockId != null) { - Toast.makeText(getContext(), getString(R.string.alreadyBlocked, number), + Toast.makeText(getContext(), ContactDisplayUtils.getTtsSpannedPhoneNumberString( + getResources(), R.string.alreadyBlocked, number), Toast.LENGTH_SHORT).show(); return; } diff --git a/src/com/android/dialer/list/DialerPhoneNumberListAdapter.java b/src/com/android/dialer/list/DialerPhoneNumberListAdapter.java index f56c6968a..9e75b2b7d 100644 --- a/src/com/android/dialer/list/DialerPhoneNumberListAdapter.java +++ b/src/com/android/dialer/list/DialerPhoneNumberListAdapter.java @@ -11,6 +11,7 @@ import android.view.ViewGroup; import com.android.contacts.common.GeoUtil; import com.android.contacts.common.list.ContactListItemView; import com.android.contacts.common.list.PhoneNumberListAdapter; +import com.android.contacts.common.util.ContactDisplayUtils; import com.android.dialer.R; /** @@ -147,9 +148,9 @@ public class DialerPhoneNumberListAdapter extends PhoneNumberListAdapter { final String number = getFormattedQueryString(); switch (shortcutType) { case SHORTCUT_DIRECT_CALL: - text = resources.getString( - R.string.search_shortcut_call_number, - mBidiFormatter.unicodeWrap(number, TextDirectionHeuristics.LTR)); + text = ContactDisplayUtils.getTtsSpannedPhoneNumberString(resources, + R.string.search_shortcut_call_number, + mBidiFormatter.unicodeWrap(number, TextDirectionHeuristics.LTR)); drawableId = R.drawable.ic_search_phone; break; case SHORTCUT_CREATE_NEW_CONTACT: -- cgit v1.2.3