diff options
author | wangqi <wangqi@google.com> | 2017-07-20 10:39:04 -0700 |
---|---|---|
committer | Eric Erfanian <erfanian@google.com> | 2017-07-25 16:43:44 +0000 |
commit | 94b472ccbee7fdc86f194ab889c85dd13477cacf (patch) | |
tree | e1e38d7dc171a697c2922b1bf437e48282a3fa8b /java | |
parent | ce2a8c9c6b423b802a509a4966bcb03a8d0364eb (diff) |
Disable swap button until second call is active.
Before the other party answers the call, the swap button won't work for second
call.
Screenshots:
https://screenshot.googleplex.com/MTjD6VHEdxd
https://screenshot.googleplex.com/cVEuoTnRAZ8
Bug: 63083257
Test: manual
PiperOrigin-RevId: 162633661
Change-Id: I79ebcece059fd256e50edb7509ac1703c3145dac
Diffstat (limited to 'java')
3 files changed, 41 insertions, 7 deletions
diff --git a/java/com/android/incallui/CallCardPresenter.java b/java/com/android/incallui/CallCardPresenter.java index 67b917767..390683233 100644 --- a/java/com/android/incallui/CallCardPresenter.java +++ b/java/com/android/incallui/CallCardPresenter.java @@ -60,6 +60,7 @@ import com.android.incallui.InCallPresenter.InCallStateListener; import com.android.incallui.InCallPresenter.IncomingCallListener; import com.android.incallui.call.CallList; import com.android.incallui.call.DialerCall; +import com.android.incallui.call.DialerCall.State; import com.android.incallui.call.DialerCallListener; import com.android.incallui.calllocation.CallLocation; import com.android.incallui.calllocation.CallLocationComponent; @@ -67,6 +68,7 @@ import com.android.incallui.incall.protocol.ContactPhotoType; import com.android.incallui.incall.protocol.InCallScreen; import com.android.incallui.incall.protocol.InCallScreenDelegate; import com.android.incallui.incall.protocol.PrimaryCallState; +import com.android.incallui.incall.protocol.PrimaryCallState.ButtonState; import com.android.incallui.incall.protocol.PrimaryInfo; import com.android.incallui.incall.protocol.SecondaryInfo; import com.android.incallui.videotech.utils.SessionModificationState; @@ -472,7 +474,8 @@ public class CallCardPresenter CallerInfoUtils.isVoiceMailNumber(mContext, mPrimary), mPrimary.isRemotelyHeld(), isBusiness, - supports2ndCallOnHold())); + supports2ndCallOnHold(), + getSwapToSecondaryButtonState())); InCallActivity activity = (InCallActivity) (mInCallScreen.getInCallScreenFragment().getActivity()); @@ -482,6 +485,16 @@ public class CallCardPresenter } } + private @ButtonState int getSwapToSecondaryButtonState() { + if (mSecondary == null) { + return ButtonState.NOT_SUPPORT; + } + if (mPrimary.getState() == State.ACTIVE) { + return ButtonState.ENABLED; + } + return ButtonState.DISABLED; + } + /** Only show the conference call button if we can manage the conference. */ private void maybeShowManageConferenceCallButton() { getUi().showManageConferenceCallButton(shouldShowManageConference()); diff --git a/java/com/android/incallui/incall/impl/InCallFragment.java b/java/com/android/incallui/incall/impl/InCallFragment.java index 54d01e716..1730c808c 100644 --- a/java/com/android/incallui/incall/impl/InCallFragment.java +++ b/java/com/android/incallui/incall/impl/InCallFragment.java @@ -60,6 +60,7 @@ import com.android.incallui.incall.protocol.InCallScreen; import com.android.incallui.incall.protocol.InCallScreenDelegate; import com.android.incallui.incall.protocol.InCallScreenDelegateFactory; import com.android.incallui.incall.protocol.PrimaryCallState; +import com.android.incallui.incall.protocol.PrimaryCallState.ButtonState; import com.android.incallui.incall.protocol.PrimaryInfo; import com.android.incallui.incall.protocol.SecondaryInfo; import java.util.ArrayList; @@ -287,10 +288,6 @@ public class InCallFragment extends Fragment @Override public void setSecondary(@NonNull SecondaryInfo secondaryInfo) { LogUtil.i("InCallFragment.setSecondary", secondaryInfo.toString()); - getButtonController(InCallButtonIds.BUTTON_SWITCH_TO_SECONDARY) - .setEnabled(secondaryInfo.shouldShow); - getButtonController(InCallButtonIds.BUTTON_SWITCH_TO_SECONDARY) - .setAllowed(secondaryInfo.shouldShow); updateButtonStates(); if (!isAdded()) { @@ -315,6 +312,10 @@ public class InCallFragment extends Fragment public void setCallState(@NonNull PrimaryCallState primaryCallState) { LogUtil.i("InCallFragment.setCallState", primaryCallState.toString()); contactGridManager.setCallState(primaryCallState); + getButtonController(InCallButtonIds.BUTTON_SWITCH_TO_SECONDARY) + .setAllowed(primaryCallState.swapToSecondaryButtonState != ButtonState.NOT_SUPPORT); + getButtonController(InCallButtonIds.BUTTON_SWITCH_TO_SECONDARY) + .setEnabled(primaryCallState.swapToSecondaryButtonState == ButtonState.ENABLED); buttonChooser = ButtonChooserFactory.newButtonChooser(voiceNetworkType, primaryCallState.isWifi, phoneType); updateButtonStates(); diff --git a/java/com/android/incallui/incall/protocol/PrimaryCallState.java b/java/com/android/incallui/incall/protocol/PrimaryCallState.java index 26dd3887a..aac6ff96b 100644 --- a/java/com/android/incallui/incall/protocol/PrimaryCallState.java +++ b/java/com/android/incallui/incall/protocol/PrimaryCallState.java @@ -17,13 +17,29 @@ package com.android.incallui.incall.protocol; import android.graphics.drawable.Drawable; +import android.support.annotation.IntDef; import android.telecom.DisconnectCause; import com.android.incallui.call.DialerCall; import com.android.incallui.videotech.utils.SessionModificationState; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; import java.util.Locale; /** State of the primary call. */ public class PrimaryCallState { + + /** + * Button state that will be invisible if not supported, visible but invalid if disabled, or + * visible if enabled. + */ + @Retention(RetentionPolicy.SOURCE) + @IntDef({ButtonState.NOT_SUPPORT, ButtonState.DISABLED, ButtonState.ENABLED}) + public @interface ButtonState { + int NOT_SUPPORT = 0; + int DISABLED = 1; + int ENABLED = 2; + } + public final int state; public final boolean isVideoCall; @SessionModificationState public final int sessionModificationState; @@ -45,6 +61,7 @@ public class PrimaryCallState { public final boolean isRemotelyHeld; public final boolean isBusinessNumber; public final boolean supportsCallOnHold; + public final @ButtonState int swapToSecondaryButtonState; // TODO: Convert to autovalue. b/34502119 public static PrimaryCallState createEmptyPrimaryCallState() { @@ -69,7 +86,8 @@ public class PrimaryCallState { false /* isVoiceMailNumber */, false /* isRemotelyHeld */, false /* isBusinessNumber */, - true /* supportsCallOnHold */); + true /* supportsCallOnHold */, + ButtonState.NOT_SUPPORT /* swapToSecondaryButtonState */); } public PrimaryCallState( @@ -93,7 +111,8 @@ public class PrimaryCallState { boolean isVoiceMailNumber, boolean isRemotelyHeld, boolean isBusinessNumber, - boolean supportsCallOnHold) { + boolean supportsCallOnHold, + @ButtonState int swapToSecondaryButtonState) { this.state = state; this.isVideoCall = isVideoCall; this.sessionModificationState = sessionModificationState; @@ -115,6 +134,7 @@ public class PrimaryCallState { this.isRemotelyHeld = isRemotelyHeld; this.isBusinessNumber = isBusinessNumber; this.supportsCallOnHold = supportsCallOnHold; + this.swapToSecondaryButtonState = swapToSecondaryButtonState; } @Override |