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 com.android.wm.shell.bubbles.BubbleExpandedView; 19 20 /** 21 * Animation controller for bubble expanded view collapsing 22 */ 23 public interface ExpandedViewAnimationController { 24 /** 25 * Set expanded view that this controller is working with. 26 */ setExpandedView(BubbleExpandedView expandedView)27 void setExpandedView(BubbleExpandedView expandedView); 28 29 /** 30 * Set current collapse value, in pixels. 31 * 32 * @param distance pixels that user dragged the view by 33 */ updateDrag(float distance)34 void updateDrag(float distance); 35 36 /** 37 * Set current swipe velocity. 38 * Velocity is directional: 39 * <ul> 40 * <li>velocity < 0 means swipe direction is up</li> 41 * <li>velocity > 0 means swipe direction is down</li> 42 * </ul> 43 */ setSwipeVelocity(float velocity)44 void setSwipeVelocity(float velocity); 45 46 /** 47 * Check if view is dragged past collapse threshold or swipe up velocity exceeds min velocity 48 * required to collapse the view 49 */ shouldCollapse()50 boolean shouldCollapse(); 51 52 /** 53 * Animate view to collapsed state 54 * 55 * @param startStackCollapse runnable that is triggered when bubbles can start moving back to 56 * their collapsed location 57 * @param after runnable to run after animation is complete 58 */ animateCollapse(Runnable startStackCollapse, Runnable after)59 void animateCollapse(Runnable startStackCollapse, Runnable after); 60 61 /** 62 * Animate the view back to fully expanded state. 63 */ animateBackToExpanded()64 void animateBackToExpanded(); 65 66 /** 67 * Animate view for IME visibility change 68 */ animateForImeVisibilityChange(boolean visible)69 void animateForImeVisibilityChange(boolean visible); 70 71 /** 72 * Reset the view to fully expanded state 73 */ reset()74 void reset(); 75 } 76