• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 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.systemui.log
18 
19 import com.android.systemui.log.core.LogLevel.DEBUG
20 import com.google.errorprone.annotations.CompileTimeConstant
21 
22 data class TouchHandlingViewLogger
23 constructor(
24     private val logBuffer: LogBuffer,
25     @CompileTimeConstant private val tag: String = "TouchHandlingViewLogger",
26 ) {
schedulingLongPressnull27     fun schedulingLongPress(delay: Long) {
28         logBuffer.log(
29             tag,
30             DEBUG,
31             { long1 = delay },
32             { "on MotionEvent.Down: scheduling long press activation after $long1 ms" },
33         )
34     }
35 
longPressTriggerednull36     fun longPressTriggered() {
37         logBuffer.log(tag, DEBUG, "long press event detected and dispatched")
38     }
39 
motionEventCancellednull40     fun motionEventCancelled() {
41         logBuffer.log(tag, DEBUG, "Long press may be cancelled due to MotionEventModel.Cancel")
42     }
43 
dispatchingSingleTapnull44     fun dispatchingSingleTap() {
45         logBuffer.log(tag, DEBUG, "Dispatching single tap instead of long press")
46     }
47 
onUpEventnull48     fun onUpEvent(distanceMoved: Float, touchSlop: Int, gestureDuration: Long) {
49         logBuffer.log(
50             tag,
51             DEBUG,
52             {
53                 double1 = distanceMoved.toDouble()
54                 int1 = touchSlop
55                 long1 = gestureDuration
56             },
57             {
58                 "on MotionEvent.Up: distanceMoved: $double1, " +
59                     "allowedTouchSlop: $int1, " +
60                     "eventDuration: $long1"
61             },
62         )
63     }
64 
cancelingLongPressDueToTouchSlopnull65     fun cancelingLongPressDueToTouchSlop(distanceMoved: Float, allowedTouchSlop: Int) {
66         logBuffer.log(
67             tag,
68             DEBUG,
69             {
70                 double1 = distanceMoved.toDouble()
71                 int1 = allowedTouchSlop
72             },
73             {
74                 "on MotionEvent.Motion: May cancel long press due to movement: " +
75                     "distanceMoved: $double1, " +
76                     "allowedTouchSlop: $int1 "
77             },
78         )
79     }
80 }
81