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