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