blob: 9d68dc9e8f70ed4cf0d2394e4b238b012f0bb7eb [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;
21import android.graphics.Rect;
22import android.graphics.drawable.Drawable;
23import android.os.Bundle;
24import android.view.View;
25
26/**
27 * Manages the opening and closing app transitions from Launcher.
28 */
29public class LauncherAppTransitionManager {
30
31 public Bundle getDefaultActivityLaunchOptions(Launcher launcher, View v) {
32 if (Utilities.ATLEAST_MARSHMALLOW) {
33 int left = 0, top = 0;
34 int width = v.getMeasuredWidth(), height = v.getMeasuredHeight();
35 if (v instanceof BubbleTextView) {
36 // Launch from center of icon, not entire view
37 Drawable icon = ((BubbleTextView) v).getIcon();
38 if (icon != null) {
39 Rect bounds = icon.getBounds();
40 left = (width - bounds.width()) / 2;
41 top = v.getPaddingTop();
42 width = bounds.width();
43 height = bounds.height();
44 }
45 }
46 return ActivityOptions.makeClipRevealAnimation(v, left, top, width, height)
47 .toBundle();
48 } else if (Utilities.ATLEAST_LOLLIPOP_MR1) {
49 // On L devices, we use the device default slide-up transition.
50 // On L MR1 devices, we use a custom version of the slide-up transition which
51 // doesn't have the delay present in the device default.
52 return ActivityOptions.makeCustomAnimation(launcher, R.anim.task_open_enter,
53 R.anim.no_anim).toBundle();
54 }
55 return null;
56 }
57
58 public Bundle getActivityLaunchOptions(Launcher launcher, View v) {
59 return getDefaultActivityLaunchOptions(launcher, v);
60 }
61
62 public void registerRemoteAnimations() {
63 }
64}