blob: 43d5e623dc7d90fb19ba6b7ffa6df1070a770c27 [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
20import android.app.ActivityOptions;
Sunny Goyalf8d56fc2018-01-31 15:18:11 -080021import android.content.Context;
Jon Miranda54441f52018-01-24 15:38:25 -080022import android.graphics.Rect;
23import android.graphics.drawable.Drawable;
24import android.os.Bundle;
25import android.view.View;
26
27/**
28 * Manages the opening and closing app transitions from Launcher.
29 */
30public class LauncherAppTransitionManager {
31
Sunny Goyalf8d56fc2018-01-31 15:18:11 -080032 public static LauncherAppTransitionManager newInstance(Context context) {
33 return Utilities.getOverrideObject(LauncherAppTransitionManager.class,
34 context, R.string.app_transition_manager_class);
35 }
36
Jon Miranda54441f52018-01-24 15:38:25 -080037 public Bundle getDefaultActivityLaunchOptions(Launcher launcher, View v) {
38 if (Utilities.ATLEAST_MARSHMALLOW) {
39 int left = 0, top = 0;
40 int width = v.getMeasuredWidth(), height = v.getMeasuredHeight();
41 if (v instanceof BubbleTextView) {
42 // Launch from center of icon, not entire view
43 Drawable icon = ((BubbleTextView) v).getIcon();
44 if (icon != null) {
45 Rect bounds = icon.getBounds();
46 left = (width - bounds.width()) / 2;
47 top = v.getPaddingTop();
48 width = bounds.width();
49 height = bounds.height();
50 }
51 }
52 return ActivityOptions.makeClipRevealAnimation(v, left, top, width, height)
53 .toBundle();
54 } else if (Utilities.ATLEAST_LOLLIPOP_MR1) {
55 // On L devices, we use the device default slide-up transition.
56 // On L MR1 devices, we use a custom version of the slide-up transition which
57 // doesn't have the delay present in the device default.
58 return ActivityOptions.makeCustomAnimation(launcher, R.anim.task_open_enter,
59 R.anim.no_anim).toBundle();
60 }
61 return null;
62 }
63
64 public Bundle getActivityLaunchOptions(Launcher launcher, View v) {
65 return getDefaultActivityLaunchOptions(launcher, v);
66 }
Tonydc76f8e2018-02-02 21:45:39 -060067
Jon Miranda0d5daaf2018-02-07 15:18:00 -080068 /** Cancels the current Launcher transition animation */
69 public void finishLauncherAnimation() {
Tonydc76f8e2018-02-02 21:45:39 -060070 }
Jon Miranda54441f52018-01-24 15:38:25 -080071}