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

Commit 31fe9985 authored by Android Dialer's avatar Android Dialer Committed by Copybara-Service
Browse files

Updating PrimaryCallState value class to use AutoValue with builder pattern.

Bug: 34502119
Test: BottomRowTest,CallCardPresenterTest,PrimaryCallStateTest,TopRowTest
PiperOrigin-RevId: 187071451
Change-Id: Ib1b4baee397f61eade84bf1a887596dddc37230a
parent b2c8e1c6
Loading
Loading
Loading
Loading
+34 −29
Original line number Diff line number Diff line
@@ -352,7 +352,7 @@ public class CallCardPresenter
      callState = this.primary.getState();
      updatePrimaryCallState();
    } else {
      getUi().setCallState(PrimaryCallState.createEmptyPrimaryCallState());
      getUi().setCallState(PrimaryCallState.empty());
    }

    maybeShowManageConferenceCallButton();
@@ -472,34 +472,39 @@ public class CallCardPresenter
          !VideoCallPresenter.showIncomingVideo(primary.getVideoState(), primary.getState());
      getUi()
          .setCallState(
              new PrimaryCallState(
                  primary.getState(),
                  primary.isVideoCall(),
                  primary.getVideoTech().getSessionModificationState(),
                  primary.getDisconnectCause(),
                  getConnectionLabel(),
                  getCallStateIcon(),
                  getGatewayNumber(),
                  shouldShowCallSubject(primary) ? primary.getCallSubject() : null,
              PrimaryCallState.builder()
                  .setState(primary.getState())
                  .setIsVideoCall(primary.isVideoCall())
                  .setSessionModificationState(primary.getVideoTech().getSessionModificationState())
                  .setDisconnectCause(primary.getDisconnectCause())
                  .setConnectionLabel(getConnectionLabel())
                  .setConnectionIcon(getCallStateIcon())
                  .setGatewayNumber(getGatewayNumber())
                  .setCallSubject(shouldShowCallSubject(primary) ? primary.getCallSubject() : null)
                  .setCallbackNumber(
                      PhoneNumberHelper.formatNumber(
                      primary.getCallbackNumber(), primary.getSimCountryIso()),
                  primary.hasProperty(Details.PROPERTY_WIFI),
                          primary.getCallbackNumber(), primary.getSimCountryIso()))
                  .setIsWifi(primary.hasProperty(Details.PROPERTY_WIFI))
                  .setIsConference(
                      primary.isConferenceCall()
                      && !primary.hasProperty(Details.PROPERTY_GENERIC_CONFERENCE),
                  isWorkCall,
                  isAttemptingHdAudioCall,
                  isHdAudioCall,
                  !TextUtils.isEmpty(primary.getLastForwardedNumber()) || primary.isCallForwarded(),
                  shouldShowContactPhoto,
                  primary.getConnectTimeMillis(),
                  primary.isVoiceMailNumber(),
                  primary.isRemotelyHeld(),
                  isBusiness,
                  supports2ndCallOnHold(),
                  getSwapToSecondaryButtonState(),
                  primary.isAssistedDialed(),
                  null,
                  primary.getAssistedDialingExtras()));
                          && !primary.hasProperty(Details.PROPERTY_GENERIC_CONFERENCE))
                  .setIsWorkCall(isWorkCall)
                  .setIsHdAttempting(isAttemptingHdAudioCall)
                  .setIsHdAudioCall(isHdAudioCall)
                  .setIsForwardedNumber(
                      !TextUtils.isEmpty(primary.getLastForwardedNumber())
                          || primary.isCallForwarded())
                  .setShouldShowContactPhoto(shouldShowContactPhoto)
                  .setConnectTimeMillis(primary.getConnectTimeMillis())
                  .setIsVoiceMailNumber(primary.isVoiceMailNumber())
                  .setIsRemotelyHeld(primary.isRemotelyHeld())
                  .setIsBusinessNumber(isBusiness)
                  .setSupportsCallOnHold(supports2ndCallOnHold())
                  .setSwapToSecondaryButtonState(getSwapToSecondaryButtonState())
                  .setIsAssistedDialed(primary.isAssistedDialed())
                  .setCustomLabel(null)
                  .setAssistedDialingExtras(primary.getAssistedDialingExtras())
                  .build());

      InCallActivity activity =
          (InCallActivity) (inCallScreen.getInCallScreenFragment().getActivity());
+5 −5
Original line number Diff line number Diff line
@@ -858,7 +858,7 @@ public class AnswerFragment extends Fragment
  public void onAnswerProgressUpdate(@FloatRange(from = -1f, to = 1f) float answerProgress) {
    // Don't fade the window background for call waiting or video upgrades. Fading the background
    // shows the system wallpaper which looks bad because on reject we switch to another call.
    if (primaryCallState.state == State.INCOMING && !isVideoCall()) {
    if (primaryCallState.state() == State.INCOMING && !isVideoCall()) {
      answerScreenDelegate.updateWindowBackgroundColor(answerProgress);
    }

@@ -969,7 +969,7 @@ public class AnswerFragment extends Fragment
        if (hasCallOnHold()) {
          getAnswerMethod()
              .setHintText(getText(R.string.call_incoming_default_label_answer_and_release_third));
        } else if (primaryCallState.supportsCallOnHold) {
        } else if (primaryCallState.supportsCallOnHold()) {
          getAnswerMethod()
              .setHintText(getText(R.string.call_incoming_default_label_answer_and_release_second));
        }
@@ -1048,9 +1048,9 @@ public class AnswerFragment extends Fragment

  private boolean canRejectCallWithSms() {
    return primaryCallState != null
        && !(primaryCallState.state == State.DISCONNECTED
            || primaryCallState.state == State.DISCONNECTING
            || primaryCallState.state == State.IDLE);
        && !(primaryCallState.state() == State.DISCONNECTED
            || primaryCallState.state() == State.DISCONNECTING
            || primaryCallState.state() == State.IDLE);
  }

  private void createInCallScreenDelegate() {
+4 −2
Original line number Diff line number Diff line
@@ -147,8 +147,10 @@ public class CallPendingActivity extends FragmentActivity
        (InCallScreen) getSupportFragmentManager().findFragmentByTag(TAG_IN_CALL_SCREEN);
    inCallScreen.setPrimary(createPrimaryInfo());
    inCallScreen.setCallState(
        PrimaryCallState.createEmptyPrimaryCallStateWithState(
            State.CALL_PENDING, getCallPendingLabel()));
        PrimaryCallState.builder()
            .setState(State.CALL_PENDING)
            .setCustomLabel(getCallPendingLabel())
            .build());
    inCallScreen.setEndCallButtonEnabled(true, true);
  }

+9 −9
Original line number Diff line number Diff line
@@ -74,11 +74,11 @@ public class BottomRow {

  public static Info getInfo(Context context, PrimaryCallState state, PrimaryInfo primaryInfo) {
    CharSequence label;
    boolean isTimerVisible = state.state == State.ACTIVE;
    boolean isForwardIconVisible = state.isForwardedNumber;
    boolean isWorkIconVisible = state.isWorkCall;
    boolean isHdIconVisible = state.isHdAudioCall && !isForwardIconVisible;
    boolean isHdAttemptingIconVisible = state.isHdAttempting;
    boolean isTimerVisible = state.state() == State.ACTIVE;
    boolean isForwardIconVisible = state.isForwardedNumber();
    boolean isWorkIconVisible = state.isWorkCall();
    boolean isHdIconVisible = state.isHdAudioCall() && !isForwardIconVisible;
    boolean isHdAttemptingIconVisible = state.isHdAttempting();
    boolean isSpamIconVisible = false;
    boolean shouldPopulateAccessibilityEvent = true;

@@ -86,14 +86,14 @@ public class BottomRow {
      label = context.getString(R.string.contact_grid_incoming_suspected_spam);
      isSpamIconVisible = true;
      isHdIconVisible = false;
    } else if (state.state == State.DISCONNECTING) {
    } else if (state.state() == State.DISCONNECTING) {
      // While in the DISCONNECTING state we display a "Hanging up" message in order to make the UI
      // feel more responsive.  (In GSM it's normal to see a delay of a couple of seconds while
      // negotiating the disconnect with the network, so the "Hanging up" state at least lets the
      // user know that we're doing something.  This state is currently not used with CDMA.)
      label = context.getString(R.string.incall_hanging_up);
    } else if (state.state == State.DISCONNECTED) {
      label = state.disconnectCause.getLabel();
    } else if (state.state() == State.DISCONNECTED) {
      label = state.disconnectCause().getLabel();
      if (TextUtils.isEmpty(label)) {
        label = context.getString(R.string.incall_call_ended);
      }
@@ -134,6 +134,6 @@ public class BottomRow {
  }

  private static boolean isIncoming(PrimaryCallState state) {
    return state.state == State.INCOMING || state.state == State.CALL_WAITING;
    return state.state() == State.INCOMING || state.state() == State.CALL_WAITING;
  }
}
+8 −7
Original line number Diff line number Diff line
@@ -86,7 +86,7 @@ public class ContactGridManager {
  private final View deviceNumberDivider;

  private PrimaryInfo primaryInfo = PrimaryInfo.empty();
  private PrimaryCallState primaryCallState = PrimaryCallState.createEmptyPrimaryCallState();
  private PrimaryCallState primaryCallState = PrimaryCallState.empty();
  private final LetterTileDrawable letterTile;
  private boolean isInMultiWindowMode;

@@ -305,11 +305,11 @@ public class ContactGridManager {
              primaryInfo.contactInfoLookupKey(),
              LetterTileDrawable.SHAPE_CIRCLE,
              LetterTileDrawable.getContactTypeFromPrimitives(
                  primaryCallState.isVoiceMailNumber,
                  primaryCallState.isVoiceMailNumber(),
                  primaryInfo.isSpam(),
                  primaryCallState.isBusinessNumber,
                  primaryCallState.isBusinessNumber(),
                  primaryInfo.numberPresentation(),
                  primaryCallState.isConference));
                  primaryCallState.isConference()));
          // By invalidating the avatarImageView we force a redraw of the letter tile.
          // This is required to properly display the updated letter tile iconography based on the
          // contact type, because the background drawable reference cached in the view, and the
@@ -381,7 +381,7 @@ public class ContactGridManager {
    if (info.isTimerVisible) {
      bottomTextSwitcher.setDisplayedChild(1);
      bottomTimerView.setBase(
          primaryCallState.connectTimeMillis
          primaryCallState.connectTimeMillis()
              - System.currentTimeMillis()
              + SystemClock.elapsedRealtime());
      if (!isTimerStarted) {
@@ -404,14 +404,15 @@ public class ContactGridManager {
    if (deviceNumberTextView == null) {
      return;
    }
    if (isInMultiWindowMode || TextUtils.isEmpty(primaryCallState.callbackNumber)) {
    if (isInMultiWindowMode || TextUtils.isEmpty(primaryCallState.callbackNumber())) {
      deviceNumberTextView.setVisibility(View.GONE);
      deviceNumberDivider.setVisibility(View.GONE);
      return;
    }
    // This is used for carriers like Project Fi to show the callback number for emergency calls.
    deviceNumberTextView.setText(
        context.getString(R.string.contact_grid_callback_number, primaryCallState.callbackNumber));
        context.getString(
            R.string.contact_grid_callback_number, primaryCallState.callbackNumber()));
    deviceNumberTextView.setVisibility(View.VISIBLE);
    if (primaryInfo.shouldShowLocation()) {
      deviceNumberDivider.setVisibility(View.VISIBLE);
Loading