summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
authorlinyuh <linyuh@google.com>2018-06-07 17:34:13 -0700
committerCopybara-Service <copybara-piper@google.com>2018-06-07 18:43:10 -0700
commitbac4da9d520846ab4e4f8cbcbb80927076deec27 (patch)
treec32cdaeff8e83f712332a27f603809686db53139 /java
parentecd339905308fd7101a6bf35d947bc6432e1b331 (diff)
Wrap phone numbers in custom content descriptions in the new call log with TTS span.
Bug: 70989658 Test: Manual (TTS span is not testable) PiperOrigin-RevId: 199724621 Change-Id: I6dc809660eecdd987ee966f30b68dbbf7bcf2094
Diffstat (limited to 'java')
-rw-r--r--java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java8
-rw-r--r--java/com/android/dialer/calllog/ui/res/values/strings.xml2
-rw-r--r--java/com/android/dialer/calllogutils/CallLogEntryDescriptions.java53
-rw-r--r--java/com/android/dialer/calllogutils/CallLogEntryText.java3
-rw-r--r--java/com/android/dialer/calllogutils/res/values/strings.xml24
-rw-r--r--java/com/android/dialer/glidephotomanager/impl/GlidePhotoManagerImpl.java10
-rw-r--r--java/com/android/dialer/glidephotomanager/impl/res/values/strings.xml26
7 files changed, 78 insertions, 48 deletions
diff --git a/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java b/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java
index cdc0858da..2377c35ee 100644
--- a/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java
+++ b/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java
@@ -304,11 +304,9 @@ final class NewCallLogViewHolder extends RecyclerView.ViewHolder {
private void setOnClickListenerForMenuButon(CoalescedRow row) {
menuButton.setOnClickListener(NewCallLogMenu.createOnClickListener(activity, row));
menuButton.setContentDescription(
- activity
- .getResources()
- .getString(
- R.string.a11y_new_call_log_entry_expand_menu,
- CallLogEntryText.buildPrimaryText(activity, row)));
+ TextUtils.expandTemplate(
+ activity.getResources().getText(R.string.a11y_new_call_log_entry_expand_menu),
+ CallLogEntryText.buildPrimaryText(activity, row)));
}
private class RealtimeRowFutureCallback implements FutureCallback<CoalescedRow> {
diff --git a/java/com/android/dialer/calllog/ui/res/values/strings.xml b/java/com/android/dialer/calllog/ui/res/values/strings.xml
index 112044f6e..b97a10625 100644
--- a/java/com/android/dialer/calllog/ui/res/values/strings.xml
+++ b/java/com/android/dialer/calllog/ui/res/values/strings.xml
@@ -30,7 +30,7 @@
[CHAR LIMIT=NONE]
-->
<string name="a11y_new_call_log_entry_expand_menu">
- Expand call log menu for <xliff:g example="Jane Smith" id="primaryTextForEntry">%1$s</xliff:g>
+ Expand call log menu for <xliff:g example="Jane Smith" id="primaryTextForEntry">^1</xliff:g>
</string>
<!-- Header in call log to group calls from the current day. [CHAR LIMIT=30] -->
diff --git a/java/com/android/dialer/calllogutils/CallLogEntryDescriptions.java b/java/com/android/dialer/calllogutils/CallLogEntryDescriptions.java
index 244087989..52f0cfdb7 100644
--- a/java/com/android/dialer/calllogutils/CallLogEntryDescriptions.java
+++ b/java/com/android/dialer/calllogutils/CallLogEntryDescriptions.java
@@ -20,6 +20,7 @@ import android.content.Context;
import android.provider.CallLog.Calls;
import android.support.annotation.PluralsRes;
import android.telecom.PhoneAccountHandle;
+import android.telephony.PhoneNumberUtils;
import android.text.TextUtils;
import com.android.dialer.calllog.model.CoalescedRow;
import com.android.dialer.telecom.TelecomUtil;
@@ -65,13 +66,14 @@ public final class CallLogEntryDescriptions {
// (2) For entries containing multiple calls:
// "2 calls, the latest is a missed call from Jame Smith".
CharSequence primaryDescription =
- context
- .getResources()
- .getQuantityString(
- getPrimaryDescriptionResIdForCallType(row),
- row.getCoalescedIds().getCoalescedIdCount(),
- row.getCoalescedIds().getCoalescedIdCount(),
- CallLogEntryText.buildPrimaryText(context, row));
+ TextUtils.expandTemplate(
+ context
+ .getResources()
+ .getQuantityString(
+ getPrimaryDescriptionResIdForCallType(row),
+ row.getCoalescedIds().getCoalescedIdCount()),
+ String.valueOf(row.getCoalescedIds().getCoalescedIdCount()),
+ CallLogEntryText.buildPrimaryText(context, row));
// Build the secondary description.
// An example: "mobile, 11 minutes ago".
@@ -85,19 +87,20 @@ public final class CallLogEntryDescriptions {
CharSequence phoneAccountDescription = buildPhoneAccountDescription(context, row);
return TextUtils.isEmpty(phoneAccountDescription)
- ? context
- .getResources()
- .getString(
- R.string.a11y_new_call_log_entry_full_description_without_phone_account_info,
- primaryDescription,
- secondaryDescription)
- : context
- .getResources()
- .getString(
- R.string.a11y_new_call_log_entry_full_description_with_phone_account_info,
- primaryDescription,
- secondaryDescription,
- phoneAccountDescription);
+ ? TextUtils.expandTemplate(
+ context
+ .getResources()
+ .getText(
+ R.string.a11y_new_call_log_entry_full_description_without_phone_account_info),
+ primaryDescription,
+ secondaryDescription)
+ : TextUtils.expandTemplate(
+ context
+ .getResources()
+ .getText(R.string.a11y_new_call_log_entry_full_description_with_phone_account_info),
+ primaryDescription,
+ secondaryDescription,
+ phoneAccountDescription);
}
private static @PluralsRes int getPrimaryDescriptionResIdForCallType(CoalescedRow row) {
@@ -139,12 +142,10 @@ public final class CallLogEntryDescriptions {
return "";
}
- return context
- .getResources()
- .getString(
- R.string.a11y_new_call_log_entry_phone_account,
- phoneAccountLabel,
- row.getNumber().getNormalizedNumber());
+ return TextUtils.expandTemplate(
+ context.getResources().getText(R.string.a11y_new_call_log_entry_phone_account),
+ phoneAccountLabel,
+ PhoneNumberUtils.createTtsSpannable(row.getNumber().getNormalizedNumber()));
}
private static CharSequence joinSecondaryTextComponents(List<CharSequence> components) {
diff --git a/java/com/android/dialer/calllogutils/CallLogEntryText.java b/java/com/android/dialer/calllogutils/CallLogEntryText.java
index 895497f0f..1ec172f6f 100644
--- a/java/com/android/dialer/calllogutils/CallLogEntryText.java
+++ b/java/com/android/dialer/calllogutils/CallLogEntryText.java
@@ -18,6 +18,7 @@ package com.android.dialer.calllogutils;
import android.content.Context;
import android.provider.CallLog.Calls;
+import android.telephony.PhoneNumberUtils;
import android.text.TextUtils;
import com.android.dialer.calllog.model.CoalescedRow;
import com.android.dialer.duo.DuoComponent;
@@ -69,7 +70,7 @@ public final class CallLogEntryText {
// 4th preference: the formatted number.
if (!TextUtils.isEmpty(row.getFormattedNumber())) {
- return row.getFormattedNumber();
+ return PhoneNumberUtils.createTtsSpannable(row.getFormattedNumber());
}
// Last resort: show "Unknown".
diff --git a/java/com/android/dialer/calllogutils/res/values/strings.xml b/java/com/android/dialer/calllogutils/res/values/strings.xml
index 52b6d3408..3fbfb4447 100644
--- a/java/com/android/dialer/calllogutils/res/values/strings.xml
+++ b/java/com/android/dialer/calllogutils/res/values/strings.xml
@@ -151,8 +151,8 @@
[CHAR LIMIT=NONE]
-->
<plurals name="a11y_new_call_log_entry_missed_call">
- <item quantity="one"><xliff:g example="1" id="count">%1$d</xliff:g> missed call from <xliff:g example="Jane Smith" id="primaryInfoForEntry">%2$s</xliff:g></item>
- <item quantity="other"><xliff:g example="2" id="count">%1$d</xliff:g> calls, the latest is a missed call from <xliff:g example="Jane Smith" id="primaryInfoForEntry">%2$s</xliff:g></item>
+ <item quantity="one"><xliff:g example="1" id="count">^1</xliff:g> missed call from <xliff:g example="Jane Smith" id="primaryInfoForEntry">^2</xliff:g></item>
+ <item quantity="other"><xliff:g example="2" id="count">^1</xliff:g> calls, the latest is a missed call from <xliff:g example="Jane Smith" id="primaryInfoForEntry">^2</xliff:g></item>
</plurals>
<!--
@@ -160,8 +160,8 @@
[CHAR LIMIT=NONE]
-->
<plurals name="a11y_new_call_log_entry_answered_call">
- <item quantity="one"><xliff:g example="1" id="count">%1$d</xliff:g> answered call from <xliff:g example="Jane Smith" id="primaryInfoForEntry">%2$s</xliff:g></item>
- <item quantity="other"><xliff:g example="2" id="count">%1$d</xliff:g> calls, the latest is an answered call from <xliff:g example="Jane Smith" id="primaryInfoForEntry">%2$s</xliff:g></item>
+ <item quantity="one"><xliff:g example="1" id="count">^1</xliff:g> answered call from <xliff:g example="Jane Smith" id="primaryInfoForEntry">^2</xliff:g></item>
+ <item quantity="other"><xliff:g example="2" id="count">^1</xliff:g> calls, the latest is an answered call from <xliff:g example="Jane Smith" id="primaryInfoForEntry">^2</xliff:g></item>
</plurals>
<!--
@@ -169,8 +169,8 @@
[CHAR LIMIT=NONE]
-->
<plurals name="a11y_new_call_log_entry_outgoing_call">
- <item quantity="one"><xliff:g example="1" id="count">%1$d</xliff:g> outgoing call to <xliff:g example="Jane Smith" id="primaryInfoForEntry">%2$s</xliff:g></item>
- <item quantity="other"><xliff:g example="2" id="count">%1$d</xliff:g> calls, the latest is an outgoing call to <xliff:g example="Jane Smith" id="primaryInfoForEntry">%2$s</xliff:g></item>
+ <item quantity="one"><xliff:g example="1" id="count">^1</xliff:g> outgoing call to <xliff:g example="Jane Smith" id="primaryInfoForEntry">^2</xliff:g></item>
+ <item quantity="other"><xliff:g example="2" id="count">^1</xliff:g> calls, the latest is an outgoing call to <xliff:g example="Jane Smith" id="primaryInfoForEntry">^2</xliff:g></item>
</plurals>
<!--
@@ -178,8 +178,8 @@
[CHAR LIMIT=NONE]
-->
<plurals name="a11y_new_call_log_entry_blocked_call">
- <item quantity="one"><xliff:g example="1" id="count">%1$d</xliff:g> blocked call from <xliff:g example="Jane Smith" id="primaryInfoForEntry">%2$s</xliff:g></item>
- <item quantity="other"><xliff:g example="2" id="count">%1$d</xliff:g> calls, the latest is a blocked call from <xliff:g example="Jane Smith" id="primaryInfoForEntry">%2$s</xliff:g></item>
+ <item quantity="one"><xliff:g example="1" id="count">^1</xliff:g> blocked call from <xliff:g example="Jane Smith" id="primaryInfoForEntry">^2</xliff:g></item>
+ <item quantity="other"><xliff:g example="2" id="count">^1</xliff:g> calls, the latest is a blocked call from <xliff:g example="Jane Smith" id="primaryInfoForEntry">^2</xliff:g></item>
</plurals>
@@ -189,8 +189,8 @@
[CHAR LIMIT=NONE]
-->
<string name="a11y_new_call_log_entry_phone_account">
- on <xliff:g example="SIM 1" id="phoneAccount">%1$s</xliff:g>,
- via <xliff:g example="(555) 555-5555" id="number">%2$s</xliff:g>
+ on <xliff:g example="SIM 1" id="phoneAccount">^1</xliff:g>,
+ via <xliff:g example="(555) 555-5555" id="number">^2</xliff:g>
</string>
<!--
@@ -198,7 +198,7 @@
[CHAR LIMIT=NONE]
-->
<string name="a11y_new_call_log_entry_full_description_without_phone_account_info">
- <xliff:g example="A missed call from Jane Smith" id="primaryDescriptionForEntry">%1$s</xliff:g>, <xliff:g example="mobile, 30 minutes ago" id="secondaryDescriptionForEntry">%2$s</xliff:g>.
+ <xliff:g example="A missed call from Jane Smith" id="primaryDescriptionForEntry">^1</xliff:g>, <xliff:g example="mobile, 30 minutes ago" id="secondaryDescriptionForEntry">^2</xliff:g>.
</string>
<!--
@@ -206,6 +206,6 @@
[CHAR LIMIT=NONE]
-->
<string name="a11y_new_call_log_entry_full_description_with_phone_account_info">
- <xliff:g example="A missed call from Jane Smith" id="primaryDescriptionForEntry">%1$s</xliff:g>, <xliff:g example="mobile, 30 minutes ago" id="secondaryDescriptionForEntry">%2$s</xliff:g>, <xliff:g example="on SIM 1, via (555) 555-5555">%3$s</xliff:g>.
+ <xliff:g example="A missed call from Jane Smith" id="primaryDescriptionForEntry">^1</xliff:g>, <xliff:g example="mobile, 30 minutes ago" id="secondaryDescriptionForEntry">^2</xliff:g>, <xliff:g example="on SIM 1, via (555) 555-5555">^3</xliff:g>.
</string>
</resources>
diff --git a/java/com/android/dialer/glidephotomanager/impl/GlidePhotoManagerImpl.java b/java/com/android/dialer/glidephotomanager/impl/GlidePhotoManagerImpl.java
index bd9cc31e4..9129e588f 100644
--- a/java/com/android/dialer/glidephotomanager/impl/GlidePhotoManagerImpl.java
+++ b/java/com/android/dialer/glidephotomanager/impl/GlidePhotoManagerImpl.java
@@ -34,6 +34,7 @@ import com.android.dialer.glide.GlideRequest;
import com.android.dialer.glide.GlideRequests;
import com.android.dialer.glidephotomanager.GlidePhotoManager;
import com.android.dialer.glidephotomanager.PhotoInfo;
+import com.android.dialer.i18n.DialerBidiFormatter;
import com.android.dialer.inject.ApplicationContext;
import com.android.dialer.lettertile.LetterTileDrawable;
import java.util.List;
@@ -69,9 +70,12 @@ public class GlidePhotoManagerImpl implements GlidePhotoManager {
public void loadContactPhoto(ImageView imageView, PhotoInfo photoInfo) {
Assert.isMainThread();
imageView.setContentDescription(
- appContext.getString(
- com.android.dialer.contactphoto.R.string.description_quick_contact_for,
- photoInfo.getName()));
+ TextUtils.expandTemplate(
+ appContext.getText(R.string.a11y_glide_photo_manager_contact_photo_description),
+ // The display name in "photoInfo" can be a contact name, a number, or a mixture of text
+ // and a phone number. We use DialerBidiFormatter to wrap the phone number with TTS
+ // span.
+ DialerBidiFormatter.format(photoInfo.getName())));
GlideRequest<Drawable> request = buildRequest(GlideApp.with(imageView), photoInfo);
request.into(imageView);
}
diff --git a/java/com/android/dialer/glidephotomanager/impl/res/values/strings.xml b/java/com/android/dialer/glidephotomanager/impl/res/values/strings.xml
new file mode 100644
index 000000000..217ad6061
--- /dev/null
+++ b/java/com/android/dialer/glidephotomanager/impl/res/values/strings.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2018 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License
+ -->
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <!--
+ String describing to a11y users the image view containing a contact photo loaded by
+ GlidePhotoManager [CHAR LIMIT=NONE]
+ -->
+ <string name="a11y_glide_photo_manager_contact_photo_description">
+ Quick contact for <xliff:g example="Jane Smith" id="name">^1</xliff:g>
+ </string>
+</resources> \ No newline at end of file