1 /*
2  * Copyright (C) 2015 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.systemui.statusbar.notification.stack;
18 
19 import android.graphics.Path;
20 import android.view.animation.PathInterpolator;
21 
22 /**
23  * An interpolator specifically designed for the appear animation of heads up notifications.
24  */
25 public class HeadsUpAppearInterpolator extends PathInterpolator {
26 
27     private static float X1 = 250f;
28     private static float X2 = 200f;
29     private static float XTOT = (X1 + X2);;
30 
HeadsUpAppearInterpolator()31     public HeadsUpAppearInterpolator() {
32         super(getAppearPath());
33     }
34 
getAppearPath()35     private static Path getAppearPath() {
36         Path path = new Path();
37         path.moveTo(0, 0);
38         float y1 = 90f;
39         float y2 = 80f;
40         path.cubicTo(X1 * 0.8f / XTOT, y1 / y2,
41                 X1 * 0.8f / XTOT, y1 / y2,
42                 X1 / XTOT, y1 / y2);
43         path.cubicTo((X1 + X2 * 0.4f) / XTOT, y1 / y2,
44                 (X1 + X2 * 0.2f) / XTOT, 1.0f,
45                 1.0f , 1.0f);
46         return path;
47     }
48 
getFractionUntilOvershoot()49     public static float getFractionUntilOvershoot() {
50         return X1 / XTOT;
51     }
52 }
53