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

Commit 9e335e2d authored by Android Dialer's avatar Android Dialer Committed by Copybara-Service
Browse files

Updating SecondaryInfo value class to use AutoValue with builder pattern.

Test: CallCardPresenterTest,SecondaryInfoTest
PiperOrigin-RevId: 187481728
Change-Id: I3d2b23b5d51ea1e5ff30b8f6b6570d76c006fe86
parent f127d3ca
Loading
Loading
Loading
Loading
+22 −22
Original line number Diff line number Diff line
@@ -907,7 +907,7 @@ public class CallCardPresenter

    if (secondary == null) {
      // Clear the secondary display info.
      inCallScreen.setSecondary(SecondaryInfo.createEmptySecondaryInfo(isFullscreen));
      inCallScreen.setSecondary(SecondaryInfo.builder().setIsFullscreen(isFullscreen).build());
      return;
    }

@@ -915,39 +915,39 @@ public class CallCardPresenter
      LogUtil.i(
          "CallCardPresenter.updateSecondaryDisplayInfo",
          "secondary call is merge in process, clearing info");
      inCallScreen.setSecondary(SecondaryInfo.createEmptySecondaryInfo(isFullscreen));
      inCallScreen.setSecondary(SecondaryInfo.builder().setIsFullscreen(isFullscreen).build());
      return;
    }

    if (secondary.isConferenceCall()) {
      inCallScreen.setSecondary(
          new SecondaryInfo(
              true /* show */,
          SecondaryInfo.builder()
              .setShouldShow(true)
              .setName(
                  CallerInfoUtils.getConferenceString(
                  context, secondary.hasProperty(Details.PROPERTY_GENERIC_CONFERENCE)),
              false /* nameIsNumber */,
              null /* label */,
              secondary.getCallProviderLabel(),
              true /* isConference */,
              secondary.isVideoCall(),
              isFullscreen));
                      context, secondary.hasProperty(Details.PROPERTY_GENERIC_CONFERENCE)))
              .setProviderLabel(secondary.getCallProviderLabel())
              .setIsConference(true)
              .setIsVideoCall(secondary.isVideoCall())
              .setIsFullscreen(isFullscreen)
              .build());
    } else if (secondaryContactInfo != null) {
      LogUtil.v("CallCardPresenter.updateSecondaryDisplayInfo", "" + secondaryContactInfo);
      String name = getNameForCall(secondaryContactInfo);
      boolean nameIsNumber = name != null && name.equals(secondaryContactInfo.number);
      inCallScreen.setSecondary(
          new SecondaryInfo(
              true /* show */,
              secondary.updateNameIfRestricted(name),
              nameIsNumber,
              secondaryContactInfo.label,
              secondary.getCallProviderLabel(),
              false /* isConference */,
              secondary.isVideoCall(),
              isFullscreen));
          SecondaryInfo.builder()
              .setShouldShow(true)
              .setName(secondary.updateNameIfRestricted(name))
              .setNameIsNumber(nameIsNumber)
              .setLabel(secondaryContactInfo.label)
              .setProviderLabel(secondary.getCallProviderLabel())
              .setIsVideoCall(secondary.isVideoCall())
              .setIsFullscreen(isFullscreen)
              .build());
    } else {
      // Clear the secondary display info.
      inCallScreen.setSecondary(SecondaryInfo.createEmptySecondaryInfo(isFullscreen));
      inCallScreen.setSecondary(SecondaryInfo.builder().setIsFullscreen(isFullscreen).build());
    }
  }

+4 −4
Original line number Diff line number Diff line
@@ -59,14 +59,14 @@ public class OnHoldFragment extends Fragment {

    ((TextView) view.findViewById(R.id.hold_contact_name))
        .setText(
            secondaryInfo.nameIsNumber
            secondaryInfo.nameIsNumber()
                ? PhoneNumberUtils.createTtsSpannable(
                    BidiFormatter.getInstance()
                        .unicodeWrap(secondaryInfo.name, TextDirectionHeuristics.LTR))
                : secondaryInfo.name);
                        .unicodeWrap(secondaryInfo.name(), TextDirectionHeuristics.LTR))
                : secondaryInfo.name());
    ((ImageView) view.findViewById(R.id.hold_phone_icon))
        .setImageResource(
            secondaryInfo.isVideoCall
            secondaryInfo.isVideoCall()
                ? R.drawable.quantum_ic_videocam_white_18
                : R.drawable.quantum_ic_phone_paused_vd_theme_24);
    view.addOnAttachStateChangeListener(
+1 −1
Original line number Diff line number Diff line
@@ -305,7 +305,7 @@ public class InCallFragment extends Fragment
    savedSecondaryInfo = null;
    FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
    Fragment oldBanner = getChildFragmentManager().findFragmentById(R.id.incall_on_hold_banner);
    if (secondaryInfo.shouldShow) {
    if (secondaryInfo.shouldShow()) {
      transaction.replace(R.id.incall_on_hold_banner, OnHoldFragment.newInstance(secondaryInfo));
    } else {
      if (oldBanner != null) {
+72 −53
Original line number Diff line number Diff line
@@ -18,41 +18,62 @@ package com.android.incallui.incall.protocol;

import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.Nullable;
import com.android.dialer.common.LogUtil;
import com.google.auto.value.AutoValue;
import java.util.Locale;

/** Information about the secondary call. */
public class SecondaryInfo implements Parcelable {
  public final boolean shouldShow;
  public final String name;
  public final boolean nameIsNumber;
  public final String label;
  public final String providerLabel;
  public final boolean isConference;
  public final boolean isVideoCall;
  public final boolean isFullscreen;

  public static SecondaryInfo createEmptySecondaryInfo(boolean isFullScreen) {
    return new SecondaryInfo(false, null, false, null, null, false, false, isFullScreen);
@AutoValue
public abstract class SecondaryInfo implements Parcelable {
  public abstract boolean shouldShow();

  @Nullable
  public abstract String name();

  public abstract boolean nameIsNumber();

  @Nullable
  public abstract String label();

  @Nullable
  public abstract String providerLabel();

  public abstract boolean isConference();

  public abstract boolean isVideoCall();

  public abstract boolean isFullscreen();

  public static Builder builder() {
    return new AutoValue_SecondaryInfo.Builder()
        .setShouldShow(false)
        .setNameIsNumber(false)
        .setIsConference(false)
        .setIsVideoCall(false)
        .setIsFullscreen(false);
  }

  public SecondaryInfo(
      boolean shouldShow,
      String name,
      boolean nameIsNumber,
      String label,
      String providerLabel,
      boolean isConference,
      boolean isVideoCall,
      boolean isFullscreen) {
    this.shouldShow = shouldShow;
    this.name = name;
    this.nameIsNumber = nameIsNumber;
    this.label = label;
    this.providerLabel = providerLabel;
    this.isConference = isConference;
    this.isVideoCall = isVideoCall;
    this.isFullscreen = isFullscreen;
  /** Builder class for secondary info. */
  @AutoValue.Builder
  public abstract static class Builder {
    public abstract Builder setShouldShow(boolean shouldShow);

    public abstract Builder setName(String name);

    public abstract Builder setNameIsNumber(boolean nameIsNumber);

    public abstract Builder setLabel(String label);

    public abstract Builder setProviderLabel(String providerLabel);

    public abstract Builder setIsConference(boolean isConference);

    public abstract Builder setIsVideoCall(boolean isVideoCall);

    public abstract Builder setIsFullscreen(boolean isFullscreen);

    public abstract SecondaryInfo build();
  }

  @Override
@@ -60,28 +81,26 @@ public class SecondaryInfo implements Parcelable {
    return String.format(
        Locale.US,
        "SecondaryInfo, show: %b, name: %s, label: %s, " + "providerLabel: %s",
        shouldShow,
        LogUtil.sanitizePii(name),
        label,
        providerLabel);
  }

  protected SecondaryInfo(Parcel in) {
    shouldShow = in.readByte() != 0;
    name = in.readString();
    nameIsNumber = in.readByte() != 0;
    label = in.readString();
    providerLabel = in.readString();
    isConference = in.readByte() != 0;
    isVideoCall = in.readByte() != 0;
    isFullscreen = in.readByte() != 0;
        shouldShow(),
        LogUtil.sanitizePii(name()),
        label(),
        providerLabel());
  }

  public static final Creator<SecondaryInfo> CREATOR =
      new Creator<SecondaryInfo>() {
        @Override
        public SecondaryInfo createFromParcel(Parcel in) {
          return new SecondaryInfo(in);
          return builder()
              .setShouldShow(in.readByte() != 0)
              .setName(in.readString())
              .setNameIsNumber(in.readByte() != 0)
              .setLabel(in.readString())
              .setProviderLabel(in.readString())
              .setIsConference(in.readByte() != 0)
              .setIsVideoCall(in.readByte() != 0)
              .setIsFullscreen(in.readByte() != 0)
              .build();
        }

        @Override
@@ -97,13 +116,13 @@ public class SecondaryInfo implements Parcelable {

  @Override
  public void writeToParcel(Parcel dest, int flags) {
    dest.writeByte((byte) (shouldShow ? 1 : 0));
    dest.writeString(name);
    dest.writeByte((byte) (nameIsNumber ? 1 : 0));
    dest.writeString(label);
    dest.writeString(providerLabel);
    dest.writeByte((byte) (isConference ? 1 : 0));
    dest.writeByte((byte) (isVideoCall ? 1 : 0));
    dest.writeByte((byte) (isFullscreen ? 1 : 0));
    dest.writeByte((byte) (shouldShow() ? 1 : 0));
    dest.writeString(name());
    dest.writeByte((byte) (nameIsNumber() ? 1 : 0));
    dest.writeString(label());
    dest.writeString(providerLabel());
    dest.writeByte((byte) (isConference() ? 1 : 0));
    dest.writeByte((byte) (isVideoCall() ? 1 : 0));
    dest.writeByte((byte) (isFullscreen() ? 1 : 0));
  }
}
+1 −1
Original line number Diff line number Diff line
@@ -846,7 +846,7 @@ public class SurfaceViewVideoCallFragment extends Fragment
    updateButtonStates();
    FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
    Fragment oldBanner = getChildFragmentManager().findFragmentById(R.id.videocall_on_hold_banner);
    if (secondaryInfo.shouldShow) {
    if (secondaryInfo.shouldShow()) {
      OnHoldFragment onHoldFragment = OnHoldFragment.newInstance(secondaryInfo);
      onHoldFragment.setPadTopInset(!isInFullscreenMode);
      transaction.replace(R.id.videocall_on_hold_banner, onHoldFragment);
Loading