Program: 157471
Project: 157471
Buggy source:
@Override public boolean onTouchEvent(MotionEvent me){
  Log.d(TAG,"String_Node_Str" + me.getPointerCount() + "String_Node_Str");
  if (getKeyboard() == null)   return false;
  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,isAtTwoFingersState());
break;
case DIRECTION_RIGHT:
mKeyboardActionListener.onSwipeRight(true,isAtTwoFingersState());
break;
}
}
 else {
super.onTouchEvent(me);
}
return true;
}
}
if (!mIsFirstDownEventInsideSpaceBar && me.getY() < mExtensionKeyboardYActivationPoint && !isPopupShowing() && !mExtensionVisible && me.getAction() == MotionEvent.ACTION_MOVE) {
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.externalResourcePopupLayout=mExtensionKey.popupResId != 0;
mExtensionKey.x=getWidth() / 2;
mExtensionKey.y=mExtensionKeyboardPopupOffset;
}
mExtensionKey.x=(int)me.getX();
onLongPress(extKbd.getPackageContext(),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){
  Log.d(TAG,"String_Node_Str" + me.getPointerCount() + "String_Node_Str");
  if (getKeyboard() == null)   return false;
  if (areTouchesDisabled())   return super.onTouchEvent(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,isAtTwoFingersState());
break;
case DIRECTION_RIGHT:
mKeyboardActionListener.onSwipeRight(true,isAtTwoFingersState());
break;
}
}
 else {
super.onTouchEvent(me);
}
return true;
}
}
if (!mIsFirstDownEventInsideSpaceBar && me.getY() < mExtensionKeyboardYActivationPoint && !isPopupShowing() && !mExtensionVisible && me.getAction() == MotionEvent.ACTION_MOVE) {
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.externalResourcePopupLayout=mExtensionKey.popupResId != 0;
mExtensionKey.x=getWidth() / 2;
mExtensionKey.y=mExtensionKeyboardPopupOffset;
}
mExtensionKey.x=(int)me.getX();
onLongPress(extKbd.getPackageContext(),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);
}
}