Jon Miranda | 54441f5 | 2018-01-24 15:38:25 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 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.launcher3; |
| 18 | |
| 19 | |
Sunny Goyal | c4bb373 | 2019-06-20 11:34:14 -0700 | [diff] [blame] | 20 | import android.animation.Animator; |
Jon Miranda | 54441f5 | 2018-01-24 15:38:25 -0800 | [diff] [blame] | 21 | import android.app.ActivityOptions; |
Sunny Goyal | f8d56fc | 2018-01-31 15:18:11 -0800 | [diff] [blame] | 22 | import android.content.Context; |
Jon Miranda | 54441f5 | 2018-01-24 15:38:25 -0800 | [diff] [blame] | 23 | import android.graphics.Rect; |
| 24 | import android.graphics.drawable.Drawable; |
Jon Miranda | 54441f5 | 2018-01-24 15:38:25 -0800 | [diff] [blame] | 25 | import android.view.View; |
| 26 | |
Sunny Goyal | 7f920b8 | 2018-06-27 15:47:49 -0700 | [diff] [blame] | 27 | import com.android.launcher3.util.ResourceBasedOverride; |
| 28 | |
Jon Miranda | 54441f5 | 2018-01-24 15:38:25 -0800 | [diff] [blame] | 29 | /** |
| 30 | * Manages the opening and closing app transitions from Launcher. |
| 31 | */ |
Sunny Goyal | 7f920b8 | 2018-06-27 15:47:49 -0700 | [diff] [blame] | 32 | public class LauncherAppTransitionManager implements ResourceBasedOverride { |
Jon Miranda | 54441f5 | 2018-01-24 15:38:25 -0800 | [diff] [blame] | 33 | |
Sunny Goyal | f8d56fc | 2018-01-31 15:18:11 -0800 | [diff] [blame] | 34 | public static LauncherAppTransitionManager newInstance(Context context) { |
Sunny Goyal | 7f920b8 | 2018-06-27 15:47:49 -0700 | [diff] [blame] | 35 | return Overrides.getObject(LauncherAppTransitionManager.class, |
Sunny Goyal | f8d56fc | 2018-01-31 15:18:11 -0800 | [diff] [blame] | 36 | context, R.string.app_transition_manager_class); |
| 37 | } |
| 38 | |
Jon Miranda | 73c27ec | 2018-05-16 18:06:23 -0700 | [diff] [blame] | 39 | public ActivityOptions getActivityLaunchOptions(Launcher launcher, View v) { |
Sunny Goyal | 8c48d8b | 2019-01-25 15:10:18 -0800 | [diff] [blame] | 40 | int left = 0, top = 0; |
| 41 | int width = v.getMeasuredWidth(), height = v.getMeasuredHeight(); |
| 42 | if (v instanceof BubbleTextView) { |
| 43 | // Launch from center of icon, not entire view |
| 44 | Drawable icon = ((BubbleTextView) v).getIcon(); |
| 45 | if (icon != null) { |
| 46 | Rect bounds = icon.getBounds(); |
| 47 | left = (width - bounds.width()) / 2; |
| 48 | top = v.getPaddingTop(); |
| 49 | width = bounds.width(); |
| 50 | height = bounds.height(); |
Jon Miranda | 54441f5 | 2018-01-24 15:38:25 -0800 | [diff] [blame] | 51 | } |
Jon Miranda | 54441f5 | 2018-01-24 15:38:25 -0800 | [diff] [blame] | 52 | } |
Sunny Goyal | 8c48d8b | 2019-01-25 15:10:18 -0800 | [diff] [blame] | 53 | return ActivityOptions.makeClipRevealAnimation(v, left, top, width, height); |
Jon Miranda | 54441f5 | 2018-01-24 15:38:25 -0800 | [diff] [blame] | 54 | } |
Jon Miranda | 6dfa312 | 2019-06-12 13:33:51 -0700 | [diff] [blame] | 55 | |
| 56 | public boolean supportsAdaptiveIconAnimation() { |
| 57 | return false; |
| 58 | } |
Sunny Goyal | c4bb373 | 2019-06-20 11:34:14 -0700 | [diff] [blame] | 59 | |
| 60 | /** |
| 61 | * Number of animations which run on state properties. |
| 62 | */ |
| 63 | public int getStateElementAnimationsCount() { |
| 64 | return 0; |
| 65 | } |
| 66 | |
| 67 | public Animator createStateElementAnimation(int index, float... values) { |
| 68 | throw new RuntimeException("Unknown gesture animation " + index); |
| 69 | } |
Winson Chung | 24ab40c | 2019-10-30 22:35:09 -0700 | [diff] [blame^] | 70 | |
| 71 | /** |
| 72 | * Registers remote animations for certain system transitions. |
| 73 | */ |
| 74 | public void registerRemoteAnimations() { |
| 75 | // Do nothing |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * Unregisters all remote animations. |
| 80 | */ |
| 81 | public void unregisterRemoteAnimations() { |
| 82 | // Do nothing |
| 83 | } |
Jon Miranda | 54441f5 | 2018-01-24 15:38:25 -0800 | [diff] [blame] | 84 | } |