Program: 157492
Project: 157492
Buggy source:
/** 
 * Called when a key is long pressed. By default this will open any popup keyboard associated with this key through the attributes popupLayout and popupCharacters.
 * @param popupKey the key that was long pressed
 * @return true if the long press is handled, false otherwise. Subclassesshould call the method on the base class if the subclass doesn't wish to handle the call.
 */
protected boolean onLongPress(Context packageContext,Key popupKey,boolean isSticky,boolean requireSlideInto){
  if (popupKey.popupResId == 0)   return false;
  if (mMiniKeyboard == null) {
    createMiniKeyboard();
  }
  setupMiniKeyboardContainer(packageContext,popupKey.popupCharacters,popupKey.popupResId,isSticky);
  mMiniKeyboardVisible=true;
  if (mWindowOffset == null) {
    mWindowOffset=new int[2];
    getLocationInWindow(mWindowOffset);
  }
  int popupX=popupKey.x + mWindowOffset[0];
  popupX-=mMiniKeyboard.getPaddingLeft();
  int popupY=popupKey.y + mWindowOffset[1];
  popupY+=getPaddingTop();
  popupY-=mMiniKeyboard.getMeasuredHeight();
  popupY-=mMiniKeyboard.getPaddingBottom();
  final int x=popupX;
  final int y=mShowPreview && mOldPreviewKeyIndex != NOT_A_KEY && isOneRowKeys(mMiniKeyboard.getKeyboard().getKeys()) ? mPopupPreviewDisplayedY : popupY;
  int adjustedX=x;
  if (x < 0) {
    adjustedX=0;
  }
 else   if (x > (getMeasuredWidth() - mMiniKeyboard.getMeasuredWidth())) {
    adjustedX=getMeasuredWidth() - mMiniKeyboard.getMeasuredWidth();
  }
  mMiniKeyboardOriginX=adjustedX + mMiniKeyboard.getPaddingLeft() - mWindowOffset[0];
  mMiniKeyboardOriginY=y + mMiniKeyboard.getPaddingTop() - mWindowOffset[1];
  mMiniKeyboard.setPopupOffset(adjustedX,y);
  mMiniKeyboard.setShifted(mKeyboard != null ? mKeyboard.isShifted() : false);
  mMiniKeyboard.setPreviewEnabled(false);
  mMiniKeyboardPopup.setContentView(mMiniKeyboard);
  mMiniKeyboardPopup.setWidth(mMiniKeyboard.getMeasuredWidth());
  mMiniKeyboardPopup.setHeight(mMiniKeyboard.getMeasuredHeight());
  mMiniKeyboardPopup.showAtLocation(this,Gravity.NO_GRAVITY,adjustedX,y);
  if (requireSlideInto) {
    long eventTime=SystemClock.uptimeMillis();
    mMiniKeyboardPopupTime=eventTime;
    MotionEvent downEvent=generateMiniKeyboardMotionEvent(MotionEvent.ACTION_DOWN,popupKey.x + popupKey.width / 2,popupKey.y + popupKey.height / 2,eventTime);
    mMiniKeyboard.onTouchEvent(downEvent);
    downEvent.recycle();
  }
  invalidateAllKeys();
  return true;
}

Fixed version (ground truth):
/** 
 * Called when a key is long pressed. By default this will open any popup keyboard associated with this key through the attributes popupLayout and popupCharacters.
 * @param popupKey the key that was long pressed
 * @return true if the long press is handled, false otherwise. Subclassesshould call the method on the base class if the subclass doesn't wish to handle the call.
 */
protected boolean onLongPress(Context packageContext,Key popupKey,boolean isSticky,boolean requireSlideInto){
  if (popupKey.popupResId == 0)   return false;
  if (mMiniKeyboard == null) {
    createMiniKeyboard();
  }
  setupMiniKeyboardContainer(popupKey.popupCharacters,popupKey.popupResId,isSticky);
  mMiniKeyboardVisible=true;
  if (mWindowOffset == null) {
    mWindowOffset=new int[2];
    getLocationInWindow(mWindowOffset);
  }
  int popupX=popupKey.x + mWindowOffset[0];
  popupX-=mMiniKeyboard.getPaddingLeft();
  int popupY=popupKey.y + mWindowOffset[1];
  popupY+=getPaddingTop();
  popupY-=mMiniKeyboard.getMeasuredHeight();
  popupY-=mMiniKeyboard.getPaddingBottom();
  final int x=popupX;
  final int y=mShowPreview && mOldPreviewKeyIndex != NOT_A_KEY && isOneRowKeys(mMiniKeyboard.getKeyboard().getKeys()) ? mPopupPreviewDisplayedY : popupY;
  int adjustedX=x;
  if (x < 0) {
    adjustedX=0;
  }
 else   if (x > (getMeasuredWidth() - mMiniKeyboard.getMeasuredWidth())) {
    adjustedX=getMeasuredWidth() - mMiniKeyboard.getMeasuredWidth();
  }
  mMiniKeyboardOriginX=adjustedX + mMiniKeyboard.getPaddingLeft() - mWindowOffset[0];
  mMiniKeyboardOriginY=y + mMiniKeyboard.getPaddingTop() - mWindowOffset[1];
  mMiniKeyboard.setPopupOffset(adjustedX,y);
  mMiniKeyboard.setShifted(mKeyboard != null ? mKeyboard.isShifted() : false);
  mMiniKeyboard.setPreviewEnabled(false);
  mMiniKeyboardPopup.setContentView(mMiniKeyboard);
  mMiniKeyboardPopup.setWidth(mMiniKeyboard.getMeasuredWidth());
  mMiniKeyboardPopup.setHeight(mMiniKeyboard.getMeasuredHeight());
  mMiniKeyboardPopup.showAtLocation(this,Gravity.NO_GRAVITY,adjustedX,y);
  if (requireSlideInto) {
    long eventTime=SystemClock.uptimeMillis();
    mMiniKeyboardPopupTime=eventTime;
    MotionEvent downEvent=generateMiniKeyboardMotionEvent(MotionEvent.ACTION_DOWN,popupKey.x + popupKey.width / 2,popupKey.y + popupKey.height / 2,eventTime);
    mMiniKeyboard.onTouchEvent(downEvent);
    downEvent.recycle();
  }
  invalidateAllKeys();
  return true;
}