Michael Jurka | 2ecf995 | 2012-06-18 12:52:28 -0700 | [diff] [blame] | 1 | /* |
| 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 Sandler | 325dc23 | 2013-06-05 22:57:57 -0400 | [diff] [blame] | 17 | package com.android.launcher3; |
Michael Jurka | 2ecf995 | 2012-06-18 12:52:28 -0700 | [diff] [blame] | 18 | |
Jon Miranda | 2d89ea8 | 2017-05-04 11:47:53 -0700 | [diff] [blame] | 19 | import android.graphics.drawable.Drawable; |
Sunny Goyal | 5d2fc32 | 2015-07-06 22:52:49 -0700 | [diff] [blame] | 20 | import android.util.Property; |
Michael Jurka | f1ad608 | 2013-03-13 12:55:46 +0100 | [diff] [blame] | 21 | import android.view.View; |
Michael Jurka | 2ecf995 | 2012-06-18 12:52:28 -0700 | [diff] [blame] | 22 | |
| 23 | public class LauncherAnimUtils { |
Sunny Goyal | aeb1643 | 2017-10-16 11:46:41 -0700 | [diff] [blame] | 24 | /** |
| 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 Goyal | 4c7f215 | 2017-10-17 17:17:16 -0700 | [diff] [blame] | 31 | public static final int SPRING_LOADED_EXIT_DELAY = 500; |
Sunny Goyal | aeb1643 | 2017-10-16 11:46:41 -0700 | [diff] [blame] | 32 | |
Tony Wickham | 0f640b6 | 2018-05-09 16:00:14 -0700 | [diff] [blame] | 33 | // 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 Miranda | 2d89ea8 | 2017-05-04 11:47:53 -0700 | [diff] [blame] | 36 | 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 Goyal | aeb1643 | 2017-10-16 11:46:41 -0700 | [diff] [blame] | 48 | |
| 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 Goyal | ea52908 | 2017-10-31 13:33:03 -0700 | [diff] [blame] | 62 | |
Tony Wickham | 0f640b6 | 2018-05-09 16:00:14 -0700 | [diff] [blame] | 63 | /** 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 Jurka | 2ecf995 | 2012-06-18 12:52:28 -0700 | [diff] [blame] | 67 | } |