Program: 157493
Project: 157493
Buggy source:
@Override public boolean onTouchEvent(MotionEvent me){
  if (me.getAction() == MotionEvent.ACTION_DOWN) {
    mFirstTouchPont.x=(int)me.getX();
    mFirstTouchPont.y=(int)me.getY();
    mIsFirstDownEventInsideSpaceBar=mSpaceBarKey != null && mSpaceBarKey.isInside(mFirstTouchPont.x,mFirstTouchPont.y);
  }
 else   if (mIsFirstDownEventInsideSpaceBar) {
    if (me.getAction() == MotionEvent.ACTION_MOVE) {
      setGesturePreviewText(mSwitcher,me);
      return true;
    }
 else     if (me.getAction() == MotionEvent.ACTION_UP) {
      final int slide=getSlideDistance(me);
      final int distance=slide & 0x00FF;
      if (distance > SLIDE_RATIO_FOR_GESTURE) {
switch (slide & 0xFF00) {
case DIRECTION_DOWN:
          mKeyboardActionListener.onSwipeDown(true);
        break;
case DIRECTION_UP:
      mKeyboardActionListener.onSwipeUp(true);
    break;
case DIRECTION_LEFT:
  mKeyboardActionListener.onSwipeLeft(true);
break;
case DIRECTION_RIGHT:
mKeyboardActionListener.onSwipeRight(true);
break;
}
}
 else {
super.onTouchEvent(me);
}
return true;
}
}
if (!mIsFirstDownEventInsideSpaceBar && me.getY() < mExtensionKeyboardYActivationPoint && !isPopupShowing() && !mExtensionVisible && me.getAction() != MotionEvent.ACTION_UP) {
if (mExtensionKeyboardAreaEntranceTime <= 0) mExtensionKeyboardAreaEntranceTime=System.currentTimeMillis();
if (System.currentTimeMillis() - mExtensionKeyboardAreaEntranceTime > DELAY_BEFORE_POPING_UP_EXTENSION_KBD) {
KeyboardExtension extKbd=((ExternalAnyKeyboard)getKeyboard()).getExtensionLayout();
if (extKbd == null || extKbd.getKeyboardResId() == -1) {
return super.onTouchEvent(me);
}
 else {
MotionEvent cancel=MotionEvent.obtain(me.getDownTime(),me.getEventTime(),MotionEvent.ACTION_CANCEL,me.getX(),me.getY(),0);
super.onTouchEvent(cancel);
cancel.recycle();
mExtensionVisible=true;
dismissKeyPreview();
if (mExtensionKey == null) {
mExtensionKey=new AnyKey(new Row(getKeyboard()),getThemedKeyboardDimens());
mExtensionKey.codes=new int[]{0};
mExtensionKey.edgeFlags=0;
mExtensionKey.height=1;
mExtensionKey.width=1;
mExtensionKey.popupResId=extKbd.getKeyboardResId();
mExtensionKey.x=getWidth() / 2;
mExtensionKey.y=mExtensionKeyboardPopupOffset;
}
mExtensionKey.x=(int)me.getX();
onLongPress(getContext(),mExtensionKey,AnyApplication.getConfig().isStickyExtensionKeyboard(),!AnyApplication.getConfig().isStickyExtensionKeyboard());
mMiniKeyboard.setPreviewEnabled(true);
return true;
}
}
 else {
return super.onTouchEvent(me);
}
}
 else if (mExtensionVisible && me.getY() > mExtensionKeyboardYDismissPoint) {
dismissPopupKeyboard();
return true;
}
 else {
return super.onTouchEvent(me);
}
}

Fixed version (ground truth):
@Override public boolean onTouchEvent(MotionEvent me){
  if (me.getAction() == MotionEvent.ACTION_DOWN) {
    mFirstTouchPont.x=(int)me.getX();
    mFirstTouchPont.y=(int)me.getY();
    mIsFirstDownEventInsideSpaceBar=mSpaceBarKey != null && mSpaceBarKey.isInside(mFirstTouchPont.x,mFirstTouchPont.y);
  }
 else   if (mIsFirstDownEventInsideSpaceBar) {
    if (me.getAction() == MotionEvent.ACTION_MOVE) {
      setGesturePreviewText(mSwitcher,me);
      return true;
    }
 else     if (me.getAction() == MotionEvent.ACTION_UP) {
      final int slide=getSlideDistance(me);
      final int distance=slide & 0x00FF;
      if (distance > SLIDE_RATIO_FOR_GESTURE) {
switch (slide & 0xFF00) {
case DIRECTION_DOWN:
          mKeyboardActionListener.onSwipeDown(true);
        break;
case DIRECTION_UP:
      mKeyboardActionListener.onSwipeUp(true);
    break;
case DIRECTION_LEFT:
  mKeyboardActionListener.onSwipeLeft(true);
break;
case DIRECTION_RIGHT:
mKeyboardActionListener.onSwipeRight(true);
break;
}
}
 else {
super.onTouchEvent(me);
}
return true;
}
}
if (!mIsFirstDownEventInsideSpaceBar && me.getY() < mExtensionKeyboardYActivationPoint && !isPopupShowing() && !mExtensionVisible && me.getAction() != MotionEvent.ACTION_UP) {
if (mExtensionKeyboardAreaEntranceTime <= 0) mExtensionKeyboardAreaEntranceTime=System.currentTimeMillis();
if (System.currentTimeMillis() - mExtensionKeyboardAreaEntranceTime > DELAY_BEFORE_POPING_UP_EXTENSION_KBD) {
KeyboardExtension extKbd=((ExternalAnyKeyboard)getKeyboard()).getExtensionLayout();
if (extKbd == null || extKbd.getKeyboardResId() == -1) {
return super.onTouchEvent(me);
}
 else {
MotionEvent cancel=MotionEvent.obtain(me.getDownTime(),me.getEventTime(),MotionEvent.ACTION_CANCEL,me.getX(),me.getY(),0);
super.onTouchEvent(cancel);
cancel.recycle();
mExtensionVisible=true;
dismissKeyPreview();
if (mExtensionKey == null) {
mExtensionKey=new AnyKey(new Row(getKeyboard()),getThemedKeyboardDimens());
mExtensionKey.codes=new int[]{0};
mExtensionKey.edgeFlags=0;
mExtensionKey.height=1;
mExtensionKey.width=1;
mExtensionKey.popupResId=extKbd.getKeyboardResId();
mExtensionKey.x=getWidth() / 2;
mExtensionKey.y=mExtensionKeyboardPopupOffset;
}
mExtensionKey.x=(int)me.getX();
onLongPress(getKeyboard().getKeyboardContext(),mExtensionKey,AnyApplication.getConfig().isStickyExtensionKeyboard(),!AnyApplication.getConfig().isStickyExtensionKeyboard());
mMiniKeyboard.setPreviewEnabled(true);
return true;
}
}
 else {
return super.onTouchEvent(me);
}
}
 else if (mExtensionVisible && me.getY() > mExtensionKeyboardYDismissPoint) {
dismissPopupKeyboard();
return true;
}
 else {
return super.onTouchEvent(me);
}
}