DragLayer.java revision 4db52312c10e822162a21c60404f06f6e507f0d6
1/*
2 * Copyright (C) 2008 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
17package com.android.launcher2;
18
19import android.content.Context;
20import android.graphics.Bitmap;
21import android.graphics.Canvas;
22import android.graphics.Matrix;
23import android.graphics.Rect;
24import android.graphics.RectF;
25import android.graphics.Paint;
26import android.graphics.PorterDuffColorFilter;
27import android.graphics.PorterDuff;
28import android.os.Vibrator;
29import android.os.SystemClock;
30import android.util.AttributeSet;
31import android.util.Log;
32import android.view.MotionEvent;
33import android.view.View;
34import android.view.ViewGroup;
35import android.view.KeyEvent;
36import android.view.inputmethod.InputMethodManager;
37import android.widget.FrameLayout;
38
39/**
40 * A ViewGroup that coordinated dragging across its dscendants
41 */
42public class DragLayer extends FrameLayout {
43    private static final String TAG = "Launcher.DragLayer";
44
45    DragController mDragController;
46
47    /**
48     * Used to create a new DragLayer from XML.
49     *
50     * @param context The application's context.
51     * @param attrs The attribtues set containing the Workspace's customization values.
52     */
53    public DragLayer(Context context, AttributeSet attrs) {
54        super(context, attrs);
55    }
56
57    public void setDragController(DragController controller) {
58        mDragController = controller;
59    }
60
61    @Override
62    public boolean dispatchKeyEvent(KeyEvent event) {
63        return mDragController.dispatchKeyEvent(event) || super.dispatchKeyEvent(event);
64    }
65
66    @Override
67    public boolean onInterceptTouchEvent(MotionEvent ev) {
68        return mDragController.onInterceptTouchEvent(ev);
69    }
70
71    @Override
72    public boolean onTouchEvent(MotionEvent ev) {
73        return mDragController.onTouchEvent(ev);
74    }
75}
76