nus-yam/ex-repair huggingface dataset:
Program: 157243
Project: 157243
Buggy source:
private int[] getPathCorners(ArrayList<Integer> xs,ArrayList<Integer> ys,int curvatureSize){
  ArrayList<Integer> maxima=new ArrayList<>();
  if (xs.size() > 0) {
    maxima.add(xs.get(0));
    maxima.add(ys.get(0));
  }
  for (int i=0; i < xs.size(); i++) {
    if (curvature(xs,ys,i,curvatureSize)) {
      int end=i;
      while (end < xs.size()) {
        if (curvature(xs,ys,end,curvatureSize)) {
          break;
        }
        end++;
      }
      int avgX=0;
      int avgY=0;
      for (int j=i; j <= end; j++) {
        avgX+=xs.get(i);
        avgY+=ys.get(i);
      }
      avgX/=(end - i + 1);
      avgY/=(end - i + 1);
      maxima.add(avgX);
      maxima.add(avgY);
      i=end;
    }
  }
  if (xs.size() > 1) {
    maxima.add(xs.get(xs.size() - 1));
    maxima.add(ys.get(ys.size() - 1));
  }
  int[] arr=new int[maxima.size()];
  for (int i=0; i < maxima.size(); i++)   arr[i]=maxima.get(i);
  return arr;
}

Fixed version (ground truth):
private int[] getPathCorners(ArrayList<Integer> xs,ArrayList<Integer> ys,int curvatureSize){
  ArrayList<Integer> maxima=new ArrayList<>();
  if (xs.size() > 0) {
    maxima.add(xs.get(0));
    maxima.add(ys.get(0));
  }
  for (int i=0; i < xs.size(); i++) {
    if (curvature(xs,ys,i,curvatureSize)) {
      maxima.add(xs.get(i));
      maxima.add(ys.get(i));
    }
  }
  if (xs.size() > 1) {
    maxima.add(xs.get(xs.size() - 1));
    maxima.add(ys.get(ys.size() - 1));
  }
  int[] arr=new int[maxima.size()];
  for (int i=0; i < maxima.size(); i++)   arr[i]=maxima.get(i);
  return arr;
}
Program: 157244
Project: 157244
Buggy source:
private double getWordDistance(int[] user,int[] word){
  if (word.length > user.length)   return Float.MAX_VALUE;
  double dist=0;
  int currentWordIndex=0;
  for (int i=0; i < user.length / 2; i++) {
    int ux=user[i * 2];
    int uy=user[i * 2 + 1];
    double d=dist(ux,uy,word[currentWordIndex * 2] / WORDS_SIZE * width,word[currentWordIndex * 2 + 1] / WORDS_SIZE * height);
    double d2;
    if (currentWordIndex + 1 < word.length / 2 && i > 0 && (d2=dist(ux,uy,word[currentWordIndex * 2 + 2] / WORDS_SIZE * width,word[currentWordIndex * 2 + 3] / WORDS_SIZE * width)) < d) {
      d=d2;
      currentWordIndex++;
    }
    dist+=d;
  }
  while (currentWordIndex + 1 < word.length / 2) {
    currentWordIndex++;
    dist+=10 * dist(user[user.length - 2],user[user.length - 1],word[currentWordIndex * 2] / WORDS_SIZE * width,word[currentWordIndex * 2 + 1] / WORDS_SIZE * width);
  }
  return dist;
}

Fixed version (ground truth):
private double getWordDistance(int[] user,int[] word){
  if (word.length > user.length)   return Float.MAX_VALUE;
  double dist=0;
  int currentWordIndex=0;
  for (int i=0; i < user.length / 2; i++) {
    int ux=user[i * 2];
    int uy=user[i * 2 + 1];
    double d=dist(ux,uy,word[currentWordIndex * 2] * width / WORDS_SIZE,word[currentWordIndex * 2 + 1] * height / WORDS_SIZE);
    double d2;
    if (currentWordIndex + 1 < word.length / 2 && i > 0 && (d2=dist(ux,uy,word[currentWordIndex * 2 + 2] * width / WORDS_SIZE,word[currentWordIndex * 2 + 3] * height / WORDS_SIZE)) < d) {
      d=d2;
      currentWordIndex++;
    }
    dist+=d;
  }
  while (currentWordIndex + 1 < word.length / 2) {
    currentWordIndex++;
    dist+=10 * dist(user[user.length - 2],user[user.length - 1],word[currentWordIndex * 2] * width / WORDS_SIZE,word[currentWordIndex * 2 + 1] * height / WORDS_SIZE);
  }
  return dist;
}
Program: 157245
Project: 157245
Buggy source:
/** 
 * Did we come close enough to a normal (alphabet) character for this to be considered the start of a gesture?
 */
public boolean isValidStartTouch(int x,int y){
  for (  Keyboard.Key key : keys) {
    final float closestX=(x < key.x) ? key.x : (x > (key.x + key.width)) ? (key.x + key.width) : x;
    final float closestY=(y < key.y) ? key.y : (y > (key.y + key.height)) ? (key.y + key.height) : y;
    final float xDist=Math.abs(closestX - x);
    final float yDist=Math.abs(closestY - y);
    if (xDist <= key.width / 3f && yDist <= key.height / 3f && key.label != null && key.label.length() == 1 && Character.isLetter(key.label.charAt(0))) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Did we come close enough to a normal (alphabet) character for this to be considered the start of a gesture?
 */
public boolean isValidStartTouch(int x,int y){
  for (  Keyboard.Key key : mKeys) {
    final float closestX=(x < key.x) ? key.x : (x > (key.x + key.width)) ? (key.x + key.width) : x;
    final float closestY=(y < key.y) ? key.y : (y > (key.y + key.height)) ? (key.y + key.height) : y;
    final float xDist=Math.abs(closestX - x);
    final float yDist=Math.abs(closestY - y);
    if (xDist <= key.width / 3f && yDist <= key.height / 3f && key.label != null && key.label.length() == 1 && Character.isLetter(key.label.charAt(0))) {
      return true;
    }
  }
  return false;
}
Program: 157246
Project: 157246
Buggy source:
public void clearGesture(){
  xs.clear();
  ys.clear();
  times.clear();
}

Fixed version (ground truth):
public void clearGesture(){
  mXs.clear();
  mYs.clear();
  mTimestamps.clear();
}
Program: 157247
Project: 157247
Buggy source:
public ArrayList<String> getCandidates(){
  DEBUG_PATH_CORNERS=getPathCorners();
  DEBUG_PATH_X.clear();
  DEBUG_PATH_X.addAll(xs);
  DEBUG_PATH_Y.clear();
  DEBUG_PATH_Y.addAll(ys);
  ArrayList<String> arr=new ArrayList<>();
  arr.add(words.get(0));
  arr.add(words.get(1));
  return arr;
}

Fixed version (ground truth):
public ArrayList<String> getCandidates(){
  DEBUG_PATH_CORNERS=getPathCorners();
  DEBUG_PATH_X.clear();
  DEBUG_PATH_X.addAll(mXs);
  DEBUG_PATH_Y.clear();
  DEBUG_PATH_Y.addAll(mYs);
  ArrayList<String> arr=new ArrayList<>();
  arr.add(mWords.get(0));
  arr.add(mWords.get(1));
  return arr;
}
Program: 157248
Project: 157248
Buggy source:
private ArrayList<Integer> getPathCorners(){
  ArrayList<Integer> maxima=new ArrayList<>();
  if (xs.size() > 0) {
    maxima.add(xs.get(0));
    maxima.add(ys.get(0));
  }
  for (int i=0; i < xs.size(); i++) {
    if (curvature(i)) {
      int end=i;
      while (end < xs.size()) {
        if (curvature(end)) {
          break;
        }
        end++;
      }
      int avg_x=0;
      int avg_y=0;
      for (int j=i; j <= end; j++) {
        avg_x+=xs.get(i);
        avg_y+=ys.get(i);
      }
      avg_x/=(end - i + 1);
      avg_y/=(end - i + 1);
      maxima.add(avg_x);
      maxima.add(avg_y);
      i=end;
    }
  }
  if (xs.size() > 1) {
    maxima.add(xs.get(xs.size() - 1));
    maxima.add(ys.get(ys.size() - 1));
  }
  return maxima;
}

Fixed version (ground truth):
private ArrayList<Integer> getPathCorners(){
  ArrayList<Integer> maxima=new ArrayList<>();
  if (mXs.size() > 0) {
    maxima.add(mXs.get(0));
    maxima.add(mYs.get(0));
  }
  for (int i=0; i < mXs.size(); i++) {
    if (curvature(i)) {
      int end=i;
      while (end < mXs.size()) {
        if (curvature(end)) {
          break;
        }
        end++;
      }
      int avgX=0;
      int avgY=0;
      for (int j=i; j <= end; j++) {
        avgX+=mXs.get(i);
        avgY+=mYs.get(i);
      }
      avgX/=(end - i + 1);
      avgY/=(end - i + 1);
      maxima.add(avgX);
      maxima.add(avgY);
      i=end;
    }
  }
  if (mXs.size() > 1) {
    maxima.add(mXs.get(mXs.size() - 1));
    maxima.add(mYs.get(mYs.size() - 1));
  }
  return maxima;
}
Program: 157249
Project: 157249
Buggy source:
public GestureTypingDetector(Iterable<Keyboard.Key> keys,Context context){
  this.keys=keys;
  try {
    InputStream is=context.getResources().openRawResource(R.raw.gesturetyping_temp_dictionary);
    BufferedReader reader=new BufferedReader(new InputStreamReader(is));
    String line;
    while ((line=reader.readLine()) != null) {
      if (!line.isEmpty())       words.add(line);
    }
    reader.close();
    is.close();
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
public GestureTypingDetector(Iterable<Keyboard.Key> keys,Context context){
  this.mKeys=keys;
  try {
    InputStream is=context.getResources().openRawResource(R.raw.gesturetyping_temp_dictionary);
    BufferedReader reader=new BufferedReader(new InputStreamReader(is));
    String line;
    while ((line=reader.readLine()) != null) {
      if (!line.isEmpty())       mWords.add(line);
    }
    reader.close();
    is.close();
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
}
Program: 157250
Project: 157250
Buggy source:
public void addPoint(int x,int y,long time){
  if (xs.size() > 0) {
    int dx=xs.get(xs.size() - 1) - x;
    int dy=ys.get(ys.size() - 1) - y;
    if (dx * dx + dy * dy <= 5)     return;
  }
  xs.add(x);
  ys.add(y);
  times.add(time);
}

Fixed version (ground truth):
public void addPoint(int x,int y,long time){
  if (mXs.size() > 0) {
    int dx=mXs.get(mXs.size() - 1) - x;
    int dy=mYs.get(mYs.size() - 1) - y;
    if (dx * dx + dy * dy <= 5)     return;
  }
  mXs.add(x);
  mYs.add(y);
  mTimestamps.add(time);
}
Program: 157251
Project: 157251
Buggy source:
private boolean curvature(int middle){
  int si=Math.max(0,middle - CURVATURE_SIZE);
  int sx=xs.get(si);
  int sy=ys.get(si);
  int ei=Math.min(xs.size() - 1,middle + CURVATURE_SIZE);
  int ex=xs.get(ei);
  int ey=ys.get(ei);
  int mx=xs.get(middle);
  int my=ys.get(middle);
  double m1=Math.sqrt((sx - mx) * (sx - mx) + (sy - my) * (sy - my));
  double m2=Math.sqrt((ex - mx) * (ex - mx) + (ey - my) * (ey - my));
  double dot=(sx - mx) * (ex - mx) + (sy - my) * (ey - my);
  double angle=Math.abs(Math.acos(dot / m1 / m2));
  System.out.println("String_Node_Str" + Math.toDegrees(angle));
  return angle > 0 && angle <= CURVATURE_THRESHOLD;
}

Fixed version (ground truth):
private boolean curvature(int middle){
  int si=Math.max(0,middle - CURVATURE_SIZE);
  int sx=mXs.get(si);
  int sy=mYs.get(si);
  int ei=Math.min(mXs.size() - 1,middle + CURVATURE_SIZE);
  int ex=mXs.get(ei);
  int ey=mYs.get(ei);
  int mx=mXs.get(middle);
  int my=mYs.get(middle);
  double m1=Math.sqrt((sx - mx) * (sx - mx) + (sy - my) * (sy - my));
  double m2=Math.sqrt((ex - mx) * (ex - mx) + (ey - my) * (ey - my));
  double dot=(sx - mx) * (ex - mx) + (sy - my) * (ey - my);
  double angle=Math.abs(Math.acos(dot / m1 / m2));
  System.out.println("String_Node_Str" + Math.toDegrees(angle));
  return angle > 0 && angle <= CURVATURE_THRESHOLD;
}
Program: 157252
Project: 157252
Buggy source:
@Override public void onGestureTypingInputDone(){
  InputConnection ic=getCurrentInputConnection();
  if (mGestureTypingEnabled && ic != null) {
    ArrayList<String> gestureTypingPossibilities=gestureTypingDetector.getCandidates();
    final boolean isShifted=mShiftKeyState.isActive();
    final boolean isCapsLocked=mShiftKeyState.isLocked();
    if (gestureTypingPossibilities.size() > 0) {
      ic.beginBatchEdit();
      final boolean alsoAddSpace=TextEntryState.getState() == TextEntryState.State.PERFORMED_GESTURE;
      abortCorrectionAndResetPredictionState(false);
      if (alsoAddSpace) {
        ic.commitText("String_Node_Str",1);
      }
      CharSequence word=gestureTypingPossibilities.get(0);
      mWord.reset();
      mWord.setAutoCapitalized(isShifted || isCapsLocked);
      mWord.simulateTypedWord(word);
      commitWordToInput(mWord.getTypedWord(),false);
      TextEntryState.performedGesture();
      if (gestureTypingPossibilities.size() > 1) {
        setCandidatesViewShown(true);
        setSuggestions(gestureTypingPossibilities,false,true,true);
      }
 else {
        setSuggestions(Collections.<CharSequence>emptyList(),false,false,false);
      }
      ic.endBatchEdit();
    }
    gestureTypingDetector.clearGesture();
  }
}

Fixed version (ground truth):
@Override public void onGestureTypingInputDone(){
  InputConnection ic=getCurrentInputConnection();
  if (mGestureTypingEnabled && ic != null) {
    ArrayList<String> gestureTypingPossibilities=mGestureTypingDetector.getCandidates();
    final boolean isShifted=mShiftKeyState.isActive();
    final boolean isCapsLocked=mShiftKeyState.isLocked();
    if (gestureTypingPossibilities.size() > 0) {
      ic.beginBatchEdit();
      final boolean alsoAddSpace=TextEntryState.getState() == TextEntryState.State.PERFORMED_GESTURE;
      abortCorrectionAndResetPredictionState(false);
      if (alsoAddSpace) {
        ic.commitText("String_Node_Str",1);
      }
      CharSequence word=gestureTypingPossibilities.get(0);
      mWord.reset();
      mWord.setAutoCapitalized(isShifted || isCapsLocked);
      mWord.simulateTypedWord(word);
      commitWordToInput(mWord.getTypedWord(),false);
      TextEntryState.performedGesture();
      if (gestureTypingPossibilities.size() > 1) {
        setCandidatesViewShown(true);
        setSuggestions(gestureTypingPossibilities,false,true,true);
      }
 else {
        setSuggestions(Collections.<CharSequence>emptyList(),false,false,false);
      }
      ic.endBatchEdit();
    }
    mGestureTypingDetector.clearGesture();
  }
}
Program: 157253
Project: 157253
Buggy source:
@Override public void onGestureTypingInput(int x,int y,long eventTime){
  gestureTypingDetector.addPoint(x,y,eventTime);
}

Fixed version (ground truth):
@Override public void onGestureTypingInput(int x,int y,long eventTime){
  mGestureTypingDetector.addPoint(x,y,eventTime);
}
Program: 157254
Project: 157254
Buggy source:
@Override public boolean isValidGestureTypingStart(int x,int y){
  if (gestureTypingDetector == null) {
    gestureTypingDetector=new GestureTypingDetector(getCurrentAlphabetKeyboard().getKeys(),this);
  }
  return gestureTypingDetector.isValidStartTouch(x,y);
}

Fixed version (ground truth):
@Override public boolean isValidGestureTypingStart(int x,int y){
  if (mGestureTypingDetector == null) {
    mGestureTypingDetector=new GestureTypingDetector(getCurrentAlphabetKeyboard().getKeys(),this);
  }
  return mGestureTypingDetector.isValidStartTouch(x,y);
}
Program: 157255
Project: 157255
Buggy source:
@Override public void onGestureTypingInputStart(int x,int y,long eventTime){
  gestureTypingDetector.clearGesture();
  gestureTypingDetector.addPoint(x,y,eventTime);
}

Fixed version (ground truth):
@Override public void onGestureTypingInputStart(int x,int y,long eventTime){
  mGestureTypingDetector.clearGesture();
  mGestureTypingDetector.addPoint(x,y,eventTime);
}
Program: 157256
Project: 157256
Buggy source:
private void setInitialCondensedState(Configuration newConfig){
  final String defaultCondensed=mAskPrefs.getInitialKeyboardCondenseState();
  mKeyboardInCondensedMode=CondenseType.None;
switch (defaultCondensed) {
case "String_Node_Str":
    mKeyboardInCondensedMode=CondenseType.Split;
  break;
case "String_Node_Str":
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) mKeyboardInCondensedMode=CondenseType.Split;
 else mKeyboardInCondensedMode=CondenseType.None;
break;
case "String_Node_Str":
mKeyboardInCondensedMode=CondenseType.CompactToRight;
break;
case "String_Node_Str":
mKeyboardInCondensedMode=CondenseType.CompactToLeft;
break;
}
}

Fixed version (ground truth):
private void setInitialCondensedState(SharedPreferences sp,Configuration configuration){
  final int settingsKeyResId=configuration.orientation == Configuration.ORIENTATION_LANDSCAPE ? R.string.settings_key_default_split_state_landscape : R.string.settings_key_default_split_state_portrait;
  final String initialKeyboardCondenseState=sp.getString(getString(settingsKeyResId),getString(R.string.settings_default_default_split_state));
  final CondenseType previousCondenseType=mKeyboardInCondensedMode;
  mKeyboardInCondensedMode=CondenseType.None;
switch (initialKeyboardCondenseState) {
case "String_Node_Str":
    mKeyboardInCondensedMode=CondenseType.Split;
  break;
case "String_Node_Str":
mKeyboardInCondensedMode=CondenseType.CompactToRight;
break;
case "String_Node_Str":
mKeyboardInCondensedMode=CondenseType.CompactToLeft;
break;
}
if (previousCondenseType != mKeyboardInCondensedMode) {
getKeyboardSwitcher().flushKeyboardsCache();
resetKeyboardView(false);
}
}
Program: 157258
Project: 157258
Buggy source:
@Override public void onConfigurationChanged(Configuration newConfig){
  super.onConfigurationChanged(newConfig);
  if (newConfig.orientation != mOrientation) {
    mOrientation=newConfig.orientation;
    setInitialCondensedState(newConfig);
    abortCorrectionAndResetPredictionState(false);
    String sentenceSeparatorsForCurrentKeyboard=getKeyboardSwitcher().getCurrentKeyboardSentenceSeparators();
    if (sentenceSeparatorsForCurrentKeyboard == null) {
      mSentenceSeparators.clear();
    }
 else {
      fillSeparatorsSparseArray(mSentenceSeparators,sentenceSeparatorsForCurrentKeyboard.toCharArray());
    }
  }
}

Fixed version (ground truth):
@Override public void onConfigurationChanged(Configuration newConfig){
  super.onConfigurationChanged(newConfig);
  if (newConfig.orientation != mOrientation) {
    mOrientation=newConfig.orientation;
    setInitialCondensedState(getSharedPrefs(),newConfig);
    abortCorrectionAndResetPredictionState(false);
    String sentenceSeparatorsForCurrentKeyboard=getKeyboardSwitcher().getCurrentKeyboardSentenceSeparators();
    if (sentenceSeparatorsForCurrentKeyboard == null) {
      mSentenceSeparators.clear();
    }
 else {
      fillSeparatorsSparseArray(mSentenceSeparators,sentenceSeparatorsForCurrentKeyboard.toCharArray());
    }
  }
}
Program: 157259
Project: 157259
Buggy source:
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,String key){
  super.onSharedPreferenceChanged(sharedPreferences,key);
  AnyApplication.requestBackupToCloud();
  onLoadSettingsRequired(sharedPreferences);
  if (key.startsWith(KeyboardAddOnAndBuilder.KEYBOARD_PREF_PREFIX) && key.endsWith(PREFS_KEY_POSTFIX_OVERRIDE_DICTIONARY)) {
    setDictionariesForCurrentKeyboard();
  }
 else   if (key.startsWith(KeyboardAddOnAndBuilder.KEYBOARD_PREF_PREFIX) || key.startsWith("String_Node_Str") || key.equals(getString(R.string.settings_key_active_quick_text_key))|| key.equals(getString(R.string.settings_key_ext_kbd_bottom_row_key))|| key.equals(getString(R.string.settings_key_ext_kbd_top_row_key))|| key.equals(getString(R.string.settings_key_ext_kbd_ext_ketboard_key))|| key.equals(getString(R.string.settings_key_ext_kbd_hidden_bottom_row_key))|| key.equals(getString(R.string.settings_key_keyboard_theme_key))|| key.equals("String_Node_Str")|| key.equals("String_Node_Str")|| key.equals(getString(R.string.settings_key_smiley_icon_on_smileys_key))|| key.equals(getString(R.string.settings_key_long_press_timeout))|| key.equals(getString(R.string.settings_key_multitap_timeout))|| key.equals(getString(R.string.settings_key_always_hide_language_key))|| key.equals(getString(R.string.settings_key_default_split_state))|| key.equals(getString(R.string.settings_key_support_password_keyboard_type_state))) {
    resetKeyboardView(true);
  }
}

Fixed version (ground truth):
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,String key){
  super.onSharedPreferenceChanged(sharedPreferences,key);
  AnyApplication.requestBackupToCloud();
  onLoadSettingsRequired(sharedPreferences);
  if (key.startsWith(KeyboardAddOnAndBuilder.KEYBOARD_PREF_PREFIX) && key.endsWith(PREFS_KEY_POSTFIX_OVERRIDE_DICTIONARY)) {
    setDictionariesForCurrentKeyboard();
  }
 else   if (key.startsWith(KeyboardAddOnAndBuilder.KEYBOARD_PREF_PREFIX) || key.startsWith("String_Node_Str") || key.equals(getString(R.string.settings_key_active_quick_text_key))|| key.equals(getString(R.string.settings_key_ext_kbd_bottom_row_key))|| key.equals(getString(R.string.settings_key_ext_kbd_top_row_key))|| key.equals(getString(R.string.settings_key_ext_kbd_ext_ketboard_key))|| key.equals(getString(R.string.settings_key_ext_kbd_hidden_bottom_row_key))|| key.equals(getString(R.string.settings_key_keyboard_theme_key))|| key.equals("String_Node_Str")|| key.equals("String_Node_Str")|| key.equals(getString(R.string.settings_key_smiley_icon_on_smileys_key))|| key.equals(getString(R.string.settings_key_long_press_timeout))|| key.equals(getString(R.string.settings_key_multitap_timeout))|| key.equals(getString(R.string.settings_key_always_hide_language_key))|| key.equals(getString(R.string.settings_key_default_split_state_portrait))|| key.equals(getString(R.string.settings_key_default_split_state_landscape))|| key.equals(getString(R.string.settings_key_support_password_keyboard_type_state))) {
    resetKeyboardView(true);
  }
}
Program: 157260
Project: 157260
Buggy source:
public void resetKeyboardView(boolean recreateView){
  hideWindow();
  if (recreateView) {
    setInputView(onCreateInputView());
    setCandidatesView(onCreateCandidatesView());
    setCandidatesViewShown(false);
  }
}

Fixed version (ground truth):
public void resetKeyboardView(boolean recreateView){
  hideWindow();
  if (recreateView) {
    getKeyboardSwitcher().flushKeyboardsCache();
    setInputView(onCreateInputView());
    setCandidatesView(onCreateCandidatesView());
    setCandidatesViewShown(false);
  }
}
Program: 157262
Project: 157262
Buggy source:
@Override public void onCreate(){
  SharedPreferencesBackupHelper helper=new SharedPreferencesBackupHelper(getApplicationContext(),DEFAULT_PREFS_FILE){
    @Override public void restoreEntity(    BackupDataInputStream data){
      final String key=data.getKey();
      if (!TextUtils.isEmpty(key)) {
        if (key.equalsIgnoreCase(getApplicationContext().getString(R.string.settings_key_default_split_state)))         return;
        if (key.equalsIgnoreCase("String_Node_Str"))         return;
        if (key.equalsIgnoreCase("String_Node_Str"))         return;
        if (key.equalsIgnoreCase(getApplicationContext().getString(R.string.settings_key_portrait_fullscreen)))         return;
        if (key.equalsIgnoreCase(getApplicationContext().getString(R.string.settings_key_landscape_fullscreen)))         return;
        if (key.equalsIgnoreCase(getApplicationContext().getString(R.string.settings_key_workaround_disable_rtl_fix)))         return;
        if (key.equalsIgnoreCase(getApplicationContext().getString(R.string.settings_key_allow_suggestions_restart)))         return;
      }
      super.restoreEntity(data);
    }
  }
;
  addHelper(PREFS_BACKUP_KEY,helper);
}

Fixed version (ground truth):
@Override public void onCreate(){
  SharedPreferencesBackupHelper helper=new SharedPreferencesBackupHelper(getApplicationContext(),DEFAULT_PREFS_FILE){
    @Override public void restoreEntity(    BackupDataInputStream data){
      final String key=data.getKey();
      if (!TextUtils.isEmpty(key)) {
        if (key.equalsIgnoreCase(getApplicationContext().getString(R.string.settings_key_default_split_state_landscape)))         return;
        if (key.equalsIgnoreCase(getApplicationContext().getString(R.string.settings_key_default_split_state_portrait)))         return;
        if (key.equalsIgnoreCase("String_Node_Str"))         return;
        if (key.equalsIgnoreCase("String_Node_Str"))         return;
        if (key.equalsIgnoreCase(getApplicationContext().getString(R.string.settings_key_portrait_fullscreen)))         return;
        if (key.equalsIgnoreCase(getApplicationContext().getString(R.string.settings_key_landscape_fullscreen)))         return;
        if (key.equalsIgnoreCase(getApplicationContext().getString(R.string.settings_key_workaround_disable_rtl_fix)))         return;
        if (key.equalsIgnoreCase(getApplicationContext().getString(R.string.settings_key_allow_suggestions_restart)))         return;
      }
      super.restoreEntity(data);
    }
  }
;
  addHelper(PREFS_BACKUP_KEY,helper);
}
Program: 157263
Project: 157263
Buggy source:
@Override public void restoreEntity(BackupDataInputStream data){
  final String key=data.getKey();
  if (!TextUtils.isEmpty(key)) {
    if (key.equalsIgnoreCase(getApplicationContext().getString(R.string.settings_key_default_split_state)))     return;
    if (key.equalsIgnoreCase("String_Node_Str"))     return;
    if (key.equalsIgnoreCase("String_Node_Str"))     return;
    if (key.equalsIgnoreCase(getApplicationContext().getString(R.string.settings_key_portrait_fullscreen)))     return;
    if (key.equalsIgnoreCase(getApplicationContext().getString(R.string.settings_key_landscape_fullscreen)))     return;
    if (key.equalsIgnoreCase(getApplicationContext().getString(R.string.settings_key_workaround_disable_rtl_fix)))     return;
    if (key.equalsIgnoreCase(getApplicationContext().getString(R.string.settings_key_allow_suggestions_restart)))     return;
  }
  super.restoreEntity(data);
}

Fixed version (ground truth):
@Override public void restoreEntity(BackupDataInputStream data){
  final String key=data.getKey();
  if (!TextUtils.isEmpty(key)) {
    if (key.equalsIgnoreCase(getApplicationContext().getString(R.string.settings_key_default_split_state_landscape)))     return;
    if (key.equalsIgnoreCase(getApplicationContext().getString(R.string.settings_key_default_split_state_portrait)))     return;
    if (key.equalsIgnoreCase("String_Node_Str"))     return;
    if (key.equalsIgnoreCase("String_Node_Str"))     return;
    if (key.equalsIgnoreCase(getApplicationContext().getString(R.string.settings_key_portrait_fullscreen)))     return;
    if (key.equalsIgnoreCase(getApplicationContext().getString(R.string.settings_key_landscape_fullscreen)))     return;
    if (key.equalsIgnoreCase(getApplicationContext().getString(R.string.settings_key_workaround_disable_rtl_fix)))     return;
    if (key.equalsIgnoreCase(getApplicationContext().getString(R.string.settings_key_allow_suggestions_restart)))     return;
  }
  super.restoreEntity(data);
}
Program: 157264
Project: 157264
Buggy source:
public void setCondensedKeys(CondenseType condenseType){
  if (mKeyboardCondenser.setCondensedKeys(condenseType))   computeNearestNeighbors();
}

Fixed version (ground truth):
public void setCondensedKeys(CondenseType condenseType){
  if (mKeyboardCondenser.setCondensedKeys(condenseType)) {
    computeNearestNeighbors();
  }
}
Program: 157265
Project: 157265
Buggy source:
void condenseRightSide(final float CONDENSING_FACTOR,final int keyboardWidth,int currentRightX,Stack<Key> rightKeys,Key spaceKey){
  currentRightX=(int)(keyboardWidth - ((keyboardWidth - currentRightX) * CONDENSING_FACTOR));
  while (!rightKeys.isEmpty()) {
    Key rightKey=rightKeys.pop();
    currentRightX-=rightKey.width;
    rightKey.x=currentRightX;
    currentRightX-=(rightKey.gap * CONDENSING_FACTOR);
  }
  if (spaceKey != null) {
    spaceKey.width=currentRightX - spaceKey.x;
  }
}

Fixed version (ground truth):
private void condenseRightSide(final float CONDENSING_FACTOR,final int keyboardWidth,int currentRightX,Stack<Key> rightKeys,Key spaceKey){
  currentRightX=(int)(keyboardWidth - ((keyboardWidth - currentRightX) * CONDENSING_FACTOR));
  while (!rightKeys.isEmpty()) {
    Key rightKey=rightKeys.pop();
    currentRightX-=rightKey.width;
    rightKey.x=currentRightX;
    currentRightX-=(rightKey.gap * CONDENSING_FACTOR);
  }
  if (spaceKey != null) {
    spaceKey.width=currentRightX - spaceKey.x;
  }
}
Program: 157266
Project: 157266
Buggy source:
int stackRightSideKeyForLater(Stack<Key> rightKeys,Key k,int targetWidth){
  int currentRightX;
  rightKeys.push(k);
  currentRightX=k.x + k.width;
  k.width=targetWidth;
  return currentRightX;
}

Fixed version (ground truth):
private int stackRightSideKeyForLater(Stack<Key> rightKeys,Key k,int targetWidth){
  int currentRightX;
  rightKeys.push(k);
  currentRightX=k.x + k.width;
  k.width=targetWidth;
  return currentRightX;
}
Program: 157267
Project: 157267
Buggy source:
int condenseLeftSide(final float CONDENSING_FACTOR,int currentLeftX,Key k,int targetWidth){
  currentLeftX+=(k.gap * CONDENSING_FACTOR);
  k.x=currentLeftX;
  k.width=targetWidth;
  currentLeftX+=k.width;
  return currentLeftX;
}

Fixed version (ground truth):
private int condenseLeftSide(final float CONDENSING_FACTOR,int currentLeftX,Key k,int targetWidth){
  currentLeftX+=(k.gap * CONDENSING_FACTOR);
  k.x=currentLeftX;
  k.width=targetWidth;
  currentLeftX+=k.width;
  return currentLeftX;
}
Program: 157268
Project: 157268
Buggy source:
@Override public void onClick(View v){
switch (v.getId()) {
case R.id.quick_keys_popup_close:
    mKeyboardActionListener.onCancel();
  break;
case R.id.quick_keys_popup_backspace:
mKeyboardActionListener.onKey(KeyCodes.DELETE,null,0,null,true);
break;
case R.id.quick_keys_popup_quick_keys_settings:
Intent startSettings=FragmentChauffeurActivity.createStartActivityIntentForAddingFragmentToUi(v.getContext(),MainSettingsActivity.class,new QuickTextSettingsFragment(),TransitionExperiences.ROOT_FRAGMENT_EXPERIENCE_TRANSITION);
startSettings.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
v.getContext().startActivity(startSettings);
mKeyboardActionListener.onCancel();
break;
}
}

Fixed version (ground truth):
@Override public void onClick(View v){
switch (v.getId()) {
case R.id.quick_keys_popup_close:
    mKeyboardActionListener.onKey(KeyCodes.CANCEL,null,0,null,true);
  break;
case R.id.quick_keys_popup_backspace:
mKeyboardActionListener.onKey(KeyCodes.DELETE,null,0,null,true);
break;
case R.id.quick_keys_popup_quick_keys_settings:
Intent startSettings=FragmentChauffeurActivity.createStartActivityIntentForAddingFragmentToUi(v.getContext(),MainSettingsActivity.class,new QuickTextSettingsFragment(),TransitionExperiences.ROOT_FRAGMENT_EXPERIENCE_TRANSITION);
startSettings.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
v.getContext().startActivity(startSettings);
mKeyboardActionListener.onKey(KeyCodes.CANCEL,null,0,null,true);
break;
}
}
Program: 157269
Project: 157269
Buggy source:
@Test public void testOnClickClose() throws Exception {
  OnKeyboardActionListener keyboardActionListener=Mockito.mock(OnKeyboardActionListener.class);
  FrameKeyboardViewClickListener listener=new FrameKeyboardViewClickListener(keyboardActionListener);
  Mockito.verifyZeroInteractions(keyboardActionListener);
  View view=new View(RuntimeEnvironment.application);
  view.setId(R.id.quick_keys_popup_close);
  listener.onClick(view);
  Mockito.verify(keyboardActionListener).onCancel();
  Mockito.verifyNoMoreInteractions(keyboardActionListener);
}

Fixed version (ground truth):
@Test public void testOnClickClose() throws Exception {
  OnKeyboardActionListener keyboardActionListener=Mockito.mock(OnKeyboardActionListener.class);
  FrameKeyboardViewClickListener listener=new FrameKeyboardViewClickListener(keyboardActionListener);
  Mockito.verifyZeroInteractions(keyboardActionListener);
  View view=new View(RuntimeEnvironment.application);
  view.setId(R.id.quick_keys_popup_close);
  listener.onClick(view);
  Mockito.verify(keyboardActionListener).onKey(KeyCodes.CANCEL,null,0,null,true);
  Mockito.verifyNoMoreInteractions(keyboardActionListener);
}
Program: 157270
Project: 157270
Buggy source:
private void switchToQuickTextKeyboard(){
  abortCorrectionAndResetPredictionState(false);
  setCandidatesViewShown(false);
  cleanUpQuickTextKeyboard(false);
  View standardKeyboardView=(View)getInputView();
  final int height=standardKeyboardView.getHeight();
  standardKeyboardView.setVisibility(View.GONE);
  QuickTextPagerView quickTextsLayout=QuickTextViewFactory.createQuickTextView(getApplicationContext(),getInputViewContainer(),height);
  quickTextsLayout.setThemeValues(((AnyKeyboardView)getInputView()).getLabelTextSize(),((AnyKeyboardView)getInputView()).getKeyTextColor(),((AnyKeyboardView)getInputView()).getDrawableForKeyCode(KeyCodes.CANCEL),((AnyKeyboardView)getInputView()).getDrawableForKeyCode(KeyCodes.DELETE),((AnyKeyboardView)getInputView()).getDrawableForKeyCode(KeyCodes.SETTINGS));
  getInputViewContainer().addView(quickTextsLayout);
}

Fixed version (ground truth):
private void switchToQuickTextKeyboard(){
  abortCorrectionAndResetPredictionState(false);
  setCandidatesViewShown(false);
  cleanUpQuickTextKeyboard(false);
  View standardKeyboardView=(View)getInputView();
  final int height=standardKeyboardView.getHeight();
  standardKeyboardView.setVisibility(View.GONE);
  QuickTextPagerView quickTextsLayout=QuickTextViewFactory.createQuickTextView(getApplicationContext(),getInputViewContainer(),height);
  AnyKeyboardView actualInputView=(AnyKeyboardView)getInputView();
  quickTextsLayout.setThemeValues(actualInputView.getLabelTextSize(),actualInputView.getKeyTextColor(),actualInputView.getDrawableForKeyCode(KeyCodes.CANCEL),actualInputView.getDrawableForKeyCode(KeyCodes.DELETE),actualInputView.getDrawableForKeyCode(KeyCodes.SETTINGS),actualInputView.getBackground());
  getInputViewContainer().addView(quickTextsLayout);
}
Program: 157271
Project: 157271
Buggy source:
private static void setupSlidingTab(View rootView,float tabTitleTextSize,ColorStateList tabTitleTextColor,ViewPager pager,PagerAdapter adapter,ViewPager.OnPageChangeListener onPageChangeListener,int startIndex){
  PagerSlidingTabStrip pagerTabStrip=(PagerSlidingTabStrip)rootView.findViewById(R.id.pager_tabs);
  pagerTabStrip.setTextSize((int)tabTitleTextSize);
  pagerTabStrip.setTextColor(tabTitleTextColor.getDefaultColor());
  pagerTabStrip.setIndicatorColor(tabTitleTextColor.getDefaultColor());
  pager.setAdapter(adapter);
  pager.setCurrentItem(startIndex);
  pagerTabStrip.setViewPager(pager);
  pagerTabStrip.setOnPageChangeListener(onPageChangeListener);
}

Fixed version (ground truth):
@RequiresApi(Build.VERSION_CODES.GINGERBREAD_MR1) private static void setupSlidingTab(View rootView,float tabTitleTextSize,ColorStateList tabTitleTextColor,ViewPager pager,PagerAdapter adapter,ViewPager.OnPageChangeListener onPageChangeListener,int startIndex){
  PagerSlidingTabStrip pagerTabStrip=(PagerSlidingTabStrip)rootView.findViewById(R.id.pager_tabs);
  pagerTabStrip.setTextSize((int)tabTitleTextSize);
  pagerTabStrip.setTextColor(tabTitleTextColor.getDefaultColor());
  pagerTabStrip.setIndicatorColor(tabTitleTextColor.getDefaultColor());
  pager.setAdapter(adapter);
  pager.setCurrentItem(startIndex);
  pagerTabStrip.setViewPager(pager);
  pagerTabStrip.setOnPageChangeListener(onPageChangeListener);
}
Program: 157272
Project: 157272
Buggy source:
private static void setupSupportTab(float tabTitleTextSize,ColorStateList tabTitleTextColor,ViewPager pager,PagerAdapter adapter,ViewPager.OnPageChangeListener onPageChangeListener,int startIndex){
  PagerTabStrip pagerTabStrip=(PagerTabStrip)pager.findViewById(R.id.pager_tabs);
  pagerTabStrip.setTextSize(TypedValue.COMPLEX_UNIT_PX,tabTitleTextSize);
  pagerTabStrip.setTextColor(tabTitleTextColor.getDefaultColor());
  pagerTabStrip.setTabIndicatorColor(tabTitleTextColor.getDefaultColor());
  pager.setAdapter(adapter);
  pager.setCurrentItem(startIndex);
  pager.setOnPageChangeListener(onPageChangeListener);
}

Fixed version (ground truth):
@TargetApi(Build.VERSION_CODES.GINGERBREAD) private static void setupSupportTab(float tabTitleTextSize,ColorStateList tabTitleTextColor,ViewPager pager,PagerAdapter adapter,ViewPager.OnPageChangeListener onPageChangeListener,int startIndex){
  PagerTabStrip pagerTabStrip=(PagerTabStrip)pager.findViewById(R.id.pager_tabs);
  pagerTabStrip.setTextSize(TypedValue.COMPLEX_UNIT_PX,tabTitleTextSize);
  pagerTabStrip.setTextColor(tabTitleTextColor.getDefaultColor());
  pagerTabStrip.setTabIndicatorColor(tabTitleTextColor.getDefaultColor());
  pager.setAdapter(adapter);
  pager.setCurrentItem(startIndex);
  pager.setOnPageChangeListener(onPageChangeListener);
}
Program: 157273
Project: 157273
Buggy source:
public void setThemeValues(float tabTextSize,ColorStateList tabTextColor,Drawable closeKeyboardIcon,Drawable backspaceIcon,Drawable settingsIcon){
  mTabTitleTextSize=tabTextSize;
  mTabTitleTextColor=tabTextColor;
  mCloseKeyboardIcon=closeKeyboardIcon;
  mBackspaceIcon=backspaceIcon;
  mSettingsIcon=settingsIcon;
}

Fixed version (ground truth):
public void setThemeValues(float tabTextSize,ColorStateList tabTextColor,Drawable closeKeyboardIcon,Drawable backspaceIcon,Drawable settingsIcon,Drawable keyboardDrawable){
  mTabTitleTextSize=tabTextSize;
  mTabTitleTextColor=tabTextColor;
  mCloseKeyboardIcon=closeKeyboardIcon;
  mBackspaceIcon=backspaceIcon;
  mSettingsIcon=settingsIcon;
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
    setBackground(keyboardDrawable);
  }
 else {
    setBackgroundDrawable(keyboardDrawable);
  }
}
Program: 157274
Project: 157274
Buggy source:
@Test public void testInstantiateItem() throws Exception {
  ViewGroup container=new LinearLayout(RuntimeEnvironment.application);
  Object instance0=mUnderTest.instantiateItem(container,0);
  Assert.assertNotNull(instance0);
  Assert.assertTrue(instance0 instanceof ScrollViewWithDisable);
  Assert.assertEquals(1,container.getChildCount());
  Assert.assertSame(instance0,container.getChildAt(0));
  final QuickKeysKeyboardView keyboardView0=(QuickKeysKeyboardView)((View)instance0).findViewById(R.id.keys_container);
  Assert.assertNotNull(keyboardView0);
  Object instance1=mUnderTest.instantiateItem(container,1);
  Assert.assertNotNull(instance1);
  Assert.assertNotSame(instance0,instance1);
  final QuickKeysKeyboardView keyboardView1=(QuickKeysKeyboardView)((View)instance1).findViewById(R.id.keys_container);
  Assert.assertNotNull(keyboardView1);
  Assert.assertNotEquals(keyboardView0.getKeyboard().getKeyboardAddOn().getId(),keyboardView1.getKeyboard().getKeyboardAddOn().getId());
  Object instance0Again=mUnderTest.instantiateItem(container,0);
  Assert.assertNotNull(instance0Again);
  Assert.assertNotSame(instance0,instance0Again);
  final QuickKeysKeyboardView keyboardView0Again=(QuickKeysKeyboardView)((View)instance0Again).findViewById(R.id.keys_container);
  Assert.assertNotNull(keyboardView0Again);
  Assert.assertSame(keyboardView0.getKeyboard(),keyboardView0Again.getKeyboard());
}

Fixed version (ground truth):
@Test public void testInstantiateItem() throws Exception {
  ViewGroup container=new LinearLayout(RuntimeEnvironment.application);
  Object instance0=mUnderTest.instantiateItem(container,0);
  Assert.assertNotNull(instance0);
  Assert.assertTrue(instance0 instanceof ScrollViewWithDisable);
  Assert.assertEquals(1,container.getChildCount());
  Assert.assertSame(instance0,container.getChildAt(0));
  final QuickKeysKeyboardView keyboardView0=(QuickKeysKeyboardView)((View)instance0).findViewById(R.id.keys_container);
  Assert.assertNotNull(keyboardView0);
  Object instance1=mUnderTest.instantiateItem(container,1);
  Assert.assertNotNull(instance1);
  Assert.assertNotSame(instance0,instance1);
  final QuickKeysKeyboardView keyboardView1=(QuickKeysKeyboardView)((View)instance1).findViewById(R.id.keys_container);
  Assert.assertNotNull(keyboardView1);
  Assert.assertNotEquals(keyboardView0.getKeyboard().getKeyboardAddOn().getId(),keyboardView1.getKeyboard().getKeyboardAddOn().getId());
  Object instance0Again=mUnderTest.instantiateItem(container,0);
  Assert.assertNotNull(instance0Again);
  Assert.assertNotSame(instance0,instance0Again);
  final QuickKeysKeyboardView keyboardView0Again=(QuickKeysKeyboardView)((View)instance0Again).findViewById(R.id.keys_container);
  Assert.assertNotNull(keyboardView0Again);
  Assert.assertSame(keyboardView0.getKeyboard(),keyboardView0Again.getKeyboard());
  Assert.assertSame(null,keyboardView0.getBackground());
  Assert.assertSame(null,keyboardView1.getBackground());
}
Program: 157275
Project: 157275
Buggy source:
@Before public void setup(){
  Context context=RuntimeEnvironment.application;
  mUnderTest=(QuickTextPagerView)LayoutInflater.from(RuntimeEnvironment.application).inflate(R.layout.quick_text_popup_root_view,null,false);
  mUnderTest.setThemeValues(10f,new ColorStateList(new int[][]{{0}},new int[]{Color.WHITE}),context.getDrawable(R.drawable.ic_cancel),context.getDrawable(R.drawable.sym_keyboard_delete_light),context.getDrawable(R.drawable.ic_action_settings));
}

Fixed version (ground truth):
@Before public void setup(){
  Context context=RuntimeEnvironment.application;
  mUnderTest=(QuickTextPagerView)LayoutInflater.from(RuntimeEnvironment.application).inflate(R.layout.quick_text_popup_root_view,null,false);
  mUnderTest.setThemeValues(10f,new ColorStateList(new int[][]{{0}},new int[]{Color.WHITE}),context.getDrawable(R.drawable.ic_cancel),context.getDrawable(R.drawable.sym_keyboard_delete_light),context.getDrawable(R.drawable.ic_action_settings),context.getDrawable(R.drawable.dark_background));
}
Program: 157277
Project: 157277
Buggy source:
public boolean areTouchesDisabled(){
  return mTouchesAreDisabledTillLastFingerIsUp;
}

Fixed version (ground truth):
public boolean areTouchesDisabled(MotionEvent motionEvent){
  if (motionEvent != null && mTouchesAreDisabledTillLastFingerIsUp) {
    final int action=MotionEventCompat.getActionMasked(motionEvent);
    if (MotionEventCompat.getPointerCount(motionEvent) == 1 && (action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_UP)) {
      mTouchesAreDisabledTillLastFingerIsUp=false;
      return action == MotionEvent.ACTION_UP;
    }
  }
  return mTouchesAreDisabledTillLastFingerIsUp;
}
Program: 157279
Project: 157279
Buggy source:
@Test public void testTouchIsDisabledOnGestureUntilAllPointersAreUp(){
  final int primaryKey1='a';
  final int keyAIndex=findKeyIndex(primaryKey1);
  final int keyFIndex=findKeyIndex('f');
  final int keyJIndex=findKeyIndex('j');
  AnyKeyboard.AnyKey key1=(AnyKeyboard.AnyKey)mEnglishKeyboard.getKeys().get(keyAIndex);
  AnyKeyboard.AnyKey key2=(AnyKeyboard.AnyKey)mEnglishKeyboard.getKeys().get(keyJIndex);
  Assert.assertFalse(mViewUnderTest.areTouchesDisabled());
  ViewTestUtils.navigateFromTo(mViewUnderTest,key1,key2,100,true,false);
  InOrder inOrder=Mockito.inOrder(mMockKeyboardListener);
  inOrder.verify(mMockKeyboardListener).onPress(primaryKey1);
  Mockito.verify(mMockKeyboardListener).onFirstDownKey(primaryKey1);
  for (int keyIndex=keyAIndex; keyIndex < keyFIndex; keyIndex++) {
    inOrder.verify(mMockKeyboardListener).onRelease(mEnglishKeyboard.getKeys().get(keyIndex).getCodeAtIndex(0,false));
    inOrder.verify(mMockKeyboardListener).onPress(mEnglishKeyboard.getKeys().get(keyIndex + 1).getCodeAtIndex(0,false));
  }
  inOrder.verify(mMockKeyboardListener).onSwipeRight(false);
  inOrder.verifyNoMoreInteractions();
  Assert.assertTrue(mViewUnderTest.areTouchesDisabled());
  ViewTestUtils.navigateFromTo(mViewUnderTest,key2,key2,20,false,true);
  Assert.assertFalse(mViewUnderTest.areTouchesDisabled());
}

Fixed version (ground truth):
@Test public void testTouchIsDisabledOnGestureUntilAllPointersAreUp(){
  final int primaryKey1='a';
  final int keyAIndex=findKeyIndex(primaryKey1);
  final int keyFIndex=findKeyIndex('f');
  final int keyJIndex=findKeyIndex('j');
  AnyKeyboard.AnyKey key1=(AnyKeyboard.AnyKey)mEnglishKeyboard.getKeys().get(keyAIndex);
  AnyKeyboard.AnyKey key2=(AnyKeyboard.AnyKey)mEnglishKeyboard.getKeys().get(keyJIndex);
  Assert.assertFalse(mViewUnderTest.areTouchesDisabled(null));
  ViewTestUtils.navigateFromTo(mViewUnderTest,key1,key2,100,true,false);
  InOrder inOrder=Mockito.inOrder(mMockKeyboardListener);
  inOrder.verify(mMockKeyboardListener).onPress(primaryKey1);
  Mockito.verify(mMockKeyboardListener).onFirstDownKey(primaryKey1);
  for (int keyIndex=keyAIndex; keyIndex < keyFIndex; keyIndex++) {
    inOrder.verify(mMockKeyboardListener).onRelease(mEnglishKeyboard.getKeys().get(keyIndex).getCodeAtIndex(0,false));
    inOrder.verify(mMockKeyboardListener).onPress(mEnglishKeyboard.getKeys().get(keyIndex + 1).getCodeAtIndex(0,false));
  }
  inOrder.verify(mMockKeyboardListener).onSwipeRight(false);
  inOrder.verifyNoMoreInteractions();
  Assert.assertTrue(mViewUnderTest.areTouchesDisabled(null));
  ViewTestUtils.navigateFromTo(mViewUnderTest,key2,key2,20,false,true);
  Assert.assertFalse(mViewUnderTest.areTouchesDisabled(null));
}
Program: 157280
Project: 157280
Buggy source:
public void onCancel(){
  hideWindow();
}

Fixed version (ground truth):
public void onCancel(){
}
Program: 157282
Project: 157282
Buggy source:
private void onNonFunctionKey(final int primaryCode,final Key key,final int multiTapIndex,final int[] nearByKeyCodes,final boolean fromUI){
  if (BuildConfig.DEBUG)   Logger.d(TAG,"String_Node_Str",primaryCode);
  final InputConnection ic=getCurrentInputConnection();
switch (primaryCode) {
case KeyCodes.ENTER:
case KeyCodes.SPACE:
    handleSeparator(primaryCode);
  if (!isInAlphabetKeyboardMode()) {
    Logger.d(TAG,"String_Node_Str");
    if (mAskPrefs.getSwitchKeyboardOnSpace()) {
      Logger.d(TAG,"String_Node_Str");
      getKeyboardSwitcher().nextKeyboard(getCurrentInputEditorInfo(),NextKeyboardType.Alphabet);
    }
  }
break;
case KeyCodes.TAB:
sendTab();
break;
case KeyCodes.ESCAPE:
sendEscape();
break;
default :
if (isWordSeparator(primaryCode)) {
handleSeparator(primaryCode);
}
 else {
if (mControlKeyState.isActive() && primaryCode >= 32 && primaryCode < 127) {
int controlCode=primaryCode & 31;
Logger.d(TAG,"String_Node_Str",primaryCode,controlCode);
if (controlCode == 9) {
sendTab();
}
 else {
ic.commitText(Character.toString((char)controlCode),1);
}
}
 else {
handleCharacter(primaryCode,key,multiTapIndex,nearByKeyCodes);
}
mJustAddedAutoSpace=false;
}
break;
}
}

Fixed version (ground truth):
private void onNonFunctionKey(final int primaryCode,final Key key,final int multiTapIndex,final int[] nearByKeyCodes,final boolean fromUI){
  if (BuildConfig.DEBUG)   Logger.d(TAG,"String_Node_Str",primaryCode);
  final InputConnection ic=getCurrentInputConnection();
switch (primaryCode) {
case KeyCodes.ENTER:
    if (mShiftKeyState.isPressed() && ic != null) {
      ic.commitText("String_Node_Str",1);
      break;
    }
  final EditorInfo editorInfo=getCurrentInputEditorInfo();
final int imeOptionsActionId=IMEUtil.getImeOptionsActionIdFromEditorInfo(editorInfo);
if (ic != null && IMEUtil.IME_ACTION_CUSTOM_LABEL == imeOptionsActionId) {
ic.performEditorAction(editorInfo.actionId);
}
 else if (ic != null && EditorInfo.IME_ACTION_NONE != imeOptionsActionId) {
ic.performEditorAction(imeOptionsActionId);
}
 else {
handleSeparator(primaryCode);
}
break;
case KeyCodes.SPACE:
handleSeparator(primaryCode);
if (!isInAlphabetKeyboardMode()) {
Logger.d(TAG,"String_Node_Str");
if (mAskPrefs.getSwitchKeyboardOnSpace()) {
Logger.d(TAG,"String_Node_Str");
getKeyboardSwitcher().nextKeyboard(getCurrentInputEditorInfo(),NextKeyboardType.Alphabet);
}
}
break;
case KeyCodes.TAB:
sendTab();
break;
case KeyCodes.ESCAPE:
sendEscape();
break;
default :
if (isWordSeparator(primaryCode)) {
handleSeparator(primaryCode);
}
 else {
if (mControlKeyState.isActive() && primaryCode >= 32 && primaryCode < 127) {
int controlCode=primaryCode & 31;
Logger.d(TAG,"String_Node_Str",primaryCode,controlCode);
if (controlCode == 9) {
sendTab();
}
 else {
ic.commitText(Character.toString((char)controlCode),1);
}
}
 else {
handleCharacter(primaryCode,key,multiTapIndex,nearByKeyCodes);
}
mJustAddedAutoSpace=false;
}
break;
}
}
Program: 157283
Project: 157283
Buggy source:
public void setKeyboardActionType(final int imeOptions){
  if ((imeOptions & EditorInfo.IME_FLAG_NO_ENTER_ACTION) != 0)   mKeyboardActionType=EditorInfo.IME_ACTION_UNSPECIFIED;
 else   mKeyboardActionType=(imeOptions & EditorInfo.IME_MASK_ACTION);
  setSpecialKeysIconsAndLabels();
}

Fixed version (ground truth):
public void setKeyboardActionType(final int imeOptions){
  if ((imeOptions & EditorInfo.IME_FLAG_NO_ENTER_ACTION) != 0)   mKeyboardActionType=EditorInfo.IME_ACTION_NONE;
 else   mKeyboardActionType=(imeOptions & EditorInfo.IME_MASK_ACTION);
  setSpecialKeysIconsAndLabels();
}