1 package com.android.contacts.interactions; 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 */ TouchPointManager()20 private TouchPointManager() { 21 } 22 getInstance()23 public static TouchPointManager getInstance() { 24 return sInstance; 25 } 26 getPoint()27 public Point getPoint() { 28 return mPoint; 29 } 30 setPoint(int x, int y)31 public void setPoint(int x, int y) { 32 mPoint.set(x, y); 33 } 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 */ hasValidPoint()43 public boolean hasValidPoint() { 44 return mPoint.x != 0 || mPoint.y != 0; 45 } 46 } 47