The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 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 | |
Joe Onorato | a590252 | 2009-07-30 13:37:37 -0700 | [diff] [blame] | 17 | package com.android.launcher2; |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 18 | |
| 19 | import android.content.Context; |
| 20 | import android.graphics.Bitmap; |
| 21 | import android.graphics.Canvas; |
| 22 | import android.graphics.Matrix; |
| 23 | import android.graphics.Rect; |
| 24 | import android.graphics.RectF; |
| 25 | import android.graphics.Paint; |
| 26 | import android.graphics.PorterDuffColorFilter; |
| 27 | import android.graphics.PorterDuff; |
| 28 | import android.os.Vibrator; |
| 29 | import android.os.SystemClock; |
| 30 | import android.util.AttributeSet; |
Joe Onorato | 5979117 | 2009-07-31 16:21:40 -0700 | [diff] [blame] | 31 | import android.util.Log; |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 32 | import android.view.MotionEvent; |
| 33 | import android.view.View; |
| 34 | import android.view.ViewGroup; |
| 35 | import android.view.KeyEvent; |
| 36 | import android.view.inputmethod.InputMethodManager; |
| 37 | import android.widget.FrameLayout; |
| 38 | |
| 39 | /** |
| 40 | * A ViewGroup that coordinated dragging across its dscendants |
| 41 | */ |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 42 | public class DragLayer extends FrameLayout { |
Joe Onorato | 85a02a8 | 2009-09-08 12:34:22 -0700 | [diff] [blame] | 43 | private static final String TAG = "Launcher.DragLayer"; |
| 44 | |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 45 | DragController mDragController; |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 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); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 55 | } |
| 56 | |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 57 | public void setDragController(DragController controller) { |
| 58 | mDragController = controller; |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 59 | } |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 60 | |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 61 | @Override |
| 62 | public boolean dispatchKeyEvent(KeyEvent event) { |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 63 | return mDragController.dispatchKeyEvent(event) || super.dispatchKeyEvent(event); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 64 | } |
| 65 | |
| 66 | @Override |
| 67 | public boolean onInterceptTouchEvent(MotionEvent ev) { |
Joe Onorato | 4db5231 | 2009-10-06 11:17:43 -0700 | [diff] [blame^] | 68 | return mDragController.onInterceptTouchEvent(ev); |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | @Override |
| 72 | public boolean onTouchEvent(MotionEvent ev) { |
Joe Onorato | 4db5231 | 2009-10-06 11:17:43 -0700 | [diff] [blame^] | 73 | return mDragController.onTouchEvent(ev); |
Romain Guy | 91a9c96 | 2009-06-12 13:52:17 -0700 | [diff] [blame] | 74 | } |
The Android Open Source Project | 31dd503 | 2009-03-03 19:32:27 -0800 | [diff] [blame] | 75 | } |