blob: 67387e5d4f283903307d31eca1ad87bee76ef1c2 [file] [log] [blame]
Gary Mai69c182a2016-12-05 13:07:03 -08001package com.android.contacts.interactions;
Nancy Chenf4474e62014-08-13 12:30:10 -07002
3import android.graphics.Point;
4
5/**
6 * Singleton class to keep track of where the user last touched the screen.
7 *
8 * Used to pass on to the InCallUI for animation.
9 */
10public class TouchPointManager {
11 public static final String TOUCH_POINT = "touchPoint";
12
13 private static TouchPointManager sInstance = new TouchPointManager();
14
15 private Point mPoint = new Point();
16
17 /**
18 * Private constructor. Instance should only be acquired through getInstance().
19 */
20 private TouchPointManager() {
21 }
22
23 public static TouchPointManager getInstance() {
24 return sInstance;
25 }
26
27 public Point getPoint() {
28 return mPoint;
29 }
30
31 public void setPoint(int x, int y) {
32 mPoint.set(x, y);
33 }
Nancy Chenaca95b82014-08-18 20:35:37 -070034
35 /**
36 * When a point is initialized, its value is (0,0). Since it is highly unlikely a user will
37 * touch at that exact point, if the point in TouchPointManager is (0,0), it is safe to assume
38 * that the TouchPointManager has not yet collected a touch.
39 *
40 * @return True if there is a valid point saved. Define a valid point as any point that is
41 * not (0,0).
42 */
43 public boolean hasValidPoint() {
44 return mPoint.x != 0 || mPoint.y != 0;
45 }
Nancy Chenf4474e62014-08-13 12:30:10 -070046}