1 /* 2 * Copyright (C) 2020 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 package com.android.quickstep.interaction; 17 18 import android.animation.Animator; 19 import android.animation.AnimatorListenerAdapter; 20 import android.animation.AnimatorSet; 21 import android.view.MotionEvent; 22 import android.view.View; 23 24 import androidx.annotation.Nullable; 25 26 import com.android.launcher3.R; 27 import com.android.quickstep.interaction.TutorialController.TutorialType; 28 29 import java.util.ArrayList; 30 31 /** Shows the Overview gesture interactive tutorial. */ 32 public class OverviewGestureTutorialFragment extends TutorialFragment { 33 34 @Nullable 35 @Override getEdgeAnimationResId()36 Integer getEdgeAnimationResId() { 37 return R.drawable.gesture_tutorial_loop_overview; 38 } 39 40 @Nullable 41 @Override createGestureAnimation()42 protected Animator createGestureAnimation() { 43 if (!(mTutorialController instanceof OverviewGestureTutorialController)) { 44 return null; 45 } 46 float fingerDotStartTranslationY = (float) mRootView.getFullscreenHeight() / 2; 47 OverviewGestureTutorialController controller = 48 (OverviewGestureTutorialController) mTutorialController; 49 50 AnimatorSet fingerDotAppearanceAnimator = controller.createFingerDotAppearanceAnimatorSet(); 51 fingerDotAppearanceAnimator.addListener(new AnimatorListenerAdapter() { 52 @Override 53 public void onAnimationStart(Animator animation) { 54 super.onAnimationStart(animation); 55 56 mFingerDotView.setTranslationY(fingerDotStartTranslationY); 57 } 58 }); 59 60 AnimatorSet fingerDotDisappearanceAnimator = 61 controller.createFingerDotDisappearanceAnimatorSet(); 62 fingerDotDisappearanceAnimator.addListener(new AnimatorListenerAdapter() { 63 @Override 64 public void onAnimationStart(Animator animation) { 65 super.onAnimationStart(animation); 66 controller.animateTaskViewToOverview(); 67 } 68 }); 69 70 Animator animationPause = controller.createAnimationPause(); 71 animationPause.addListener(new AnimatorListenerAdapter() { 72 @Override 73 public void onAnimationEnd(Animator animation) { 74 super.onAnimationEnd(animation); 75 controller.resetFakeTaskView(false); 76 } 77 }); 78 ArrayList<Animator> animators = new ArrayList<>(); 79 80 animators.add(fingerDotAppearanceAnimator); 81 animators.add(controller.createFingerDotOverviewSwipeAnimator(fingerDotStartTranslationY)); 82 animators.add(controller.createAnimationPause()); 83 animators.add(fingerDotDisappearanceAnimator); 84 animators.add(animationPause); 85 86 AnimatorSet finalAnimation = new AnimatorSet(); 87 finalAnimation.addListener(new AnimatorListenerAdapter() { 88 @Override 89 public void onAnimationCancel(Animator animation) { 90 super.onAnimationCancel(animation); 91 controller.resetFakeTaskView(false); 92 } 93 }); 94 finalAnimation.playSequentially(animators); 95 96 return finalAnimation; 97 } 98 99 @Override createController(TutorialType type)100 TutorialController createController(TutorialType type) { 101 return new OverviewGestureTutorialController(this, type); 102 } 103 104 @Override getControllerClass()105 Class<? extends TutorialController> getControllerClass() { 106 return OverviewGestureTutorialController.class; 107 } 108 109 @Override onTouch(View view, MotionEvent motionEvent)110 public boolean onTouch(View view, MotionEvent motionEvent) { 111 releaseFeedbackAnimation(); 112 return super.onTouch(view, motionEvent); 113 } 114 } 115