From f473e1d0988bb13874a0774db9cbcd66777f9150 Mon Sep 17 00:00:00 2001 From: yueg Date: Tue, 2 Jan 2018 16:23:14 -0800 Subject: Bubble v2 dismiss. Drag and drop bubble to bottom to hide or end call. Flinging to bottom does not trigger the actions. Color/text is not final. Navigation bar is not hiden and the change will be in a following CL. Bug: 67605985 Test: NewBubbleTest PiperOrigin-RevId: 180608133 Change-Id: Iff4cb32226d8fbf0f8e5319f6876a1d74c336b4a --- java/com/android/newbubble/NewBubble.java | 43 +++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 5 deletions(-) (limited to 'java/com/android/newbubble/NewBubble.java') diff --git a/java/com/android/newbubble/NewBubble.java b/java/com/android/newbubble/NewBubble.java index 469c15d71..f5a036f93 100644 --- a/java/com/android/newbubble/NewBubble.java +++ b/java/com/android/newbubble/NewBubble.java @@ -60,6 +60,7 @@ import android.view.animation.AnticipateInterpolator; import android.view.animation.OvershootInterpolator; import android.widget.ImageView; import android.widget.TextView; +import android.widget.Toast; import android.widget.ViewAnimator; import com.android.dialer.common.LogUtil; import com.android.dialer.logging.DialerImpression; @@ -830,6 +831,12 @@ public class NewBubble { */ void replaceViewHolder() { LogUtil.enterBlock("NewBubble.replaceViewHolder"); + // Don't do it. If windowParams is null, either we haven't initialized it or we set it to null. + // There is no need to recreate bubble. + if (windowParams == null) { + return; + } + ViewHolder oldViewHolder = viewHolder; // Create a new ViewHolder and copy needed info. @@ -873,6 +880,27 @@ public class NewBubble { return viewHolder.getExpandedView().getVisibility(); } + void bottomActionDismiss() { + logBasicOrCallImpression(DialerImpression.Type.BUBBLE_V2_BOTTOM_ACTION_DISMISS); + // Create bubble at default location at next time + hideAndReset(); + windowParams = null; + } + + void bottomActionEndCall() { + logBasicOrCallImpression(DialerImpression.Type.BUBBLE_V2_BOTTOM_ACTION_END_CALL); + // Hide without animation + hideHelper( + () -> { + defaultAfterHidingAnimation(); + DialerCall call = getCall(); + if (call != null) { + call.disconnect(); + Toast.makeText(context, R.string.incall_call_ended, Toast.LENGTH_SHORT).show(); + } + }); + } + private boolean isDrawingFromRight() { return (windowParams.gravity & Gravity.RIGHT) == Gravity.RIGHT; } @@ -896,11 +924,7 @@ public class NewBubble { } private void logBasicOrCallImpression(DialerImpression.Type impressionType) { - // Bubble is shown for outgoing, active or background call - DialerCall call = CallList.getInstance().getOutgoingCall(); - if (call == null) { - call = CallList.getInstance().getActiveOrBackgroundCall(); - } + DialerCall call = getCall(); if (call != null) { Logger.get(context) .logCallImpression(impressionType, call.getUniqueCallId(), call.getTimeAddedMs()); @@ -909,6 +933,15 @@ public class NewBubble { } } + private DialerCall getCall() { + // Bubble is shown for outgoing, active or background call + DialerCall call = CallList.getInstance().getOutgoingCall(); + if (call == null) { + call = CallList.getInstance().getActiveOrBackgroundCall(); + } + return call; + } + private void setPrimaryButtonAccessibilityAction(String description) { viewHolder .getPrimaryButton() -- cgit v1.2.3