• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2019 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.inputconsumers;
17 
18 import android.view.MotionEvent;
19 
20 import com.android.launcher3.taskbar.TaskbarActivityContext;
21 import com.android.quickstep.InputConsumer;
22 import com.android.quickstep.TaskAnimationManager;
23 
24 import java.util.function.Supplier;
25 
26 /**
27  * A NO_OP input consumer which also resets any pending gesture
28  */
29 public class ResetGestureInputConsumer implements InputConsumer {
30 
31     private final TaskAnimationManager mTaskAnimationManager;
32     private final Supplier<TaskbarActivityContext> mActivityContextSupplier;
33 
ResetGestureInputConsumer( TaskAnimationManager taskAnimationManager, Supplier<TaskbarActivityContext> activityContextSupplier)34     public ResetGestureInputConsumer(
35             TaskAnimationManager taskAnimationManager,
36             Supplier<TaskbarActivityContext> activityContextSupplier) {
37         mTaskAnimationManager = taskAnimationManager;
38         mActivityContextSupplier = activityContextSupplier;
39     }
40 
41     @Override
getType()42     public int getType() {
43         return TYPE_RESET_GESTURE;
44     }
45 
46     @Override
onMotionEvent(MotionEvent ev)47     public void onMotionEvent(MotionEvent ev) {
48         if (ev.getAction() == MotionEvent.ACTION_DOWN
49                 && mTaskAnimationManager.isRecentsAnimationRunning()) {
50             TaskbarActivityContext tac = mActivityContextSupplier.get();
51             mTaskAnimationManager.finishRunningRecentsAnimation(
52                     /* toHome= */ tac != null && !tac.isInApp());
53         }
54     }
55 }
56