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 20 import android.animation.Animator; 21 import android.app.ActivityOptions; 22 import android.content.Context; 23 import android.graphics.Rect; 24 import android.graphics.drawable.Drawable; 25 import android.view.View; 26 27 import com.android.launcher3.util.ResourceBasedOverride; 28 29 /** 30 * Manages the opening and closing app transitions from Launcher. 31 */ 32 public class LauncherAppTransitionManager implements ResourceBasedOverride { 33 newInstance(Context context)34 public static LauncherAppTransitionManager newInstance(Context context) { 35 return Overrides.getObject(LauncherAppTransitionManager.class, 36 context, R.string.app_transition_manager_class); 37 } 38 getActivityLaunchOptions(Launcher launcher, View v)39 public ActivityOptions getActivityLaunchOptions(Launcher launcher, View v) { 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(); 51 } 52 } 53 return ActivityOptions.makeClipRevealAnimation(v, left, top, width, height); 54 } 55 supportsAdaptiveIconAnimation()56 public boolean supportsAdaptiveIconAnimation() { 57 return false; 58 } 59 60 /** 61 * Number of animations which run on state properties. 62 */ getStateElementAnimationsCount()63 public int getStateElementAnimationsCount() { 64 return 0; 65 } 66 createStateElementAnimation(int index, float... values)67 public Animator createStateElementAnimation(int index, float... values) { 68 throw new RuntimeException("Unknown gesture animation " + index); 69 } 70 } 71