blob: 9148c2f0d5890095b9e8b228badeceb7b54cdd44 [file] [log] [blame]
Jon Miranda54441f52018-01-24 15:38:25 -08001/*
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
17package com.android.launcher3;
18
19
Sunny Goyalc4bb3732019-06-20 11:34:14 -070020import android.animation.Animator;
Jon Miranda54441f52018-01-24 15:38:25 -080021import android.app.ActivityOptions;
Sunny Goyalf8d56fc2018-01-31 15:18:11 -080022import android.content.Context;
Jon Miranda54441f52018-01-24 15:38:25 -080023import android.graphics.Rect;
24import android.graphics.drawable.Drawable;
Jon Miranda54441f52018-01-24 15:38:25 -080025import android.view.View;
26
Sunny Goyal7f920b82018-06-27 15:47:49 -070027import com.android.launcher3.util.ResourceBasedOverride;
28
Jon Miranda54441f52018-01-24 15:38:25 -080029/**
30 * Manages the opening and closing app transitions from Launcher.
31 */
Sunny Goyal7f920b82018-06-27 15:47:49 -070032public class LauncherAppTransitionManager implements ResourceBasedOverride {
Jon Miranda54441f52018-01-24 15:38:25 -080033
Sunny Goyalf8d56fc2018-01-31 15:18:11 -080034 public static LauncherAppTransitionManager newInstance(Context context) {
Sunny Goyal7f920b82018-06-27 15:47:49 -070035 return Overrides.getObject(LauncherAppTransitionManager.class,
Sunny Goyalf8d56fc2018-01-31 15:18:11 -080036 context, R.string.app_transition_manager_class);
37 }
38
Jon Miranda73c27ec2018-05-16 18:06:23 -070039 public ActivityOptions getActivityLaunchOptions(Launcher launcher, View v) {
Sunny Goyal8c48d8b2019-01-25 15:10:18 -080040 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 Miranda54441f52018-01-24 15:38:25 -080051 }
Jon Miranda54441f52018-01-24 15:38:25 -080052 }
Sunny Goyal8c48d8b2019-01-25 15:10:18 -080053 return ActivityOptions.makeClipRevealAnimation(v, left, top, width, height);
Jon Miranda54441f52018-01-24 15:38:25 -080054 }
Jon Miranda6dfa3122019-06-12 13:33:51 -070055
56 public boolean supportsAdaptiveIconAnimation() {
57 return false;
58 }
Sunny Goyalc4bb3732019-06-20 11:34:14 -070059
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 Chung24ab40c2019-10-30 22:35:09 -070070
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 Miranda54441f52018-01-24 15:38:25 -080084}