17f98feacfed7511118aa342f06d09c0b97b9779bNancy Chen/*
27f98feacfed7511118aa342f06d09c0b97b9779bNancy Chen * Copyright (C) 2014 The Android Open Source Project
37f98feacfed7511118aa342f06d09c0b97b9779bNancy Chen *
47f98feacfed7511118aa342f06d09c0b97b9779bNancy Chen * Licensed under the Apache License, Version 2.0 (the "License");
57f98feacfed7511118aa342f06d09c0b97b9779bNancy Chen * you may not use this file except in compliance with the License.
67f98feacfed7511118aa342f06d09c0b97b9779bNancy Chen * You may obtain a copy of the License at
77f98feacfed7511118aa342f06d09c0b97b9779bNancy Chen *
87f98feacfed7511118aa342f06d09c0b97b9779bNancy Chen *      http://www.apache.org/licenses/LICENSE-2.0
97f98feacfed7511118aa342f06d09c0b97b9779bNancy Chen *
107f98feacfed7511118aa342f06d09c0b97b9779bNancy Chen * Unless required by applicable law or agreed to in writing, software
117f98feacfed7511118aa342f06d09c0b97b9779bNancy Chen * distributed under the License is distributed on an "AS IS" BASIS,
127f98feacfed7511118aa342f06d09c0b97b9779bNancy Chen * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
137f98feacfed7511118aa342f06d09c0b97b9779bNancy Chen * See the License for the specific language governing permissions and
147f98feacfed7511118aa342f06d09c0b97b9779bNancy Chen * limitations under the License.
157f98feacfed7511118aa342f06d09c0b97b9779bNancy Chen */
167f98feacfed7511118aa342f06d09c0b97b9779bNancy Chen
177f98feacfed7511118aa342f06d09c0b97b9779bNancy Chenpackage com.android.contacts.common.widget;
187f98feacfed7511118aa342f06d09c0b97b9779bNancy Chen
197f98feacfed7511118aa342f06d09c0b97b9779bNancy Chenimport android.content.Context;
207f98feacfed7511118aa342f06d09c0b97b9779bNancy Chenimport android.util.AttributeSet;
217f98feacfed7511118aa342f06d09c0b97b9779bNancy Chenimport android.view.MotionEvent;
227f98feacfed7511118aa342f06d09c0b97b9779bNancy Chenimport android.widget.LinearLayout;
237f98feacfed7511118aa342f06d09c0b97b9779bNancy Chen
247f98feacfed7511118aa342f06d09c0b97b9779bNancy Chenimport com.android.contacts.common.interactions.TouchPointManager;
257f98feacfed7511118aa342f06d09c0b97b9779bNancy Chen
267f98feacfed7511118aa342f06d09c0b97b9779bNancy Chen/**
277f98feacfed7511118aa342f06d09c0b97b9779bNancy Chen * Linear layout for an activity that listens to all touch events on the screen and saves the touch
287f98feacfed7511118aa342f06d09c0b97b9779bNancy Chen * point.
297f98feacfed7511118aa342f06d09c0b97b9779bNancy Chen * Typically touch events are handled by child views--this class intercepts those touch events
307f98feacfed7511118aa342f06d09c0b97b9779bNancy Chen * before passing them on to the child.
317f98feacfed7511118aa342f06d09c0b97b9779bNancy Chen */
327f98feacfed7511118aa342f06d09c0b97b9779bNancy Chenpublic class ActivityTouchLinearLayout extends LinearLayout {
337f98feacfed7511118aa342f06d09c0b97b9779bNancy Chen    public ActivityTouchLinearLayout(Context context, AttributeSet attrs) {
347f98feacfed7511118aa342f06d09c0b97b9779bNancy Chen        super(context, attrs);
357f98feacfed7511118aa342f06d09c0b97b9779bNancy Chen    }
367f98feacfed7511118aa342f06d09c0b97b9779bNancy Chen
377f98feacfed7511118aa342f06d09c0b97b9779bNancy Chen    @Override
387f98feacfed7511118aa342f06d09c0b97b9779bNancy Chen    public boolean onInterceptTouchEvent (MotionEvent ev) {
397f98feacfed7511118aa342f06d09c0b97b9779bNancy Chen        if (ev.getAction() == MotionEvent.ACTION_DOWN) {
407f98feacfed7511118aa342f06d09c0b97b9779bNancy Chen            TouchPointManager.getInstance().setPoint((int) ev.getRawX(), (int) ev.getRawY());
417f98feacfed7511118aa342f06d09c0b97b9779bNancy Chen        }
427f98feacfed7511118aa342f06d09c0b97b9779bNancy Chen        return false;
437f98feacfed7511118aa342f06d09c0b97b9779bNancy Chen    }
447f98feacfed7511118aa342f06d09c0b97b9779bNancy Chen}
45