From b91261f1fd54fc9517b3e848fc18ca7d7edc0e26 Mon Sep 17 00:00:00 2001 From: mdooley Date: Tue, 5 Sep 2017 13:11:03 -0700 Subject: Updating transcription UI to match latest mocks, part 1 -add branding 'Google is transcribing' -add branding 'Transcribed by Google' in-progress screenshot: https://drive.google.com/open?id=0B9o_KvtLkcuIdVVTX3BBZkNzV180alZPQ3EtR3gzRFNoamhV transcribed by screenshot: https://drive.google.com/open?id=0B9o_KvtLkcuISUdaRjBlUFpjYTBWWTg1STVHS0oyQmNiSUVR Bug: 37340510 Test: manual PiperOrigin-RevId: 167620447 Change-Id: I5526bebb6999cf77b0902ae50ca72e380538a6e7 --- .../app/calllog/CallLogListItemViewHolder.java | 25 ++++++++----- .../dialer/app/calllog/PhoneCallDetailsHelper.java | 42 +++++++++++++--------- .../dialer/app/res/layout/call_log_list_item.xml | 18 +++++----- java/com/android/dialer/app/res/values/strings.xml | 18 +++++++--- 4 files changed, 65 insertions(+), 38 deletions(-) (limited to 'java/com/android/dialer/app') diff --git a/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java b/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java index 60ed7dd09..ef6236bf0 100644 --- a/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java +++ b/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java @@ -781,19 +781,28 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder 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())) { + if (!isExpanded) { transcriptContainerView.setVisibility(View.GONE); return; } - transcriptContainerView.setVisibility(View.VISIBLE); - transcriptView.setVisibility(View.VISIBLE); + + boolean show = false; + if (TextUtils.isEmpty(transcriptView.getText())) { + transcriptView.setVisibility(View.GONE); + } else { + transcriptView.setVisibility(View.VISIBLE); + show = true; + } if (TextUtils.isEmpty(transcriptBrandingView.getText())) { - phoneCallDetailsViews.voicemailTranscriptionBrandingView.setVisibility(View.GONE); + transcriptBrandingView.setVisibility(View.GONE); } else { - phoneCallDetailsViews.voicemailTranscriptionBrandingView.setVisibility(View.VISIBLE); + transcriptBrandingView.setVisibility(View.VISIBLE); + show = true; + } + if (show) { + transcriptContainerView.setVisibility(View.VISIBLE); + } else { + transcriptContainerView.setVisibility(View.GONE); } } diff --git a/java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java b/java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java index a6e8f10f0..189279edf 100644 --- a/java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java +++ b/java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java @@ -146,31 +146,41 @@ public class PhoneCallDetailsHelper { if (isVoicemail) { int relevantLinkTypes = Linkify.EMAIL_ADDRESSES | Linkify.PHONE_NUMBERS | Linkify.WEB_URLS; views.voicemailTranscriptionView.setAutoLinkMask(relevantLinkTypes); - boolean showTranscriptBranding = false; + + String transcript = ""; + String branding = ""; if (!TextUtils.isEmpty(details.transcription)) { - views.voicemailTranscriptionView.setText(details.transcription); + transcript = 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 == VoicemailCompat.TRANSCRIPTION_AVAILABLE; + if (details.transcriptionState == VoicemailCompat.TRANSCRIPTION_AVAILABLE) { + branding = mResources.getString(R.string.voicemail_transcription_branding_text); + } } else { - if (details.transcriptionState == VoicemailCompat.TRANSCRIPTION_IN_PROGRESS) { - views.voicemailTranscriptionView.setText( - mResources.getString(R.string.voicemail_transcription_in_progress)); - } else if (details.transcriptionState == VoicemailCompat.TRANSCRIPTION_FAILED) { - views.voicemailTranscriptionView.setText( - mResources.getString(R.string.voicemail_transcription_failed)); + switch (details.transcriptionState) { + case VoicemailCompat.TRANSCRIPTION_IN_PROGRESS: + branding = mResources.getString(R.string.voicemail_transcription_in_progress); + break; + case VoicemailCompat.TRANSCRIPTION_FAILED_NO_SPEECH_DETECTED: + branding = mResources.getString(R.string.voicemail_transcription_failed_no_speech); + break; + case VoicemailCompat.TRANSCRIPTION_FAILED_LANGUAGE_NOT_SUPPORTED: + branding = + mResources.getString( + R.string.voicemail_transcription_failed_language_not_supported); + break; + case VoicemailCompat.TRANSCRIPTION_FAILED: + branding = mResources.getString(R.string.voicemail_transcription_failed); + break; + default: + break; // Fall through } } - if (showTranscriptBranding) { - views.voicemailTranscriptionBrandingView.setText( - mResources.getString(R.string.voicemail_transcription_branding_text)); - } else { - views.voicemailTranscriptionBrandingView.setText(""); - } + views.voicemailTranscriptionView.setText(transcript); + views.voicemailTranscriptionBrandingView.setText(branding); } // Bold if not read 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 e9679242f..2c248198d 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 @@ -156,15 +156,6 @@ android:visibility="gone" android:orientation="vertical"> - - + + diff --git a/java/com/android/dialer/app/res/values/strings.xml b/java/com/android/dialer/app/res/values/strings.xml index 50e717492..841eb9c9b 100644 --- a/java/com/android/dialer/app/res/values/strings.xml +++ b/java/com/android/dialer/app/res/values/strings.xml @@ -648,14 +648,22 @@ About - + Transcribed by Google - - Google is transcribing … + + Google is transcribing… - - Transcript not available + + Transcript not available. + + + Transcript not available. Language not supported. + + + Transcript not available. No speech detected. View -- cgit v1.2.3