2009-03-03 19:32:27 -08:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2008 The Android Open Source Project
|
|
|
|
|
*
|
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
|
*
|
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
*
|
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
|
* limitations under the License.
|
|
|
|
|
*/
|
|
|
|
|
|
2009-07-30 13:37:37 -07:00
|
|
|
package com.android.launcher2;
|
2009-03-03 19:32:27 -08:00
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
|
import android.util.AttributeSet;
|
|
|
|
|
import android.view.KeyEvent;
|
2010-06-30 17:07:39 -07:00
|
|
|
import android.view.MotionEvent;
|
2010-01-11 18:02:04 -08:00
|
|
|
import android.view.View;
|
2009-03-03 19:32:27 -08:00
|
|
|
import android.widget.FrameLayout;
|
|
|
|
|
|
|
|
|
|
/**
|
2010-06-30 17:07:39 -07:00
|
|
|
* A ViewGroup that coordinates dragging across its descendants
|
2009-03-03 19:32:27 -08:00
|
|
|
*/
|
2009-08-04 16:04:30 -04:00
|
|
|
public class DragLayer extends FrameLayout {
|
|
|
|
|
DragController mDragController;
|
2009-03-03 19:32:27 -08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Used to create a new DragLayer from XML.
|
|
|
|
|
*
|
|
|
|
|
* @param context The application's context.
|
2010-06-30 17:07:39 -07:00
|
|
|
* @param attrs The attributes set containing the Workspace's customization values.
|
2009-03-03 19:32:27 -08:00
|
|
|
*/
|
|
|
|
|
public DragLayer(Context context, AttributeSet attrs) {
|
|
|
|
|
super(context, attrs);
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-04 16:04:30 -04:00
|
|
|
public void setDragController(DragController controller) {
|
|
|
|
|
mDragController = controller;
|
2009-03-03 19:32:27 -08:00
|
|
|
}
|
2009-08-04 16:04:30 -04:00
|
|
|
|
2009-03-03 19:32:27 -08:00
|
|
|
@Override
|
|
|
|
|
public boolean dispatchKeyEvent(KeyEvent event) {
|
2009-08-04 16:04:30 -04:00
|
|
|
return mDragController.dispatchKeyEvent(event) || super.dispatchKeyEvent(event);
|
2009-03-03 19:32:27 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
2009-10-06 11:17:43 -07:00
|
|
|
return mDragController.onInterceptTouchEvent(ev);
|
2009-03-03 19:32:27 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean onTouchEvent(MotionEvent ev) {
|
2009-10-06 11:17:43 -07:00
|
|
|
return mDragController.onTouchEvent(ev);
|
2009-06-12 13:52:17 -07:00
|
|
|
}
|
2010-01-11 18:02:04 -08:00
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean dispatchUnhandledMove(View focused, int direction) {
|
|
|
|
|
return mDragController.dispatchUnhandledMove(focused, direction);
|
|
|
|
|
}
|
2009-03-03 19:32:27 -08:00
|
|
|
}
|