Methods Summary |
---|
public boolean | onInterceptTouchEvent(android.view.MotionEvent event)
if (mSourceView == null || mDelegateView == null || mBar.shouldDisableNavbarGestures()) {
return false;
}
mSourceView.getLocationOnScreen(mTempPoint);
final float sourceX = mTempPoint[0];
final float sourceY = mTempPoint[1];
final int action = event.getAction();
switch (action) {
case MotionEvent.ACTION_DOWN:
mPanelShowing = mDelegateView.getVisibility() == View.VISIBLE;
mDownPoint[0] = event.getX();
mDownPoint[1] = event.getY();
mStarted = mInitialTouch.contains(mDownPoint[0] + sourceX, mDownPoint[1] + sourceY);
break;
}
if (!mStarted) {
return false;
}
if (!mDisabled && !mPanelShowing && action == MotionEvent.ACTION_MOVE) {
final int historySize = event.getHistorySize();
for (int k = 0; k < historySize + 1; k++) {
float x = k < historySize ? event.getHistoricalX(k) : event.getX();
float y = k < historySize ? event.getHistoricalY(k) : event.getY();
final float distance = mSwapXY ? (mDownPoint[0] - x) : (mDownPoint[1] - y);
if (distance > mTriggerThreshhold) {
mBar.showSearchPanel();
mPanelShowing = true;
break;
}
}
}
if (action == MotionEvent.ACTION_DOWN) {
mBar.setInteracting(StatusBarManager.WINDOW_NAVIGATION_BAR, true);
} else if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
mBar.setInteracting(StatusBarManager.WINDOW_NAVIGATION_BAR, false);
}
mDelegateView.getLocationOnScreen(mTempPoint);
final float delegateX = mTempPoint[0];
final float delegateY = mTempPoint[1];
float deltaX = sourceX - delegateX;
float deltaY = sourceY - delegateY;
event.offsetLocation(deltaX, deltaY);
mDelegateView.dispatchTouchEvent(event);
event.offsetLocation(-deltaX, -deltaY);
return mPanelShowing;
|
public void | setBar(BaseStatusBar phoneStatusBar)
mBar = phoneStatusBar;
|
public void | setDelegateView(android.view.View view)
mDelegateView = view;
|
public void | setDisabled(boolean disabled)
mDisabled = disabled;
|
public void | setInitialTouchRegion(android.view.View views)Selects the initial touch region based on a list of views. This is meant to be called by
a container widget on children over which the initial touch should be detected. Note this
will compute a minimum bound that contains all specified views.
RectF bounds = new RectF();
int p[] = new int[2];
for (int i = 0; i < views.length; i++) {
View view = views[i];
if (view == null) continue;
view.getLocationOnScreen(p);
if (i == 0) {
bounds.set(p[0], p[1], p[0] + view.getWidth(), p[1] + view.getHeight());
} else {
bounds.union(p[0], p[1], p[0] + view.getWidth(), p[1] + view.getHeight());
}
}
mInitialTouch.set(bounds);
|
public void | setSourceView(android.view.View view)
mSourceView = view;
if (mSourceView != null) {
Resources r = mSourceView.getContext().getResources();
mTriggerThreshhold = r.getDimensionPixelSize(R.dimen.navigation_bar_min_swipe_distance);
}
|
public void | setSwapXY(boolean swap)When rotation is set to NO_SENSOR, then this allows swapping x/y for gesture detection
mSwapXY = swap;
|