1 /* 2 * Copyright (C) 2020 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.wm.shell.animation; 18 19 import android.graphics.Path; 20 import android.view.animation.BackGestureInterpolator; 21 import android.view.animation.Interpolator; 22 import android.view.animation.LinearInterpolator; 23 import android.view.animation.PathInterpolator; 24 25 /** 26 * Common interpolators used in wm shell library. 27 */ 28 public class Interpolators { 29 30 public static final Interpolator LINEAR = new LinearInterpolator(); 31 32 /** 33 * Interpolator for alpha in animation. 34 */ 35 public static final Interpolator ALPHA_IN = new PathInterpolator(0.4f, 0f, 1f, 1f); 36 37 /** 38 * Interpolator for alpha out animation. 39 */ 40 public static final Interpolator ALPHA_OUT = new PathInterpolator(0f, 0f, 0.8f, 1f); 41 42 /** 43 * Interpolator for fast out linear in animation. 44 */ 45 public static final Interpolator FAST_OUT_LINEAR_IN = new PathInterpolator(0.4f, 0f, 1f, 1f); 46 47 /** 48 * Interpolator for fast out slow in animation. 49 */ 50 public static final Interpolator FAST_OUT_SLOW_IN = new PathInterpolator(0.4f, 0f, 0.2f, 1f); 51 52 /** 53 * Interpolator for linear out slow in animation. 54 */ 55 public static final Interpolator LINEAR_OUT_SLOW_IN = new PathInterpolator(0f, 0f, 0.2f, 1f); 56 57 /** 58 * The default emphasized interpolator. Used for hero / emphasized movement of content. 59 */ 60 public static final Interpolator EMPHASIZED = createEmphasizedInterpolator(); 61 62 /** 63 * The accelerated emphasized interpolator. Used for hero / emphasized movement of content that 64 * is disappearing e.g. when moving off screen. 65 */ 66 public static final Interpolator EMPHASIZED_ACCELERATE = new PathInterpolator( 67 0.3f, 0f, 0.8f, 0.15f); 68 69 /** 70 * The decelerating emphasized interpolator. Used for hero / emphasized movement of content that 71 * is appearing e.g. when coming from off screen 72 */ 73 public static final Interpolator EMPHASIZED_DECELERATE = new PathInterpolator( 74 0.05f, 0.7f, 0.1f, 1f); 75 76 /** 77 * The standard decelerating interpolator that should be used on every regular movement of 78 * content that is appearing e.g. when coming from off screen. 79 */ 80 public static final Interpolator STANDARD_DECELERATE = new PathInterpolator(0f, 0f, 0f, 1f); 81 82 /** 83 * Interpolator to be used when animating a move based on a click. Pair with enough duration. 84 */ 85 public static final Interpolator TOUCH_RESPONSE = new PathInterpolator(0.3f, 0f, 0.1f, 1f); 86 87 /** 88 * Interpolator to be used when animating a panel closing. 89 */ 90 public static final Interpolator PANEL_CLOSE_ACCELERATED = 91 new PathInterpolator(0.3f, 0, 0.5f, 1); 92 93 public static final PathInterpolator SLOWDOWN_INTERPOLATOR = 94 new PathInterpolator(0.5f, 1f, 0.5f, 1f); 95 96 public static final PathInterpolator DIM_INTERPOLATOR = 97 new PathInterpolator(.23f, .87f, .52f, -0.11f); 98 99 /** 100 * Use this interpolator for animating progress values coming from the back callback to get 101 * the predictive-back-typical decelerate motion. 102 * 103 * This interpolator is similar to {@link Interpolators#STANDARD_DECELERATE} but has a slight 104 * acceleration phase at the start. 105 */ 106 public static final Interpolator BACK_GESTURE = new BackGestureInterpolator(); 107 108 // Create the default emphasized interpolator createEmphasizedInterpolator()109 private static PathInterpolator createEmphasizedInterpolator() { 110 Path path = new Path(); 111 // Doing the same as fast_out_extra_slow_in 112 path.moveTo(0f, 0f); 113 path.cubicTo(0.05f, 0f, 0.133333f, 0.06f, 0.166666f, 0.4f); 114 path.cubicTo(0.208333f, 0.82f, 0.25f, 1f, 1f, 1f); 115 return new PathInterpolator(path); 116 } 117 } 118