mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
am Ramasubramanian <sriram@mozilla.com>
# Date 1363299281 25200 # Node ID 8a1125546d125b3fd42a0603146856194bfb74e3 # Parent 6bbd7ce8308e4aeaeca73b2540f557bab3905681 Bug 848719: No Tail delegation needed for Menu button. [r=mfinkle] --HG-- extra : rebase_source : ac72b0d0412f956f1327433b86f48e6404943163
This commit is contained in:
parent
c89f422b19
commit
34c05933dd
@ -379,14 +379,8 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory,
|
||||
int width = mTabs.getWidth();
|
||||
int tail = (width - height) / 2;
|
||||
|
||||
Rect leftBounds = new Rect(0, 0, tail, height);
|
||||
Rect rightBounds = new Rect(width - tail, 0, width, height);
|
||||
|
||||
TailTouchDelegate delegate = new TailTouchDelegate(leftBounds, mAddressBarView);
|
||||
|
||||
if (mHasSoftMenuButton)
|
||||
delegate.add(rightBounds, mMenu);
|
||||
|
||||
Rect bounds = new Rect(0, 0, tail, height);
|
||||
TailTouchDelegate delegate = new TailTouchDelegate(bounds, mAddressBarView);
|
||||
mTabs.setTouchDelegate(delegate);
|
||||
}
|
||||
});
|
||||
|
@ -10,41 +10,21 @@ import android.view.TouchDelegate;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A TouchDelegate to pass the events from one view to another.
|
||||
* Usually it's better to give half of the tail's width to the other
|
||||
* view that is being overlapped.
|
||||
*/
|
||||
public class TailTouchDelegate extends TouchDelegate {
|
||||
// Actual delegate that got the ACTION_DOWN event.
|
||||
private TouchDelegate mDelegate;
|
||||
|
||||
// List of delegates.
|
||||
private List<TouchDelegate> mDelegates;
|
||||
|
||||
/**
|
||||
* Creates an empty TailTouchDelegate for a view.
|
||||
* Creates a TailTouchDelegate for a view.
|
||||
*
|
||||
* @param bounds The rectangular bounds on the view which should delegate events.
|
||||
* @param delegateView The view that should get the delegated events.
|
||||
*/
|
||||
public TailTouchDelegate(Rect bounds, View delegateView) {
|
||||
super(bounds, delegateView);
|
||||
mDelegates = new ArrayList<TouchDelegate>();
|
||||
mDelegates.add(new TouchDelegate(bounds, delegateView));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an Android TouchDelegate for the view.
|
||||
*
|
||||
* @param bounds The rectangular bounds on the view which should delegate events.
|
||||
* @param delegateView The view that should get the delegated events.
|
||||
*/
|
||||
public void add(Rect bounds, View delegateView) {
|
||||
mDelegates.add(new TouchDelegate(bounds, delegateView));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -52,23 +32,16 @@ public class TailTouchDelegate extends TouchDelegate {
|
||||
switch (event.getAction()) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
// Android bug 36445: Touch Delegation not reset on ACTION_DOWN.
|
||||
for (TouchDelegate delegate : mDelegates) {
|
||||
if (delegate.onTouchEvent(event)) {
|
||||
mDelegate = delegate;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!super.onTouchEvent(event)) {
|
||||
MotionEvent cancelEvent = MotionEvent.obtain(event);
|
||||
cancelEvent.setAction(MotionEvent.ACTION_CANCEL);
|
||||
delegate.onTouchEvent(cancelEvent);
|
||||
mDelegate = null;
|
||||
}
|
||||
return false;
|
||||
default:
|
||||
if (mDelegate != null)
|
||||
return mDelegate.onTouchEvent(event);
|
||||
else
|
||||
super.onTouchEvent(cancelEvent);
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
return super.onTouchEvent(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user