From 71bf7e4d449fa28a644658b01029b7475a4a4162 Mon Sep 17 00:00:00 2001 From: yueg Date: Mon, 30 Apr 2018 12:00:48 -0700 Subject: Bubble changes for background calling. Bug: 74022483 Test: manual PiperOrigin-RevId: 194822680 Change-Id: I4df144b21a0fc32e39eb970fadc24ef7eb6e7199 --- java/com/android/incallui/InCallPresenter.java | 2 +- .../android/incallui/ReturnToCallController.java | 33 ++++++++++++++++++++-- 2 files changed, 32 insertions(+), 3 deletions(-) (limited to 'java/com/android/incallui') diff --git a/java/com/android/incallui/InCallPresenter.java b/java/com/android/incallui/InCallPresenter.java index 8193c6e05..3020bf1fa 100644 --- a/java/com/android/incallui/InCallPresenter.java +++ b/java/com/android/incallui/InCallPresenter.java @@ -414,7 +414,7 @@ public class InCallPresenter implements CallList.Listener, AudioModeProvider.Aud * Return whether we should start call in bubble mode and not show InCallActivity. The call mode * should be set in CallConfiguration in EXTRA_OUTGOING_CALL_EXTRAS when starting a call intent. */ - private boolean shouldStartInBubbleMode() { + public boolean shouldStartInBubbleMode() { if (!ReturnToCallController.isEnabled(context)) { return false; } diff --git a/java/com/android/incallui/ReturnToCallController.java b/java/com/android/incallui/ReturnToCallController.java index 4a7b3fbce..96bdda1ba 100644 --- a/java/com/android/incallui/ReturnToCallController.java +++ b/java/com/android/incallui/ReturnToCallController.java @@ -37,6 +37,7 @@ import com.android.dialer.lettertile.LetterTileDrawable; import com.android.dialer.telecom.TelecomUtil; import com.android.incallui.ContactInfoCache.ContactCacheEntry; import com.android.incallui.ContactInfoCache.ContactInfoCacheCallback; +import com.android.incallui.InCallPresenter.InCallState; import com.android.incallui.InCallPresenter.InCallUiListener; import com.android.incallui.audiomode.AudioModeProvider; import com.android.incallui.audiomode.AudioModeProvider.AudioModeListener; @@ -77,6 +78,8 @@ public class ReturnToCallController implements InCallUiListener, Listener, Audio private final ContactInfoCache contactInfoCache; + private InCallState inCallState; + public static boolean isEnabled(Context context) { return ConfigProviderBindings.get(context).getBoolean("enable_return_to_call_bubble_v2", false); } @@ -186,7 +189,19 @@ public class ReturnToCallController implements InCallUiListener, Listener, Audio return; } - if ((bubble == null || !(bubble.isVisible() || bubble.isDismissed())) + boolean shouldStartInBubbleMode = InCallPresenter.getInstance().shouldStartInBubbleMode(); + InCallState newInCallState = + InCallPresenter.getInstance().getPotentialStateFromCallList(callList); + boolean isNewBackgroundCall = + newInCallState != inCallState + && newInCallState == InCallState.OUTGOING + && shouldStartInBubbleMode; + if (bubble != null && isNewBackgroundCall) { + // If new outgoing call is in bubble mode, update bubble info. + // We don't update if new call is not in bubble mode even if the existing call is. + bubble.setBubbleInfo(generateBubbleInfoForBackgroundCalling()); + } + if ((bubble == null || !(bubble.isVisible() || bubble.isDismissed()) || isNewBackgroundCall) && getCall() != null && !InCallPresenter.getInstance().isShowingInCallUi()) { LogUtil.i("ReturnToCallController.onCallListChange", "going to show bubble"); @@ -195,6 +210,7 @@ public class ReturnToCallController implements InCallUiListener, Listener, Audio // The call to display might be different for the existing bubble startContactInfoSearch(); } + inCallState = newInCallState; } @Override @@ -274,7 +290,20 @@ public class ReturnToCallController implements InCallUiListener, Listener, Audio .setPrimaryColor(context.getResources().getColor(R.color.dialer_theme_color, null)) .setPrimaryIcon(Icon.createWithResource(context, R.drawable.on_going_call)) .setStartingYPosition( - context.getResources().getDimensionPixelOffset(R.dimen.return_to_call_initial_offset_y)) + InCallPresenter.getInstance().shouldStartInBubbleMode() + ? context.getResources().getDisplayMetrics().heightPixels / 2 + : context + .getResources() + .getDimensionPixelOffset(R.dimen.return_to_call_initial_offset_y)) + .setActions(generateActions()) + .build(); + } + + private BubbleInfo generateBubbleInfoForBackgroundCalling() { + return BubbleInfo.builder() + .setPrimaryColor(context.getResources().getColor(R.color.dialer_theme_color, null)) + .setPrimaryIcon(Icon.createWithResource(context, R.drawable.on_going_call)) + .setStartingYPosition(context.getResources().getDisplayMetrics().heightPixels / 2) .setActions(generateActions()) .build(); } -- cgit v1.2.3