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 
17 package com.android.quickstep.util;
18 
19 import static com.android.app.animation.Interpolators.LINEAR;
20 
21 import android.view.animation.Interpolator;
22 
23 /**
24  * Organizes timing information for split screen animations.
25  */
26 public interface SplitAnimationTimings {
27     /** Total duration (ms) for initiating split screen (staging the first app) on tablets. */
28     int TABLET_ENTER_DURATION = 866;
29     /** Total duration (ms) for confirming split screen (selecting the second app) on tablets. */
30     int TABLET_CONFIRM_DURATION = 500;
31     /** Total duration (ms) for initiating split screen (staging the first app) on phones. */
32     int PHONE_ENTER_DURATION = 517;
33     /** Total duration (ms) for confirming split screen (selecting the second app) on phones. */
34     int PHONE_CONFIRM_DURATION = 333;
35     /** Total duration (ms) for aborting split screen (before selecting the second app). */
36     int ABORT_DURATION = 500;
37     /** Total duration (ms) for launching an app pair from its icon on tablets. */
38     int TABLET_APP_PAIR_LAUNCH_DURATION = 998;
39     /** Total duration (ms) for launching an app pair from its icon on phones. */
40     int PHONE_APP_PAIR_LAUNCH_DURATION = 915;
41 
42     // Initialize timing classes so they can be accessed statically
43     SplitAnimationTimings TABLET_OVERVIEW_TO_SPLIT = new TabletOverviewToSplitTimings();
44     SplitAnimationTimings TABLET_HOME_TO_SPLIT = new TabletHomeToSplitTimings();
45     SplitAnimationTimings TABLET_SPLIT_TO_CONFIRM = new TabletSplitToConfirmTimings();
46     SplitAnimationTimings PHONE_OVERVIEW_TO_SPLIT = new PhoneOverviewToSplitTimings();
47     SplitAnimationTimings PHONE_SPLIT_TO_CONFIRM = new PhoneSplitToConfirmTimings();
48     SplitAnimationTimings TABLET_APP_PAIR_LAUNCH = new TabletAppPairLaunchTimings();
49     SplitAnimationTimings PHONE_APP_PAIR_LAUNCH = new PhoneAppPairLaunchTimings();
50 
51     // Shared methods: all split animations have these parameters
getDuration()52     int getDuration();
53     /** Start fading in the floating view tile at this time (in ms). */
getPlaceholderFadeInStart()54     int getPlaceholderFadeInStart();
getPlaceholderFadeInEnd()55     int getPlaceholderFadeInEnd();
56     /** Start fading in the app icon at this time (in ms). */
getPlaceholderIconFadeInStart()57     int getPlaceholderIconFadeInStart();
getPlaceholderIconFadeInEnd()58     int getPlaceholderIconFadeInEnd();
59     /** Start translating the floating view tile at this time (in ms). */
getStagedRectSlideStart()60     int getStagedRectSlideStart();
61     /** The floating tile has reached its final position at this time (in ms). */
getStagedRectSlideEnd()62     int getStagedRectSlideEnd();
getStagedRectXInterpolator()63     Interpolator getStagedRectXInterpolator();
getStagedRectYInterpolator()64     Interpolator getStagedRectYInterpolator();
getStagedRectScaleXInterpolator()65     Interpolator getStagedRectScaleXInterpolator();
getStagedRectScaleYInterpolator()66     Interpolator getStagedRectScaleYInterpolator();
getPlaceholderFadeInStartOffset()67     default float getPlaceholderFadeInStartOffset() {
68         return (float) getPlaceholderFadeInStart() / getDuration();
69     }
getPlaceholderFadeInEndOffset()70     default float getPlaceholderFadeInEndOffset() {
71         return (float) getPlaceholderFadeInEnd() / getDuration();
72     }
getPlaceholderIconFadeInStartOffset()73     default float getPlaceholderIconFadeInStartOffset() {
74         return (float) getPlaceholderIconFadeInStart() / getDuration();
75     }
getPlaceholderIconFadeInEndOffset()76     default float getPlaceholderIconFadeInEndOffset() {
77         return (float) getPlaceholderIconFadeInEnd() / getDuration();
78     }
getStagedRectSlideStartOffset()79     default float getStagedRectSlideStartOffset() {
80         return (float) getStagedRectSlideStart() / getDuration();
81     }
getStagedRectSlideEndOffset()82     default float getStagedRectSlideEndOffset() {
83         return (float) getStagedRectSlideEnd() / getDuration();
84     }
85 
86     // DEFAULT VALUES: We define default values here so that SplitAnimationTimings can be used
87     // flexibly in animation-running functions, e.g. a single function that handles 2 types of split
88     // animations. The values are not intended to be used, and can safely be removed if refactoring
89     // these classes.
90 
91     // Defaults for OverviewToSplit
getGridSlideStartOffset()92     default float getGridSlideStartOffset() { return 0; }
getGridSlideStaggerOffset()93     default float getGridSlideStaggerOffset() { return 0; }
getGridSlideDurationOffset()94     default float getGridSlideDurationOffset() { return 0; }
getActionsFadeStartOffset()95     default float getActionsFadeStartOffset() { return 0; }
getActionsFadeEndOffset()96     default float getActionsFadeEndOffset() { return 0; }
getIconFadeStartOffset()97     default float getIconFadeStartOffset() { return 0; }
getIconFadeEndOffset()98     default float getIconFadeEndOffset() { return 0; }
getInstructionsContainerFadeInStartOffset()99     default float getInstructionsContainerFadeInStartOffset() { return 0; }
getInstructionsContainerFadeInEndOffset()100     default float getInstructionsContainerFadeInEndOffset() { return 0; }
getInstructionsTextFadeInStartOffset()101     default float getInstructionsTextFadeInStartOffset() { return 0; }
getInstructionsTextFadeInEndOffset()102     default float getInstructionsTextFadeInEndOffset() { return 0; }
getInstructionsUnfoldStartOffset()103     default float getInstructionsUnfoldStartOffset() { return 0; }
getInstructionsUnfoldEndOffset()104     default float getInstructionsUnfoldEndOffset() { return 0; }
getGridSlidePrimaryInterpolator()105     default Interpolator getGridSlidePrimaryInterpolator() { return LINEAR; }
getGridSlideSecondaryInterpolator()106     default Interpolator getGridSlideSecondaryInterpolator() { return LINEAR; }
107 
108     // Defaults for HomeToSplit
getScrimFadeInStartOffset()109     default float getScrimFadeInStartOffset() { return 0; }
getScrimFadeInEndOffset()110     default float getScrimFadeInEndOffset() { return 0; }
111 
112     // Defaults for SplitToConfirm
getInstructionsFadeStartOffset()113     default float getInstructionsFadeStartOffset() { return 0; }
getInstructionsFadeEndOffset()114     default float getInstructionsFadeEndOffset() { return 0; }
115 
116     // Defaults for AppPair
getCellSplitStartOffset()117     default float getCellSplitStartOffset() { return 0; }
getCellSplitEndOffset()118     default float getCellSplitEndOffset() { return 0; }
getAppRevealStartOffset()119     default float getAppRevealStartOffset() { return 0; }
getAppRevealEndOffset()120     default float getAppRevealEndOffset() { return 0; }
getCellSplitInterpolator()121     default Interpolator getCellSplitInterpolator() { return LINEAR; }
getIconFadeInterpolator()122     default Interpolator getIconFadeInterpolator() { return LINEAR; }
123 }
124 
125