• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.NonNull;
25 import androidx.annotation.Nullable;
26 
27 import com.android.launcher3.R;
28 import com.android.launcher3.logging.StatsLogManager;
29 import com.android.quickstep.interaction.TutorialController.TutorialType;
30 
31 import java.util.ArrayList;
32 
33 /** Shows the Overview gesture interactive tutorial. */
34 public class OverviewGestureTutorialFragment extends TutorialFragment {
35 
OverviewGestureTutorialFragment()36     public OverviewGestureTutorialFragment() {
37         this(false);
38     }
39 
OverviewGestureTutorialFragment(boolean fromTutorialMenu)40     public OverviewGestureTutorialFragment(boolean fromTutorialMenu) {
41         super(fromTutorialMenu);
42     }
43 
44     @NonNull
45     @Override
getDefaultTutorialType()46     TutorialType getDefaultTutorialType() {
47         return TutorialType.OVERVIEW_NAVIGATION;
48     }
49 
50     @Nullable
51     @Override
getEdgeAnimationResId()52     Integer getEdgeAnimationResId() {
53         return R.drawable.gesture_tutorial_loop_overview;
54     }
55 
56     @Nullable
57     @Override
createGestureAnimation()58     protected Animator createGestureAnimation() {
59         if (!(mTutorialController instanceof OverviewGestureTutorialController)) {
60             return null;
61         }
62         float fingerDotStartTranslationY = (float) mRootView.getFullscreenHeight() / 2;
63         OverviewGestureTutorialController controller =
64                 (OverviewGestureTutorialController) mTutorialController;
65 
66         AnimatorSet fingerDotAppearanceAnimator = controller.createFingerDotAppearanceAnimatorSet();
67         fingerDotAppearanceAnimator.addListener(new AnimatorListenerAdapter() {
68             @Override
69             public void onAnimationStart(Animator animation) {
70                 super.onAnimationStart(animation);
71 
72                 mFingerDotView.setTranslationY(fingerDotStartTranslationY);
73             }
74         });
75 
76         AnimatorSet fingerDotDisappearanceAnimator =
77                 controller.createFingerDotDisappearanceAnimatorSet();
78         fingerDotDisappearanceAnimator.addListener(new AnimatorListenerAdapter() {
79             @Override
80             public void onAnimationStart(Animator animation) {
81                 super.onAnimationStart(animation);
82                 controller.animateTaskViewToOverview(false);
83             }
84         });
85 
86         Animator animationPause = controller.createAnimationPause();
87         animationPause.addListener(new AnimatorListenerAdapter() {
88             @Override
89             public void onAnimationEnd(Animator animation) {
90                 super.onAnimationEnd(animation);
91                 controller.resetFakeTaskViewFromOverview();
92             }
93         });
94         ArrayList<Animator> animators = new ArrayList<>();
95 
96         animators.add(fingerDotAppearanceAnimator);
97         animators.add(controller.createFingerDotOverviewSwipeAnimator(fingerDotStartTranslationY));
98         animators.add(controller.createAnimationPause());
99         animators.add(fingerDotDisappearanceAnimator);
100         animators.add(animationPause);
101 
102         AnimatorSet finalAnimation = new AnimatorSet();
103         finalAnimation.addListener(new AnimatorListenerAdapter() {
104             @Override
105             public void onAnimationCancel(Animator animation) {
106                 super.onAnimationCancel(animation);
107                 controller.resetFakeTaskView(false);
108             }
109         });
110         finalAnimation.playSequentially(animators);
111 
112         return finalAnimation;
113     }
114 
115     @Override
createController(TutorialType type)116     TutorialController createController(TutorialType type) {
117         return new OverviewGestureTutorialController(this, type);
118     }
119 
120     @Override
getControllerClass()121     Class<? extends TutorialController> getControllerClass() {
122         return OverviewGestureTutorialController.class;
123     }
124 
125     @Override
onTouch(View view, MotionEvent motionEvent)126     public boolean onTouch(View view, MotionEvent motionEvent) {
127         releaseFeedbackAnimation();
128         return super.onTouch(view, motionEvent);
129     }
130 
131     @Override
logTutorialStepShown(@onNull StatsLogManager statsLogManager)132     void logTutorialStepShown(@NonNull StatsLogManager statsLogManager) {
133         statsLogManager.logger().log(
134                 StatsLogManager.LauncherEvent.LAUNCHER_GESTURE_TUTORIAL_OVERVIEW_STEP_SHOWN);
135     }
136 
137     @Override
logTutorialStepCompleted(@onNull StatsLogManager statsLogManager)138     void logTutorialStepCompleted(@NonNull StatsLogManager statsLogManager) {
139         statsLogManager.logger().log(
140                 StatsLogManager.LauncherEvent.LAUNCHER_GESTURE_TUTORIAL_OVERVIEW_STEP_COMPLETED);
141     }
142 }
143