blob: ac07e8887f3c3fea694f756a4603b4e8c3cbd1a0 [file] [log] [blame]
Michael Jurka2ecf9952012-06-18 12:52:28 -07001/*
2 * Copyright (C) 2012 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
Daniel Sandler325dc232013-06-05 22:57:57 -040017package com.android.launcher3;
Michael Jurka2ecf9952012-06-18 12:52:28 -070018
Jon Miranda2d89ea82017-05-04 11:47:53 -070019import android.graphics.drawable.Drawable;
Sunny Goyal5d2fc322015-07-06 22:52:49 -070020import android.util.Property;
Michael Jurkaf1ad6082013-03-13 12:55:46 +010021import android.view.View;
Michael Jurka2ecf9952012-06-18 12:52:28 -070022
23public class LauncherAnimUtils {
Sunny Goyalaeb16432017-10-16 11:46:41 -070024 /**
25 * Durations for various state animations. These are not defined in resources to allow
26 * easier access from static classes and enums
27 */
28 public static final int ALL_APPS_TRANSITION_MS = 320;
29 public static final int OVERVIEW_TRANSITION_MS = 250;
30 public static final int SPRING_LOADED_TRANSITION_MS = 150;
Sunny Goyal4c7f2152017-10-17 17:17:16 -070031 public static final int SPRING_LOADED_EXIT_DELAY = 500;
Sunny Goyalaeb16432017-10-16 11:46:41 -070032
Tony Wickham0f640b62018-05-09 16:00:14 -070033 // The progress of an animation to all apps must be at least this far along to snap to all apps.
34 public static final float MIN_PROGRESS_TO_ALL_APPS = 0.5f;
35
Jon Miranda2d89ea82017-05-04 11:47:53 -070036 public static final Property<Drawable, Integer> DRAWABLE_ALPHA =
37 new Property<Drawable, Integer>(Integer.TYPE, "drawableAlpha") {
38 @Override
39 public Integer get(Drawable drawable) {
40 return drawable.getAlpha();
41 }
42
43 @Override
44 public void set(Drawable drawable, Integer alpha) {
45 drawable.setAlpha(alpha);
46 }
47 };
Sunny Goyalaeb16432017-10-16 11:46:41 -070048
49 public static final Property<View, Float> SCALE_PROPERTY =
50 new Property<View, Float>(Float.class, "scale") {
51 @Override
52 public Float get(View view) {
53 return view.getScaleX();
54 }
55
56 @Override
57 public void set(View view, Float scale) {
58 view.setScaleX(scale);
59 view.setScaleY(scale);
60 }
61 };
Sunny Goyalea529082017-10-31 13:33:03 -070062
Tony Wickham0f640b62018-05-09 16:00:14 -070063 /** Increase the duration if we prevented the fling, as we are going against a high velocity. */
64 public static int blockedFlingDurationFactor(float velocity) {
65 return (int) Utilities.boundToRange(Math.abs(velocity) / 2, 2f, 6f);
66 }
Michael Jurka2ecf9952012-06-18 12:52:28 -070067}