Gary Mai | 69c182a | 2016-12-05 13:07:03 -0800 | [diff] [blame] | 1 | package com.android.contacts.interactions; |
Nancy Chen | f4474e6 | 2014-08-13 12:30:10 -0700 | [diff] [blame] | 2 | |
| 3 | import 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 | */ |
| 10 | public 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 Chen | aca95b8 | 2014-08-18 20:35:37 -0700 | [diff] [blame] | 34 | |
| 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 Chen | f4474e6 | 2014-08-13 12:30:10 -0700 | [diff] [blame] | 46 | } |