1 /* 2 * Copyright (C) 2016 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.dialer.util; 18 19 import android.graphics.Point; 20 21 /** 22 * Singleton class to keep track of where the user last touched the screen. 23 * 24 * <p>Used to pass on to the InCallUI for animation. 25 */ 26 public class TouchPointManager { 27 28 public static final String TOUCH_POINT = "touchPoint"; 29 30 private static TouchPointManager sInstance = new TouchPointManager(); 31 32 private Point mPoint = new Point(); 33 34 /** Private constructor. Instance should only be acquired through getRunningInstance(). */ 35 private TouchPointManager() {} 36 37 public static TouchPointManager getInstance() { 38 return sInstance; 39 } 40 41 public Point getPoint() { 42 return mPoint; 43 } 44 45 public void setPoint(int x, int y) { 46 mPoint.set(x, y); 47 } 48 49 /** 50 * When a point is initialized, its value is (0,0). Since it is highly unlikely a user will touch 51 * at that exact point, if the point in TouchPointManager is (0,0), it is safe to assume that the 52 * TouchPointManager has not yet collected a touch. 53 * 54 * @return True if there is a valid point saved. Define a valid point as any point that is not 55 * (0,0). 56 */ 57 public boolean hasValidPoint() { 58 return mPoint.x != 0 || mPoint.y != 0; 59 } 60 } 61