2 * Copyright (C) 2013 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package com.android.camera.ui;
19 import android.content.Context;
20 import android.util.AttributeSet;
21 import android.view.MotionEvent;
22 import android.view.View;
23 import android.widget.FrameLayout;
25 import com.android.camera.debug.Log;
27 public class MainActivityLayout extends FrameLayout {
29 private MotionEvent mDown;
30 private final Log.Tag TAG = new Log.Tag("MainActivityLayout");
31 private boolean mRequestToInterceptTouchEvents = false;
32 private View mTouchReceiver = null;
34 public MainActivityLayout(Context context, AttributeSet attrs) {
35 super(context, attrs);
39 public boolean onInterceptTouchEvent(MotionEvent ev) {
40 if (ev.getActionMasked() == MotionEvent.ACTION_DOWN) {
41 mDown = MotionEvent.obtain(ev);
42 mTouchReceiver = null;
43 mRequestToInterceptTouchEvents = false;
45 } else if (mRequestToInterceptTouchEvents) {
46 mRequestToInterceptTouchEvents = false;
49 } else if (ev.getActionMasked() == MotionEvent.ACTION_POINTER_DOWN) {
50 // Do not intercept touch once child is in zoom mode
57 public boolean onTouchEvent(MotionEvent ev) {
58 if (mTouchReceiver != null) {
59 mTouchReceiver.setVisibility(VISIBLE);
60 return mTouchReceiver.dispatchTouchEvent(ev);
65 public void redirectTouchEventsTo(View touchReceiver) {
66 if (touchReceiver == null) {
67 Log.e(TAG, "Cannot redirect touch to a null receiver.");
70 mTouchReceiver = touchReceiver;
71 mRequestToInterceptTouchEvents = true;