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

Commit 287a1838 authored by mdooley's avatar mdooley Committed by Eric Erfanian
Browse files

Adding voicemail transcription branding and progress UI

screen shot showing branding (its harder to capture the progress UI):
https://drive.google.com/open?id=0B9o_KvtLkcuIdkkycVo1RFhsaENYV3J2Yi1LWnJzR0FfSHJR

Bug: 62376944,62424455
Test: device testing
PiperOrigin-RevId: 159993127
Change-Id: I8355164b5831e85de13915e221f6e0f0163e8c81
parent 268a1958
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -907,6 +907,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;
@@ -916,6 +920,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);
+12 −4
Original line number Diff line number Diff line
@@ -769,12 +769,20 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder
      return;
    }

    final TextView view = phoneCallDetailsViews.voicemailTranscriptionView;
    if (!isExpanded || TextUtils.isEmpty(view.getText())) {
      view.setVisibility(View.GONE);
    TextView transcriptView = phoneCallDetailsViews.voicemailTranscriptionView;
    TextView transcriptBrandingView = phoneCallDetailsViews.voicemailTranscriptionBrandingView;
    if (!isExpanded || TextUtils.isEmpty(transcriptView.getText())) {
      Assert.checkArgument(TextUtils.isEmpty(transcriptBrandingView.getText()));
      transcriptView.setVisibility(View.GONE);
      transcriptBrandingView.setVisibility(View.GONE);
      return;
    }
    view.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() {
+33 −2
Original line number Diff line number Diff line
@@ -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_AVALIABLE = 3;

  private final Context mContext;
  private final Resources mResources;
  private final CallLogCache mCallLogCache;
@@ -145,14 +152,38 @@ public class PhoneCallDetailsHelper {
    if (isVoicemail) {
      int relevantLinkTypes = Linkify.EMAIL_ADDRESSES | Linkify.PHONE_NUMBERS | Linkify.WEB_URLS;
      views.voicemailTranscriptionView.setAutoLinkMask(relevantLinkTypes);
      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_AVALIABLE;
      } else {
        if (details.transcriptionState == TRANSCRIPTION_IN_PROGRESS) {
          views.voicemailTranscriptionView.setText(
          TextUtils.isEmpty(details.transcription) ? null : details.transcription);
              mResources.getString(R.string.voicemail_transcription_in_progress));
          showTranscriptBranding = true;
        } 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(
+5 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ public final class PhoneCallDetailsViews {
  public final CallTypeIconsView callTypeIcons;
  public final TextView callLocationAndDate;
  public final TextView voicemailTranscriptionView;
  public final TextView voicemailTranscriptionBrandingView;
  public final TextView callAccountLabel;

  private PhoneCallDetailsViews(
@@ -38,12 +39,14 @@ public final class PhoneCallDetailsViews {
      CallTypeIconsView callTypeIcons,
      TextView callLocationAndDate,
      TextView voicemailTranscriptionView,
      TextView voicemailTranscriptionBrandingView,
      TextView callAccountLabel) {
    this.nameView = nameView;
    this.callTypeView = callTypeView;
    this.callTypeIcons = callTypeIcons;
    this.callLocationAndDate = callLocationAndDate;
    this.voicemailTranscriptionView = voicemailTranscriptionView;
    this.voicemailTranscriptionBrandingView = voicemailTranscriptionBrandingView;
    this.callAccountLabel = callAccountLabel;
  }

@@ -61,6 +64,7 @@ public final class PhoneCallDetailsViews {
        (CallTypeIconsView) view.findViewById(R.id.call_type_icons),
        (TextView) view.findViewById(R.id.call_location_and_date),
        (TextView) view.findViewById(R.id.voicemail_transcription),
        (TextView) view.findViewById(R.id.voicemail_transcription_branding),
        (TextView) view.findViewById(R.id.call_account_label));
  }

@@ -71,6 +75,7 @@ public final class PhoneCallDetailsViews {
        new CallTypeIconsView(context),
        new TextView(context),
        new TextView(context),
        new TextView(context),
        new TextView(context));
  }
}
+26 −8
Original line number Diff line number Diff line
@@ -148,11 +148,27 @@
            android:visibility="gone"
            android:singleLine="true"/>

          <LinearLayout
            android:id="@+id/transcription"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/call_log_icon_margin"
            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:visibility="gone"
              android:singleLine="true"/>

            <TextView
              android:id="@+id/voicemail_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"
@@ -162,6 +178,8 @@

          </LinearLayout>

        </LinearLayout>

        <ImageView
          android:id="@+id/primary_action_button"
          android:layout_width="@dimen/call_log_list_item_primary_action_dimen"
Loading