diff options
Diffstat (limited to 'java')
-rw-r--r-- | java/com/android/bubble/Bubble.java | 48 | ||||
-rw-r--r-- | java/com/android/dialer/logging/dialer_impression.proto | 2 | ||||
-rw-r--r-- | java/com/android/incallui/ReturnToCallController.java | 30 |
3 files changed, 54 insertions, 26 deletions
diff --git a/java/com/android/bubble/Bubble.java b/java/com/android/bubble/Bubble.java index 9abfa432f..392daaf28 100644 --- a/java/com/android/bubble/Bubble.java +++ b/java/com/android/bubble/Bubble.java @@ -124,9 +124,11 @@ public class Bubble { private BubbleExpansionStateListener bubbleExpansionStateListener; + /** Type of action after bubble collapse */ @Retention(RetentionPolicy.SOURCE) @IntDef({CollapseEnd.NOTHING, CollapseEnd.HIDE}) - private @interface CollapseEnd { + @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) + public @interface CollapseEnd { int NOTHING = 0; int HIDE = 1; } @@ -210,18 +212,10 @@ public class Bubble { } /** Expands the main bubble menu. */ - public void expand() { - if (expanded || textShowing || currentInfo.getActions().isEmpty()) { - try { - currentInfo.getPrimaryIntent().send(); - } catch (CanceledException e) { - throw new RuntimeException(e); - } - return; - } - + public void expand(boolean isUserAction) { if (bubbleExpansionStateListener != null) { - bubbleExpansionStateListener.onBubbleExpansionStateChanged(ExpansionState.START_EXPANDING); + bubbleExpansionStateListener.onBubbleExpansionStateChanged( + ExpansionState.START_EXPANDING, isUserAction); } doResize( () -> { @@ -378,7 +372,7 @@ public class Bubble { public void showText(@NonNull CharSequence text) { textShowing = true; if (expanded) { - startCollapse(CollapseEnd.NOTHING); + startCollapse(CollapseEnd.NOTHING, false); doShowText(text); } else { // Need to transition from old bounds to new bounds manually @@ -456,7 +450,7 @@ public class Bubble { } void onMoveStart() { - startCollapse(CollapseEnd.NOTHING); + startCollapse(CollapseEnd.NOTHING, true); viewHolder .getPrimaryButton() .animate() @@ -474,7 +468,17 @@ public class Bubble { } void primaryButtonClick() { - expand(); + // Send primary intent if not to expand. + if (expanded || textShowing || currentInfo.getActions().isEmpty()) { + try { + currentInfo.getPrimaryIntent().send(); + } catch (CanceledException e) { + throw new RuntimeException(e); + } + return; + } + + expand(true); } void onLeftRightSwitch(boolean onRight) { @@ -534,7 +538,7 @@ public class Bubble { } if (expanded) { - startCollapse(CollapseEnd.HIDE); + startCollapse(CollapseEnd.HIDE, false); return; } @@ -692,7 +696,8 @@ public class Bubble { }); } - private void startCollapse(@CollapseEnd int endAction) { + @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) + public void startCollapse(@CollapseEnd int endAction, boolean isUserAction) { View expandedView = viewHolder.getExpandedView(); if (expandedView.getVisibility() != View.VISIBLE || collapseAnimation != null) { // Drawer is already collapsed or animation is running. @@ -706,7 +711,8 @@ public class Bubble { collapseEndAction = endAction; } if (bubbleExpansionStateListener != null && collapseEndAction == CollapseEnd.NOTHING) { - bubbleExpansionStateListener.onBubbleExpansionStateChanged(ExpansionState.START_COLLAPSING); + bubbleExpansionStateListener.onBubbleExpansionStateChanged( + ExpansionState.START_COLLAPSING, isUserAction); } collapseAnimation = expandedView @@ -805,7 +811,7 @@ public class Bubble { root.setOnBackPressedListener( () -> { if (visibility == Visibility.SHOWING && expanded) { - startCollapse(CollapseEnd.NOTHING); + startCollapse(CollapseEnd.NOTHING, true); return true; } return false; @@ -820,7 +826,7 @@ public class Bubble { root.setOnTouchListener( (v, event) -> { if (expanded && event.getActionMasked() == MotionEvent.ACTION_OUTSIDE) { - startCollapse(CollapseEnd.NOTHING); + startCollapse(CollapseEnd.NOTHING, true); return true; } return false; @@ -910,6 +916,6 @@ public class Bubble { /** Listener for bubble expansion state change. */ public interface BubbleExpansionStateListener { - void onBubbleExpansionStateChanged(@ExpansionState int expansionState); + void onBubbleExpansionStateChanged(@ExpansionState int expansionState, boolean isUserAction); } } diff --git a/java/com/android/dialer/logging/dialer_impression.proto b/java/com/android/dialer/logging/dialer_impression.proto index f273a3654..ed3866a92 100644 --- a/java/com/android/dialer/logging/dialer_impression.proto +++ b/java/com/android/dialer/logging/dialer_impression.proto @@ -479,7 +479,7 @@ message DialerImpression { // In in call UI UPGRADE_TO_VIDEO_CALL_BUTTON_SHOWN = 1236; - // Bubble primary button first click to expand bubble + // Bubble primary button first click to expand bubble (by user) BUBBLE_PRIMARY_BUTTON_EXPAND = 1237; // Bubble prinary button second click to return to call BUBBLE_PRIMARY_BUTTON_RETURN_TO_CALL = 1238; diff --git a/java/com/android/incallui/ReturnToCallController.java b/java/com/android/incallui/ReturnToCallController.java index fd48b37e1..89731bc0d 100644 --- a/java/com/android/incallui/ReturnToCallController.java +++ b/java/com/android/incallui/ReturnToCallController.java @@ -134,14 +134,36 @@ public class ReturnToCallController implements InCallUiListener, Listener, Audio returnToCallBubble.setBubbleExpansionStateListener( new BubbleExpansionStateListener() { @Override - public void onBubbleExpansionStateChanged(@ExpansionState int expansionState) { + public void onBubbleExpansionStateChanged( + @ExpansionState int expansionState, boolean isUserAction) { + if (!isUserAction) { + return; + } + + DialerCall call = CallList.getInstance().getActiveOrBackgroundCall(); switch (expansionState) { case ExpansionState.START_EXPANDING: - Logger.get(context) - .logImpression(DialerImpression.Type.BUBBLE_PRIMARY_BUTTON_EXPAND); + if (call != null) { + Logger.get(context) + .logCallImpression( + DialerImpression.Type.BUBBLE_PRIMARY_BUTTON_EXPAND, + call.getUniqueCallId(), + call.getTimeAddedMs()); + } else { + Logger.get(context) + .logImpression(DialerImpression.Type.BUBBLE_PRIMARY_BUTTON_EXPAND); + } break; case ExpansionState.START_COLLAPSING: - Logger.get(context).logImpression(DialerImpression.Type.BUBBLE_COLLAPSE_BY_USER); + if (call != null) { + Logger.get(context) + .logCallImpression( + DialerImpression.Type.BUBBLE_COLLAPSE_BY_USER, + call.getUniqueCallId(), + call.getTimeAddedMs()); + } else { + Logger.get(context).logImpression(DialerImpression.Type.BUBBLE_COLLAPSE_BY_USER); + } break; default: break; |