summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormdooley <mdooley@google.com>2017-08-23 13:22:03 -0700
committerEric Erfanian <erfanian@google.com>2017-08-30 21:28:33 +0000
commit9941f9595c16f1b890578fa4698e93c6af7630e6 (patch)
treee340dd07c381fbc31c4e5d779883cfd1e8909ead
parentd9d2c230091a5d3cd9b571f0435cd8222c596eef (diff)
Fixing assertion in voicemail transcription branding
The original version of this cl (cl/159993127) was rolled back because of b/63059930. The bug was that the branding text was also getting set while the transcription was in progress, but it should only be set when a transcription has completed successfully. This cl is just cl/159993127 with the fix. screen shot showing branding (its harder to capture the progress UI): https://drive.google.com/open?id=0B9o_KvtLkcuIdkkycVo1RFhsaENYV3J2Yi1LWnJzR0FfSHJR The branding spec has changed a bit since this original cl but those changes will be made in a subsequent cl. Bug: 62376944,62424455,63059930 Test: manual PiperOrigin-RevId: 166244652 Change-Id: Ia1895f27c5b932579cbef2845ecab30ef5e8b70b
-rw-r--r--java/com/android/dialer/app/calllog/CallLogAdapter.java5
-rw-r--r--java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java19
-rw-r--r--java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java34
-rw-r--r--java/com/android/dialer/app/calllog/PhoneCallDetailsViews.java10
-rw-r--r--java/com/android/dialer/app/res/layout/call_log_list_item.xml31
-rw-r--r--java/com/android/dialer/app/res/values/colors.xml2
-rw-r--r--java/com/android/dialer/app/res/values/strings.xml9
-rw-r--r--java/com/android/dialer/calllogutils/PhoneCallDetails.java3
-rw-r--r--java/com/android/dialer/phonenumbercache/CallLogQuery.java18
9 files changed, 118 insertions, 13 deletions
diff --git a/java/com/android/dialer/app/calllog/CallLogAdapter.java b/java/com/android/dialer/app/calllog/CallLogAdapter.java
index b335cd571..61129a7ce 100644
--- a/java/com/android/dialer/app/calllog/CallLogAdapter.java
+++ b/java/com/android/dialer/app/calllog/CallLogAdapter.java
@@ -904,6 +904,10 @@ public class CallLogAdapter extends GroupingListAdapter
(VERSION.SDK_INT >= VERSION_CODES.N) ? cursor.getString(CallLogQuery.VIA_NUMBER) : "";
final int numberPresentation = cursor.getInt(CallLogQuery.NUMBER_PRESENTATION);
final ContactInfo cachedContactInfo = ContactInfoHelper.getContactInfo(cursor);
+ final int transcriptionState =
+ (VERSION.SDK_INT >= VERSION_CODES.O)
+ ? cursor.getInt(CallLogQuery.TRANSCRIPTION_STATE)
+ : PhoneCallDetailsHelper.TRANSCRIPTION_NOT_STARTED;
final PhoneCallDetails details =
new PhoneCallDetails(number, numberPresentation, postDialDigits);
details.viaNumber = viaNumber;
@@ -913,6 +917,7 @@ public class CallLogAdapter extends GroupingListAdapter
details.features = getCallFeatures(cursor, count);
details.geocode = cursor.getString(CallLogQuery.GEOCODED_LOCATION);
details.transcription = cursor.getString(CallLogQuery.TRANSCRIPTION);
+ details.transcriptionState = transcriptionState;
details.callTypes = getCallTypes(cursor, count);
details.accountComponentName = cursor.getString(CallLogQuery.ACCOUNT_COMPONENT_NAME);
diff --git a/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java b/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java
index d2b6bcca5..60ed7dd09 100644
--- a/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java
+++ b/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java
@@ -778,12 +778,23 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder
return;
}
- final TextView view = phoneCallDetailsViews.voicemailTranscriptionView;
- if (!isExpanded || TextUtils.isEmpty(view.getText())) {
- view.setVisibility(View.GONE);
+ View transcriptContainerView = phoneCallDetailsViews.transcriptionView;
+ TextView transcriptView = phoneCallDetailsViews.voicemailTranscriptionView;
+ TextView transcriptBrandingView = phoneCallDetailsViews.voicemailTranscriptionBrandingView;
+ if (TextUtils.isEmpty(transcriptView.getText())) {
+ Assert.checkArgument(TextUtils.isEmpty(transcriptBrandingView.getText()));
+ }
+ if (!isExpanded || TextUtils.isEmpty(transcriptView.getText())) {
+ transcriptContainerView.setVisibility(View.GONE);
return;
}
- view.setVisibility(View.VISIBLE);
+ transcriptContainerView.setVisibility(View.VISIBLE);
+ transcriptView.setVisibility(View.VISIBLE);
+ if (TextUtils.isEmpty(transcriptBrandingView.getText())) {
+ phoneCallDetailsViews.voicemailTranscriptionBrandingView.setVisibility(View.GONE);
+ } else {
+ phoneCallDetailsViews.voicemailTranscriptionBrandingView.setVisibility(View.VISIBLE);
+ }
}
public void updatePhoto() {
diff --git a/java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java b/java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java
index 0c720775a..c1a00e58d 100644
--- a/java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java
+++ b/java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java
@@ -45,6 +45,13 @@ public class PhoneCallDetailsHelper {
/** The maximum number of icons will be shown to represent the call types in a group. */
private static final int MAX_CALL_TYPE_ICONS = 3;
+ // TODO(mdooley): remove when these api's become public
+ // Copied from android.provider.VoicemailContract
+ static final int TRANSCRIPTION_NOT_STARTED = 0;
+ static final int TRANSCRIPTION_IN_PROGRESS = 1;
+ static final int TRANSCRIPTION_FAILED = 2;
+ static final int TRANSCRIPTION_AVAILABLE = 3;
+
private final Context mContext;
private final Resources mResources;
private final CallLogCache mCallLogCache;
@@ -145,14 +152,37 @@ public class PhoneCallDetailsHelper {
if (isVoicemail) {
int relevantLinkTypes = Linkify.EMAIL_ADDRESSES | Linkify.PHONE_NUMBERS | Linkify.WEB_URLS;
views.voicemailTranscriptionView.setAutoLinkMask(relevantLinkTypes);
- views.voicemailTranscriptionView.setText(
- TextUtils.isEmpty(details.transcription) ? null : details.transcription);
+ boolean showTranscriptBranding = false;
+ if (!TextUtils.isEmpty(details.transcription)) {
+ views.voicemailTranscriptionView.setText(details.transcription);
+
+ // Set the branding text if the voicemail was transcribed by google
+ // TODO(mdooley): the transcription state is only set by the google transcription code,
+ // but a better solution would be to check the SOURCE_PACKAGE
+ showTranscriptBranding = details.transcriptionState == TRANSCRIPTION_AVAILABLE;
+ } else {
+ if (details.transcriptionState == TRANSCRIPTION_IN_PROGRESS) {
+ views.voicemailTranscriptionView.setText(
+ mResources.getString(R.string.voicemail_transcription_in_progress));
+ } else if (details.transcriptionState == TRANSCRIPTION_FAILED) {
+ views.voicemailTranscriptionView.setText(
+ mResources.getString(R.string.voicemail_transcription_failed));
+ }
+ }
+
+ if (showTranscriptBranding) {
+ views.voicemailTranscriptionBrandingView.setText(
+ mResources.getString(R.string.voicemail_transcription_branding_text));
+ } else {
+ views.voicemailTranscriptionBrandingView.setText("");
+ }
}
// Bold if not read
Typeface typeface = details.isRead ? Typeface.SANS_SERIF : Typeface.DEFAULT_BOLD;
views.nameView.setTypeface(typeface);
views.voicemailTranscriptionView.setTypeface(typeface);
+ views.voicemailTranscriptionBrandingView.setTypeface(typeface);
views.callLocationAndDate.setTypeface(typeface);
views.callLocationAndDate.setTextColor(
ContextCompat.getColor(
diff --git a/java/com/android/dialer/app/calllog/PhoneCallDetailsViews.java b/java/com/android/dialer/app/calllog/PhoneCallDetailsViews.java
index e2e27a179..40c0894f0 100644
--- a/java/com/android/dialer/app/calllog/PhoneCallDetailsViews.java
+++ b/java/com/android/dialer/app/calllog/PhoneCallDetailsViews.java
@@ -29,7 +29,9 @@ public final class PhoneCallDetailsViews {
public final View callTypeView;
public final CallTypeIconsView callTypeIcons;
public final TextView callLocationAndDate;
+ public final View transcriptionView;
public final TextView voicemailTranscriptionView;
+ public final TextView voicemailTranscriptionBrandingView;
public final TextView callAccountLabel;
private PhoneCallDetailsViews(
@@ -37,13 +39,17 @@ public final class PhoneCallDetailsViews {
View callTypeView,
CallTypeIconsView callTypeIcons,
TextView callLocationAndDate,
+ View transcriptionView,
TextView voicemailTranscriptionView,
+ TextView voicemailTranscriptionBrandingView,
TextView callAccountLabel) {
this.nameView = nameView;
this.callTypeView = callTypeView;
this.callTypeIcons = callTypeIcons;
this.callLocationAndDate = callLocationAndDate;
+ this.transcriptionView = transcriptionView;
this.voicemailTranscriptionView = voicemailTranscriptionView;
+ this.voicemailTranscriptionBrandingView = voicemailTranscriptionBrandingView;
this.callAccountLabel = callAccountLabel;
}
@@ -60,7 +66,9 @@ public final class PhoneCallDetailsViews {
view.findViewById(R.id.call_type),
(CallTypeIconsView) view.findViewById(R.id.call_type_icons),
(TextView) view.findViewById(R.id.call_location_and_date),
+ view.findViewById(R.id.transcription),
(TextView) view.findViewById(R.id.voicemail_transcription),
+ (TextView) view.findViewById(R.id.voicemail_transcription_branding),
(TextView) view.findViewById(R.id.call_account_label));
}
@@ -70,6 +78,8 @@ public final class PhoneCallDetailsViews {
new View(context),
new CallTypeIconsView(context),
new TextView(context),
+ new View(context),
+ new TextView(context),
new TextView(context),
new TextView(context));
}
diff --git a/java/com/android/dialer/app/res/layout/call_log_list_item.xml b/java/com/android/dialer/app/res/layout/call_log_list_item.xml
index afb50ffba..e9679242f 100644
--- a/java/com/android/dialer/app/res/layout/call_log_list_item.xml
+++ b/java/com/android/dialer/app/res/layout/call_log_list_item.xml
@@ -148,17 +148,34 @@
android:visibility="gone"
android:singleLine="true"/>
- <TextView
- android:id="@+id/voicemail_transcription"
+ <LinearLayout
+ android:id="@+id/transcription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/call_log_icon_margin"
- android:textColor="@color/call_log_voicemail_transcript_color"
- android:textSize="@dimen/call_log_voicemail_transcription_text_size"
- android:ellipsize="marquee"
android:visibility="gone"
- android:singleLine="false"
- android:maxLines="10"/>
+ android:orientation="vertical">
+
+ <TextView
+ android:id="@+id/voicemail_transcription_branding"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textColor="@color/call_log_voicemail_transcript_branding_color"
+ android:textSize="@dimen/call_log_voicemail_transcription_text_size"
+ android:paddingBottom="2dp"
+ android:singleLine="true"/>
+
+ <TextView
+ android:id="@+id/voicemail_transcription"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textColor="@color/call_log_voicemail_transcript_color"
+ android:textSize="@dimen/call_log_voicemail_transcription_text_size"
+ android:ellipsize="marquee"
+ android:singleLine="false"
+ android:maxLines="10"/>
+
+ </LinearLayout>
</LinearLayout>
diff --git a/java/com/android/dialer/app/res/values/colors.xml b/java/com/android/dialer/app/res/values/colors.xml
index aca63d2b5..f1f5002ed 100644
--- a/java/com/android/dialer/app/res/values/colors.xml
+++ b/java/com/android/dialer/app/res/values/colors.xml
@@ -32,6 +32,8 @@
<color name="call_log_detail_color">#8a000000</color>
<!-- 87% black -->
<color name="call_log_voicemail_transcript_color">#de000000</color>
+ <!-- 54% black -->
+ <color name="call_log_voicemail_transcript_branding_color">#8a000000</color>
<!-- 70% black -->
<color name="call_log_action_color">#b3000000</color>
<!-- 54% black -->
diff --git a/java/com/android/dialer/app/res/values/strings.xml b/java/com/android/dialer/app/res/values/strings.xml
index 368e062c1..50e717492 100644
--- a/java/com/android/dialer/app/res/values/strings.xml
+++ b/java/com/android/dialer/app/res/values/strings.xml
@@ -648,6 +648,15 @@
<!-- Label for setting that shows more information about the Phone app [CHAR LIMIT=30] -->
<string name="about_phone_label">About</string>
+ <!-- Label indicating who provided the voicemail transcription [CHAR LIMIT=40] -->
+ <string name="voicemail_transcription_branding_text">Transcribed by Google</string>
+
+ <!-- Label indicating that a voicemail transcription is in progress [CHAR LIMIT=40] -->
+ <string name="voicemail_transcription_in_progress">Google is transcribing &#8230;</string>
+
+ <!-- Label indicating that a voicemail transcription failed [CHAR LIMIT=40] -->
+ <string name="voicemail_transcription_failed">Transcript not available</string>
+
<!-- Button text to prompt a user to open an sms conversation [CHAR LIMIT=NONE] -->
<string name="view_conversation">View</string>
diff --git a/java/com/android/dialer/calllogutils/PhoneCallDetails.java b/java/com/android/dialer/calllogutils/PhoneCallDetails.java
index 13c528ad2..869a3d099 100644
--- a/java/com/android/dialer/calllogutils/PhoneCallDetails.java
+++ b/java/com/android/dialer/calllogutils/PhoneCallDetails.java
@@ -99,6 +99,9 @@ public class PhoneCallDetails {
// Voicemail transcription
public String transcription;
+ // Voicemail transcription state, ie. in-progress, failed, etc.
+ public int transcriptionState;
+
// The display string for the number.
public String displayNumber;
diff --git a/java/com/android/dialer/phonenumbercache/CallLogQuery.java b/java/com/android/dialer/phonenumbercache/CallLogQuery.java
index 6d4756927..2ebc302cf 100644
--- a/java/com/android/dialer/phonenumbercache/CallLogQuery.java
+++ b/java/com/android/dialer/phonenumbercache/CallLogQuery.java
@@ -60,6 +60,9 @@ public final class CallLogQuery {
@RequiresApi(VERSION_CODES.N)
public static final int VIA_NUMBER = 25;
+ @RequiresApi(VERSION_CODES.O)
+ public static final int TRANSCRIPTION_STATE = 26;
+
private static final String[] PROJECTION_M =
new String[] {
Calls._ID, // 0
@@ -97,8 +100,23 @@ public final class CallLogQuery {
PROJECTION_N = projectionList.toArray(new String[projectionList.size()]);
}
+ private static final String[] PROJECTION_O;
+
+ // TODO(mdooley): remove when this becomes a public api
+ // Copied from android.provider.CallLog.Calls
+ private static final String TRANSCRIPTION_STATE_COLUMN = "transcription_state";
+
+ static {
+ List<String> projectionList = new ArrayList<>(Arrays.asList(PROJECTION_N));
+ projectionList.add(TRANSCRIPTION_STATE_COLUMN);
+ PROJECTION_O = projectionList.toArray(new String[projectionList.size()]);
+ }
+
@NonNull
public static String[] getProjection() {
+ if (VERSION.SDK_INT >= VERSION_CODES.O) {
+ return PROJECTION_O;
+ }
if (VERSION.SDK_INT >= VERSION_CODES.N) {
return PROJECTION_N;
}