• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.android.wm.shell.bubbles.animation;
17 
18 import android.graphics.PointF;
19 
20 import com.android.wm.shell.bubbles.BubbleExpandedView;
21 
22 /**
23  * Animation controller for bubble expanded view collapsing
24  */
25 public interface ExpandedViewAnimationController {
26     /**
27      * Set expanded view that this controller is working with.
28      */
setExpandedView(BubbleExpandedView expandedView)29     void setExpandedView(BubbleExpandedView expandedView);
30 
31     /**
32      * Set current collapse value, in pixels.
33      *
34      * @param distance pixels that user dragged the view by
35      */
updateDrag(float distance)36     void updateDrag(float distance);
37 
38     /**
39      * Set current swipe velocity.
40      * Velocity is directional:
41      * <ul>
42      *     <li>velocity < 0 means swipe direction is up</li>
43      *     <li>velocity > 0 means swipe direction is down</li>
44      * </ul>
45      */
setSwipeVelocity(float velocity)46     void setSwipeVelocity(float velocity);
47 
48     /**
49      * Check if view is dragged past collapse threshold or swipe up velocity exceeds min velocity
50      * required to collapse the view
51      */
shouldCollapse()52     boolean shouldCollapse();
53 
54     /**
55      * Animate view to collapsed state
56      *
57      * @param startStackCollapse runnable that is triggered when bubbles can start moving back to
58      *                           their collapsed location
59      * @param after              runnable to run after animation is complete
60      * @param collapsePosition the position on screen the stack will collapse to
61      */
animateCollapse(Runnable startStackCollapse, Runnable after, PointF collapsePosition)62     void animateCollapse(Runnable startStackCollapse, Runnable after, PointF collapsePosition);
63 
64     /**
65      * Animate the view back to fully expanded state.
66      */
animateBackToExpanded()67     void animateBackToExpanded();
68 
69     /**
70      * Animate view for IME visibility change
71      */
animateForImeVisibilityChange(boolean visible)72     void animateForImeVisibilityChange(boolean visible);
73 
74     /**
75      * Whether this controller should also animate the expansion for the bubble
76      */
shouldAnimateExpansion()77     boolean shouldAnimateExpansion();
78 
79     /**
80      * Animate the expansion of the bubble.
81      *
82      * @param startDelayMillis how long to delay starting the expansion animation
83      * @param after runnable to run after the animation is complete
84      * @param collapsePosition the position on screen the stack will collapse to (and expand from)
85      * @param bubblePosition the position of the bubble on screen that the view is associated with
86      */
animateExpansion(long startDelayMillis, Runnable after, PointF collapsePosition, PointF bubblePosition)87     void animateExpansion(long startDelayMillis, Runnable after, PointF collapsePosition,
88             PointF bubblePosition);
89 
90     /**
91      * Reset the view to fully expanded state
92      */
reset()93     void reset();
94 }
95