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.Interpolator; 21 import android.view.animation.LinearInterpolator; 22 import android.view.animation.PathInterpolator; 23 24 /** 25 * Common interpolators used in wm shell library. 26 */ 27 public class Interpolators { 28 29 public static final Interpolator LINEAR = new LinearInterpolator(); 30 31 /** 32 * Interpolator for alpha in animation. 33 */ 34 public static final Interpolator ALPHA_IN = new PathInterpolator(0.4f, 0f, 1f, 1f); 35 36 /** 37 * Interpolator for alpha out animation. 38 */ 39 public static final Interpolator ALPHA_OUT = new PathInterpolator(0f, 0f, 0.8f, 1f); 40 41 /** 42 * Interpolator for fast out linear in animation. 43 */ 44 public static final Interpolator FAST_OUT_LINEAR_IN = new PathInterpolator(0.4f, 0f, 1f, 1f); 45 46 /** 47 * Interpolator for fast out slow in animation. 48 */ 49 public static final Interpolator FAST_OUT_SLOW_IN = new PathInterpolator(0.4f, 0f, 0.2f, 1f); 50 51 /** 52 * Interpolator for linear out slow in animation. 53 */ 54 public static final Interpolator LINEAR_OUT_SLOW_IN = new PathInterpolator(0f, 0f, 0.2f, 1f); 55 56 /** 57 * The default emphasized interpolator. Used for hero / emphasized movement of content. 58 */ 59 public static final Interpolator EMPHASIZED = createEmphasizedInterpolator(); 60 61 /** 62 * The accelerated emphasized interpolator. Used for hero / emphasized movement of content that 63 * is disappearing e.g. when moving off screen. 64 */ 65 public static final Interpolator EMPHASIZED_ACCELERATE = new PathInterpolator( 66 0.3f, 0f, 0.8f, 0.15f); 67 68 /** 69 * The decelerating emphasized interpolator. Used for hero / emphasized movement of content that 70 * is appearing e.g. when coming from off screen 71 */ 72 public static final Interpolator EMPHASIZED_DECELERATE = new PathInterpolator( 73 0.05f, 0.7f, 0.1f, 1f); 74 /** 75 * Interpolator to be used when animating a move based on a click. Pair with enough duration. 76 */ 77 public static final Interpolator TOUCH_RESPONSE = new PathInterpolator(0.3f, 0f, 0.1f, 1f); 78 79 /** 80 * Interpolator to be used when animating a panel closing. 81 */ 82 public static final Interpolator PANEL_CLOSE_ACCELERATED = 83 new PathInterpolator(0.3f, 0, 0.5f, 1); 84 85 public static final PathInterpolator SLOWDOWN_INTERPOLATOR = 86 new PathInterpolator(0.5f, 1f, 0.5f, 1f); 87 88 public static final PathInterpolator DIM_INTERPOLATOR = 89 new PathInterpolator(.23f, .87f, .52f, -0.11f); 90 91 // Create the default emphasized interpolator createEmphasizedInterpolator()92 private static PathInterpolator createEmphasizedInterpolator() { 93 Path path = new Path(); 94 // Doing the same as fast_out_extra_slow_in 95 path.moveTo(0f, 0f); 96 path.cubicTo(0.05f, 0f, 0.133333f, 0.06f, 0.166666f, 0.4f); 97 path.cubicTo(0.208333f, 0.82f, 0.25f, 1f, 1f, 1f); 98 return new PathInterpolator(path); 99 } 100 } 101